49
J Autom Reasoning (2006) 37:155–203 DOI 10.1007/s10817-006-9057-7 Mechanizing and Improving Dependency Pairs Jürgen Giesl · René Thiemann · Peter Schneider-Kamp · Stephan Falke Received: 9 December 2003 / Accepted: 29 May 2006 / Published online: 10 January 2007 © Springer Science + Business Media B.V. 2007 Abstract The dependency pair technique is a powerful method for automated termination and innermost termination proofs of term rewrite systems (TRSs). For any TRS, it generates inequality constraints that have to be satisfied by well-founded orders. We improve the dependency pair technique by considerably reducing the number of constraints produced for (innermost) termination proofs. Moreover, we extend transformation techniques to manipulate dependency pairs that simplify (in- nermost) termination proofs significantly. To fully mechanize the approach, we show how transformations and the search for suitable orders can be mechanized efficiently. We implemented our results in the automated termination prover AProVE and evaluated them on large collections of examples. Key words termination · term rewriting · dependency pairs 1 Introduction Termination is an essential property of term rewrite systems. Before the develop- ment of dependency pairs in the mid-1990s, most methods to prove termination Supported by the Deutsche Forschungsgemeinschaft DFG, grant GI 274/5-1. J. Giesl (B ) · R. Thiemann · P. Schneider-Kamp LuFG Informatik 2, RWTH Aachen, Ahornstr. 55, 52074 Aachen, Germany e-mail: [email protected] R. Thiemann e-mail: [email protected] P. Schneider-Kamp e-mail: [email protected] S. Falke Computer Science Department, University of New Mexico, Albuquerque, NM 87131, USA e-mail: [email protected]

Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

  • Upload
    others

  • View
    16

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

J Autom Reasoning (2006) 37155ndash203DOI 101007s10817-006-9057-7

Mechanizing and Improving Dependency Pairs

Juumlrgen Giesl middot Reneacute Thiemann middotPeter Schneider-Kamp middot Stephan Falke

Received 9 December 2003 Accepted 29 May 2006 Published online 10 January 2007copy Springer Science + Business Media BV 2007

Abstract The dependency pair technique is a powerful method for automatedtermination and innermost termination proofs of term rewrite systems (TRSs) Forany TRS it generates inequality constraints that have to be satisfied by well-foundedorders We improve the dependency pair technique by considerably reducing thenumber of constraints produced for (innermost) termination proofs Moreover weextend transformation techniques to manipulate dependency pairs that simplify (in-nermost) termination proofs significantly To fully mechanize the approach we showhow transformations and the search for suitable orders can be mechanized efficientlyWe implemented our results in the automated termination prover AProVE andevaluated them on large collections of examples

Key words termination middot term rewriting middot dependency pairs

1 Introduction

Termination is an essential property of term rewrite systems Before the develop-ment of dependency pairs in the mid-1990s most methods to prove termination

Supported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1

J Giesl (B) middot R Thiemann middot P Schneider-KampLuFG Informatik 2 RWTH Aachen Ahornstr 55 52074 Aachen Germanye-mail gieslinformatikrwth-aachende

R Thiemanne-mail thiemanninformatikrwth-aachende

P Schneider-Kampe-mail pskinformatikrwth-aachende

S FalkeComputer Science Department University of New Mexico Albuquerque NM 87131 USAe-mail spfcsunmedu

156 J Giesl et al

of TRSs automatically used simplification orders [7] where a term is greater thanits proper subterms (subterm property) Examples for simplification orders includelexicographic or recursive path orders possibly with status (RPOS [7]) the Knuth-Bendix order (KBO [28]) and many polynomial orders [31] However there arenumerous important TRSs that are not simply terminating that is their terminationcannot be shown by simplification orders Therefore the dependency pair approach[1 11 12] was developed that allows the application of simplification orders to non-simply terminating TRSs In this way the class of systems where termination isprovable mechanically increased significantly

Example 1 The following TRS from [1] is not simply terminating because the left-hand side of divrsquos last rule is embedded in the right-hand side if y is instantiated withs(x) Hence approaches for termination proofs based on simplification orders failwhile the example is easy to handle with dependency pairs

minus(x0) rarr xminus(s(x) s(y)) rarr minus(x y)

div(0 s(y)) rarr 0div(s(x) s(y)) rarr s(div(minus(x y) s(y)))

In Section 2 we discuss the dependency pair technique for termination and inner-most termination proofs Then we present new results that improve the techniquesignificantly Section 3 shows that for termination it suffices to require only the sameconstraints as for innermost termination Section 4 introduces a refinement to reducethe constraints (for both termination and innermost termination) even more bycombining the concepts of ldquousable rulesrdquo and ldquoargument filteringrdquo Section 5 presentstechniques for transforming dependency pairs in order to simplify (innermost)termination proofs further Compared to previous such transformations Section 5weakens their applicability conditions introduces an additional new transformationand shows how to combine the transformations with the improvements of Section 3and Section 4

The remainder of the paper is concerned with mechanizing dependency pairsTo this end we show how to solve the indeterminisms and search problems of thedependency pair technique efficiently One problem is the question of when andhow often to apply the dependency pair transformations discussed above Thereforein Section 5 we also show how to use these transformations in practice in order toguarantee the termination of their application without compromising their power

For automated (innermost) termination proofs one tries to solve the constraintsgenerated by the dependency pair technique with standard orders like RPOS KBOor polynomial orders If one uses classical simplification orders however then theconstraints should first be pre-processed by an argument filtering in order to benefitfrom the full power of dependency pairs Since the number of possible argumentfilterings is exponential the search for a suitable filtering is one of the main problemswhen automating dependency pairs We present an algorithm to generate argumentfilterings efficiently for our improved dependency pair technique in Section 6 Insteadof using orders such as RPOS or KBO in combination with argument filterings onecan also apply polynomial orders which already simulate the concept of argumentfiltering themselves In Section 7 we show how to mechanize the dependency pairapproach using polynomial orders efficiently

Mechanizing and improving dependency pairs 157

Our improvements and algorithms are implemented in our termination proverAProVE [17] In Section 8 we give empirical results that show that our algorithmsare extremely successful in practice Thus the contributions of this paper are alsovery helpful for other current tools that use dependency pairs (eg CiME [6]TORPA [45] TPA [29] TTT [24]) Dependency pairs can also be combined withother termination techniques (eg [40] integrates dependency pairs and the size-change principle from termination analysis of functional [32] and logic programs[8]) Moreover the systems TALP [36] and AProVE also use dependency pairs fortermination proofs of logic programs So techniques to mechanize and to improvedependency pairs are useful for termination analysis of other kinds of programminglanguages as well Of course dependency pairs are not the only successful methodfor automated termination proofs of non-simply terminating TRSs Other powerfulmethods include semantic labeling [44] match-bounds [9] and the monotonic seman-tic path order [5] For that reason several tools (including AProVE) also offer othertermination techniques possibly in combination with dependency pairs

2 Dependency Pairs

We briefly present the dependency pair method and refer to [1 11 12 15 16 2225 34 35] for refinements and motivations Here we use the new formulation of[15] where the method is presented as a general framework for termination proofsthat combines several separate subtechniques This formulation was inspired by thecycle analysis algorithm of [25] and it is related to the constraint-based approachof [4 Chapter 7] A main advantage of this formulation is that one can incorporateother termination techniques into the cycle analysis algorithm of [25] which leads toa substantial increase in modularity and power After presenting the structure of thedependency pair framework in Section 21 we introduce two of the main componentsof the framework in Section 22 and 23 the dependency graph processor and thereduction pair processor

21 The Dependency Pair Framework

We assume familiarity with term rewriting (see eg [3]) For a signature F and a setof variables V let T (F V) denote the set of terms over F and V For a TRS R overa signature F the defined symbols DR are the root symbols of the left-hand sides ofrules We restrict ourselves to finite signatures and TRSs For every defined symbolf isin DR we extend the signature F by a fresh tuple symbol f where f has the samearity as f To ease readability in the examples we usually adopt the original notationof [1] where tuple symbols were written with capital letters that is we often write Ffor f and so forth If t = g(t1 tm) with g isin DR we write t for g(t1 tm)

Definition 2 (Dependency Pair) If l rarr r isin R and t is a subterm of r with defined rootsymbol then the rule l rarr t is a dependency pair of R The set of all dependencypairs of R is denoted by DP(R)

158 J Giesl et al

So the dependency pairs of the TRS in Example 1 are

MINUS(s(x) s(y)) rarr MINUS(x y) (1)

DIV(s(x) s(y)) rarr MINUS(x y) (2)

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

To use dependency pairs for (innermost) termination proofs we need the notionof (innermost) chains Intuitively a dependency pair corresponds to a (possiblyrecursive) function call and a chain of dependency pairs represents a sequence ofcalls that can occur during a reduction We always assume that different occurrencesof dependency pairs are variable disjoint and consider substitutions whose domainsmay be infinite In the following P is usually a set of dependency pairs

Definition 3 (Chain) Let PR be TRSs A (possibly infinite) sequence of pairs s1 rarrt1 s2 rarr t2 from P is a (PR)-chain iff there is a substitution σ with tiσ rarrlowast

R si+1σ

for all i The chain is minimal if all tiσ are terminating wrt R The chain is aninnermost (PR)-chain iff tiσ irarrlowast

R si+1σ and siσ is in normal form wrt R for all iHere ldquo irarrRrdquo denotes innermost reductions An innermost (PR)-chain as above isminimal if all tiσ are innermost terminating wrt R

In Example 1 the following sequence is a minimal (innermost) chain

DIV(s(x1) s(y1)) rarr DIV(minus(x1 y1) s(y1)) (4)

DIV(s(x2) s(y2)) rarr DIV(minus(x2 y2) s(y2)) (5)

since DIV(minus(x1 y1) s(y1))σ rarrlowastR DIV(s(x2) s(y2))σ holds for a suitable substi-

tution σ For example σ could instantiate x1 with s(0) and y1 x2 y2 with 0 Whilethere are chains of arbitrary finite length in Example 1 we have no infinite chains Weobtain the following sufficient and necessary criterion for termination and innermosttermination

Theorem 4 (Termination Criterion [1]) A TRS R is terminating iff there is no infiniteminimal (DP(R)R)-chain R is innermost terminating iff there is no infinite minimalinnermost (DP(R)R)-chain

To prove absence of infinite minimal (innermost) chains automatically weconsider so-called dependency pair problems (ldquoDP problemsrdquo)1 A DP problemconsists of two TRSs P and R (where initially P = DP(R)) and a flag e isin t ifor ldquoterminationrdquo or ldquoinnermost terminationrdquo Instead of ldquo(PR)-chainsrdquo we alsospeak of ldquo(PR t)-chainsrdquo and instead of ldquoinnermost (PR)-chainsrdquo we speak ofldquo(PR i)-chainsrdquo Our goal is to show that there is no infinite minimal (PR e)-chain In this case we call the problem finite So Theorem 4 can be reformulated asfollows A TRS R is terminating iff the DP problem (DP(R)R t) is finite and it isinnermost terminating iff (DP(R)R i) is finite

1To ease readability we use a simpler definition of DP problems than [15] since this simple definitionsuffices for the presentation of the new results of this paper

Mechanizing and improving dependency pairs 159

A DP problem (PR e) that is not finite is called infinite But in addition (PR t)is already infinite whenever R is not terminating and (PR i) is already infinite if Ris not innermost terminating The reason for this nonsymmetric definition of ldquofiniterdquoand ldquoinfiniterdquo is that in this way there are more finite (resp infinite) DP problemsand therefore it becomes easier to detect (in)finiteness of a problem2 While theinitial DP problem (DP(R)R e) is either finite or infinite other DP problems(PR e) that can occur in termination proofs can be both finite and infinite Forexample the DP problem (PR e) with P = F(s(x)) rarr F(x) and R = f(s(x)) rarrf(x)a rarr a is finite since there is no infinite minimal (PR e)-chain but also infinitesince R is not (innermost) terminating

Such DP problems do not cause difficulties If one detects an infinite problemduring a termination proof one can always abort the proof since terminationhas been disproved (if all proof steps were ldquocompleterdquo ie if they preserved thetermination behavior) If the problem is both finite and infinite then even if one onlyconsiders it as being finite the proof is still correct since then there exists anotherresulting DP problem that is infinite and not finite The reason is that by Theorem 4non-termination implies that there is an infinite minimal chain Indeed when provingtermination of the TRS R above one also obtains a DP problem with the infiniteminimal chain A rarr A A rarr A

Termination techniques should now operate on DP problems instead of TRSs Werefer to such techniques as dependency pair processors (ldquoDP processorsrdquo) Formallya DP processor is a function Proc that takes a DP problem as input and returns anew set of DP problems that then have to be solved instead Alternatively it canalso return ldquonordquo A DP processor Proc is sound if for all DP problems d d is finitewhenever Proc(d) is not ldquonordquo and all DP problems in Proc(d) are finite Proc iscomplete if for all DP problems d d is infinite whenever Proc(d) is ldquonordquo or whenProc(d) contains an infinite DP problem

Soundness of Proc is required to prove termination (in particular to concludethat d is finite if Proc(d) = empty) Completeness is needed to prove non-termination (inparticular to conclude that d is infinite if Proc(d) = no) Completeness also ensuresthat one does not transform non-infinite DP problems into infinite ones (ie applyingthe processor does not ldquoharmrdquo ndash but of course it could still have a negative impact onthe success or efficiency of the termination proof attempt)

Corollary 5 introduces the DP framework The idea is to start with the initial DPproblem (DP(R)R e) where e depends on whether one wants to prove terminationor innermost termination Then this problem is transformed repeatedly by sound DPprocessors If the final processors return empty sets of DP problems termination isproved If one of the processors returns ldquonordquo and all processors used before werecomplete one has disproved termination of the TRS R

Corollary 5 (Dependency Pair Framework) Let R be a TRS We construct a treewhose nodes are labeled with DP problems or ldquoyesrdquo or ldquonordquo and whose root is labeled

2That a DP problem is already ldquoinfiniterdquo if R is not terminating is required for the completeness ofthe dependency pair transformations in Section 5 (cf Ex 32 in Section 51)

160 J Giesl et al

with (DP(R)R e) where e isin t i For every inner node labeled with d there is asound DP processor Proc satisfying one of the following conditions

ndash Proc(d) = no and the node has just one child labeled with ldquonordquondash Proc(d) = empty and the node has just one child labeled with ldquoyesrdquondash Proc(d) = no Proc(d) = empty and the children of the node are labeled with the DP

problems in Proc(d)

If all leaves of the tree are labeled with ldquoyesrdquo then R is terminating if e = t (respinnermost terminating if e = i) Otherwise if there is a leaf labeled with ldquonordquo and ifall processors used on the path from the root to this leaf are complete then R is notterminating if e = t (resp not innermost terminating if e = i)

Example 6 If d0 is the initial problem (DP(R)R e) if Proc0 Proc1 Proc2 are soundDP processors and if Proc0(d0) = d1 d2 Proc1(d1) = empty and Proc2(d2) = empty thenone could obtain the first tree below and conclude (innermost) termination

d0

d1 d2

yes yes

d0

d1

d2

d3 d4 d5 no

But if Proc1(d1) = d3 d4 d5 and Proc2(d2) = no one could obtain the second treeIf both Proc0 and Proc2 are complete then now one could conclude non-termination

22 The Dependency Graph Processor

We first introduce a processor to decompose a DP problem into several subproblemsTo this end one tries to determine which pairs can follow each other in chains byconstructing a so-called dependency graph

Definition 7 (Dependency Graph) For a problem (PR e) the nodes of the(PR e)-dependency graph are the pairs of P and there is an arc from s rarr t tov rarr w iff s rarr t v rarr w is a (PR e)-chain

In Example 1 we have the following dependency graph for both e isin t i

DIV(s(x)s(y)) rarr MINUS(x y ) (2)

DIV(s(x)s(y))rarrDIV(minus(x y )s(y)) (3) MINUS(s(x)s(y))rarrMINUS(x y ) (1)

A set P prime = empty of dependency pairs is a cycle if for any s rarr t and v rarr w in P prime thereis a non-empty path from s rarr t to v rarr w in the graph that traverses only pairs of P primeA cycle P prime is a strongly connected component (ldquoSCCrdquo) if P prime is not a proper subset ofanother cycle

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 2: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

156 J Giesl et al

of TRSs automatically used simplification orders [7] where a term is greater thanits proper subterms (subterm property) Examples for simplification orders includelexicographic or recursive path orders possibly with status (RPOS [7]) the Knuth-Bendix order (KBO [28]) and many polynomial orders [31] However there arenumerous important TRSs that are not simply terminating that is their terminationcannot be shown by simplification orders Therefore the dependency pair approach[1 11 12] was developed that allows the application of simplification orders to non-simply terminating TRSs In this way the class of systems where termination isprovable mechanically increased significantly

Example 1 The following TRS from [1] is not simply terminating because the left-hand side of divrsquos last rule is embedded in the right-hand side if y is instantiated withs(x) Hence approaches for termination proofs based on simplification orders failwhile the example is easy to handle with dependency pairs

minus(x0) rarr xminus(s(x) s(y)) rarr minus(x y)

div(0 s(y)) rarr 0div(s(x) s(y)) rarr s(div(minus(x y) s(y)))

In Section 2 we discuss the dependency pair technique for termination and inner-most termination proofs Then we present new results that improve the techniquesignificantly Section 3 shows that for termination it suffices to require only the sameconstraints as for innermost termination Section 4 introduces a refinement to reducethe constraints (for both termination and innermost termination) even more bycombining the concepts of ldquousable rulesrdquo and ldquoargument filteringrdquo Section 5 presentstechniques for transforming dependency pairs in order to simplify (innermost)termination proofs further Compared to previous such transformations Section 5weakens their applicability conditions introduces an additional new transformationand shows how to combine the transformations with the improvements of Section 3and Section 4

The remainder of the paper is concerned with mechanizing dependency pairsTo this end we show how to solve the indeterminisms and search problems of thedependency pair technique efficiently One problem is the question of when andhow often to apply the dependency pair transformations discussed above Thereforein Section 5 we also show how to use these transformations in practice in order toguarantee the termination of their application without compromising their power

For automated (innermost) termination proofs one tries to solve the constraintsgenerated by the dependency pair technique with standard orders like RPOS KBOor polynomial orders If one uses classical simplification orders however then theconstraints should first be pre-processed by an argument filtering in order to benefitfrom the full power of dependency pairs Since the number of possible argumentfilterings is exponential the search for a suitable filtering is one of the main problemswhen automating dependency pairs We present an algorithm to generate argumentfilterings efficiently for our improved dependency pair technique in Section 6 Insteadof using orders such as RPOS or KBO in combination with argument filterings onecan also apply polynomial orders which already simulate the concept of argumentfiltering themselves In Section 7 we show how to mechanize the dependency pairapproach using polynomial orders efficiently

Mechanizing and improving dependency pairs 157

Our improvements and algorithms are implemented in our termination proverAProVE [17] In Section 8 we give empirical results that show that our algorithmsare extremely successful in practice Thus the contributions of this paper are alsovery helpful for other current tools that use dependency pairs (eg CiME [6]TORPA [45] TPA [29] TTT [24]) Dependency pairs can also be combined withother termination techniques (eg [40] integrates dependency pairs and the size-change principle from termination analysis of functional [32] and logic programs[8]) Moreover the systems TALP [36] and AProVE also use dependency pairs fortermination proofs of logic programs So techniques to mechanize and to improvedependency pairs are useful for termination analysis of other kinds of programminglanguages as well Of course dependency pairs are not the only successful methodfor automated termination proofs of non-simply terminating TRSs Other powerfulmethods include semantic labeling [44] match-bounds [9] and the monotonic seman-tic path order [5] For that reason several tools (including AProVE) also offer othertermination techniques possibly in combination with dependency pairs

2 Dependency Pairs

We briefly present the dependency pair method and refer to [1 11 12 15 16 2225 34 35] for refinements and motivations Here we use the new formulation of[15] where the method is presented as a general framework for termination proofsthat combines several separate subtechniques This formulation was inspired by thecycle analysis algorithm of [25] and it is related to the constraint-based approachof [4 Chapter 7] A main advantage of this formulation is that one can incorporateother termination techniques into the cycle analysis algorithm of [25] which leads toa substantial increase in modularity and power After presenting the structure of thedependency pair framework in Section 21 we introduce two of the main componentsof the framework in Section 22 and 23 the dependency graph processor and thereduction pair processor

21 The Dependency Pair Framework

We assume familiarity with term rewriting (see eg [3]) For a signature F and a setof variables V let T (F V) denote the set of terms over F and V For a TRS R overa signature F the defined symbols DR are the root symbols of the left-hand sides ofrules We restrict ourselves to finite signatures and TRSs For every defined symbolf isin DR we extend the signature F by a fresh tuple symbol f where f has the samearity as f To ease readability in the examples we usually adopt the original notationof [1] where tuple symbols were written with capital letters that is we often write Ffor f and so forth If t = g(t1 tm) with g isin DR we write t for g(t1 tm)

Definition 2 (Dependency Pair) If l rarr r isin R and t is a subterm of r with defined rootsymbol then the rule l rarr t is a dependency pair of R The set of all dependencypairs of R is denoted by DP(R)

158 J Giesl et al

So the dependency pairs of the TRS in Example 1 are

MINUS(s(x) s(y)) rarr MINUS(x y) (1)

DIV(s(x) s(y)) rarr MINUS(x y) (2)

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

To use dependency pairs for (innermost) termination proofs we need the notionof (innermost) chains Intuitively a dependency pair corresponds to a (possiblyrecursive) function call and a chain of dependency pairs represents a sequence ofcalls that can occur during a reduction We always assume that different occurrencesof dependency pairs are variable disjoint and consider substitutions whose domainsmay be infinite In the following P is usually a set of dependency pairs

Definition 3 (Chain) Let PR be TRSs A (possibly infinite) sequence of pairs s1 rarrt1 s2 rarr t2 from P is a (PR)-chain iff there is a substitution σ with tiσ rarrlowast

R si+1σ

for all i The chain is minimal if all tiσ are terminating wrt R The chain is aninnermost (PR)-chain iff tiσ irarrlowast

R si+1σ and siσ is in normal form wrt R for all iHere ldquo irarrRrdquo denotes innermost reductions An innermost (PR)-chain as above isminimal if all tiσ are innermost terminating wrt R

In Example 1 the following sequence is a minimal (innermost) chain

DIV(s(x1) s(y1)) rarr DIV(minus(x1 y1) s(y1)) (4)

DIV(s(x2) s(y2)) rarr DIV(minus(x2 y2) s(y2)) (5)

since DIV(minus(x1 y1) s(y1))σ rarrlowastR DIV(s(x2) s(y2))σ holds for a suitable substi-

tution σ For example σ could instantiate x1 with s(0) and y1 x2 y2 with 0 Whilethere are chains of arbitrary finite length in Example 1 we have no infinite chains Weobtain the following sufficient and necessary criterion for termination and innermosttermination

Theorem 4 (Termination Criterion [1]) A TRS R is terminating iff there is no infiniteminimal (DP(R)R)-chain R is innermost terminating iff there is no infinite minimalinnermost (DP(R)R)-chain

To prove absence of infinite minimal (innermost) chains automatically weconsider so-called dependency pair problems (ldquoDP problemsrdquo)1 A DP problemconsists of two TRSs P and R (where initially P = DP(R)) and a flag e isin t ifor ldquoterminationrdquo or ldquoinnermost terminationrdquo Instead of ldquo(PR)-chainsrdquo we alsospeak of ldquo(PR t)-chainsrdquo and instead of ldquoinnermost (PR)-chainsrdquo we speak ofldquo(PR i)-chainsrdquo Our goal is to show that there is no infinite minimal (PR e)-chain In this case we call the problem finite So Theorem 4 can be reformulated asfollows A TRS R is terminating iff the DP problem (DP(R)R t) is finite and it isinnermost terminating iff (DP(R)R i) is finite

1To ease readability we use a simpler definition of DP problems than [15] since this simple definitionsuffices for the presentation of the new results of this paper

Mechanizing and improving dependency pairs 159

A DP problem (PR e) that is not finite is called infinite But in addition (PR t)is already infinite whenever R is not terminating and (PR i) is already infinite if Ris not innermost terminating The reason for this nonsymmetric definition of ldquofiniterdquoand ldquoinfiniterdquo is that in this way there are more finite (resp infinite) DP problemsand therefore it becomes easier to detect (in)finiteness of a problem2 While theinitial DP problem (DP(R)R e) is either finite or infinite other DP problems(PR e) that can occur in termination proofs can be both finite and infinite Forexample the DP problem (PR e) with P = F(s(x)) rarr F(x) and R = f(s(x)) rarrf(x)a rarr a is finite since there is no infinite minimal (PR e)-chain but also infinitesince R is not (innermost) terminating

Such DP problems do not cause difficulties If one detects an infinite problemduring a termination proof one can always abort the proof since terminationhas been disproved (if all proof steps were ldquocompleterdquo ie if they preserved thetermination behavior) If the problem is both finite and infinite then even if one onlyconsiders it as being finite the proof is still correct since then there exists anotherresulting DP problem that is infinite and not finite The reason is that by Theorem 4non-termination implies that there is an infinite minimal chain Indeed when provingtermination of the TRS R above one also obtains a DP problem with the infiniteminimal chain A rarr A A rarr A

Termination techniques should now operate on DP problems instead of TRSs Werefer to such techniques as dependency pair processors (ldquoDP processorsrdquo) Formallya DP processor is a function Proc that takes a DP problem as input and returns anew set of DP problems that then have to be solved instead Alternatively it canalso return ldquonordquo A DP processor Proc is sound if for all DP problems d d is finitewhenever Proc(d) is not ldquonordquo and all DP problems in Proc(d) are finite Proc iscomplete if for all DP problems d d is infinite whenever Proc(d) is ldquonordquo or whenProc(d) contains an infinite DP problem

Soundness of Proc is required to prove termination (in particular to concludethat d is finite if Proc(d) = empty) Completeness is needed to prove non-termination (inparticular to conclude that d is infinite if Proc(d) = no) Completeness also ensuresthat one does not transform non-infinite DP problems into infinite ones (ie applyingthe processor does not ldquoharmrdquo ndash but of course it could still have a negative impact onthe success or efficiency of the termination proof attempt)

Corollary 5 introduces the DP framework The idea is to start with the initial DPproblem (DP(R)R e) where e depends on whether one wants to prove terminationor innermost termination Then this problem is transformed repeatedly by sound DPprocessors If the final processors return empty sets of DP problems termination isproved If one of the processors returns ldquonordquo and all processors used before werecomplete one has disproved termination of the TRS R

Corollary 5 (Dependency Pair Framework) Let R be a TRS We construct a treewhose nodes are labeled with DP problems or ldquoyesrdquo or ldquonordquo and whose root is labeled

2That a DP problem is already ldquoinfiniterdquo if R is not terminating is required for the completeness ofthe dependency pair transformations in Section 5 (cf Ex 32 in Section 51)

160 J Giesl et al

with (DP(R)R e) where e isin t i For every inner node labeled with d there is asound DP processor Proc satisfying one of the following conditions

ndash Proc(d) = no and the node has just one child labeled with ldquonordquondash Proc(d) = empty and the node has just one child labeled with ldquoyesrdquondash Proc(d) = no Proc(d) = empty and the children of the node are labeled with the DP

problems in Proc(d)

If all leaves of the tree are labeled with ldquoyesrdquo then R is terminating if e = t (respinnermost terminating if e = i) Otherwise if there is a leaf labeled with ldquonordquo and ifall processors used on the path from the root to this leaf are complete then R is notterminating if e = t (resp not innermost terminating if e = i)

Example 6 If d0 is the initial problem (DP(R)R e) if Proc0 Proc1 Proc2 are soundDP processors and if Proc0(d0) = d1 d2 Proc1(d1) = empty and Proc2(d2) = empty thenone could obtain the first tree below and conclude (innermost) termination

d0

d1 d2

yes yes

d0

d1

d2

d3 d4 d5 no

But if Proc1(d1) = d3 d4 d5 and Proc2(d2) = no one could obtain the second treeIf both Proc0 and Proc2 are complete then now one could conclude non-termination

22 The Dependency Graph Processor

We first introduce a processor to decompose a DP problem into several subproblemsTo this end one tries to determine which pairs can follow each other in chains byconstructing a so-called dependency graph

Definition 7 (Dependency Graph) For a problem (PR e) the nodes of the(PR e)-dependency graph are the pairs of P and there is an arc from s rarr t tov rarr w iff s rarr t v rarr w is a (PR e)-chain

In Example 1 we have the following dependency graph for both e isin t i

DIV(s(x)s(y)) rarr MINUS(x y ) (2)

DIV(s(x)s(y))rarrDIV(minus(x y )s(y)) (3) MINUS(s(x)s(y))rarrMINUS(x y ) (1)

A set P prime = empty of dependency pairs is a cycle if for any s rarr t and v rarr w in P prime thereis a non-empty path from s rarr t to v rarr w in the graph that traverses only pairs of P primeA cycle P prime is a strongly connected component (ldquoSCCrdquo) if P prime is not a proper subset ofanother cycle

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 3: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 157

Our improvements and algorithms are implemented in our termination proverAProVE [17] In Section 8 we give empirical results that show that our algorithmsare extremely successful in practice Thus the contributions of this paper are alsovery helpful for other current tools that use dependency pairs (eg CiME [6]TORPA [45] TPA [29] TTT [24]) Dependency pairs can also be combined withother termination techniques (eg [40] integrates dependency pairs and the size-change principle from termination analysis of functional [32] and logic programs[8]) Moreover the systems TALP [36] and AProVE also use dependency pairs fortermination proofs of logic programs So techniques to mechanize and to improvedependency pairs are useful for termination analysis of other kinds of programminglanguages as well Of course dependency pairs are not the only successful methodfor automated termination proofs of non-simply terminating TRSs Other powerfulmethods include semantic labeling [44] match-bounds [9] and the monotonic seman-tic path order [5] For that reason several tools (including AProVE) also offer othertermination techniques possibly in combination with dependency pairs

2 Dependency Pairs

We briefly present the dependency pair method and refer to [1 11 12 15 16 2225 34 35] for refinements and motivations Here we use the new formulation of[15] where the method is presented as a general framework for termination proofsthat combines several separate subtechniques This formulation was inspired by thecycle analysis algorithm of [25] and it is related to the constraint-based approachof [4 Chapter 7] A main advantage of this formulation is that one can incorporateother termination techniques into the cycle analysis algorithm of [25] which leads toa substantial increase in modularity and power After presenting the structure of thedependency pair framework in Section 21 we introduce two of the main componentsof the framework in Section 22 and 23 the dependency graph processor and thereduction pair processor

21 The Dependency Pair Framework

We assume familiarity with term rewriting (see eg [3]) For a signature F and a setof variables V let T (F V) denote the set of terms over F and V For a TRS R overa signature F the defined symbols DR are the root symbols of the left-hand sides ofrules We restrict ourselves to finite signatures and TRSs For every defined symbolf isin DR we extend the signature F by a fresh tuple symbol f where f has the samearity as f To ease readability in the examples we usually adopt the original notationof [1] where tuple symbols were written with capital letters that is we often write Ffor f and so forth If t = g(t1 tm) with g isin DR we write t for g(t1 tm)

Definition 2 (Dependency Pair) If l rarr r isin R and t is a subterm of r with defined rootsymbol then the rule l rarr t is a dependency pair of R The set of all dependencypairs of R is denoted by DP(R)

158 J Giesl et al

So the dependency pairs of the TRS in Example 1 are

MINUS(s(x) s(y)) rarr MINUS(x y) (1)

DIV(s(x) s(y)) rarr MINUS(x y) (2)

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

To use dependency pairs for (innermost) termination proofs we need the notionof (innermost) chains Intuitively a dependency pair corresponds to a (possiblyrecursive) function call and a chain of dependency pairs represents a sequence ofcalls that can occur during a reduction We always assume that different occurrencesof dependency pairs are variable disjoint and consider substitutions whose domainsmay be infinite In the following P is usually a set of dependency pairs

Definition 3 (Chain) Let PR be TRSs A (possibly infinite) sequence of pairs s1 rarrt1 s2 rarr t2 from P is a (PR)-chain iff there is a substitution σ with tiσ rarrlowast

R si+1σ

for all i The chain is minimal if all tiσ are terminating wrt R The chain is aninnermost (PR)-chain iff tiσ irarrlowast

R si+1σ and siσ is in normal form wrt R for all iHere ldquo irarrRrdquo denotes innermost reductions An innermost (PR)-chain as above isminimal if all tiσ are innermost terminating wrt R

In Example 1 the following sequence is a minimal (innermost) chain

DIV(s(x1) s(y1)) rarr DIV(minus(x1 y1) s(y1)) (4)

DIV(s(x2) s(y2)) rarr DIV(minus(x2 y2) s(y2)) (5)

since DIV(minus(x1 y1) s(y1))σ rarrlowastR DIV(s(x2) s(y2))σ holds for a suitable substi-

tution σ For example σ could instantiate x1 with s(0) and y1 x2 y2 with 0 Whilethere are chains of arbitrary finite length in Example 1 we have no infinite chains Weobtain the following sufficient and necessary criterion for termination and innermosttermination

Theorem 4 (Termination Criterion [1]) A TRS R is terminating iff there is no infiniteminimal (DP(R)R)-chain R is innermost terminating iff there is no infinite minimalinnermost (DP(R)R)-chain

To prove absence of infinite minimal (innermost) chains automatically weconsider so-called dependency pair problems (ldquoDP problemsrdquo)1 A DP problemconsists of two TRSs P and R (where initially P = DP(R)) and a flag e isin t ifor ldquoterminationrdquo or ldquoinnermost terminationrdquo Instead of ldquo(PR)-chainsrdquo we alsospeak of ldquo(PR t)-chainsrdquo and instead of ldquoinnermost (PR)-chainsrdquo we speak ofldquo(PR i)-chainsrdquo Our goal is to show that there is no infinite minimal (PR e)-chain In this case we call the problem finite So Theorem 4 can be reformulated asfollows A TRS R is terminating iff the DP problem (DP(R)R t) is finite and it isinnermost terminating iff (DP(R)R i) is finite

1To ease readability we use a simpler definition of DP problems than [15] since this simple definitionsuffices for the presentation of the new results of this paper

Mechanizing and improving dependency pairs 159

A DP problem (PR e) that is not finite is called infinite But in addition (PR t)is already infinite whenever R is not terminating and (PR i) is already infinite if Ris not innermost terminating The reason for this nonsymmetric definition of ldquofiniterdquoand ldquoinfiniterdquo is that in this way there are more finite (resp infinite) DP problemsand therefore it becomes easier to detect (in)finiteness of a problem2 While theinitial DP problem (DP(R)R e) is either finite or infinite other DP problems(PR e) that can occur in termination proofs can be both finite and infinite Forexample the DP problem (PR e) with P = F(s(x)) rarr F(x) and R = f(s(x)) rarrf(x)a rarr a is finite since there is no infinite minimal (PR e)-chain but also infinitesince R is not (innermost) terminating

Such DP problems do not cause difficulties If one detects an infinite problemduring a termination proof one can always abort the proof since terminationhas been disproved (if all proof steps were ldquocompleterdquo ie if they preserved thetermination behavior) If the problem is both finite and infinite then even if one onlyconsiders it as being finite the proof is still correct since then there exists anotherresulting DP problem that is infinite and not finite The reason is that by Theorem 4non-termination implies that there is an infinite minimal chain Indeed when provingtermination of the TRS R above one also obtains a DP problem with the infiniteminimal chain A rarr A A rarr A

Termination techniques should now operate on DP problems instead of TRSs Werefer to such techniques as dependency pair processors (ldquoDP processorsrdquo) Formallya DP processor is a function Proc that takes a DP problem as input and returns anew set of DP problems that then have to be solved instead Alternatively it canalso return ldquonordquo A DP processor Proc is sound if for all DP problems d d is finitewhenever Proc(d) is not ldquonordquo and all DP problems in Proc(d) are finite Proc iscomplete if for all DP problems d d is infinite whenever Proc(d) is ldquonordquo or whenProc(d) contains an infinite DP problem

Soundness of Proc is required to prove termination (in particular to concludethat d is finite if Proc(d) = empty) Completeness is needed to prove non-termination (inparticular to conclude that d is infinite if Proc(d) = no) Completeness also ensuresthat one does not transform non-infinite DP problems into infinite ones (ie applyingthe processor does not ldquoharmrdquo ndash but of course it could still have a negative impact onthe success or efficiency of the termination proof attempt)

Corollary 5 introduces the DP framework The idea is to start with the initial DPproblem (DP(R)R e) where e depends on whether one wants to prove terminationor innermost termination Then this problem is transformed repeatedly by sound DPprocessors If the final processors return empty sets of DP problems termination isproved If one of the processors returns ldquonordquo and all processors used before werecomplete one has disproved termination of the TRS R

Corollary 5 (Dependency Pair Framework) Let R be a TRS We construct a treewhose nodes are labeled with DP problems or ldquoyesrdquo or ldquonordquo and whose root is labeled

2That a DP problem is already ldquoinfiniterdquo if R is not terminating is required for the completeness ofthe dependency pair transformations in Section 5 (cf Ex 32 in Section 51)

160 J Giesl et al

with (DP(R)R e) where e isin t i For every inner node labeled with d there is asound DP processor Proc satisfying one of the following conditions

ndash Proc(d) = no and the node has just one child labeled with ldquonordquondash Proc(d) = empty and the node has just one child labeled with ldquoyesrdquondash Proc(d) = no Proc(d) = empty and the children of the node are labeled with the DP

problems in Proc(d)

If all leaves of the tree are labeled with ldquoyesrdquo then R is terminating if e = t (respinnermost terminating if e = i) Otherwise if there is a leaf labeled with ldquonordquo and ifall processors used on the path from the root to this leaf are complete then R is notterminating if e = t (resp not innermost terminating if e = i)

Example 6 If d0 is the initial problem (DP(R)R e) if Proc0 Proc1 Proc2 are soundDP processors and if Proc0(d0) = d1 d2 Proc1(d1) = empty and Proc2(d2) = empty thenone could obtain the first tree below and conclude (innermost) termination

d0

d1 d2

yes yes

d0

d1

d2

d3 d4 d5 no

But if Proc1(d1) = d3 d4 d5 and Proc2(d2) = no one could obtain the second treeIf both Proc0 and Proc2 are complete then now one could conclude non-termination

22 The Dependency Graph Processor

We first introduce a processor to decompose a DP problem into several subproblemsTo this end one tries to determine which pairs can follow each other in chains byconstructing a so-called dependency graph

Definition 7 (Dependency Graph) For a problem (PR e) the nodes of the(PR e)-dependency graph are the pairs of P and there is an arc from s rarr t tov rarr w iff s rarr t v rarr w is a (PR e)-chain

In Example 1 we have the following dependency graph for both e isin t i

DIV(s(x)s(y)) rarr MINUS(x y ) (2)

DIV(s(x)s(y))rarrDIV(minus(x y )s(y)) (3) MINUS(s(x)s(y))rarrMINUS(x y ) (1)

A set P prime = empty of dependency pairs is a cycle if for any s rarr t and v rarr w in P prime thereis a non-empty path from s rarr t to v rarr w in the graph that traverses only pairs of P primeA cycle P prime is a strongly connected component (ldquoSCCrdquo) if P prime is not a proper subset ofanother cycle

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 4: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

158 J Giesl et al

So the dependency pairs of the TRS in Example 1 are

MINUS(s(x) s(y)) rarr MINUS(x y) (1)

DIV(s(x) s(y)) rarr MINUS(x y) (2)

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

To use dependency pairs for (innermost) termination proofs we need the notionof (innermost) chains Intuitively a dependency pair corresponds to a (possiblyrecursive) function call and a chain of dependency pairs represents a sequence ofcalls that can occur during a reduction We always assume that different occurrencesof dependency pairs are variable disjoint and consider substitutions whose domainsmay be infinite In the following P is usually a set of dependency pairs

Definition 3 (Chain) Let PR be TRSs A (possibly infinite) sequence of pairs s1 rarrt1 s2 rarr t2 from P is a (PR)-chain iff there is a substitution σ with tiσ rarrlowast

R si+1σ

for all i The chain is minimal if all tiσ are terminating wrt R The chain is aninnermost (PR)-chain iff tiσ irarrlowast

R si+1σ and siσ is in normal form wrt R for all iHere ldquo irarrRrdquo denotes innermost reductions An innermost (PR)-chain as above isminimal if all tiσ are innermost terminating wrt R

In Example 1 the following sequence is a minimal (innermost) chain

DIV(s(x1) s(y1)) rarr DIV(minus(x1 y1) s(y1)) (4)

DIV(s(x2) s(y2)) rarr DIV(minus(x2 y2) s(y2)) (5)

since DIV(minus(x1 y1) s(y1))σ rarrlowastR DIV(s(x2) s(y2))σ holds for a suitable substi-

tution σ For example σ could instantiate x1 with s(0) and y1 x2 y2 with 0 Whilethere are chains of arbitrary finite length in Example 1 we have no infinite chains Weobtain the following sufficient and necessary criterion for termination and innermosttermination

Theorem 4 (Termination Criterion [1]) A TRS R is terminating iff there is no infiniteminimal (DP(R)R)-chain R is innermost terminating iff there is no infinite minimalinnermost (DP(R)R)-chain

To prove absence of infinite minimal (innermost) chains automatically weconsider so-called dependency pair problems (ldquoDP problemsrdquo)1 A DP problemconsists of two TRSs P and R (where initially P = DP(R)) and a flag e isin t ifor ldquoterminationrdquo or ldquoinnermost terminationrdquo Instead of ldquo(PR)-chainsrdquo we alsospeak of ldquo(PR t)-chainsrdquo and instead of ldquoinnermost (PR)-chainsrdquo we speak ofldquo(PR i)-chainsrdquo Our goal is to show that there is no infinite minimal (PR e)-chain In this case we call the problem finite So Theorem 4 can be reformulated asfollows A TRS R is terminating iff the DP problem (DP(R)R t) is finite and it isinnermost terminating iff (DP(R)R i) is finite

1To ease readability we use a simpler definition of DP problems than [15] since this simple definitionsuffices for the presentation of the new results of this paper

Mechanizing and improving dependency pairs 159

A DP problem (PR e) that is not finite is called infinite But in addition (PR t)is already infinite whenever R is not terminating and (PR i) is already infinite if Ris not innermost terminating The reason for this nonsymmetric definition of ldquofiniterdquoand ldquoinfiniterdquo is that in this way there are more finite (resp infinite) DP problemsand therefore it becomes easier to detect (in)finiteness of a problem2 While theinitial DP problem (DP(R)R e) is either finite or infinite other DP problems(PR e) that can occur in termination proofs can be both finite and infinite Forexample the DP problem (PR e) with P = F(s(x)) rarr F(x) and R = f(s(x)) rarrf(x)a rarr a is finite since there is no infinite minimal (PR e)-chain but also infinitesince R is not (innermost) terminating

Such DP problems do not cause difficulties If one detects an infinite problemduring a termination proof one can always abort the proof since terminationhas been disproved (if all proof steps were ldquocompleterdquo ie if they preserved thetermination behavior) If the problem is both finite and infinite then even if one onlyconsiders it as being finite the proof is still correct since then there exists anotherresulting DP problem that is infinite and not finite The reason is that by Theorem 4non-termination implies that there is an infinite minimal chain Indeed when provingtermination of the TRS R above one also obtains a DP problem with the infiniteminimal chain A rarr A A rarr A

Termination techniques should now operate on DP problems instead of TRSs Werefer to such techniques as dependency pair processors (ldquoDP processorsrdquo) Formallya DP processor is a function Proc that takes a DP problem as input and returns anew set of DP problems that then have to be solved instead Alternatively it canalso return ldquonordquo A DP processor Proc is sound if for all DP problems d d is finitewhenever Proc(d) is not ldquonordquo and all DP problems in Proc(d) are finite Proc iscomplete if for all DP problems d d is infinite whenever Proc(d) is ldquonordquo or whenProc(d) contains an infinite DP problem

Soundness of Proc is required to prove termination (in particular to concludethat d is finite if Proc(d) = empty) Completeness is needed to prove non-termination (inparticular to conclude that d is infinite if Proc(d) = no) Completeness also ensuresthat one does not transform non-infinite DP problems into infinite ones (ie applyingthe processor does not ldquoharmrdquo ndash but of course it could still have a negative impact onthe success or efficiency of the termination proof attempt)

Corollary 5 introduces the DP framework The idea is to start with the initial DPproblem (DP(R)R e) where e depends on whether one wants to prove terminationor innermost termination Then this problem is transformed repeatedly by sound DPprocessors If the final processors return empty sets of DP problems termination isproved If one of the processors returns ldquonordquo and all processors used before werecomplete one has disproved termination of the TRS R

Corollary 5 (Dependency Pair Framework) Let R be a TRS We construct a treewhose nodes are labeled with DP problems or ldquoyesrdquo or ldquonordquo and whose root is labeled

2That a DP problem is already ldquoinfiniterdquo if R is not terminating is required for the completeness ofthe dependency pair transformations in Section 5 (cf Ex 32 in Section 51)

160 J Giesl et al

with (DP(R)R e) where e isin t i For every inner node labeled with d there is asound DP processor Proc satisfying one of the following conditions

ndash Proc(d) = no and the node has just one child labeled with ldquonordquondash Proc(d) = empty and the node has just one child labeled with ldquoyesrdquondash Proc(d) = no Proc(d) = empty and the children of the node are labeled with the DP

problems in Proc(d)

If all leaves of the tree are labeled with ldquoyesrdquo then R is terminating if e = t (respinnermost terminating if e = i) Otherwise if there is a leaf labeled with ldquonordquo and ifall processors used on the path from the root to this leaf are complete then R is notterminating if e = t (resp not innermost terminating if e = i)

Example 6 If d0 is the initial problem (DP(R)R e) if Proc0 Proc1 Proc2 are soundDP processors and if Proc0(d0) = d1 d2 Proc1(d1) = empty and Proc2(d2) = empty thenone could obtain the first tree below and conclude (innermost) termination

d0

d1 d2

yes yes

d0

d1

d2

d3 d4 d5 no

But if Proc1(d1) = d3 d4 d5 and Proc2(d2) = no one could obtain the second treeIf both Proc0 and Proc2 are complete then now one could conclude non-termination

22 The Dependency Graph Processor

We first introduce a processor to decompose a DP problem into several subproblemsTo this end one tries to determine which pairs can follow each other in chains byconstructing a so-called dependency graph

Definition 7 (Dependency Graph) For a problem (PR e) the nodes of the(PR e)-dependency graph are the pairs of P and there is an arc from s rarr t tov rarr w iff s rarr t v rarr w is a (PR e)-chain

In Example 1 we have the following dependency graph for both e isin t i

DIV(s(x)s(y)) rarr MINUS(x y ) (2)

DIV(s(x)s(y))rarrDIV(minus(x y )s(y)) (3) MINUS(s(x)s(y))rarrMINUS(x y ) (1)

A set P prime = empty of dependency pairs is a cycle if for any s rarr t and v rarr w in P prime thereis a non-empty path from s rarr t to v rarr w in the graph that traverses only pairs of P primeA cycle P prime is a strongly connected component (ldquoSCCrdquo) if P prime is not a proper subset ofanother cycle

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 5: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 159

A DP problem (PR e) that is not finite is called infinite But in addition (PR t)is already infinite whenever R is not terminating and (PR i) is already infinite if Ris not innermost terminating The reason for this nonsymmetric definition of ldquofiniterdquoand ldquoinfiniterdquo is that in this way there are more finite (resp infinite) DP problemsand therefore it becomes easier to detect (in)finiteness of a problem2 While theinitial DP problem (DP(R)R e) is either finite or infinite other DP problems(PR e) that can occur in termination proofs can be both finite and infinite Forexample the DP problem (PR e) with P = F(s(x)) rarr F(x) and R = f(s(x)) rarrf(x)a rarr a is finite since there is no infinite minimal (PR e)-chain but also infinitesince R is not (innermost) terminating

Such DP problems do not cause difficulties If one detects an infinite problemduring a termination proof one can always abort the proof since terminationhas been disproved (if all proof steps were ldquocompleterdquo ie if they preserved thetermination behavior) If the problem is both finite and infinite then even if one onlyconsiders it as being finite the proof is still correct since then there exists anotherresulting DP problem that is infinite and not finite The reason is that by Theorem 4non-termination implies that there is an infinite minimal chain Indeed when provingtermination of the TRS R above one also obtains a DP problem with the infiniteminimal chain A rarr A A rarr A

Termination techniques should now operate on DP problems instead of TRSs Werefer to such techniques as dependency pair processors (ldquoDP processorsrdquo) Formallya DP processor is a function Proc that takes a DP problem as input and returns anew set of DP problems that then have to be solved instead Alternatively it canalso return ldquonordquo A DP processor Proc is sound if for all DP problems d d is finitewhenever Proc(d) is not ldquonordquo and all DP problems in Proc(d) are finite Proc iscomplete if for all DP problems d d is infinite whenever Proc(d) is ldquonordquo or whenProc(d) contains an infinite DP problem

Soundness of Proc is required to prove termination (in particular to concludethat d is finite if Proc(d) = empty) Completeness is needed to prove non-termination (inparticular to conclude that d is infinite if Proc(d) = no) Completeness also ensuresthat one does not transform non-infinite DP problems into infinite ones (ie applyingthe processor does not ldquoharmrdquo ndash but of course it could still have a negative impact onthe success or efficiency of the termination proof attempt)

Corollary 5 introduces the DP framework The idea is to start with the initial DPproblem (DP(R)R e) where e depends on whether one wants to prove terminationor innermost termination Then this problem is transformed repeatedly by sound DPprocessors If the final processors return empty sets of DP problems termination isproved If one of the processors returns ldquonordquo and all processors used before werecomplete one has disproved termination of the TRS R

Corollary 5 (Dependency Pair Framework) Let R be a TRS We construct a treewhose nodes are labeled with DP problems or ldquoyesrdquo or ldquonordquo and whose root is labeled

2That a DP problem is already ldquoinfiniterdquo if R is not terminating is required for the completeness ofthe dependency pair transformations in Section 5 (cf Ex 32 in Section 51)

160 J Giesl et al

with (DP(R)R e) where e isin t i For every inner node labeled with d there is asound DP processor Proc satisfying one of the following conditions

ndash Proc(d) = no and the node has just one child labeled with ldquonordquondash Proc(d) = empty and the node has just one child labeled with ldquoyesrdquondash Proc(d) = no Proc(d) = empty and the children of the node are labeled with the DP

problems in Proc(d)

If all leaves of the tree are labeled with ldquoyesrdquo then R is terminating if e = t (respinnermost terminating if e = i) Otherwise if there is a leaf labeled with ldquonordquo and ifall processors used on the path from the root to this leaf are complete then R is notterminating if e = t (resp not innermost terminating if e = i)

Example 6 If d0 is the initial problem (DP(R)R e) if Proc0 Proc1 Proc2 are soundDP processors and if Proc0(d0) = d1 d2 Proc1(d1) = empty and Proc2(d2) = empty thenone could obtain the first tree below and conclude (innermost) termination

d0

d1 d2

yes yes

d0

d1

d2

d3 d4 d5 no

But if Proc1(d1) = d3 d4 d5 and Proc2(d2) = no one could obtain the second treeIf both Proc0 and Proc2 are complete then now one could conclude non-termination

22 The Dependency Graph Processor

We first introduce a processor to decompose a DP problem into several subproblemsTo this end one tries to determine which pairs can follow each other in chains byconstructing a so-called dependency graph

Definition 7 (Dependency Graph) For a problem (PR e) the nodes of the(PR e)-dependency graph are the pairs of P and there is an arc from s rarr t tov rarr w iff s rarr t v rarr w is a (PR e)-chain

In Example 1 we have the following dependency graph for both e isin t i

DIV(s(x)s(y)) rarr MINUS(x y ) (2)

DIV(s(x)s(y))rarrDIV(minus(x y )s(y)) (3) MINUS(s(x)s(y))rarrMINUS(x y ) (1)

A set P prime = empty of dependency pairs is a cycle if for any s rarr t and v rarr w in P prime thereis a non-empty path from s rarr t to v rarr w in the graph that traverses only pairs of P primeA cycle P prime is a strongly connected component (ldquoSCCrdquo) if P prime is not a proper subset ofanother cycle

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 6: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

160 J Giesl et al

with (DP(R)R e) where e isin t i For every inner node labeled with d there is asound DP processor Proc satisfying one of the following conditions

ndash Proc(d) = no and the node has just one child labeled with ldquonordquondash Proc(d) = empty and the node has just one child labeled with ldquoyesrdquondash Proc(d) = no Proc(d) = empty and the children of the node are labeled with the DP

problems in Proc(d)

If all leaves of the tree are labeled with ldquoyesrdquo then R is terminating if e = t (respinnermost terminating if e = i) Otherwise if there is a leaf labeled with ldquonordquo and ifall processors used on the path from the root to this leaf are complete then R is notterminating if e = t (resp not innermost terminating if e = i)

Example 6 If d0 is the initial problem (DP(R)R e) if Proc0 Proc1 Proc2 are soundDP processors and if Proc0(d0) = d1 d2 Proc1(d1) = empty and Proc2(d2) = empty thenone could obtain the first tree below and conclude (innermost) termination

d0

d1 d2

yes yes

d0

d1

d2

d3 d4 d5 no

But if Proc1(d1) = d3 d4 d5 and Proc2(d2) = no one could obtain the second treeIf both Proc0 and Proc2 are complete then now one could conclude non-termination

22 The Dependency Graph Processor

We first introduce a processor to decompose a DP problem into several subproblemsTo this end one tries to determine which pairs can follow each other in chains byconstructing a so-called dependency graph

Definition 7 (Dependency Graph) For a problem (PR e) the nodes of the(PR e)-dependency graph are the pairs of P and there is an arc from s rarr t tov rarr w iff s rarr t v rarr w is a (PR e)-chain

In Example 1 we have the following dependency graph for both e isin t i

DIV(s(x)s(y)) rarr MINUS(x y ) (2)

DIV(s(x)s(y))rarrDIV(minus(x y )s(y)) (3) MINUS(s(x)s(y))rarrMINUS(x y ) (1)

A set P prime = empty of dependency pairs is a cycle if for any s rarr t and v rarr w in P prime thereis a non-empty path from s rarr t to v rarr w in the graph that traverses only pairs of P primeA cycle P prime is a strongly connected component (ldquoSCCrdquo) if P prime is not a proper subset ofanother cycle

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 7: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 161

Note that in standard graph terminology a path n0 rArr n1 rArr rArr nk in a directedgraph forms a cycle if n0 = nk and k ge 1 In our context we identify cycles with the setof elements that occur in it that is we call n0 n1 nkminus1 a cycle (cf [12]) Since aset never contains multiple occurrences of an element this results in several cyclingpaths being identified with the same set Similarly an ldquoSCCrdquo is a graph in standardgraph terminology whereas we identify an SCC with the set of elements occurring init Then indeed SCCs are the same as maximal cycles

In Example 1 we have the SCCs P1 = (1) and P2 = (3) Since we consideronly finite TRSs any infinite chain of dependency pairs corresponds to a cycle of thedependency graph Therefore one can prove the absence of infinite chains separatelyfor every cycle of the dependency graph As observed in [25] to avoid exponentialblowup one should not compute all cycles of the dependency graph but consider theSCCs instead Therefore the following DP processor decomposes a DP problem intothe subproblems corresponding to the different SCCs

Theorem 8 (Dependency Graph Processor [1 15 25]) Let Proc((PR e) ) =(P1R e) (PnR e) where P1 Pn are the SCCs of the (PR e)-dependency graph Then Proc is sound and complete

The initial problem in Example 1 is (PR e) with P = (1) (2) (3) The aboveprocessor transforms it into ((1) R e) and ((3) R e)

Unfortunately the dependency graph is not computable Therefore for automa-tion one constructs an estimated graph containing at least all arcs from the realgraph Obviously the dependency graph processor of Theorem 8 remains sound andcomplete if one uses any such estimation

Let capR(t) result from replacing all subterms of t with defined root symbol (iewith a root symbol from DR) by different fresh variables Here multiple occurrencesof the same subterm are also replaced by pairwise different variables Let ren(t)result from replacing all occurrences of variables in t by different fresh variables(ie ren(t) is a linear term) So capR(DIV(minus(x y) s(y))) = DIV(z s(y)) andren(DIV(x x)) = DIV(x1 x2)

Definition 9 (Estimated Dependency Graph) For a DP problem (PR e) the nodesof the estimated dependency graph EDG(PR) are the pairs of P and there is an arcfrom s rarr t to v rarr w iff ren(capR(t)) and v are unifiable In the estimated innermostdependency graph EIDG(PR) there is an arc from s rarr t to v rarr w iff capR(t) andv are unifiable by an mgu μ such that sμ and vμ are in normal form

The above estimations are sound that is the EDG contains the (PR t)-dependency graph and the EIDG contains the (PR i)-dependency graph Ofcourse to check whether there is an arc from s rarr t to v rarr w in E(I)DG onehas to rename the variables of s rarr t and v rarr w to make them variable disjointIn Example 1 the E(I)DG is identical to the real dependency graph Alternativeimproved techniques to estimate (innermost) dependency graphs can be found in[1 14 16 25 34 35] In particular the EIDG in Definition 9 is a slightly weakersimplified variant of the ldquoestimated innermost dependency graphrdquo from [1]

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 8: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

162 J Giesl et al

23 The Reduction Pair Processor

To prove that a DP problem is finite we now generate constraints that should besatisfied by some reduction pair () [30] consisting of a quasi-rewrite order (ie is reflexive transitive monotonic (closed under contexts) and stable (closedunder substitutions)) and a stable well-founded order that is compatible with (ie sube or sube ) However need not be monotonic For a DPproblem (PR e) the generated constraints ensure that at least one rule in P isstrictly decreasing (wrt ) and all remaining rules in P and R are weakly decreasing(wrt ) Requiring lr for all lrarrr isin R ensures that in a chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we have tiσ si+1σ for all i Hence if a reduction pair satisfiesthese constraints then the strictly decreasing pairs of P cannot occur infinitely oftenin chains Thus one can delete all these pairs from P

For innermost termination a weak decrease is not required for all rules but onlyfor the usable rules These rules are a superset of those rules that may be used toreduce right-hand sides of dependency pairs if their variables are instantiated withnormal forms3 In Example 1 the usable rules of dependency pair (3) are the minus-rules whereas the other dependency pairs have no usable rules

Definition 10 (Usable Rules) For f isin F let RlsR( f ) = lrarr risinR | root(l) = f and let Rprime = R RlsR( f ) For any term we define

ndash UR(x) = empty for x isin V andndash UR( f (t1 tn)) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r) cup ⋃ni=1 URprime(ti)

For any TRS P we define UR(P) = ⋃srarrtisinP UR(t)

We want to use standard techniques to synthesize reduction pairs satisfying theconstraints generated by the dependency pair technique Most existing techniquesgenerate monotonic orders such as RPOS or KBO But for the dependency pairapproach we need only a monotonic quasi-order whereas does not have tobe monotonic (This is often called ldquoweak monotonicityrdquo) For that reason beforesynthesizing a suitable order some arguments of function symbols can be eliminatedIn order to perform this elimination the concept of argument filtering was introducedin [1] (we use the notation of [30])

Definition 11 (Argument Filtering) An argument filtering π for a signature F mapsevery n-ary function symbol to an argument position i isin 1 n or to a (possiblyempty) list [i1 im] with 1 le i1 lt lt im le n The signature Fπ consists of allfunction symbols f such that π( f ) = [i1 im] where in Fπ the arity of f is mEvery argument filtering π induces a mapping from T (F V) to T (Fπ V)

π(t) =⎧⎨

t if t is a variableπ(ti) if t = f (t1 tn) and π( f ) = if (π(ti1) π(tim)) if t = f (t1 tn) and π( f ) = [i1 im]

3Improved definitions of the ldquousable rulesrdquo that lead to a better approximation of these rules can befound in [13 14 16]

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 9: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 163

An argument filtering with π( f ) = i for some f isin F is called collapsing For any TRSR let π(R) = π(l) rarr π(r) | l rarr r isin R

For any relation let π be the relation where t π u holds iff π(t) π(u) In[1] it was shown that if () is a reduction pair then (π π ) is a reduction pairas well For any TRS P and any relation let P = s rarr t isin P | s t that is Pcontains those rules of P that decrease wrt Now we can define a DP processorthat deletes all pairs from P that are strictly decreasing wrt a reduction pair and anargument filtering (ie all pairs of Pπ

)

Theorem 12 (Reduction Pair Processor [1 12 25]) Let () be a reduction pairand let π be an argument filtering Then the following DP processor Proc is sound andcomplete Here Proc( (PR e) ) =

ndash (P PπR e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπ= R

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

So in Example 1 we obtain the following ten constraints for termination Here(i i) is the reduction pair and πi is the argument filtering for the DP problem(PiR t) where i isin 1 2

π1(MINUS(s(x) s(y))) 1 π1(MINUS(x y)) (6)

π2(DIV(s(x) s(y))) 2 π2(DIV(minus(x y) s(y))) (7)

πi(minus(x0)) i πi(x) (8)

πi(minus(s(x) s(y))) i πi(minus(x y)) (9)

πi(div(0 s(y))) i πi(0) (10)

πi(div(s(x) s(y))) i πi(s(div(minus(x y) s(y)))) (11)

We use the filtering πi(minus)=[1] which replaces all terms minus(t1 t2) byminus(t1) and does not modify other function symbols With this filtering (6)ndash(11)are satisfied by the lexicographic path order (LPO) with the precedence div gt s gt

minus Hence one can remove the only dependency pair from the DP problems(P1R t) and (P2R t) respectively The remaining DP problems (emptyR t) aretransformed into the empty set by the dependency graph processor of Definition 8that is termination of the TRS is proved Similarly one can use a collapsing filteringπi(minus) = πi(div) = 1 that replaces all terms minus(t1 t2) or div(t1 t2) by t1 Theneven the embedding order orients the resulting constraints

For innermost termination (P1R i) gives rise only to the constraint (6) since P1

has no usable rules For (P2R i) the constraints (10) and (11) are not necessarysince the div-rules are not usable Indeed the constraints for innermost termination

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 10: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

164 J Giesl et al

are always a subset of the constraints for termination Hence for TRSs where inner-most termination already implies termination (eg locally confluent overlay systemsand in particular non-overlapping TRSs [20]) one should always use techniques forinnermost termination when attempting termination proofs

Whenever a processor modifies a DP problem one should apply the dependencygraph processor afterwards This generalizes the strategy of the recursive SCCalgorithm of [25] that was suggested for the classical dependency pair approachHere SCCs of the dependency graph were recomputed whenever some dependencypairs were strictly oriented and therefore removed In the DP framework thisapproach would correspond to a repeated alternating application of the processorsin Theorem 8 and 12 However by formulating other termination techniques as DPprocessors as well they can now be incorporated into this strategy too

3 Improving Termination Proofs by Usable Rules

Now we improve Theorem 12 such that its constraints for termination become assimple as the ones for innermost termination4 As observed in [43] the followingdefinition is useful to weaken the constraints

Definition 13 (Cε [19]) Cε is the TRS c(x y) rarr x c(x y) rarr y where c is a newfunction symbol A TRS R is Cε-terminating iff R cup Cε is terminating A relation is Cε-compatible iff c(x y)x and c(x y) y5 A reduction pair () is Cε-compatible iff is Cε-compatible

Toyamarsquos TRS R = f(01 x) rarr f(x x x) [41] is terminating but not Cε-terminating since R cup Cε has the infinite reduction f(01 c(01)) rarr f(c(01)c(01) c(01))rarr2 f(01 c(01))rarr Thus requiring l π r only for the usablerules is not sufficient for termination R cup Cεrsquos only SCC F(01 x) rarr F(x x x) hasno usable rules and there is a reduction pair () such that the dependency pairis strictly decreasing6 Hence R cup Cε is innermost terminating but not terminatingsince we cannot satisfy both F(01 x) π F(x x x) and l π r for the Cε-rules

So a reduction of the constraints in Theorem 12 is impossible in general but itis possible if we restrict ourselves to Cε-compatible quasi-orders For automationthis is not a restriction if one uses a quasi-simplification order (ie a monotonicand stable quasi-order with the subterm property f ( t ) t for any term t andsymbol f ) Thus any quasi-simplification order orients Cε A similar observationholds for polynomial orders although polynomial orders are no quasi-simplificationorders if one permits the coefficient 0 in polynomials However they can always beextended to orient Cε For example one could associate c with the polynomial thatadds its two arguments that is one could define Pol(c(x y)) = x + y

4Independently Hirokawa and Middeldorp obtained a corresponding result in [22]5Instead of ldquoCε-compatibilityrdquo [43] uses the notion ldquoπ expandabilityrdquo6For example one can use the reduction pair (rarrlowast

DP(R)cupRrarr+DP(R)cupR)

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 11: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 165

The first step in this direction was taken by Urbain [43] He showed that in ahierarchy of Cε-terminating TRSs one can disregard all rules occurring ldquolaterrdquo in thehierarchy when proving termination Hence in Example 1 to show the terminationof minus [43] would require only that the MINUS-dependency pair (1) be strictlydecreasing and the minus-rules weakly decreasing Compared to the reduction pairprocessor of Theorem 12 the advantage is that no weak decrease of the div-rules isrequired anymore since minus does not depend on div But the constraints are stillharder than the ones for innermost termination since one requires a weak decreasefor theminus-rules although they are not usable for theMINUS-dependency pair Wewill improve this approach further and show in Theorem 17 that even for terminationit suffices only to require a weak decrease for the usable rules So compared to [43]our result leads to significantly fewer constraints for termination proofs

Moreover because of the restriction to Cε-termination [43] could not use thefull power of dependency graphs For example recent improved dependency graphestimations [25 35] can detect that the dependency graph for Toyamarsquos TRS Rhas no SCC and thus is terminating But since it is not Cε-terminating it cannot behandled by [43] In contrast our result can be combined with arbitrary estimationsof dependency graphs More precisely before applying the new reduction pairprocessor of Theorem 17 one can use any other DP processor (eg the dependencygraph processor with any sound graph estimation) In this way one can also provetermination of non-Cε-terminating TRSs

To prove that it suffices to regard the usable rules in termination proofs we showthat for every minimal (PR)-chain s1 rarr t1 s2 rarr t2 there exists a substitutionσ such that tiσ reduces to si+1σ using only the rules of UR(P) cup Cε In other wordsevery minimal (PR)-chain is also a (P UR(P) cup Cε)-chain However the resulting(P UR(P) cup Cε)-chain is not necessarily minimal

For example let P consist of the DIV-dependency pair (3) Then UR(P) onlycontains the minus-rules Two (variable-renamed) occurrences of (3) (like (4) and(5)) form a minimal chain as DIV(minus(x1 y1) s(y1))σ rarrlowast

R DIV(s(x2) s(y2))σ

holds for some σ (eg σ(x1) = s(0) σ(y1) = div(0 s(0)) σ(x2) = σ(y2) = 0) Ifone uses this particular substitution σ then one indeed needs the non-usable rulediv(0 s(y)) rarr 0 to reduce σ(y1) to 0 that is to reduce DIV(minus(x1 y1) s(y1))σ toDIV(s(x2) s(y2))σ However we will show that for any σ there is also a substitutionI1(σ ) such that DIV(minus(x1 y1) s(y1))I1(σ ) reduces to DIV(s(x2) s(y2))I1(σ ) byapplying only usable rules and Cε-rules

We proceed in a similar way as in the proof of [43] and in the original proofsof Gramlich [19] More precisely we map any R-reduction to a reduction wrtUR(P) cup Cε Let contain all function symbols occurring in right-hand sides of P cupUR(P) (ie all usable symbols of P) Thus UR(P) = RlsR() (where RlsR() =⋃

fisin RlsR( f )) So for P = (3) we have = DIVminus s Our mapping I1

modifies the earlier mappings of [19 43] by treating terms g(t1 tn) with g isin

differently Figure 1 illustrates that by this mapping every minimal chain over Rcorresponds to a chain over RlsR() cup Cε but instead of the substitution σ one usesa different substitution I1(σ )

Intuitively I1(t) ldquocollectsrdquo all terms that t can be reduced to in zero or more stepsHowever we regard reductions only on or below non-usable symbols that is symbolsthat are not from To represent a collection t1 tn of terms by just one singleterm one uses the term c(t1 c(t2 c(tnd) )) with a fresh constant d

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 12: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

166 J Giesl et al

Fig 1 Transformation of chains

Definition 14 (I1) Let sube F and let t isin T (F V) be a terminating term (ie t startsno infinite R-reductions) We define I1(t)

I1(x)= x for x isin VI1( f (t1 tn))= f (I1(t1) I1(tn)) for f isin

I1(g(t1 tn))=Comp(g(I1(t1) I1(tn)) cup Red1(g(t1 tn))) for g isin

where Red1(t) = I1(tprime) | t rarrR tprime Moreover Comp(t M) = c(t Comp(M)) andComp(empty) = d where d is a fresh constant To make Comp well defined in ldquot Mrdquowe assume that t is smaller than all terms in M wrt some total well-founded ordergtT on terms

For a terminating substitution σ (ie σ(x) terminates for all xisinV) we define thesubstitution I1(σ ) as I1(σ ) (x) = I1(σ (x)) for all x isin V

Hence for P = (3) and = DIVminus s we obtain

I1(div(0 s(0))) = Comp( div(I1(0)I1(s(0))) I1(0) )

= c( div(I1(0) s(I1(0))) c(I1(0) d) )

= c( div(c(0d) s(c(0d))) c( c(0d) d) )

So in contrast to the above substitution σ the substitution I1(σ ) instantiates y1

by I1(div(0 s(0))) instead of div(0 s(0)) and it instantiates y2 by I1(0) insteadof 0 Now one can reduce I1(σ )(y1) to I1(σ )(y2) by applying Cε-rules instead ofapplying a non-usable div-rule Thus the rules of RlsR() cup Cε suffice to reduceDIV(minus(x1 y1) s(y1))I1(σ ) to DIV(s(x2) s(y2))I1(σ )

Note that Definition 14 is possible only for terminating terms t otherwise I1(t)could be infinite Before we prove the desired theorem we need some additionalproperties of Comp and I1 We want to show that for any minimal (PR)-chains1 rarr t1 s2 rarr t2 with tiσ rarrlowast

R si+1σ we also have ti I1(σ ) rarrlowastRlsR()cupCε

si+1 I1(σ )In contrast to the corresponding lemmas in [37 43] Lemma 16 shows that even ifthe left-hand sides of dependency pairs and rules are not from T (V) the rules ofR RlsR() are not needed to reduce ti I1(σ ) to si+1 I1(σ ) Therefore Lemma 16(b) and (c) replace equalities from the lemmas of [37 43] by ldquorarrlowast

Cεrdquo This is possible

by including ldquog(I1(t1) I1(tn))rdquo in the definition of I1(g(t1 tn)) for g isin

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 13: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 167

Lemma 15 (Properties of Comp) If t isin M then Comp(M) rarr+Cε

t

Proof For t1 ltT middot middot middot ltT tn and 1 le i le n we have Comp(t1 tn) = c(t1 c(ti c(tnd) ) ) rarrlowast

Cεc(ti c(tnd) ) rarrCε

ti

Lemma 16 (Properties of I1) Let subeF such that f isin implies gisin wheneverg occurs in the right-hand side of a rule from RlsR( f ) Let t s tσ isin T (F V) beterminating and let σ be a terminating substitution

(a) If t isin T (V) then I1(tσ) = t I1(σ )(b) I1(tσ) rarrlowast

Cεt I1(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI1(t) rarr+

lrarrrcupCεI1(s)

(d) If t rarrR s with root(t) isin then I1(t) rarr+Cε

I1(s)(e) If t rarrlrarrr s where l rarr r isin R then I1(t)rarr+

lrarrrcupCεI1(s) if root(l)isin and

I1(t)rarr+CεI1(s) otherwise

Proof

(a) The proof is a straightforward structural induction on t(b) The proof is by structural induction on t The only interesting case is t =

g(t1 tn) where g isin Then we obtain the following

I1(g(t1 tn)σ ) = Comp(g(I1(t1σ) I1(tnσ)) cup Red1(g(t1σ tnσ)))

rarr+Cε

g(I1(t1σ) I1(tnσ)) by Lemma 15rarrlowast

Cεg(t1 I1(σ ) tn I1(σ )) by induction hypothesis

= g(t1 tn)I1(σ )

(c) We have t= lσ rarrR rσ =s and risinT (V) by the condition on By (b) and (a)we get I1(lσ) rarrlowast

Cεl I1(σ ) rarrlrarrr r I1(σ ) = I1(rσ)

(d) The claim follows by I1(t) = Comp( cup Red1(t)) I1(s) isin Red1(t) andLemma 15

(e) We perform induction on the position p of the redex If root(t) isin we use (d)If root(t) isin and p is the root position we apply (c) Otherwise p is belowthe root t = f (t1 ti tn) s = f (t1 si tn) f isin and ti rarrlrarrr siThen the claim follows from the induction hypothesis

Now we show the desired theorem that improves upon Theorem 12 since theconstraints are reduced significantly Thus it becomes easier to find a reduction pairsatisfying the resulting constraints

Theorem 17 (Reduction Pair Processor Based on Usable Rules) Let () be areduction pair and π be an argument filtering Then the DP processor Proc is soundand complete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 14: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

168 J Giesl et al

(b) either e = t and Rπsupe UR(P) and is Cε-compatible

or e = i and Rπsupe UR(P)

ndash (PR e) otherwise

Proof PPπsubeP implies completeness For soundness we consider only the new

case e = t If (PR t) is not finite then there is a minimal infinite (PR)-chain s1 rarrt1 s2 rarr t2 with tiσ rarrlowast

R si+1σ for all iSince all terms tiσ and si+1σ are terminating we can apply I1 to both tiσ and

si+1σ (where are the usable symbols of P again) Using Lemma 16 (e) we obtainI1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ)

Moreover by the definition of UR all ti are terms over the signature So by Lemma 16 (a) and (b) we get ti I1(σ ) = I1(tiσ) rarrlowast

RlsR()cupCεI1(si+1σ) rarrlowast

si+1 I1(σ ) stating that s1 rarr t1 s2 rarr t2 is also a (P RlsR() cup Cε)-chain ie a(P UR(P) cup Cε)-chain

Thus we have

ndash si I1(σ ) π ti I1(σ ) for all i where si rarr ti isin Pπ

ndash si I1(σ ) π ti I1(σ ) for all other indash ti I1(σ ) π si+1 I1(σ ) for all i

Since π is well founded and compatible with π dependency pairs from Pπ

cannot occur infinitely often in this chain Thus there is an n ge 0 such that all pairssi rarr ti with i ge n are from P Pπ

Therefore if we omit the first n minus 1 pairs fromthe original chain we obtain a minimal infinite (P Pπ

R)-chain sn rarr tn sn+1 rarrtn+1 Hence (P Pπ

R t) is not finite either

Note that in Theorem 17 one has to orient only the usable rules UR(P) but onekeeps all rules R in the resulting DP problem (P Pπ

R e) As an alternative onemight be tempted to replace Theorem 17 by a ldquousable rule processorrdquo followed by anapplication of the reduction pair processor of Theorem 12 The usable rule processorProcU would remove all non-usable rules and add the Cε-rules in the terminationcase cf [15 Theorem 28 and Theorem 37]

ProcU ((PR t)) = (PUR(P) cup Cε t)ProcU ((PR i)) = (PUR(P) i)

However the following example shows that ProcU is not sound in the terminationcase In the example there is an infinite minimal (PR)-chain and thus there isalso an infinite (PUR(P) cup Cε)-chain However there exists no infinite minimal(PUR(P) cup Cε)-chain Therefore (PUR(P) cup Cε t) is finite whereas (PR t) isnot finite

Example 18 The following DP problem (PR t) is a variant of Toyamarsquos TRS LetP consist of

F(0 1 x1 0 1 x2 0 1 x3 y) rarr F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 15: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 169

and let R consist of the following ten rules

a rarr 0 g(x x y) rarr h(x x)

a rarr 1 g(x y x) rarr h(x x)

b rarr 0 g(y x x) rarr h(x x)

b rarr 1 h(01) rarr h(01)e rarr 0e rarr 1

There is an infinite minimal (PR)-chain as can be shown by using the substi-tution σ with σ(x1) = a σ(x2) = b σ(x3) = e and σ(y) = g(ab e) The reason isthat the instantiated right-hand side of P rsquos only rule now reduces to its instantiatedleft-hand side

F(x1 x1 x1 x2 x2 x2 x3 x3 x3 g(x1 x2 x3))σ

= F(aaa bbbee eg(abe))rarr6

R F(01 a01b0 1eg(abe))= F(01 x1 01 x2 01 x3 y)σ

The resulting infinite chain is minimal since the instantiated right-hand sideF(aaabbb eeeg(abe)) is terminating The reason is that g(ab e) canbe reduced to h(00) or to h(11) but not to h(01) Thus the DP problem (PR t)is not finite

However the DP problem (PUR(P) cup Cε t) is finite and therefore any processorthat transforms (PR t) into (PUR(P) cup Cε t) is unsound Here UR(P) consistsof all g-rules and the h-rule ie UR(P) = RlsR(gh) To prove that (PUR(P) cupCε t) is finite we have to show that there is no infinite minimal (PUR(P) cup Cε)-chain

In any chain of length greater than 1 the right-hand side of P rsquos rule has to beinstantiated by a substitution σ such that all xiσ can be reduced to both 0 and 1 withUR(P) cup Cε It is easy to see that then each xiσ can also be reduced to c(01) or toc(10) So there are at least two xiσ and x jσ with i = j that can be reduced to thesame term c(01) or c(10) Hence the subterm g(x1 x2 x3)σ of P rsquos instantiatedright-hand side can be reduced to h(c(01) c(01)) or to h(c(10) c(10)) andfurther to the non-terminating term h(01) So the instantiated right-hand side ofP rsquos rule is not terminating and thus there is no minimal chain of length greaterthan 1

The following variant of an example from [1] shows that Theorem 17 not onlyincreases efficiency but also leads to a more powerful method than Theorem 12 (ifone is restricted to Cε-compatible quasi-orders )

Example 19 In the following TRS div(x y) computes xy for x y isin IN if y = 0 and

quot(x y z) computes 1 + xminusyz if x ge y and z = 0 and it computes 0 if x lt y

div(0 y) rarr 0 (12)

div(x y) rarr quot(x y y) (13)

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 16: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

170 J Giesl et al

quot(0 s(y) z) rarr 0 (14)

quot(s(x) s(y) z) rarr quot(x y z) (15)

quot(x0 s(z)) rarr s(div(x s(z))) (16)

In contrast to our new processor Urbainrsquos result [43] is not applicable in thisexample The reason is that this TRS is not a hierarchical combination (since divand quot are mutually recursive)

Note also that this TRS does not belong to known classes of TRSs whereinnermost termination implies termination since it is not locally confluent div(00)reduces to the normal forms 0 and quot(000)

A termination proof is impossible with the previous processors from Theorem 8and Theorem 12 if one uses standard reduction pairs () where is a quasi-simplification order In contrast innermost termination can easily be proved Weobtain the following dependency pairs that form an SCC of the dependency graph

DIV(x y) rarr QUOT(x y y) (17)

QUOT(s(x) s(y) z) rarr QUOT(x y z) (18)

QUOT(x0 s(z)) rarr DIV(x s(z)) (19)

There are no usable rules because the dependency pairs have no defined symbolsin their right-hand sides Thus the reduction pair processor requires a decreaseonly for the dependency pairs Hence with a filtering π(QUOT) = π(DIV) = 1 andthe embedding order (17) and (19) are weakly decreasing while (18) is strictlydecreasing and can be removed So the reduction pair processor transforms theinitial DP problem ((17) (18) (19) R i) into ((17) (19) R i) With the newimproved processor of Theorem 17 this step can now also be done when provingfull termination Afterwards the remaining DP problem can easily be solved bythe existing DP processors we apply the reduction pair processor once more witha filtering π(s) = [ ] π(QUOT) = π(DIV) = 2 and the LPO with a precedence 0 gt sNow (17) is weakly decreasing and (19) is strictly decreasing and can be removedThe resulting DP problem ((17) R e) is solved by the dependency graph processorsince the estimated dependency graph has no cycle anymore

Now our technique for termination is nearly as powerful as the one for inner-most termination The remaining difference between termination and innermosttermination proofs is that the innermost dependency graph is a subgraph of thedependency graph and may have fewer cycles Moreover in Section 5 we will seethat the conditions for applying dependency pair transformations are less restrictivefor innermost termination than for termination Moreover for termination we useCε-compatible quasi-orders which is not necessary for innermost terminationHence in general innermost termination is still easier to prove than terminationbut the difference has become much smaller

4 Improving Termination Proofs by Argument Filtering

Now we introduce a further improvement for both termination and innermosttermination proofs in order to reduce the usable rules (and hence the resulting

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 17: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 171

constraints) further The idea is to apply the argument filtering first and to determinethe usable rules afterwards The advantage is that after the argument filtering somesymbols g may have been eliminated from the right-hand sides of dependency pairsand thus the g-rules do not have to be included in the usable rules anymoreMoreover if f rsquos rules are usable and f calls a function g then up to now grsquos rulesare also considered usable However if all calls of g are only on positions that areeliminated by the argument filtering now also grsquos rules are not considered usableanymore

However for collapsing argument filterings this refinement is not sound Considerthe following non-innermost terminating TRS

f(s(x))rarr f(double(x)) double(0)rarr0 double(s(x))rarrs(s(double(x)))

In the SCC F(s(x))rarrF(double(x)) we can use the filtering π(double) = 1which results in F(s(x)) rarr F(x) Since the filtered dependency pair contains nodefined symbols we would conclude that the SCC has no usable rules Then we couldeasily orient the only resulting constraint F(s(x)) F(x) for this SCC and falselyprove (innermost) termination Note that the elimination of double in F(double(x))

is due not to the outer symbol F but to a collapsing argument filtering for doubleitself For that reason a defined symbol like double may be ignored only whenconstructing the usable rules if all its occurrences are in positions that are filteredaway by the function symbols above them To capture this formally we define theregarded positions wrt an argument filtering In this definition collapsing argumentfilterings with π( f ) = i are treated in the same way as filterings of the form π( f ) = [i]

Definition 20 (Regarded Positions) Let π be an argument filtering For an n-aryfunction symbol f the set rpπ ( f ) of regarded positions is i if π( f ) = i and it isi1 im if π( f ) = [i1 im]

Hence if π(F) = [1] or π(F) = 1 then rpπ (F) = 1 Now we can define the usablerules wrt an argument filtering For a term like F(double(x)) the rules for allsymbols on regarded positions are considered usable Thus if rpπ (F) = 1 then thedouble-rules are usable

Definition 21 (Usable Rules wrt Argument Filtering) For f isin F let Rprime denoteRRlsR( f ) For any argument filtering π we define the following

ndash UR(x π) = empty for x isin V andndash UR( f (t1 tn) π) = RlsR( f ) cup ⋃

lrarrrisinRlsR( f ) URprime(r π)

cup ⋃iisinrpπ ( f ) URprime(ti π)

For any TRS P we define UR(P π) = ⋃srarrtisinP UR(t π)

Obviously this new definition of usable rules improves upon the previous one ofDefinition 10 that is UR(t π) sube UR(t) for any term t

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 18: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

172 J Giesl et al

Example 22 We illustrate the new definition of usable rules with the following TRSof [27] for list reversal

rev(nil) rarr nil

rev(cons(x l)) rarr cons(rev1(x l) rev2(x l))

rev1(xnil) rarr x

rev1(x cons(y l)) rarr rev1(y l)

rev2(xnil) rarr nil

rev2(x cons(y l)) rarr rev(cons(x rev(rev2(y l))))

For the SCC P containing the dependency pair REV2(x cons(y l)) rarr REV(cons(x

rev(rev2(y l)))) up to now all rules were usable since rev and rev2 occur in the right-hand side and the function rev calls rev1 In contrast if one uses an argument filteringwith π(cons) = [2] then with our new definition of usable rules from Definition 21the rev1-rules are no longer usable since rev1 is not in right-hand sides of filteredrev-rules This reduction of the set of usable rules is crucial for the success of the(innermost) termination proof with dependency pairs cf Example 27

The following lemma is needed to show that one may replace UR(P) by UR(P π)

in innermost termination proofs

Lemma 23 (Properties of Usable Rules) Let R be a TRS let π be an argumentfiltering and let σ be a normal substitution (ie σ(x) is in normal form for all x isin V)For all terms t v we have the following

(a) If tσ irarrR v then π(tσ) = π(v) or π(tσ) rarrπ(UR(tπ)) π(v) Moreover there is aterm u and a normal substitution σ prime such that v = uσ prime and UR(u π) sube UR(t π)

(b) If tσ irarrlowastR v then π(tσ) rarrlowast

π(UR(tπ))π(v)

Proof

(a) We perform induction on the position of the reduction This position must bein t because σ is normal So t has the form f (t1 tn)If the reduction is on the root position then we have tσ = lσ prime irarrR rσ prime = vwhere l rarr r isin RlsR( f ) sube UR(t π) and thus π(l) rarr π(r) isin π(UR(t π)) Letσ prime

π be the substitution with σ primeπ (x) = π(σ prime(x)) for all x isin V Then π(tσ) =

π(l)σ primeπ rarrπ(UR(tπ)) π(r)σ prime

π = π(v) Moreover σ prime is a normal substitution be-cause of the innermost strategy and by defining u = r we obtain v = uσ prime Wehave UR(u π) = UR(r π) sube RlsR( f ) cup ⋃

lprimerarrrprimeisinRlsR( f ) URprime(rprime π) sube UR(t π)Otherwise tσ = f (t1σ tiσ tnσ)rarrR f (t1σ vi tnσ)=v where tiσ rarrRvi If π(tσ) = π(v) then i isin rpπ ( f ) The induction hypothesis implies π(tiσ)

rarrπ(UR(tiπ)) π(vi) and thus π(tσ) rarrπ(UR(tiπ)) π(v) As UR(ti π)sube RlsR( f ) cup⋃lprimerarrrprimeisinRlsR( f ) URprime(rprime π) cup URprime(ti π) sube UR(t π) we also have π(tσ) rarrπ(UR(tπ))

π(v)By the induction hypothesis there is some term ui and some normal substitutionσi with vi = uiσi Let uprime

i result from ui by replacing its variables x by correspond-ing fresh variables xprime We define σ prime(xprime) = σi(x) for all these fresh variables andσ prime(x) = σ(x) for all x isin V(t) Then for u = f (t1 uprime

i tn) we obtain v = uσ prime

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 19: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 173

Obviously we have UR(uprimei π) = UR(ui π) and the induction hypothesis im-

plies UR(ui π) sube UR(ti π) As UR(ti π) sube UR(t π) (see above) we also haveUR(uprime

i π) sube UR(t π) Since UR(u π) differs from UR(t π) only by containingURprime(uprime

i π) instead of URprime(ti π) and since URprime(uprimei π) sube UR(uprime

i π) sube UR(t π) wealso obtain UR(u π) sube UR(t π)

(b) The claim immediately follows from (a) by induction on the length of thereduction tσ irarrlowast

R v

The refinement of coupling the usable rules with argument filterings can be usedfor both innermost and full termination proofs In the previous section we showedthat it suffices for termination proofs if just the usable rules UR(P) are weaklydecreasing To show that one may replace UR(P) by UR(P π) here we define anew mapping I2 that already incorporates the argument filtering π

For instance let = F rev1 and let π(cons) = [2] π(rev2) = [2]I2(cons(rev1(x l) rev2(x l))) differs from I1(cons(rev1(x l) rev2(x l))) by remov-ing the first arguments of all cons- and rev2-terms So I1 results in cons(c(rev1(x

l)d) rev2(x l)) and I2 yields cons(rev2(l))

Definition 24 (I2) Let π be a non-collapsing argument filtering let sube F and lett isin T (F V) be terminating We define I2(t)

I2(x)= x for xisinVI2( f (t1 tn))= f (I2(ti1) I2(tim)) for f isinπ( f )=[i1 im]I2(g(t1 tn))= Comp( g(I2(ti1) I2(tim))

cup Red2(g(t1 tn)) ) for g isinπ(g)=[i1 im]

where Red2(t) = I2(tprime) | t rarrR tprime For every terminating substitution σ we defineI2(σ ) as I2(σ ) (x) = I2(σ (x)) for all x isin V

Lemma 25 differs from Lemma 16 because I2 already applies the filtering π andin (e) we have ldquolowastrdquo instead of ldquo+rdquo since a reduction on a position that is filtered awayyields the same transformed terms wrt I2

Lemma 25 (Properties of I2) Let π be a non-collapsing filtering and let sube F suchthat f isin implies g isin whenever there is a rule l rarr r isin RlsR( f ) such that g occursin π(r) Let t s tσ isin T (F V) be terminating and let σ be a terminating substitution

(a) If π(t) isin T (πV) then I2(tσ) = π(t)I2(σ )(b) I2(tσ) rarrlowast

Cεπ(t)I2(σ )

(c) If t rarrlrarrr s by a root reduction step where l rarr r isin R and root(l) isin thenI2(t) rarr+

π(l)rarrπ(r)cupCεI2(s)

(d) If t rarrR s with root(t) isin then I2(t) rarr+Cε

I2(s)(e) If t rarrlrarrr s where l rarr r isin R then I2(t) rarrlowast

π(l)rarrπ(r)cupCεI2(s) if root(l) isin and

I2(t) rarrlowastCε

I2(s) otherwise

Proof The proof is analogous to the proof of Lemma 16 As in Lemma 16 thecondition on in the prerequisites of Lemma 25 is needed for (c)

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 20: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

174 J Giesl et al

Now we can refine the processor of Theorem 17 to the following one where theset of usable rules is reduced significantly

Theorem 26 (Reduction Pair Processor Based on Filtering) Let () be a reductionpair and let π be an argument filtering Then the following processor Proc is sound andcomplete Here Proc( (PR e) ) =ndash (P Pπ

R e) if the following conditions (a) and (b) hold

(a) Pπcup Pπ

= P and Pπ= empty

(b) either e = t and Rπsupe UR(P π) and is Cε-compatible

or e = i and Rπsupe UR(P π)

ndash (PR e) otherwise

Proof Again P Pπsube P implies completeness For soundness we first regard the

case e = i If (PR i) is not finite then there is an infinite innermost (PR)-chains1 rarr t1 s2 rarr t2 So we have tiσ irarrlowast

R si+1σ where all siσ are in normal form ByLemma 23 (b) we obtain π(tiσ) rarrlowast

π(UR(Pπ))π(si+1σ) All rules of UR(P π) are

decreasing wrt π and thus all rules of π(UR(P π)) are decreasing wrt Thisimplies π(tiσ) π(si+1σ) that is tiσ π si+1σ Since Pπ

cup Pπ= P pairs of Pπ

cannot occur infinitely often in the chainNow we prove soundness for e = t If (PR t) is not finite then there is a minimal

infinite (PR)-chain s1 rarr t1 s2 rarr t2 with tiσ rarrlowastR si+1σ

Let π prime be the non-collapsing variant of π where π prime( f ) = π( f ) if π( f ) = [i1 ik]and π prime( f ) = [i] if π( f ) = i Let be the usable symbols wrt π prime of P So

is the smallest set of function symbols such that contains all function sym-bols occurring in right-hand sides of π prime(P) and f isin implies g isin wheneverthere is a rule l rarr r isin RlsR( f ) such that g occurs in π prime(r) Thus π prime(UR(P π prime)) =π prime(RlsR()) Note that by definition we have UR(P π prime) = UR(P π) Then similar tothe proof of Theorem 17 tiσ rarrlowast

R si+1σ implies π prime(ti)I2(σ ) = I2(tiσ) rarrlowastπ prime(UR(Pπ))cupCε

I2(si+1σ) rarrlowastCε

π prime(si+1)I2(σ ) by Lemma 25 (a) (e) (b) So π prime(s1) rarr π prime(t1) π prime(s2) rarrπ prime(t2) is an infinite (π prime(P) π prime(UR(P π)) cup Cε)-chain

Now we show that in this chain pairs from π prime(Pπ) cannot occur infinitely often

Thus there is an n ge 0 such that all si rarr ti with i ge n are from P Pπ Then

sn rarr tn sn+1 rarr tn+1 is a minimal infinite (P Pπ R)-chain and thus (P

PπR t) is not finite either

To show that pairs from π prime(Pπ) cannot occur infinitely often in the (π prime(P)

π prime(UR(P π)) cup Cε)-chain π prime(s1) rarr π prime(t1) π prime(s2) rarr π prime(t2) let π primeprime be the argu-ment filtering for the signature Fπ prime which only performs the collapsing steps of π

(ie if π( f ) = i and thus π prime( f ) = [i] we have π primeprime( f ) = 1) All other symbols of Fπ prime

are not filtered by π primeprime Hence π = π primeprime π prime We extend π primeprime to the new symbol c bydefining π primeprime(c) = [1 2] Hence Cε-compatibility of implies Cε-compatibility of π primeprime

Now regard the reduction pair (π primeprime π primeprime) For all terms s and t the constraintldquosπ trdquo implies that the rule π prime(s)rarrπ prime(t) is strictly decreasing (ie π prime(s) π primeprime π prime(t))and the constraint ldquos π trdquo implies that the rule π prime(s) rarr π prime(t) is weakly decreas-ing (ie π prime(s) π primeprime π prime(t)) Thus by (a) the pairs of π prime(Pπ

) are strictly decreasingand by (b) all remaining pairs of π prime(P) and all rules of π prime(UR(P π)) cup Cε areweakly decreasing wrt the reduction pair (π primeprime π primeprime) Thus the chain π prime(s1) rarrπ prime(t1) π prime(s2) rarr π prime(t2) contains only finitely many pairs from π prime(Pπ

)

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 21: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 175

Example 27 The TRS R for list reversal from Example 22 shows the advantages ofTheorem 26 The dependency graph processor decomposes the initial DP problem(DP(R)R e) into ((20) R e) and ((21)ndash(24) R e) where (20)ndash(24) are thefollowing dependency pairs

REV1(x cons(y l)) rarr REV1(y l) (20)

REV(cons(x l)) rarr REV2(x l) (21)

REV2(x cons(y l)) rarr REV(cons(x rev(rev2(y l)))) (22)

REV2(x cons(y l)) rarr REV(rev2(y l)) (23)

REV2(x cons(y l)) rarr REV2(y l) (24)

Since (20) has no usable rules already the reduction pair processor of Theorem 17requires only to make the dependency pair (20) strictly decreasing For examplethis is possible by using an argument filtering with π(REV1) = 2 and the embeddingorder The resulting DP problem (emptyR e) is then removed by the dependency graphprocessor

However when proving (innermost) termination with Theorem 17 for the prob-lem ((21)ndash(24) R e) we obtain inequalities from the dependency pairs and π(l) π(r) for all rules l rarr r since all rules are usable But with standard reduction pairsbased on RPOS KBO or polynomial orders these constraints are not satisfiable forany argument filtering [14] In contrast with Theorem 26 we can use the filteringπ(cons) = [2] π(REV) = π(rev) = 1 and π(REV1) = π(REV2) = π(rev2) = 2 to-gether with the embedding order Now we obtain no constraints from the rev1-rulescf Example 22 Then the filtered dependency pairs (21) (23) and (24) are strictlydecreasing and the filtered pair (22) and all filtered usable rules are at least weaklydecreasing Thus the reduction pair processor of Theorem 26 results in the DPproblem ((22) R e) which is again removed by the dependency graph processor

5 Transforming Dependency Pairs

In order to increase the power of the dependency pair technique a dependencypair may be transformed into new pairs Section 51 introduces improved versionsof these transformations that permit a combination with our new results from theprevious sections Then in Section 52 we discuss a heuristic in order to mechanizethese transformations in practice

51 Improving Dependency Pair Transformations

In [1 11] techniques were presented to modify dependency pairs by narrowingrewriting and instantiation This approach is often crucial for the success of atermination proof The basic idea of narrowing and rewriting is the following if thereis a chain s rarr t v rarr w where tσ rarrlowast

R vσ implies that tσ must be rewritten at leastone step before it reaches vσ then these transformations perform this reduction stepdirectly on the pair s rarr t The rewriting technique can be used only for innermosttermination Here the right-hand side t must contain a redex Then one may rewritethis redex even if t contains other redexes as well In contrast for the narrowing

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 22: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

176 J Giesl et al

transformation one has to build all narrowings of t instead of doing just one rewritestep A term tprime is an R-narrowing of t with mgu μ if a subterm t|p isin V of t unifieswith the left-hand side of a (variable-renamed) rule l rarr r isin R with mgu μ andtprime = t[r]p μ Now s rarr t can be replaced by all narrowings sμ rarr tprime

The idea of the instantiation technique is to examine all pairs v rarr w that precedes rarr t in chains Here we analyze what ldquoskeletonrdquo wprime of w remains unchanged whenwe reduce wσ to sσ Then sσ must also be of this form that is wprime and s unifyThis idea was already used in E(I)DG (Definition 9) where wprime is computed by thefunctions capR and ren and where one only draws an arc from v rarr w to s rarr t if wprimeand s unify with some mgu μ Then wσ rarrlowast

R sσ implies that σ is an instance of μHence the instantiation transformation replaces s rarr t by sμ rarr tμ

The following definition improves the transformations of [1 11] Moreover weintroduce a new forward instantiation technique Here we consider all pairs v rarrw that follow s rarr t in chains For each such v rarr w we have tσ rarrlowast

R vσ that isvσ rarrlowast

Rminus1 tσ Now we compute the mgu between t and a skeleton of v Howeversince the R-reduction goes from an instantiation of t to an instantiation of v and notthe other way around the skeleton of v is not constructed with capR but with thefunction capminus1

R For any set of non-collapsing rules Rprime sube R let capminus1Rprime(v) result from

replacing all subterms of v whose root is from root(r) | l rarr r isin Rprime by different freshvariables If Rprime is collapsing then capminus1

Rprime(v) is a fresh variable As usual a rule l rarr r iscollapsing if r isin V The modifications capminus1

R and capminus1UR(t) were originally introduced

in [25 35 E(I)DGlowast] in order to improve the estimation of (innermost) dependencygraphs Thus while the instantiation transformation is influenced by the E(I)DG-estimation the new forward instantiation is influenced by the E(I)DGlowast-estimation

Definition 28 (Transformation Processors) Let P prime = P s rarr t

(a) For (P primeR e) the narrowing processor Procn returns

ndash (P cup sμ1 rarr t1 sμn rarr tnR e) if either of the following occur

- e = t and t1 tn are all R-narrowings of t with mgursquos μ1 μn andt does not unify with (variable-renamed) left-hand sides of pairs in P primeMoreover t must be linear

- e = i and t1 tn are all R-narrowings of t with the mgursquos μ1 μn

such that sμi is in normal form Moreover for all v rarr w isin P prime where tunifies with the (variable-renamed) left-hand side v by a mgu μ one ofthe terms sμ or vμ must not be in normal form

ndash (P primeR e) otherwise

(b) For (P primeR e) the rewriting processor Procr returns

ndash (P cup s rarr tprimeR e) if e = i UR(t|p) is non-overlapping and t rarrR tprimewhere p is the position of the redex

ndash (P primeR e) otherwise

(c) For (P primeR e) the instantiation processor Proci returns

ndash (P cup sμrarr tμ | μ=mgu(ren(capR(w)) s) vrarrw isin P primeR e)if e = t

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 23: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 177

ndash (P cup sμrarr tμ | μ=mgu(capR(w) s) vrarrwisinP prime sμ vμnormalR e)if e = i

(d) For (P primeR e) the forward instantiation processor Procf returns

ndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1R (v)) t) v rarr w isin P primeR e)

if e = tndash (P cup sμ rarr tμ | μ = mgu(ren(capminus1

UR(t)(v)) t) v rarr w isin P primeR e)if e = i

Example 29 shows the advantage of the new forward instantiation technique

Example 29 Without forward instantiation termination of the TRS f(x y z) rarrg(x y z) g(01 x) rarr f(x x x) cannot be shown by any Cε-compatible reductionpair The instantiation processor is useless here because in chains v rarr w s rarr tthe mgu of ren(capR(w)) and s does not modify s But the forward instantiationprocessor instantiates F(x y z) rarr G(x y z) to F(01 z) rarr G(01 z) The reasonis that in the chain F(x y z) rarr G(x y z) G(01 xprime) rarr F(xprime xprime xprime) the mgu ofren(capminus1

R (G(01 xprime))) = G(01 xprimeprime) and G(x y z) is [x0 y1 xprimeprimez] Now the ter-mination proof succeeds because the dependency graph has no cycle (as detected bythe EDGlowast-estimation of [25 35])

In addition to forward instantiation Definition 28 also extends the existingnarrowing rewriting and instantiation transformations [1 11] by permitting theirapplication for slightly more TRSs if e= i In [11] narrowing s rarr t was not permittedif t unifies with the left-hand side of a dependency pair whereas now this is possibleunder certain conditions Rewriting dependency pairs was allowed only if all usablerules for the current cycle were non-overlapping whereas now this is required onlyfor the usable rules of the redex to be rewritten Moreover for both instantiationand narrowing now one has to consider only instantiations that turn left-hand sidesof dependency pairs into normal forms

However while these liberalized applicability conditions only have a minorimpact the most important improvement of Definition 28 over [1 11] is that nowthe transformations are formulated within the DP framework and that they nowwork for minimal instead of ordinary chains of dependency pairs This is neededto combine the transformations with the improvements of Section 3 and 4 thatrequire the consideration of minimal chains Moreover because of the formulationas processors transformations can now be applied at any time during a terminationproof

Before proving soundness and completeness Example 30 illustrates that transfor-mations are often crucial for the success of the proof

Example 30 The following alternative TRS for division is from [2]

le(0 y) rarr true div(x s(y)) rarr if(le(s(y) x) x s(y))

le(s(x)0) rarr false if(true x y) rarr s(div(minus(x y) y))

le(s(x) s(y)) rarr le(x y) if(false x y) rarr 0minus(x0) rarr x

minus(s(x) s(y)) rarr minus(x y)

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 24: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

178 J Giesl et al

Without transformations no simplification order satisfies Theorem 26rsquos con-straints for innermost termination of the following SCC [14]

DIV(x s(y)) rarr IF(le(s(y) x) x s(y)) (25)

IF(true x y) rarr DIV(minus(x y) y) (26)

But when transforming the dependency pairs the resulting constraints can easily besatisfied Intuitively x minus(x y) has to be required only if le(s(y) x) reducesto true This argumentation can be simulated by using the transformations ofDefinition 28 By narrowing we perform a case analysis on how the le-term in (25)can be evaluated In the first narrowing x is instantiated by 0 The result is a pairDIV(0 s(y))rarr IF(false0 s(y)) which is not in a cycle The other narrowing is

DIV(s(x) s(y)) rarr IF(le(y x) s(x) s(y)) (27)

which forms an SCC with (26) Now we perform instantiation of (26) and see that xand y must be of the form s( ) So (26) is replaced by

IF(true s(x) s(y)) rarr DIV(minus(s(x) s(y)) s(y)) (28)

which forms an SCC with (27) Finally by rewriting (28) we obtain

IF(true s(x) s(y)) rarr DIV(minus(x y) s(y)) (29)

The constraints of the resulting SCC (27) (29) (and all other SCCs) are solved byπ(minus)=π(DIV)=1 π(IF)=2 and the embedding order

Theorem 31 states that the transformations in Definition 28 are sound and it givesconditions under which they are also complete A counterexample that shows thatProcn is not complete in general is [1 Example 43]

Theorem 31 (Sound- and Completeness) Procn Procr Proci and Procf are soundMoreover Procr Proci and Procf are also complete7 Procn is not complete ingeneral but it is complete for DP problems (PR e) where e = t or where UR(P) isnon-overlapping

Proof

Soundness of Procn

First let e = t We show that for every minimal (P primeR)-chain ldquo v1 rarr w1 s rarr tv2 rarr w2 rdquo there is a narrowing tprime of t with the mgu μ such that ldquo v1 rarr w1

sμ rarr tprime v2 rarr w2 rdquo is also a minimal chain Here s rarr t may also be the firstpair (ie v1 rarr w1 may be missing) Then all occurrences of s rarr t in a chain maybe replaced by pairs from sμ1 rarr t1 sμn rarr tn Hence every infinite minimal

7Related proofs for previous versions of the transformations can be found in [1 11] But in contrastto [1 11] now we regard these techniques within the DP framework we use them to prove absenceof minimal chains and we have more liberal applicability conditions Furthermore the forwardinstantiation technique is completely new (its soundness proof builds on proof ideas for the E(I)DGlowast-approximation of [25 35])

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 25: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 179

(P primeR)-chain results in an infinite minimal (P cup sμ1 rarr t1 sμn rarr tnR)-chainThus if (P cup sμ1 rarr t1 sμn rarr tnR) is finite then so is (P primeR)

If ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimal chain then there must be asubstitution such that

(t1) every instantiated right-hand side reduces to the instantiated left-hand side ofthe next pair in the chain and

(t2) all instantiated right-hand sides are terminating wrt R

Let σ be a substitution satisfying (t1) and (t2) where the reduction tσ rarrlowastR v2σ has

minimal length Note that tσ = v2σ as t and v2 do not unify Hence we have tσ rarrRq rarrlowast

R v2σ for some term qFirst we assume that the reduction tσ rarrR q takes place ldquoin σrdquo Hence t|p = x

for some position p such that σ(x) rarrR r and q = t[r]p The variable x occurs onlyonce in t (as t is linear) and therefore q = tσ prime for the substitution σ prime with σ prime(x) = rand σ prime(y) = σ(y) for all variables y = x As all (occurrences of) pairs in the chain arevariable disjoint σ prime behaves like σ for all pairs except s rarr t Here we have

w1σprime = w1σ rarrlowast

R sσ rarrlowastR sσ prime and tσ prime = q rarrlowast

R v2σ = v2σprime

Hence σ prime satisfies (t1) and it satisfies (t2) as well because tσ prime = q is terminatingBut as the reduction tσ prime rarrlowast

R v2σprime is shorter than the reduction tσ rarrlowast

R v2σ this is acontradiction to the definition of σ

So the reduction tσ rarrR q cannot take place ldquoin σrdquo Hence there is a sub-term t|p isin V such that a rule l rarr r has been applied to t|pσ (ie lρ = t|pσ for somematcher ρ) Hence the reduction has the form

tσ = tσ [t|pσ ]p = tσ [lρ]p rarrR tσ [rρ]p = q

We assume that V(l) are fresh variables Then we extend σ to ldquobehaverdquo like ρ onV(l) (but it remains the same on all other variables) Now σ unifies l and t|p Hencethere is also an mgu μ with σ =μτ for some τ

Let tprime be tμ[rμ]p Then t narrows to tprime with the mgu μ As we may assume sμ rarr tprimeto be variable disjoint from all other pairs we can extend σ to behave like τ on thevariables of sμ and tprime Then we have

w1σ rarrlowastR sσ = sμτ = sμσ and

tprimeσ = tprimeτ = tμτ [rμτ ]p = tσ [rσ ]p = tσ [rρ]p = q rarrlowastR v2σ

Hence ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is also a chain that is minimal sincetprimeσ = q is terminating

Now we regard the case e = i Here we prove that for every minimal innermost(P primeR)-chain ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo there exists a narrowing tprime of twith the mgu μ such that sμ is in normal form and such that ldquo v1 rarr w1 sμ rarrtprime v2 rarr w2 rdquo is a minimal innermost chain as well There must be a substitution σ

such that

(i1) every instantiated right-hand side reduces innermost to the instantiated left-hand side of the next pair in the chain

(i2) all instantiated left-hand sides are normal forms and(i3) all instantiated right-hand sides terminate innermost wrt R

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 26: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

180 J Giesl et al

Note that tσ = v2σ Otherwise σ would unify t and v2 where both sσ and v2σ arenormal forms Hence tσ irarrR q irarrlowast

R v2σ for some term q

The reduction tσirarrR q cannot take place ldquoin σrdquo because V(t) sube V(s) Hence

then sσ would not be a normal form which violates (i2) The remainder of the proofis completely analogous to the case e = t

Completeness of Procn

We first regard e = t Let (P cup sμ1 rarr t1 sμn rarr tnR t) be infinite If R is notterminating then trivially (P primeR t) is infinite as well Otherwise we show that anyinfinite (P cup sμ1 rarr t1 sμn rarr tnR)-chain can be transformed into an infinite(P primeR)-chain (Now all chains are minimal since R is terminating)

To this end we prove that if ldquo v1 rarr w1 sμ rarr tprime v2 rarr w2 rdquo is a chain wheret narrows to tprime with the mgu μ then ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a chain aswell There is a substitution σ satisfying (t1) So in particular we have

w1σ rarrlowastR sμσ and tprimeσ rarrlowast

R v2σ

Since the variables in s rarr t are disjoint from all other variables we may extend σ

to behave like μσ on V(s) Then sσ = sμσ and hence

w1σ rarrlowastR sσ (30)

Moreover by the definition of narrowing we have tμ rarrR tprime This implies tμσ rarrRtprimeσ and as tσ = tμσ we obtain

tσ rarrR tprimeσ rarrlowastR v2σ (31)

Hence ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is also a chainNow we show completeness for e = i if UR(P) is non-overlapping Again the non-

trivial case is if R is innermost terminating We show that if ldquo v1 rarr w1 sμ rarr tprimev2 rarr w2 rdquo is an innermost chain where t narrows to tprime with mgu μ then ldquo v1 rarrw1 s rarr t v2 rarr w2 rdquo is an innermost chain as well There is a substitution σ

satisfying (i1) and (i2) Analogous to (30) and (31) in the termination case oneobtains w1σ

irarrlowastR sσ and tσ rarrR tprimeσ irarrlowast

R v2σ where v2σ is a normal form by (i2)Since R is innermost terminating repeated application of innermost reduction stepsto tσ also yields some normal form q that is tσ irarrlowast

R q Note that all rules used in anyreduction of tσ are from UR(P) So tσ is weakly innermost terminating wrt UR(P)Since UR(P) is non-overlapping tσ is terminating and confluent wrt UR(P) by [21Theorem 3211] and thus wrt R as well This implies that tσ only has a uniquenormal form q = v2σ ie tσ irarrlowast

R v2σ Thus ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isalso an innermost chain

Soundness of Procr

We show that if ldquo s rarr t v rarr w rdquo is a minimal innermost (P primeR)-chain thenldquo s rarr tprime v rarr w rdquo is a minimal innermost chain as well There must be a σ withtσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where t|pσ

irarrlowastR q the terms q and vσ are normal

forms and all instantiated right-hand sides (like tσ ) are innermost terminatingWe proceed as in the completeness proof of Procn in the case e = i All rules

applicable in a reduction of t|pσ are contained in UR(t|p) Since t|pσ is weakly

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 27: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 181

innermost terminating and UR(t|p) is non-overlapping by [21 Theorem 3211] t|pσ

is confluent and terminating Note that tprime = t[r]p where t|p rarrR r for some termr Hence t|pσ rarrR rσ and thus rσ is terminating as well Thus it also reducesinnermost to some normal form qprime Now confluence of t|pσ implies q = qprime Hencetprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ Therefore ldquo s rarr tprime v rarr w rdquo is an inner-

most chain too Moreover the innermost chain is minimal since tprimeσ is innermostterminating The reason is that wlog every infinite reduction of tprimeσ starts withreducing the subterm at position p that is with tprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p However

tσ [q]p is innermost terminating since tσ is innermost terminating and since tσ irarrlowastR

tσ [q]p

Completeness of Procr

If R is not innermost terminating then completeness is again trivial Otherwise weshow that if ldquo s rarr tprime v rarr w rdquo is an innermost chain then so is ldquo s rarr tv rarr w rdquo Note that tprime = t[r]p where t|p rarrR r for some r There must be a σ withtprimeσ = tσ [rσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ where rσ irarrlowast

R q and the terms q and vσ are normalforms

Again all rules applicable in a reduction of t|pσ are contained in UR(t|p)Since t|pσ is weakly innermost terminating and UR(t|p) is non-overlapping t|pσ isterminating and confluent [21 Theorem 3211] Thus the only normal form of t|pσ isq Hence this normal form can also be reached by innermost reductions This impliestσ = tσ [t|pσ ]p

irarrlowastR tσ [q]p

irarrlowastR vσ So ldquo s rarr t v rarr w rdquo is an innermost chain

too

Soundness of Proci

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a minimalchain then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is also a minimal chain where μ =mgu(ren(capR(w1)) s)

Let w1 have the form C[p1 pn] where the context C contains no definedsymbols or variables and all pi have a defined root symbol or they are variablesThere is a substitution σ satisfying (t1) and (t2) Then sσ = C[q1 qn] for someterms qi with piσ rarrlowast

R qiWe have ren(capR(w1)) = C[y1 yn] where the yi are fresh variables Let σ prime

be the modification of σ such that σ prime(yi) = qi Then ren(capR(w1))σprime = sσ = sσ prime

namely ren(capR(w1)) and s unify Let μ = mgu(ren(capR(w1)) s) Thus σ prime =μτ

for some substitution τ As the variables of all (occurrences of all) pairs maybe assumed disjoint we may modify σ to behave like τ on the variables ofsμ rarr tμ Then w1σ rarrlowast

R sσ = sσ prime = sμτ = sμσ and tμσ = tμτ = tσ rarrlowastR v2σ Thus

ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a chain too Moreover since tσ is terminat-ing and tμσ = tσ the chain is minimal as well

In this way one can replace all occurrences of s rarr t in chains by instantiatedpairs sμ rarr tμ except for the first pair in the chain However if s rarr t v1 rarr w1 v2 rarrw2 is an infinite minimal chain then so is v1 rarr w1 v2 rarr w2 Thus by deletingthe possibly remaining first occurrence of s rarr t in the end every infinite minimal(P primeR)-chain can indeed be transformed into an infinite minimal chain that containsonly instantiations of s rarr t

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 28: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

182 J Giesl et al

Now we regard e = i Let ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo be a minimal inner-most chain We show that then ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo is a minimalinnermost chain as well Here we have μ = mgu(capR(w1) s) and sμ and v1μ are innormal form

Let w1 have the form C[p1 pn] where C contains no defined symbols (butC may contain variables) and all root(pi) are defined There is a σ satisfying(i1)ndash(i3) Then sσ = C[q1 qn] for some qi with piσ

irarrlowastR qi since σ instantiates

all variables by normal formsWe have capR(w1) = C[y1 yn] where the yi are fresh variables Let σ prime be the

modification of σ with σ prime(yi) = qi Then capR(w1)σprime = sσ = sσ prime namely capR(w1)

and s unify Let μ = mgu(capR(w1) s) Since sσ and v1σ are normal forms by (i2) andsince μ is more general than σ sμ and v1μ are normal forms as well The remainderis as for e = t

Completeness of Proci

Again if R is not (innermost) terminating completeness is trivial Otherwise letldquo sμ rarr tμ rdquo be an (innermost) chain Since different occurrences of pairs maybe assumed variable disjoint we can extend every substitution σ to behave like μσ

on the variables of s Then one immediately obtains that ldquo s rarr t rdquo is also an(innermost) chain

Soundness of Procf

We first regard e = t and show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo isa minimal chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo where μ =mgu(ren(capminus1

R (v2)) t) The nontrivial case is if R is not collapsing since otherwiseμ does not modify s or t

Let v2 have the form C[p1 pn] where C contains no root symbols of Rrsquos right-hand sides or variables and the pi are variables or terms where root(pi) occurs onroot positions of Rrsquos right-hand sides There is a substitution σ satisfying (t1) and(t2) Then tσ = C[q1 qn] for some terms qi with qi rarrlowast

R piσ that is piσ rarrlowastRminus1 qi

We have ren(capminus1R (v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ where σ prime(yi) = qi Then ren(capminus1R (v2))σ

prime = tσ = tσ primenamely ren(capminus1

R (v2)) and t unify Let μ = mgu(ren(capminus1R (v2)) t) The rest is as

in Procirsquos soundness proofNow we regard e = i We show that if ldquo v1 rarr w1 s rarr t v2 rarr w2 rdquo is a

minimal innermost chain then so is ldquo v1 rarr w1 sμ rarr tμ v2 rarr w2 rdquo whereμ = mgu(ren(capminus1

UR(t)(v2)) t) Again we consider only the nontrivial case whereUR(t) is not collapsing

Let v2 have the form C[p1 pn] where C and pi are as in the termination caseThere is a substitution σ satisfying (i1)ndash(i3) The only rules applicable in a reductionof tσ are from UR(t) Thus tσ = C[q1 qn] for some qi with qi

irarrlowastUR(t) piσ and

hence piσ rarrlowastUR(t)minus1 qi

We have ren(capminus1UR(t)(v2)) = C[y1 yn] where the yi are fresh variables Let

σ prime be the modification of σ such that σ prime(yi) = qi Then ren(capminus1UR(t)(v2))σ

prime = tσ =tσ prime namely ren(capminus1

UR(t)(v2)) and t unify Let μ = mgu(ren(capminus1UR(t)(v2)) t) The

remainder of the proof is analogous to the soundness proof of Proci

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 29: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 183

Completeness of Procf

The proof is analogous to the completeness proof of Proci

The following example shows that the processors Procn and Procr are not com-plete if one considers only those DP problems as ldquoinfiniterdquo that are not finite Insteada DP problem (PR e) should also be considered ldquoinfiniterdquo whenever R is not(innermost) terminating

Example 32 For the TRS R = f(b) rarr f(g(a))g(x) rarr ba rarr a the dependencygraph processor of Theorem 8 results in the DP problems (A rarr AR e) and(F(b) rarr F(g(a))R e) The latter DP problem is finite as F(g(a)) is not terminat-ing and thus the pair F(b) rarr F(g(a)) cannot occur in infinite minimal chains On theother hand applying Procn or Procr to this DP problem leads to a new DP problem(P primeR e) where P prime contains F(b) rarr F(b) But since F(b) rarr F(b) leads to an infiniteminimal chain the problem (P primeR e) is not finite

52 Mechanizing Dependency Pair Transformations

By Theorem 31 the transformations are sound and (under certain conditions)complete Then they cannot transform a non-infinite DP problem into an infiniteone but they may still be disadvantageous The reason is that transformations mayincrease the size of DP problems (and thus runtimes may increase too) On theother hand transformations are often needed to prove (innermost) termination asshown by Example 30

In practice the main problem is that these transformations may be applied infi-nitely many times For instance already in our initial Example 1 with the dependencypair

DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) (3)

we can obtain an infinite sequence of narrowing steps The DP problem ((3) R i)can be narrowed to ((32) (33) R i) with

DIV(s(x) s(0)) rarr DIV(x s(0)) (32)

DIV(s(s(x)) s(s(y))) rarr DIV(minus(x y) s(s(y))) (33)

Another narrowing step yields ((32) (34) (35) R i) with

DIV(s(s(x)) s(s(0))) rarr DIV(x s(s(0))) (34)

DIV(s(s(s(x))) s(s(s(y)))) rarr DIV(minus(x y) s(s(s(y)))) (35)

Obviously narrowing can be repeated infinitely many times here although the DPproblems are finite and the TRS is terminating

Therefore we have developed restricted safe transformations that are guaranteedto terminate Our experiments in Section 8 show that applying transformations onlyin these safe cases is indeed successful in practice The experiments also demonstratethat this is clearly advantageous to the alternative straightforward heuristic thatsimply applies transformations a fixed number of times

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 30: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

184 J Giesl et al

A narrowing instantiation or forward instantiation step is safe if it reducesthe number of pairs in SCCs of the estimated (innermost) dependency graph LetSCC(P) be the set of SCCs built from the pairs in P Then the transformation is safeif | ⋃SisinSCC(P) S| decreases So the forward instantiation in Example 29 was safe sincethe estimated dependency graph had an SCC before but not afterwards Moreovera transformation step is also considered safe if by this step all descendants of anoriginal dependency pair disappear from SCCs For every pair srarr t o(srarr t) denotesan original dependency pair whose repeated transformation led to srarr t Now a trans-formation is also safe if o(srarr t) | srarr t isin ⋃

SisinSCC(P) S decreases Finally for eachpair that was not narrowed yet one single narrowing step that does not satisfy theabove requirements is also considered safe The benefits of this are demonstrated byour experiments in Section 8 We use a similar condition for instantiation and forwardinstantiation where for forward instantiation we require that the transformationmay yield only one new pair So the narrowing and instantiation steps in Example 30were safe as well

The rewriting transformation may be applied without any restriction provided thatthe rules used for (innermost) rewriting are (innermost) terminating Therefore oneshould consider the recursion hierarchy in termination proofs A symbol f dependson the symbol h ( f ged h) if f = h or if some symbol g occurs in the right-hand sideof an f -rule where g depends on h Note that ged also corresponds to the definitionof usable rules in Definition 10 since UR( f (x1 xn)) consists of RlsR(g) for allf ged g We define gtd = ged led For example the div- and if-rules depend on theminus-and le-rules in Example 30 If one has to solve two DP problems (P1R e) and(P2R e) where there exist l1 rarr r

1 isin P1 and l2 rarr r

2 isin P2 with root(l1) gtd root(l2)then it is advantageous to treat (P2R e) before (P1R e) In other words inExample 30 one should solve the DP problems for minus and le before handling theDP problem of div and if Then innermost termination of minus is already verifiedwhen proving innermost termination of div and therefore innermost rewriting theDIV-dependency pair with the minus-rules is guaranteed to terminate Thus therewrite step from (28) to (29) was safe

Definition 33 (Safe Transformations) Let Q result from the set P by transformingsrarr t isin P as in Definition 28 The transformation is safe if

(1) s rarr t was transformed by Procn Proci or Procf and

ndash | ⋃SisinSCC(P) S| gt |⋃SisinSCC(Q) S| orndash

o(srarr t) | srarr t isin ⋃

SisinSCC(P) S

o(srarr t) | srarr t isin ⋃

SisinSCC(Q) S

(2) s rarr t was transformed by innermost rewriting and UR(P) is innermostterminating

(3) s rarr t was transformed by narrowing and all previous steps that transformedo(s rarr t) to s rarr t were not narrowing steps

(4) s rarr t was transformed by instantiation and all previous steps that transformedo(s rarr t) to s rarr t were not instantiation steps

(5) s rarr t was transformed by forward instantiation there is only one pair v rarr w

where ren(capminus1R (v)) and t (resp ren(capminus1

UR(t)(v)) and t) are unifiable and allprevious steps that transformed o(srarr t) to srarr t were not forward instantiationsteps

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 31: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 185

Theorem 34 proves that the application of safe transformations terminates

Theorem 34 (Termination) Let (PR e) be a DP problem Then any repeatedapplication of safe transformations on P terminates

Proof We define a measure on sets P consisting of four components

(a) |o(s rarr t) | s rarr t isin ⋃SisinSCC(P) S|

(b) | ⋃SisinSCC(P) S|(c) |P |(d) t | s rarr t isin P

These 4-tuples are compared lexicographically by the usual order on naturals forcomponents (a)ndash(c) For (d) we use the multiset extension of the innermost rewriterelation of UR(P) if it is innermost terminating Thus we obtain a well-foundedrelation where P1 P2 iff P1rsquos measure is greater than P2rsquos measure From (a)(b) and (d) any safe transformation of P with (1) or (2) decreases P rsquos measure

Let w(P) = 〈Pnotnnotinot f Pnnotinot f Pnotninot f Pnotnnoti f Pnotni f Pnnoti f Pninot f Pni f 〉Pnotnnotinot f consists of those srarr tisinP where no narrowing instantiation or forwardinstantiation was used to transform o(srarr t) to srarr t Pnnotinot f are the pairs wherenarrowing but no instantiation or forward instantiation was used and so forthEvery safe transformation step decreases w(P) lexicographically wrt the left-most component of w(P) that is changed decreases wrt whereas components onits right-hand side may increase In particular transformations with (3)ndash(5) decreaseone component of w(P) wrt by (c)

A good strategy is to apply the processors of this paper according to the followingprecedence This strategy is also used in our experiments in Section 8 Here onealways uses the first processor in the list that modifies the current DP problem Moreelaborate strategies that also take other processors into account can be found in [15]

1 Dependency Graph Processor (Theorem 8)2 Transformation Processor (Definition 28) restricted to Definition 33 (1 2)3 Reduction Pair Processor (Theorem 12 Theorem 17 or Theorem 26)4 Transformation Processor (Definition 28) restricted to Definition 33 (3ndash5)

So after each transformation one should recompute the dependency graph Hereone has to consider only the former neighbors of the transformed pair in the oldgraph The reason is that only former neighbors may have arcs to or from thenew pairs resulting from the transformation Regarding neighbors in the graphalso suffices for the unifications required for narrowing instantiation and forwardinstantiation In this way the transformations can be performed efficiently

6 Computing Argument Filterings

One of the most important processors of the DP framework is the reduction pairprocessor (Theorem 12) which we improved considerably in Theorem 17 and 26Here we may apply an argument filtering π to the constraints before orienting themwith a reduction pair When using reduction pairs based on monotonic orders

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 32: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

186 J Giesl et al

like RPOS or KBO this is necessary to benefit from the fact that in a reductionpair () need not be monotonic However the number of argument filteringsis exponential in the number and the arities of the function symbols We nowshow how to search for suitable filterings efficiently More precisely for each DPproblem (PR e) we show how to compute a small set (PR) This set includesall argument filterings that may satisfy the constraints of the reduction pair proces-sor A corresponding algorithm was presented in [25] for termination proofs withTheorem 12 However in Section 61 and Section 62 we now develop algorithmsthat can also be used for the improved versions of the reduction pair processor fromTheorem 17 and 26 In particular for Theorem 26 the algorithm is considerably moreinvolved because the set of constraints depends on the argument filtering used

61 Argument Filterings for the Processor of Theorem 17

We use the approach of [25] to consider partial argument filterings which are definedonly on a subset of the signature For example in a term f (g(x) y) if π( f ) = [2]then we do not have to determine π(g) since all occurrences of g are filteredaway Thus we leave argument filterings as undefined as possible and permit theapplication of π to a term t whenever π is sufficiently defined for t More preciselyany partial argument filtering π is sufficiently defined for a variable x So the domainof π may even be empty that is DOM(π) = empty An argument filtering π is sufficientlydefined for f (t1 tn) iff f isin DOM(π) and π is sufficiently defined for all ti withi isin rpπ ( f ) An argument filtering is sufficiently defined for a set of terms T iffit is sufficiently defined for all terms in T To compare argument filterings thatdiffer only in their domain DOM Hirokawa and Middeldorp [25] introduced thefollowing relation ldquosuberdquo π sube π prime iff DOM(π) sube DOM(π prime) and π( f ) = π prime( f ) for allf isin DOM(π)

In [25] one regards all sube-minimal filterings that permit a term to be evaluatedWe now use the same concept to define the set (P) of those argument filteringswhere at least one pair in P is strictly decreasing and the remaining ones areweakly decreasing Here (P) should contain only sube-minimal elements that is ifπ prime isin (P) then (P) does not contain any π sub π prime Of course all filterings in (P)

must be sufficiently defined for the terms in the pairs of P Let RP be a class ofreduction pairs describing the particular base order used (eg RP may contain allreduction pairs based on LPO) In the termination case we restrict ourselves to Cε-compatible reduction pairs

Definition 35 ((P)) For a set P of pairs of terms let (P) consist of all sube-minimalelements of π | there is a () isin RP such that π(s)π(t) for some srarr t isin P andπ(s)π(t) for all other srarr t isin P

In Example 1 if P = DIV(s(x) s(y)) rarr DIV(minus(x y) s(y)) and RP are allreduction pairs based on LPO then (P) consists of the 12 filterings π whereDOM(π) = DIV sminus π(DIV) isin 1 [1] [1 2] and either π(minus)isin[ ] 1 [1]and π(s) = [1] or both π(minus) = π(s) = [ ]

For any DP problem (PR e) we now define a superset (PR) of all argumentfilterings where the constraints of the reduction pair processor from Theorem 17 aresatisfied by some reduction pair of RP So only these filterings have to be regardedwhen automating Theorem 17 cf Theorem 43 As in [25] one therefore has to

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 33: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 187

extend partial filterings in order to obtain all filterings that can possibly satisfy certaininequalities

Definition 36 (Ex f (PR)) For a partial filtering π and f isin DR Ex f (π) con-sists of all sube-minimal filterings π prime with π sube π prime such that there is a () isin RPwith π prime(l) π prime(r) for all l rarr r isin RlsR( f ) For a set of filterings let Ex f () =⋃

πisin Ex f (π) We define (PR) = Ex fk( Ex f1((P)) ) where f1 fk areUR(P)rsquos defined symbols Note that the order of f1 fk is irrelevant for thedefinition of (PR)

So for the DIV-SCC P in Example 1 we have (PR) = Exminus((P))Note that all π isin (P) remove the second argument of minus Therefore inExminus((P)) their domain does not have to be extended to the symbol 0 since0 occurs only in minusrsquo second argument However in Exminus((P)) all filteringsπ with π(minus) = [ ] are eliminated since they contradict the weak decrease ofthe first minus-rule Thus while there exist 6 middot 3 middot 6 middot 1 = 144 possible argumentfilterings for the symbols DIV s minus and 0 our algorithm reduces this set to only|(PR)| = 6 candidates For TRSs with more function symbols the reduction ofthe search space is of course even more dramatic

Moreover in successful proofs we compute only a small subset of (PR) sinceits elements are determined step by step in a depth-first search until a proof is foundTo this end we start with a π isin (P) and extend it to a minimal π prime such that f1rsquosrules are weakly decreasing Then π prime is extended such that f2rsquos rules are weaklydecreasing and so forth Here f1 is considered before f2 if f1 gtd f2 where gtd isagain the ldquodependencerdquo relation from Section 52 When we have (PR)rsquos firstelement π1 we check whether the constraints of Theorem 17 are satisfiable withπ1 In case of success we do not compute further elements of (PR) Only if theconstraints are not satisfiable with π1 do we determine (PR)rsquos next element andso on The advantage of this approach is that (P) is usually small because it containsonly filterings that satisfy a strict inequality Thus by taking (P)rsquos restrictions intoaccount only a fraction of the search space is examined This depth-first strategydiffers from the corresponding algorithm in [25] where the constraints are treatedseparately in order to share and reuse results

Example 37 The following TRS illustrates the depth-first algorithm

f(s(s(x))) rarr f(g(x)) g(x) rarr h(x)

f(s(x)) rarr f(x) h(x) rarr s(x)

The only SCC of the dependency graph is P = F(s(s(x))) rarr F(g(x))F(s(x)) rarrF(x) Let RP contains all reduction pairs based on LPO Then (P) consists of thesix partial argument filterings where π(F) is 1 or [1] π(s) = [1] and π(g) isin 1 [1] [ ]

To demonstrate the depth-first algorithm we inspect filterings in the order wherecollapsing filterings are checked first otherwise filterings that do not filter anythingare preferred (so the order of preference is 1 [1] [ ]) Then we start with π1 isin (P)where π1(F) = 1 π1(s) = [1] and π1(g) = 1 When computing Exg(π1) the argumentfiltering has to be extended in order to filter h as well Moreover we must ensure thatthe g-rule can be made weakly decreasing by some LPO Thus we have to use theextension π prime

1 of π1 where π prime1(h) = 1 But then when trying to compute Exh(π prime

1) it

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 34: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

188 J Giesl et al

turns out that this set is empty because the h-rule cannot be weakly decreasing withthis filtering

So one backtracks and considers π2 isin (P) with π2(F) = 1 π2(s) = [1] andπ2(g) = [1] Now we compute the first element π prime

2 of Exg(π2) We have π prime2(h) = 1

and again Exh(π prime2) is empty Hence we backtrack and compute the next element

π primeprime2 of Exg(π2) Now π primeprime

2 (h) = [1] and Exh(π primeprime2 ) consists of π primeprime

2 Thus we have foundthe first element of (PR) = Exh(Exg((P))) Hence we stop the computationof (PR) and check whether the reduction pair processor is successful with π primeprime

2 Indeed the constraints can be solved by using an LPO where s g and h have equalprecedence Then both dependency pairs are decreasing and can be removed Thustermination can immediately be proved

The example demonstrates that the depth-first search generates only a small partof the search space when looking for argument filterings This is also illustrated bythe following tree which depicts the whole search space for determining (PR)Since we use depth-first search and stop as soon as the first solution is found we donot compute this full tree in a successful termination proof Instead we stop as soonas we reach the third leaf which corresponds to the first element of (PR) Herethose leaves where Exh is underlined denote success (ie computing Exh does notresult in the empty set)

(P)π1

π2π3

π4

π5 π6

Exg

π prime1

Exgπ prime

2

π primeprime

2

π primeprimeprime2

13131313

Exg

π prime3

Exg

π prime4

Exgπ prime

5

π primeprime

5

π primeprimeprime5

13131313

Exg

π prime6

Exh Exh Exh Exh Exh Exh Exh Exh Exh Exh

62 Argument Filterings for the Processor of Theorem 26

When automating the improved reduction pair processor of Theorem 26 instead ofTheorem 17 the set of constraints to be satisfied depends on the argument filteringused If f ged g then when orienting the rules of f we do not necessarily have toorient grsquos rules as well since all occurrences of g in f -rules may have been deletedby the argument filtering To formalize this we define a relation ldquo PRrdquo on sets ofargument filterings We extend rpπ to partial filterings by defining rpπ ( f ) = empty forf isin DOM(π) Now UR(P π) is also defined for partial filterings by disregarding allsubterms of function symbols where π is not defined

For a partial filtering π whenever RlsR( f ) is included in the usable rulesUR(P π) then the relation ldquo PRrdquo can extend π in order to make the f -rulesweakly decreasing We label each filtering by those function symbols whose rulesare already guaranteed to be weakly decreasing

Definition 38 (PR) Each argument filtering π is labeled with a set G sube DR and wedenote a labeled argument filtering by πG For labeled argument filterings we defineπG PR π prime

Gcup f if f isin DR G RlsR( f ) sube UR(P π) and π prime isin Ex f (π) We extend

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 35: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 189

ldquo PRrdquo to sets of labeled filterings as follows πG PR cup π primeG prime | πG PR

π primeG prime

To automate the reduction pair processor of Theorem 26 we consider onlyfilterings that result from (P) by applying PR-reductions as long as possible Soeach π isin (P) is extended individually by PR instead of building Ex f ((P)) asin Theorem 17rsquos automation The advantage of PR is that only those filterings π

are extended to include f in their domain where this is required by the usable rulesUR(P π) We denote the set of filterings that should be considered when automatingTheorem 26 by prime(PR) and compute it by depth-first search similar to (PR)

Example 39 We consider the SCC P = (21)ndash(24) of the REV- and REV2-dependency pairs in Example 22 and 27 Here the filterings in (P) are not definedon rev1 since rev1 does not occur in P When performing PR-reductions thoseπ isin (P) that eliminate the first argument of cons will never be extended to rev1whereas this is necessary for other filterings in (P)

For example (possibly after some backtracking) the depth-first search couldconsider the partial filtering π isin (P) π(cons) = [2] π(REV) = π(rev) = 1 andπ(REV1) = π(REV2) = π(rev2) = 2 where π is undefined on rev1 Initially thisfiltering is labeled with empty since no rule is guaranteed to be weakly decreasing yet Wehave RlsR(rev) sube UR(P π) In order to make revrsquos rules weakly decreasing π hasto be extended to a filtering π prime which is also defined on nil that is πempty PR π prime

revSince UR(P π prime) = RlsR(rev) cup RlsR(rev2) and since π prime also allows us to make allrev2-rules weakly decreasing we obtain π prime

rev PR π primerevrev2 Thus π prime is a normal

form wrt PR and therefore it is an element of prime(PR) As soon as one findsa filtering where the constraints of Theorem 26 can be solved the depth-first searchstops and we do not determine further elements of prime(PR)

Hence to compute the set of regarded argument filterings prime(PR) for Theorem26 our aim is to construct the normal form of (P) wrt PR To ensure that thisnormal form always exists and that it is unique we will prove that PR is confluentand terminating

For this proof we need the following lemma It states that Ex f (π) always consistsof pairwise incompatible argument filterings Here two argument filterings π1 and π2

are compatible if π1( f ) = π2( f ) for all f isin DOM(π1) cap DOM(π2) cf [25]8

Lemma 40 (Incompatibility) Let T be a finite set of terms

(a) Let π π1 π2 be (partial) argument filterings Let π1 π2 isin π prime | π sube π prime and π prime issufficiently defined for T where π1 is a sube-minimal element of this set If π1 andπ2 are compatible then π1 sube π2

(b) If π1 π2 isin Ex f (π) are compatible then π1 = π2 In other words Ex f (π) consistsof pairwise incompatible argument filterings

8The notion of compatibility was introduced in [25] for a different purpose there it was used tomerge sets of argument filterings whereas a statement like Lemma 40 was not presented in [25] Inthe setting of [25] Lemma 40 would mean that ldquoAF(T)rdquo consists of pairwise incompatible argumentfilterings Here ldquoAF(T)rdquo are all minimal argument filterings that are sufficiently defined for all termsin the set T

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 36: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

190 J Giesl et al

(c) If consists of pairwise incompatible argument filterings then Ex f () consistsof pairwise incompatible argument filterings too

Proof

(a) We perform induction on T using the (multi)set version of the proper subtermrelation If T = empty then the only minimal extension of π that is sufficientlydefined for T is π1 = π Hence π1 = π sube π2Next let T = T prime x for x isin V Now the claim follows from the inductionhypothesis since π1 and π2 are also sufficiently defined for T prime and π1 is aminimal extension of π with this propertyIf T = T prime f (t1 tn) then f isin DOM(π1) Let T primeprime = T prime cup ti | i isin rpπ1( f )Both π1 and π2 are sufficiently defined for T primeprime (for π2 this follows from π2( f ) =π1( f ) by compatibility of π1 and π2) If π1 is a minimal extension of π that issufficiently defined for T primeprime then the claim is implied by the induction hypothesisOtherwise f isin DOM(π) and we obtain the following minimal extension π prime

1 ofπ that is sufficiently defined for T primeprime DOM(π prime

1) = DOM(π1) f and π prime1(g) =

π1(g) for all g isin DOM(π prime1) Then the induction hypothesis implies π prime

1 sube π2Since π1 differs only from π prime

1 on f and since π1( f ) = π2( f ) we obtain π1 sube π2(b) Let π1 π2 isin Ex f (π) be compatible As both filterings are minimal extensions of

π that are sufficiently defined for the terms on left- or right-hand sides of rulesfrom RlsR( f ) we use (a) to conclude both π1 sube π2 and π2 sube π1 which impliesπ1 = π2

(c) Let π prime1 π

prime2 isin π1 isin Ex f (π

prime1) π2 isin Ex f (π

prime2) and π1 = π2 If π prime

1 = π prime2 then π1

and π2 are incompatible by (b) Otherwise π prime1 = π prime

2 and π prime1 and π prime

2 are incom-patible by the assumption about As π prime

1 sube π1 and π prime2 sube π2 then π1 and π2 are

incompatible as well

The next theorem shows the desired properties of the relation PR

Theorem 41 PR is terminating and confluent on sets of filterings

Proof Termination of PR is obvious as the labelings increase in every PR-step Hence for confluence it suffices to show local confluence The only crucialindeterminism in the definition of PR is the choice of f Let f0 f1 isin DR G withf0 = f1 and RlsR( f0) cup RlsR( f1) sube UR(P π) for some labeled filtering πG Thisleads to two possible steps

πG PR cup 0 where 0 = π0Gcup f0 | π0 isin Ex f0(π)

πG PR cup 1 where 1 = π1Gcup f1 | π1 isin Ex f1(π)

Note that UR(P π) sube UR(P π i) holds for all π i isin Ex fi(π) Thus for all π iGcup fi isin

i we have f1minusi isin DR (G cup fi) and RlsR( f1minusi) sube UR(P π i) Hence we obtain

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 37: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 191

the following reductions (where we also apply Ex f to labeled filterings by simplyignoring their labels)

cup 0

|0|PR ( 0) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

|cap1|PR ( (0 cup 1)) cup

π primeGcup f0 f1 | π prime isin Ex f1(Ex f0(π))

cupπ primeGcup f1 f0 | π prime isin Ex f0( cap 1)

cup 1

|1|PR ( 1) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

|cap0|PR ( (1 cup 0)) cup

π primeGcup f1 f0 | π prime isin Ex f0(Ex f1(π))

cupπ primeGcup f0 f1 | π prime isin Ex f1( cap 0)

where Ex f0( cap 1) sube Ex f0(Ex f1(π)) Ex f1( cap 0) sube Ex f1(Ex f0(π)) To finish theproof we show Ex f0(Ex f1(π)) = Ex f1(Ex f0(π)) By symmetry it suffices to proveEx f0(Ex f1(π)) sube Ex f1(Ex f0(π)) Here we need only to show that for every π01 isinEx f0(Ex f1(π)) there is a π10 isin Ex f1(Ex f0(π)) with π10 sube π01 The reason is that in ananalogous way one can show that for π10 there also exists a π prime

01 isin Ex f0(Ex f1(π)) withπ prime

01 sube π10 Hence π prime01 sube π10 sube π01 By Lemma 40 (b) Ex f1(π) consists of pairwise

incompatible argument filterings and hence by Lemma 40 (c) this also holds forEx f0(Ex f1(π)) However π prime

01 sube π01 implies that π prime01 and π01 are compatible So

π prime01 = π01 and thus π prime

01 = π10 = π01Let π01 isin Ex f0(Ex f1(π)) By the definition of Ex there is a π1 isin Ex f1(π) and

a reduction pair () isin RP with π1 sube π01 and π01(l) π01(r) for all l rarr r isinRlsR( f0) As π1 isin Ex f1(π) we also have π sube π1 and π1(l) prime π1(r) for all f1-rulesand some (primeprime) isin RP Since π sube π01 and since the f0-rules can be oriented ina weakly decreasing way using π01 there exists a π0 isin Ex f0(π) with π sube π0 sube π01

such that the f0-rules can also be oriented using π0 Since π0 sube π01 and since thef1-rules can be oriented with π01 there is a π10 isin Ex f1(π0) with π0 sube π10 sube π01 suchthat π10 also permits an orientation of the f1-rules As explained above this provesEx f0(Ex f1(π)) sube Ex f1(Ex f0(π))

Now we can define the set of argument filterings prime(PR) that are regarded whenautomating the reduction pair processor of Theorem 26 From Theorem 41 we candefine prime(PR) in an unambiguous way (as the unique normal form of (P))

Definition 42 (prime(PR)) Let Nf PR() be the normal form of wrt PR Thenwe define prime(PR) = Nf PR(πempty | π isin (P))

Theorem 43 states that (PR) (resp prime(PR)) indeed contain all argumentfilterings that could possibly solve the constraints of Theorem 17 (resp Theorem 26)In this way the set of argument filterings is reduced dramatically and thus efficiencyis increased

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 38: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

192 J Giesl et al

Theorem 43 Let (PR e) be a DP problem If the constraints of Theorem 17 (26) aresatisfied by some reduction pair from RP and argument filtering π then π prime sube π forsome π prime isin (PR) (π prime isin prime(PR))

Proof Let the constraints (a) and (b) from Theorem 17 or 26 be solved by somefiltering π and some () isin RP We first consider Theorem 17 Let f1 fk

be the defined symbols of UR(P) So we have (PR) = Ex fk( Ex f1((P)) )We show that for all 0 le j le k there is a π j isin Ex f j( Ex f1((P)) ) with π j sube π

by induction on j For j = 0 since π solves the constraints in (a) there is aminimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume that there is a π jminus1 isinEx f jminus1( Ex f1((P)) ) with π jminus1 sube π As π(l) π(r) for all f j-rules l rarr r thereis a filtering π j isin Ex f j(π jminus1) with π j sube π

For Theorem 26 let (P) = 0 PR 1 PR PR k = prime(PR) be aPR-reduction to normal form We show that for all 0 le j le k there is a π j isin j

with π j sube π by induction on j For j = 0 since π solves the constraints in (a)there is again a minimal filtering π0 isin (P) with π0 sube π For j gt 0 we assume thatthere is a π jminus1 isin jminus1 with π jminus1 sube π So we either have π jminus1 isin j as well or else j results from jminus1 by replacing π jminus1 by all elements of Ex f (π jminus1) for some fwith RlsR( f ) sube UR(P π jminus1) Since π jminus1 sube π we have UR(P π jminus1) sube UR(P π) andhence π also makes f rsquos rules weakly decreasing by the constraints in (b) Thus thereis a π j isin Ex f (π jminus1) sube j with π j sube π

The converse directions of this theorem do not hold since in the computationof (PR) and prime(PR) when extending argument filterings one does not takethe orders into account So even if Ex f (Exg( )) = empty it could be that there is noreduction pair such that both f - and g-rules are weakly decreasing wrt the samereduction pair from RP

7 Using Polynomial Orders for Dependency Pairs

In Section 6 we showed how to mechanize the reduction pair processor with argu-ment filterings and monotonic orders like RPOS or KBO Now we regard reductionpairs based on polynomial orders instead which are not necessarily monotonic if onealso permits the coefficient 0 in polynomials9 In contrast to RPOS and KBO it isundecidable whether a set of constraints is satisfiable by polynomial orders and thusone can use only sufficient criteria to automate them However in combination withdependency pairs even linear polynomial interpretations with coefficients from 0 1are already very powerful cf Section 8

An advantage of polynomial orders is that one does not need any extra argumentfiltering anymore since argument filtering can be simulated directly by the corre-sponding polynomials If

Pol( f (x1 xn)) = a1 xb 11

1 xb n1n + middot middot middot + am xb 1m

1 xb nmn (36)

9We consider only polynomial orders with natural coefficients Approaches for polynomials withnegative or real coefficients can be found in [23 33]

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 39: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 193

for coefficients a j ge 0 then this corresponds to the argument filtering πPol withπPol( f ) = [ i | a j gt 0 and bi j gt 0 for some 1 le j le m ] However disregarding argu-ment filterings is a problem in our improved reduction pair processor (Theorem26) since the filtering π is needed to compute the constraints resulting from theusable rules UR(P π) Hence in Section 71 we adapt the reduction pair processorto polynomial orders such that it does not use argument filterings anymore InSection 72 we improve this special reduction pair processor by eliminating theindeterminism in the constraints of type (a) Here for any DP problem (PR e)one had to select at least one pair from P that should be strictly decreasing

71 Reduction Pair Processor with Polynomial Orders

When automating Theorem 26 with polynomial orders one fixes the degree of thepolynomials and then suitable coefficients have to be found automatically So onestarts with an abstract polynomial interpretation Pol For every function symbol f Pol( f (x1 xn)) is as in (36) but m and bi j are fixed numbers whereas a j arevariable coefficients Then the constraints (a) of Theorem 26 have the form

minus Pol(s) minus Pol(t) gt 0 for all srarr t isin P prime for a non-empty P prime sube P

minus Pol(s) minus Pol(t) ge 0 for all srarr t isin P P prime (37)

An abstract polynomial interpretation Pol can be turned into a concrete one byassigning a natural number to each variable coefficient a j We denote such assign-ments by α and let α(Pol) be the corresponding concrete polynomial interpretationA set of constraints of the form p

(ge

)0 is satisfiable iff there exists an assignment

α such that all instantiated constraints α(p)(ge

)0 hold Here α(p) still contains the

variables x y occurring in P and we say that α(p)(ge

)0 holds iff it is true for

all instantiations of x y by natural numbers For example a1x + a2 minus a3 y gt 0 issatisfied by the assignment α where α(a1) = 1 α(a2) = 1 and α(a3) = 0 The reasonis that α turns the above constraint into x + 1 gt 0 which holds for all instantiationsof x with natural numbers

The constraints of type (b) in Theorem 26 require l r for all l rarr r isinUR(P πα(Pol)) The problem is how to determine these constraints in the case ofpolynomial orders where the argument filtering πα(Pol) is not given explicitly butdepends on the assignment α of natural numbers to variable coefficients a j Thusπα(Pol) is not available yet when building the constraints although we need it tocompute UR(P πα(Pol))

The solution is to translate the constraints of type (b) to polynomial constraints ofthe following form

q middot (Pol(l) minus Pol(r)) ge 0 for all rules l rarr r of UR(P) (38)

Here q will be a polynomial containing only variable coefficients a j but no variablesx y from the rules of R So for any assignment α α(q) is a number Wegenerate the constraints such that for any assignment α we have α(q) = 0 iff l rarrr isin UR(P πα(Pol)) So for any α the constraints (38) are equivalent to requiringPol(l) minus Pol(r) ge 0 for all l rarr r in UR(P πα(Pol)) but the advantage is that theconstraints (38) can be constructed before determining the assignment α

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 40: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

194 J Giesl et al

Let Pol be an abstract polynomial interpretation as in (36) To generate theconstraints (38) we first define a polynomial that sums up the coefficients of thosemonomials of Pol( f (x1 xn)) that contain xi

rpPol( f i) =sum

1le jlem bi jgt0a j

So for any assignment α α(rpPol( f i)) is a number that is greater than 0 iff iisinrpπα(Pol) ( f ) Now the constraints corresponding to (b) in Theorem 26 can be builtsimilar to the definition of usable rules (Definition 21)

Definition 44 (Usable Rules for Polynomial Orders) Let Pol be an abstract poly-nomial interpretation Again let Rprime = R RlsR( f ) For any term t we define theusable rule constraints ConR(tPol) as

minus ConR(xPol) = empty for x isin V and

minus ConR( f (t1 tn)Pol) = Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR( f )

cup ⋃lrarrrisinRlsR( f ) ConRprime(rPol)

cup ⋃1leilen rpPol( f i) middot p ge 0 | ldquop ge 0rdquo isin ConRprime(tiPol)

For any TRS P let ConR(PPol) = ⋃srarrtisinP ConR(tPol)

Example 45 Consider the TRS from Example 22 again We use the linearabstract polynomial interpretation Pol(nil) = anil Pol( f (x)) = a f0 + a f1 x forf isin revREV and Pol( f (x y)) = a f0 + a f1 x + a f2 y for all other f ThusrpPol( f i) = a fi for all symbols f and positions i

We compute ConR for the right-hand side ofREV2(x cons(y z))rarr REV(rev2(y

z)) Let Rprime = R RlsR(rev2) and Rprimeprime = Rprime RlsRprime(rev)

ConR(REV(rev2(y z))Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(REV) = emptycup⋃lrarrrisinRlsR(REV)=empty

ConR(rPol)cupaREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

= aREV1 middot p ge 0 |ldquop ge 0rdquo isin ConR(rev2(y z)Pol)

ConR(rev2(y z)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(nilPol) cup ConRprime(rev(cons(x ))Pol)cuparev21 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(yPol)cuparev22 middot p ge 0 |ldquop ge 0rdquo isin ConRprime(zPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsR(rev2)cupConRprime(rev(cons(x ))Pol)

ConRprime(rev(cons(x ))Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(nilPol) cup ConRprimeprime(cons(rev1() )Pol)cuparev1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(cons(x )Pol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprime(rev)cupConRprimeprime(cons(rev1() )Pol)

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 41: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 195

ConRprimeprime(cons(rev1() )Pol)=Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(cons) = emptycup⋃lrarrrisinRlsRprimeprime (cons)=empty

ConRprimeprime(rPol)cupacons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)cupacons2 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev2(x l)Pol)

= acons1 middot p ge 0 |ldquop ge 0rdquo isin ConRprimeprime(rev1(x l)Pol)

ConRprimeprime(rev1(x l)Pol) =Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)cup⋃lrarrrisinRlsRprimeprime (rev1) Conempty(rPol)cup

arev11 middot p ge 0 |ldquop ge 0rdquo isin Conempty(xPol)cuparev12 middot p ge 0 |ldquop ge 0rdquo isin Conempty(lPol)

= Pol(l) minus Pol(r) ge 0 | l rarr r isin RlsRprimeprime(rev1)

So ConR(REV(rev2(y z))Pol) contains aREV1 middot (Pol(l) minus Pol(r))ge0 for rev2-and rev-rules and aREV1 middot acons1 middot (Pol(l) minus Pol(r))ge0 for rev1-rules

This indicates that if cons is mapped to a polynomial that disregards its firstargument (ie if acons1 = 0) then one does not have to require that the rev1-rules beweakly decreasing As shown in Example 27 this observation is crucial for the successof the innermost termination proof For example all constraints (for all SCCs) aresatisfied by the assignment α which maps acons0 acons2 aREV1 arev1 aREV12 aREV22and arev22 to 1 and all other variable coefficients to 0 So α turns Pol into a concretepolynomial interpretation where nil and rev1(x y) are mapped to 0 cons(x y) ismapped to 1 + y REV(x) and rev(x) are mapped to x and REV1(x y) REV2(x y)and rev2(x y) are mapped to y

The following lemma shows that ConR indeed corresponds to the constraintsresulting from the usable rules

Lemma 46 (Con and U) Let Pol be an abstract polynomial interpretation and t bea term An assignment α for Polrsquos coefficients satisfies ConR(tPol) iff α satisfiesPol(l) minus Pol(r)ge0 for all lrarrrisinUR(tπα(Pol))

Proof We use induction over the sizes of R and t If t isin V then the claim is trivialOtherwise let t = f (t1 tn) The assignment α satisfies ConR( f (t1 tn)Pol)iff it satisfies Pol(l) minus Pol(r) ge 0 and ConRprime(rPol) for all lrarrr isin RlsR( f ) and if italso satisfies rpPol( f i) middot p ge 0 for all constraints p ge 0 from ConRprime(tiPol) wherei isin 1 n

We have α(rpPol( f i)) gt 0 if i isin rpπα(Pol) ( f ) and α(rpPol( f i)) = 0 otherwise Soα satisfies the last condition iff it satisfies ConRprime(tiPol) for iisinrpπα(Pol) ( f ) Now theclaim follows by the induction hypothesis

Now the reduction pair processor from Theorem 26 can be reformulated to permitthe use of reduction pairs based on polynomial orders

Theorem 47 (Reduction Pair Processor with Polynomials) Let Pol be an abstractpolynomial interpretation and let α be an assignment Then the following DP proces-sor Proc is sound and complete We define Proc( (PR e) ) =ndash (PP primeR e) if α satisfies the constraints (37) and ConR(PPol)ndash (PR e) otherwise

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 42: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

196 J Giesl et al

Proof The theorem follows from Theorem 26 for the reduction pair ldquo(π π )rdquo inTheorem 26 we choose the polynomial order α(Pol) and for computing the usablerules ldquoUR(P π)rdquo in Theorem 26 we use the filtering πα(Pol) Then (37) clearlycorresponds to the constraints (a) in Theorem 26 and ConR(PPol) correspondsto the constraints (b) by Lemma 46

72 Finding Strict Constraints Automatically

For termination proofs with dependency pairs and polynomial orders we have tosolve constraints like (37) that have the form

pj ge 0 for all 1 le j le k and pj gt 0 for one 1 le j le k (39)

for polynomials pj The reason is that for a DP problem (PR e) all pairs in Pmust be weakly decreasing but at least one has to be strictly decreasing The basicapproach is to iterate over all k possible choices for the strict constraint So in theworst case the satisfiability checker for polynomial inequalities is called k times inorder to find an assignment α satisfying (39) We present an equivalent but moreefficient method where the satisfiability checker is called only once The solution isto transform (39) into the following constraint

pj ge 0 for all 1 le j le k andsum

1le jlek

p j gt 0 (40)

Theorem 48 ((39) iff (40)) Let the pj be variable disjoint except for variable coeffi-cients An assignment α satisfies (39) iff it satisfies (40)

Proof If α satisfies (39) then wlog we have α(p1) gt 0 Using α(pj) ge 0 for all j isin2 k we obtain α(

sum1le jlek p j) gt 0

For the other direction let α satisfy (40) and assume that α(pj) gt 0 for allj isin 1 k Hence for all j there exists a variable assignment β j of the variablesx y in α(pj) such that β j(α(pj)) = 0 Since the polynomials α(pj) are pairwisevariable disjoint the assignments β j can be combined to one assignment β thatcoincides with each β j on β jrsquos domain Thus β(α(pj))=0 for all j and there-fore β(α(

sum1le jlek p j))=0 But then α cannot satisfy

sum1le jlek p j gt 0 which gives a

contradiction

There exist several methods to find variable assignments α satisfying polynomialconstraints p ge 0 or p gt 0 Most of them search for an assignment α where p isabsolutely positive [26] A polynomial p is absolutely positive if in addition to p ge 0or p gt 0 all successive partial derivatives of p are non-negative (ie partp(x1xn)

partxige 0

for all i part2 p(x1xn)

partxipartx jge 0 for all i and j etc) Examples of such approaches to determine

polynomial interpretations are the method of partial derivation [10 31] and theshifting method [26]

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 43: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 197

If in addition to p ge 0 or p gt 0 the satisfiability checker for polynomial con-straints ensures that at least the first partial derivatives are non-negative (iepartp(x1xn)

partxige 0 for all i) then (40) can be simplified further to

pj ge 0 for all 1 le j le k andsum

1le jlek

p j(0 0) gt 0 (41)

The reason is that then the constraints pj ge 0 ensure that all first partial derivativesof pj must be at least 0 But then the first partial derivatives of

sum1le jlek p j are also

at least 0 Thus it suffices to requiresum

1le jlek p j gt 0 only for the instantiation of allvariables x y by 0

Example 49 For the TRS of Example 19 we obtain constraints like (39)

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1)) (ge

)0 (42)

Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2)) (ge

)0 (43)

Pol(QUOT(x3 0 s(z3))) minus Pol(DIV(x3 s(z3))) (ge

)0 (44)

Instead of choosing one of the above constraints to be strict with our refinementin (40) one obtains the constraints (42)ndash(44) with weak inequalities (ie with ldquo gerdquo)and the additional constraint

Pol(DIV(x1 y1)) minus Pol(QUOT(x1 y1 y1))

+Pol(QUOT(s(x2) s(y2) z2)) minus Pol(QUOT(x2 y2 z2))

+Pol(QUOT(x30 s(z3))) minus Pol(DIV(x3 s(z3))) gt 0 (45)

If the satisfiability checker guarantees absolute positiveness then the aboveconstraint may be simplified by instantiating all xi yi and zi with 0 If weuse a linear abstract polynomial interpretation Pol with Pol(DIV(x y)) = aDIV0 +aDIV1 x + aDIV2 y Pol(QUOT(x y z)) = aQUOT0 + aQUOT1 x + aQUOT2 y + aQUOT3 zPol(s(x)) = as0 + as1 x and Pol(0) = a0 then instead of (45) we obtain

(aQUOT1 + aQUOT2 + aQUOT3 minus aDIV2) as0 + aQUOT2 a0 gt 0 (46)

The resulting constraints are satisfied by the assignment that maps aDIV1 aQUOT1as0 and as1 to 1 and all other variable coefficients to 0 In this way the QUOT-dependency pair corresponding to Constraint (43) is strictly decreasing and can beremoved The remaining proof is similar to the one in Example 1910

8 Conclusion and Empirical Results

We improved the dependency pair technique by significantly reducing the sets ofconstraints to be solved for (innermost) termination proofs To combine these im-provements with dependency pair transformations we extended the transformations

10To remove the dependency pair QUOT(x0 s(z)) rarr DIV(x s(z)) one uses Pol(QUOT(x y z)) =Pol(DIV(x y)) = y Pol(s) = 0 and Pol(0) = 1 Afterwards the estimated dependency graph hasno cycle anymore

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 44: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

198 J Giesl et al

and developed a criterion to ensure that their application is terminating withoutcompromising their power in practice Afterwards we introduced new techniquesto mechanize the approach both with polynomial orders and with monotonic orderscombined with argument filterings These implementation techniques are tailored tothe improvements of dependency pairs presented before

Preliminary versions of parts of this paper appeared in [13 39] The presentarticle extends [13 39] substantially for example by detailed proofs by extensionof all results to the new DP framework of [15] by the new forward instantiationtransformation by a new section on automating dependency pairs with polynomialorders by a detailed description of our experiments and by several additionalexplanations and examples

We implemented the results of the paper in the system AProVE [17] available athttpaproveinformatikrwth-aachende Due to the results of this paper AProVEwas the most powerful tool for (innermost) termination proofs of TRSs at theInternational Annual Competition of Termination Tools in 2004ndash2006 [42]

In our experiments we tested AProVE on the examples of the TerminationProblem Data Base This is the collection of problems used in the annual terminationcompetition [42] It contains 773 TRSs from different sources as a benchmark fortermination analysis of term rewriting Our experiments are presented in two tablesIn the first table we tried to prove (full) termination11 and in the second we tried toprove innermost termination of all examples

In our experiments we used AProVE with the following techniques

ndash Theorem 12 applies the dependency graph processor with the estimation ofDefinition 9 and the reduction pair processor of Theorem 12 This is the basicdependency pair technique without new improvements

ndash Theorem 17 uses the dependency graph and the reduction pair processor ofTheorem 17 Thus usable rules are also applied for termination proofs Forinnermost termination this is the same as Theorem 12

ndash Theorem 26 uses the dependency graph and the reduction pair processor ofTheorem 26 Thus now one applies the usable rules wrt argument filteringsfor both termination and innermost termination

Moreover we use five different kinds of reduction pairs for the reduction pairprocessor

ndash EMB is the embedding orderndash LPO is the lexicographic path order where we allow different symbols to be

equal in the precedencendash POLO-filter searches for linear polynomial interpretations with coefficients from

0 1 Here we do not yet use the results of Section 71 that combine the searchfor a polynomial order with the search for an argument filtering Instead wefirst determine an argument filtering and search for a monotonic polynomialorder afterwards Moreover we also do not use the improvement of Section 72

11As mentioned there are classes of TRSs where innermost termination implies full terminationThus here one should prove only innermost termination However this observation was not usedin the first table in order to obtain a clearer evaluation of our contributions for full terminationSimilarly we also did not use additional recent refinements of the dependency pair technique in ourexperiments in order to assess only the impact of contributions that come from the present paper

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 45: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 199

Instead in the reduction pair processor we try all possibilities in order to makeone dependency pair in the DP problem strictly decreasing

ndash POLO-71 differs from POLO-filter by using the results of Section 71 Now weno longer search for an argument filtering but we look for a (not necessarilymonotonic) polynomial order So in particular when applying usable rules wrtan argument filtering in Theorem 26 we proceed as in Theorem 47

ndash POLO-71+72 is like POLO-71 but it also uses the refinements of Section 72which avoid the search for a strictly decreasing dependency pair when applyingthe reduction pair processor

For the first three reduction pairs the reduction pair processor has to search forargument filterings Here we use the method of Section 6

Finally in each of the above settings we experiment with different variants for theapplication of the transformation processors of Definition 28

ndash ldquoNordquo means that we do not use any transformations at allndash ldquoOlderrdquo is the heuristic of Definition 33 for safe transformations The combi-

nation with the reduction pair processor is done as described at the end ofSection 5 However we do not use the new forward instantiation transformationand instead of Definition 28 we use the previous applicability conditions for thetransformations from [1 11]

ndash ldquoOldrdquo is like ldquoolderrdquo but with the new more liberal applicability conditions fromDefinition 28 instead

ndash ldquoSaferdquo is the heuristic of Definition 33 with the transformations from Definition28 So in contrast to ldquooldrdquo now we also use forward instantiation

ndash ldquo(1)+(2)rdquo differs from ldquosaferdquo by regarding only those transformation steps asldquosaferdquo that satisfy condition (1) or (2) of Definition 33

ndash ldquoLimrdquo uses the transformations of Definition 28 with a different heuristic fromDefinition 33 Now at most five transformations are allowed for each dependencypair In order to combine the transformations with the reduction pair processorthe strategy at the end of Section 5 is modified as follows at most two transfor-mation steps are allowed before applying the reduction pair processor while theremaining transformation steps (up to five in total) are performed afterwards

For each example we used a time limit of 60 s This corresponds to the way thattools were evaluated in the annual competitions for termination tools The computerused was an AMD Athlon 64 at 22 GHz running Sunrsquos J2SE 150 under GNULinux2610 which is similar in speed to the computer used in the 2005 competition Inthe Tables 1 and 2 we give the number of examples where termination could beproved (ldquoYrdquo) where AProVE failed within the time limit of 60 s (ldquoFrdquo) and whereit failed because of a time-out (ldquoTOrdquo) In square brackets we give the averageruntime (in seconds) needed for TRSs where AProVE could prove terminationand where it failed within the time limit The detailed results of our experiments(including experimental data for all possible combinations of our settings) can befound at httpaproveinformatikrwth-aachendeevalJAR06 At this URL one canalso download a special version of AProVE with all settings described above So thisversion of AProVE permits the reader to rerun all our experiments

Comparing the results for Theorem 12 (lines 1ndash5) Theorem 17 (lines 6ndash10) andTheorem 26 (lines 11ndash15) shows the benefits of our contributions from Section 3 and4 Irrespective of the underlying reduction pair Theorem 17 is always more powerful

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 46: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

200 J Giesl et al

Table 1 Termination proofs

Line Algorithm Order Tr Y F TO

1 Theorem 12 EMB no 89 [08] 680 [16] 42 Theorem 12 LPO no 245 [30] 399 [36] 1293 Theorem 12 POLO-filter no 234 [17] 426 [53] 1134 Theorem 12 POLO-71 no 251 [09] 512 [16] 105 Theorem 12 POLO-71+72 no 251 [09] 520 [15] 26 Theorem 17 EMB no 174 [07] 588 [14] 117 Theorem 17 LPO no 277 [15] 387 [24] 1098 Theorem 17 POLO-filter no 331 [18] 361 [20] 819 Theorem 17 POLO-71 no 341 [10] 425 [14] 710 Theorem 17 POLO-71+72 no 341 [10] 432 [14] 011 Theorem 26 EMB no 233 [08] 529 [16] 1112 Theorem 26 LPO no 292 [16] 374 [21] 10713 Theorem 26 POLO-filter no 361 [18] 334 [18] 7814 Theorem 26 POLO-71 no 368 [11] 388 [18] 1715 Theorem 26 POLO-71+72 no 369 [11] 399 [17] 51617 Theorem 26 POLO-71+72 olderold 390 [12] 349 [24] 3418 Theorem 26 POLO-71+72 (1)+(2) 374 [12] 394 [18] 519 Theorem 26 POLO-71+72 lim 396 [21] 268 [19] 10920 Theorem 26 POLO-71+72 safe 406 [11] 330 [25] 37

than Theorem 12 and increases the number of examples where termination can beproved by up to 955 Theorem 26 improves upon Theorem 17 further and increasespower by up to 339 (up to 175 for innermost termination)

To measure the impact of our contributions in Section 7 we compare the naive useof monotonic polynomial orders (POLO-filter line 13) with the more sophisticatedapproaches of Section 71 and 72 (lines 14ndash15) As all three methods are equally pow-erful in principle the difference is in efficiency Indeed the step from POLO-filter to

Table 2 Innermost termination proofs

Line Algorithm Order Tr Y F TO

16 Theorem 12 17 EMB no 246 [08] 516 [18] 1127 Theorem 12 17 LPO no 330 [21] 350 [32] 9338 Theorem 12 17 POLO-filter no 378 [21] 324 [27] 7149 Theorem 12 17 POLO-71 no 388 [10] 379 [16] 6510 Theorem 12 17 POLO-71+72 no 388 [12] 384 [17] 111 Theorem 26 EMB no 289 [09] 473 [16] 1112 Theorem 26 LPO no 341 [16] 341 [24] 9113 Theorem 26 POLO-filter no 402 [17] 305 [19] 6614 Theorem 26 POLO-71 no 408 [12] 350 [19] 1515 Theorem 26 POLO-71+72 no 408 [11] 360 [20] 516 Theorem 26 POLO-71+72 older 465 [13] 253 [56] 5517 Theorem 26 POLO-71+72 old 467 [13] 250 [55] 5618 Theorem 26 POLO-71+72 (1)+(2) 441 [16] 314 [35] 1819 Theorem 26 POLO-71+72 lim 386 [37] 144 [24] 24320 Theorem 26 POLO-71+72 safe 480 [17] 217 [69] 76

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 47: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 201

POLO-71 and further to POLO-71+72 reduces the overall runtime dramaticallyThe reason is that now a failure can often be detected quickly for examples that ledto a time-out before Thus while the number of examples where termination can beproved within the time limit increases only slightly the number of time-outs reducessubstantially (by at least 772 when going from POLO-filter to POLO-71 andby at least 667 when going from POLO-71 to POLO-71+72) This fast-failurebehavior of POLO-71+72 permits the use of further techniques in order to attempta termination proof within the time limit

Examples for such additional techniques are the dependency pair transformationsfrom Section 5 If one uses the existing ldquoolderrdquo transformations with our newheuristic for their application (line 16) then power is increased by 57 (140 forinnermost termination) While the use of dependency pair transformations increasespower it can of course also increase runtimes This holds especially for innermosttermination proofs since here the transformations are much more often applicableDefinition 28 extends the dependency pair transformations in two ways we pre-sented more liberal applicability conditions for the transformations in the innermostcase and we introduced a new forward instantiation transformation While the newapplicability conditions lead only to a minor improvement of 04 in power (cf theldquooldrdquo heuristic line 17) the forward instantiation technique increases power againby 41 (28 for innermost termination cf the ldquosaferdquo heuristic in line 20)

We also evaluate our heuristic from Definition 33 which describes when to applydependency pair transformations We consider two possible choices The first is arestriction to those transformations that make the DP problem ldquosmallerrdquo that iscorrespond to Definition 33 (1) or (2) cf line 18 Our experiments show that allowingone additional narrowing instantiation and forward instantiation step (as in theldquosaferdquo heuristic line 20) has considerable advantages because it increases powerby 86 (88 for innermost termination) As a second choice we tried a ldquolimrdquo-heuristic which simply applies transformations up to a certain limit The experimentsdemonstrate that our ldquosaferdquo-heuristic is significantly better it increases power (inparticular for innermost termination where the success rate is improved by 244)and it reduces runtimes dramatically because the ldquolimrdquo-heuristic leads to extremelymany time-outs

We also ran the experiment with the automatic mode of the newest AProVE-version (AProVE 12) which features several additional techniques (eg semanticlabeling [44] and match-bounds [9]) in addition to the results of this paper NowAProVE proved termination of 576 examples while it disproved termination for 94TRSs Innermost termination was shown for 617 examples while it was disproved for61 TRSs These results correspond exactly to the results ofAProVE in the terminationcompetition 2005 [42] The average runtime for a successful proof was 23 s (26 s forinnermost termination) and the average time for a successful disproof was 27 s (29 sfor innermost termination) Finally AProVE failed on 11 examples within the timelimit (14 for innermost termination) and the average runtime for these failures was267 s for termination and 87 s for innermost termination

To summarize our experiments indicate that the contributions of the paper areindeed useful in practice This fact also holds if our results are combined with othertermination techniques

While our experiments show that termination analysis of TRSs has reached astage where already many realistic examples can be treated automatically future

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 48: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

202 J Giesl et al

work should be devoted to the question of how these methods can be used in orderto analyze termination for programs from ldquorealrdquo programming languages Theselanguages pose several additional challenges such as evaluation strategies built-indata types partial functions non-termination analysis and higher-order functionsWe report our first results in this direction in [16 18 38]

Acknowledgements We thank the referees for many helpful remarks

References

1 Arts T Giesl J Termination of term rewriting using dependency pairs Theor Comput Sci236 133ndash178 (2000)

2 Arts T Giesl J A collection of examples for termination of term rewriting using de-pendency pairs Technical report AIB-2001-09 RWTH Aachen Germany Available fromhttpaibinformatikrwth-aachende (2001)

3 Baader F Nipkow T Term Rewriting and All That Cambridge University Press CambridgeUK (1998)

4 Borralleras C Ordering-based methods for proving termination automatically PhD thesisUniversitat Politegravecnica de Catalunya Spain (2003)

5 Borralleras C Ferreira M Rubio A Complete monotonic semantic path orderings In Pro-ceedings of the 17th CADE LNAI 1831 pp 346ndash364 (2000)

6 Contejean E Marcheacute C Monate B Urbain X CiME version 2 Available fromhttpcimelrifr (2000)

7 Dershowitz N Termination of rewriting J Symb Comput 3 69ndash116 (1987)8 Dershowitz N Lindenstrauss N Sagiv Y Serebrenik A A general framework for automatic

termination analysis of logic programs Appl Algebra Eng Commun Comput 12(1ndash2) 117ndash156(2001)

9 Geser A Hofbauer D Waldmann J Match-bounded string rewriting systems Appl AlgebraEng Commun Comput 15(3ndash4) 149ndash171 (2004)

10 Giesl J Generating polynomial orderings for termination proofs In Proceedings of the 6thRTA LNCS 914 pp 426ndash431 (1995)

11 Giesl J Arts T Verification of Erlang processes by dependency pairs Appl Algebra EngCommun Comput 12(1ndash2) 39ndash72 (2001)

12 Giesl J Arts T Ohlebusch E Modular termination proofs for rewriting using dependencypairs J Symb Comput 34(1) 21ndash58 (2002)

13 Giesl J Thiemann R Schneider-Kamp P Falke S Improving dependency pairs In Pro-ceedings of the 10th LPAR LNAI 2850 pp 165ndash179 (2003a)

14 Giesl J Thiemann R Schneider-Kamp P Falke S Mechanizing dependency pairsTechnical report AIB-2003-08 RWTH Aachen Germany Available from httpaibinformatikrwth-aachende (2003b)

15 Giesl J Thiemann R Schneider-Kamp P The dependency pair framework combiningtechniques for automated termination proofs In Proceedings of the 11th LPAR LNAI 3452pp 301ndash331 (2005a)

16 Giesl J Thiemann R Schneider-Kamp P Proving and disproving termination of higher-orderfunctions In Proceedings of the 5th FroCoS LNAI 3717 pp 216ndash231 (2005b)

17 Giesl J Schneider-Kamp P Thiemann R AProVE 12 Automatic termination proofs in thedependency pair framework In Proceedings of the 3rd IJCAR LNAI 4130 pp 281ndash286 (2006a)

18 Giesl J Swiderski S Schneider-Kamp P Thiemann R Automated termination analysis forHaskell from term rewriting to programming languages In Proceedings of the 17th RTA LNCS4098 pp 297ndash312 (2006b)

19 Gramlich B Generalized sufficient conditions for modular termination of rewriting ApplAlgebra Eng Commun Comput 5 131ndash158 (1994)

20 Gramlich B Abstract relations between restricted termination and confluence properties ofrewrite systems Fundam Inform 24 3ndash23 (1995)

21 Gramlich B Termination and confluence properties of structured rewrite systems PhD thesisUniversitaumlt Kaiserslautern Germany (1996)

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice

Page 49: Mechanizing and Improving Dependency Pairsimada.sdu.dk/~petersk/papers/JAR06-dps.pdf · Mechanizing and improving dependency pairs 159 A DP problem (P,R,e)that is not finite is called

Mechanizing and improving dependency pairs 203

22 Hirokawa N Middeldorp A Dependency pairs revisited In Proceedings of the 15th RTALNCS 3091 pp 249ndash268 (2004a)

23 Hirokawa N Middeldorp A Polynomial interpretations with negative coefficients In Pro-ceedings of the AISC rsquo04 LNAI 3249 185ndash198 (2004b)

24 Hirokawa N Middeldorp A Tyrolean termination tool In Proceedings of the 16th RTALNCS 3467 pp 175ndash184 (2005a)

25 Hirokawa N Middeldorp A Automating the dependency pair method Inf Comput 199(1ndash2)172ndash199 (2005b)

26 Hong H and Jakuš D Testing positiveness of polynomials J Autom Reason 21(1) 23ndash38(1998)

27 Huet G Hullot J-M Proofs by induction in equational theories with constructors J ComputSyst Sci 25 239ndash299 (1982)

28 Knuth D Bendix P Simple word problems in universal algebras In Leech J (ed) Computa-tional Problems in Abstract Algebra pp 263ndash297 Pergamon Press Oxford UK (1970)

29 Koprowski A TPA termination proved automatically In Proceedings of the 17th RTA LNCS4098 pp 257ndash266 (2006)

30 Kusakari K Nakamura M Toyama Y Argument filtering transformation In Proceedings ofthe 1st PPDP LNCS 1702 pp 48ndash62 (1999)

31 Lankford D On proving term rewriting systems are Noetherian Technical report MTP-3Louisiana Technical University Ruston LA (1979)

32 Lee C S Jones N D Ben-Amram A M The size-change principle for program terminationIn Proceedings of the 28th POPL pp 81ndash92 (2001)

33 Lucas S Polynomials over the reals in proofs of termination from theory to practice RAIROTheor Inform Appl 39(3) 547ndash586 (2005)

34 Middeldorp A Approximating dependency graphs using tree automata techniques In Pro-ceedings of the 1st IJCAR LNAI 2083 pp 593ndash610 (2001)

35 Middeldorp A Approximations for strategies and termination In Proceedings of the 2nd WRSENTCS 70(6) (2002)

36 Ohlebusch E Claves C Marcheacute C TALP A tool for termination analysis of logic programsIn Proceedings of the 11th RTA LNCS 1833 270ndash273 (2000)

37 Ohlebusch E Advanced Topics in Term Rewriting Springer Berlin Heidelberg New York(2002)

38 Schneider-Kamp P Giesl J Serebrenik A Thiemann R Automated termination analysisfor logic programs by term rewriting In Proceedings of the 16th LOPSTR LNCS (2007)(to appear)

39 Thiemann R Giesl J Schneider-Kamp P Improved modular termination proofs using de-pendency pairs In Proceedings of the 2nd IJCAR LNAI 3097 pp 75ndash90 (2004)

40 Thiemann R Giesl J The size-change principle and dependency pairs for termination of termrewriting Appl Algebra Eng Commun Comput 16(4) 229ndash270 (2005)

41 Toyama Y Counterexamples to the termination for the direct sum of term rewriting systemsInf Process Lett 25 141ndash143 (1987)

42 TPDB web page httpwwwlrifr˜marchetermination-competition43 Urbain X Modular and incremental automated termination proofs J Autom Reason 32(4)

315ndash355 (2004)44 Zantema H Termination of term rewriting by semantic labelling Fundam Inform 24 89ndash105

(1995)45 Zantema H Termination of string rewriting proved automatically J Autom Reason 34(2)

105ndash139 (2005)

  • Mechanizing and Improving Dependency PairsSupported by the Deutsche Forschungsgemeinschaft DFG grant GI 2745-1
    • Abstract
      • Introduction
      • Dependency Pairs
        • The Dependency Pair Framework
        • The Dependency Graph Processor
        • The Reduction Pair Processor
          • Improving Termination Proofs by Usable Rules
          • Improving Termination Proofs by Argument Filtering
          • Transforming Dependency Pairs
            • Improving Dependency Pair Transformations
            • Soundness of Procn
            • Completeness of Procn
            • Soundness of Procr
            • Completeness of Procr
            • Soundness of Proci
            • Completeness of Proci
            • Soundness of Procf
            • Completeness of Procf
            • Mechanizing Dependency Pair Transformations
              • Computing Argument Filterings
                • Argument Filterings for the Processor of Theorem 17
                • Argument Filterings for the Processor of Theorem 26
                  • Using Polynomial Orders for Dependency Pairs
                    • Reduction Pair Processor with Polynomial Orders
                    • Finding Strict Constraints Automatically
                      • Conclusion and Empirical Results
                      • References
                        • ltlt ASCII85EncodePages false AllowTransparency false AutoPositionEPSFiles true AutoRotatePages None Binding Left CalGrayProfile (Gray Gamma 22) CalRGBProfile (sRGB IEC61966-21) CalCMYKProfile (ISO Coated) sRGBProfile (sRGB IEC61966-21) CannotEmbedFontPolicy Error CompatibilityLevel 13 CompressObjects Off CompressPages true ConvertImagesToIndexed true PassThroughJPEGImages true CreateJDFFile false CreateJobTicket false DefaultRenderingIntent Perceptual DetectBlends true DetectCurves 01000 ColorConversionStrategy sRGB DoThumbnails true EmbedAllFonts true EmbedOpenType false ParseICCProfilesInComments true EmbedJobOptions true DSCReportingLevel 0 EmitDSCWarnings false EndPage -1 ImageMemory 1048576 LockDistillerParams true MaxSubsetPct 100 Optimize true OPM 1 ParseDSCComments true ParseDSCCommentsForDocInfo true PreserveCopyPage true PreserveDICMYKValues true PreserveEPSInfo true PreserveFlatness true PreserveHalftoneInfo false PreserveOPIComments false PreserveOverprintSettings true StartPage 1 SubsetFonts false TransferFunctionInfo Apply UCRandBGInfo Preserve UsePrologue false ColorSettingsFile () AlwaysEmbed [ true ] NeverEmbed [ true ] AntiAliasColorImages false CropColorImages true ColorImageMinResolution 150 ColorImageMinResolutionPolicy Warning DownsampleColorImages true ColorImageDownsampleType Bicubic ColorImageResolution 150 ColorImageDepth -1 ColorImageMinDownsampleDepth 1 ColorImageDownsampleThreshold 150000 EncodeColorImages true ColorImageFilter DCTEncode AutoFilterColorImages true ColorImageAutoFilterStrategy JPEG ColorACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt ColorImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000ColorACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000ColorImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasGrayImages false CropGrayImages true GrayImageMinResolution 150 GrayImageMinResolutionPolicy Warning DownsampleGrayImages true GrayImageDownsampleType Bicubic GrayImageResolution 150 GrayImageDepth -1 GrayImageMinDownsampleDepth 2 GrayImageDownsampleThreshold 150000 EncodeGrayImages true GrayImageFilter DCTEncode AutoFilterGrayImages true GrayImageAutoFilterStrategy JPEG GrayACSImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt GrayImageDict ltlt QFactor 076 HSamples [2 1 1 2] VSamples [2 1 1 2] gtgt JPEG2000GrayACSImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt JPEG2000GrayImageDict ltlt TileWidth 256 TileHeight 256 Quality 15 gtgt AntiAliasMonoImages false CropMonoImages true MonoImageMinResolution 600 MonoImageMinResolutionPolicy Warning DownsampleMonoImages true MonoImageDownsampleType Bicubic MonoImageResolution 600 MonoImageDepth -1 MonoImageDownsampleThreshold 150000 EncodeMonoImages true MonoImageFilter CCITTFaxEncode MonoImageDict ltlt K -1 gtgt AllowPSXObjects false CheckCompliance [ None ] PDFX1aCheck false PDFX3Check false PDFXCompliantPDFOnly false PDFXNoTrimBoxError true PDFXTrimBoxToMediaBoxOffset [ 000000 000000 000000 000000 ] PDFXSetBleedBoxToMediaBox true PDFXBleedBoxToTrimBoxOffset [ 000000 000000 000000 000000 ] PDFXOutputIntentProfile (None) PDFXOutputConditionIdentifier () PDFXOutputCondition () PDFXRegistryName () PDFXTrapped False Description ltlt CHS ltFEFF4f7f75288fd94e9b8bbe5b9a521b5efa7684002000410064006f006200650020005000440046002065876863900275284e8e55464e1a65876863768467e5770b548c62535370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c676562535f00521b5efa768400200050004400460020658768633002gt CHT ltFEFF4f7f752890194e9b8a2d7f6e5efa7acb7684002000410064006f006200650020005000440046002065874ef69069752865bc666e901a554652d965874ef6768467e5770b548c52175370300260a853ef4ee54f7f75280020004100630072006f0062006100740020548c002000410064006f00620065002000520065006100640065007200200035002e003000204ee553ca66f49ad87248672c4f86958b555f5df25efa7acb76840020005000440046002065874ef63002gt DAN ltFEFF004200720075006700200069006e0064007300740069006c006c0069006e006700650072006e0065002000740069006c0020006100740020006f007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400650072002c0020006400650072002000650067006e006500720020007300690067002000740069006c00200064006500740061006c006a006500720065007400200073006b00e60072006d007600690073006e0069006e00670020006f00670020007500640073006b007200690076006e0069006e006700200061006600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020004400650020006f007000720065007400740065006400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50062006e00650073002000690020004100630072006f00620061007400200065006c006c006500720020004100630072006f006200610074002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002egt DEU ltFEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e002000410064006f006200650020005000440046002d0044006f006b0075006d0065006e00740065006e002c00200075006d002000650069006e00650020007a0075007600650072006c00e40073007300690067006500200041006e007a006500690067006500200075006e00640020004100750073006700610062006500200076006f006e00200047006500730063006800e40066007400730064006f006b0075006d0065006e00740065006e0020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f00620061007400200075006e0064002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002egt ESP ltFEFF005500740069006c0069006300650020006500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000640065002000410064006f00620065002000500044004600200061006400650063007500610064006f007300200070006100720061002000760069007300750061006c0069007a00610063006900f3006e0020006500200069006d0070007200650073006900f3006e00200064006500200063006f006e006600690061006e007a006100200064006500200064006f00630075006d0065006e0074006f007300200063006f006d00650072006300690061006c00650073002e002000530065002000700075006500640065006e00200061006200720069007200200064006f00630075006d0065006e0074006f00730020005000440046002000630072006500610064006f007300200063006f006e0020004100630072006f006200610074002c002000410064006f00620065002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002egt FRA ltFEFF005500740069006c006900730065007a00200063006500730020006f007000740069006f006e00730020006100660069006e00200064006500200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000410064006f006200650020005000440046002000700072006f00660065007300730069006f006e006e0065006c007300200066006900610062006c0065007300200070006f007500720020006c0061002000760069007300750061006c00690073006100740069006f006e0020006500740020006c00270069006d007000720065007300730069006f006e002e0020004c0065007300200064006f00630075006d0065006e00740073002000500044004600200063007200e900e90073002000700065007500760065006e0074002000ea0074007200650020006f007500760065007200740073002000640061006e00730020004100630072006f006200610074002c002000610069006e00730069002000710075002700410064006f00620065002000520065006100640065007200200035002e0030002000650074002000760065007200730069006f006e007300200075006c007400e90072006900650075007200650073002egt ITA (Utilizzare queste impostazioni per creare documenti Adobe PDF adatti per visualizzare e stampare documenti aziendali in modo affidabile I documenti PDF creati possono essere aperti con Acrobat e Adobe Reader 50 e versioni successive) JPN ltFEFF30d330b830cd30b9658766f8306e8868793a304a3088307353705237306b90693057305f002000410064006f0062006500200050004400460020658766f8306e4f5c6210306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103055308c305f0020005000440046002030d530a130a430eb306f3001004100630072006f0062006100740020304a30883073002000410064006f00620065002000520065006100640065007200200035002e003000204ee5964d3067958b304f30533068304c3067304d307e305930023053306e8a2d5b9a3067306f30d530a930f330c8306e57cb30818fbc307f3092884c3044307e30593002gt KOR ltFEFFc7740020c124c815c7440020c0acc6a9d558c5ec0020be44c988b2c8c2a40020bb38c11cb97c0020c548c815c801c73cb85c0020bcf4ace00020c778c1c4d558b2940020b3700020ac00c7a50020c801d569d55c002000410064006f0062006500200050004400460020bb38c11cb97c0020c791c131d569b2c8b2e4002e0020c774b807ac8c0020c791c131b41c00200050004400460020bb38c11cb2940020004100630072006f0062006100740020bc0f002000410064006f00620065002000520065006100640065007200200035002e00300020c774c0c1c5d0c11c0020c5f40020c2180020c788c2b5b2c8b2e4002egt NLD (Gebruik deze instellingen om Adobe PDF-documenten te maken waarmee zakelijke documenten betrouwbaar kunnen worden weergegeven en afgedrukt De gemaakte PDF-documenten kunnen worden geopend met Acrobat en Adobe Reader 50 en hoger) NOR ltFEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f0070007000720065007400740065002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e00740065007200200073006f006d002000650072002000650067006e0065007400200066006f00720020007000e5006c006900740065006c006900670020007600690073006e0069006e00670020006f00670020007500740073006b007200690066007400200061007600200066006f0072007200650074006e0069006e006700730064006f006b0075006d0065006e007400650072002e0020005000440046002d0064006f006b0075006d0065006e00740065006e00650020006b0061006e002000e50070006e00650073002000690020004100630072006f00620061007400200065006c006c00650072002000410064006f00620065002000520065006100640065007200200035002e003000200065006c006c00650072002egt PTB ltFEFF005500740069006c0069007a006500200065007300730061007300200063006f006e00660069006700750072006100e700f50065007300200064006500200066006f0072006d00610020006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000410064006f00620065002000500044004600200061006400650071007500610064006f00730020007000610072006100200061002000760069007300750061006c0069007a006100e700e3006f002000650020006100200069006d0070007200650073007300e3006f00200063006f006e0066006900e1007600650069007300200064006500200064006f00630075006d0065006e0074006f007300200063006f006d0065007200630069006100690073002e0020004f007300200064006f00630075006d0065006e0074006f00730020005000440046002000630072006900610064006f007300200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002000650020006f002000410064006f00620065002000520065006100640065007200200035002e0030002000650020007600650072007300f50065007300200070006f00730074006500720069006f007200650073002egt SUO ltFEFF004b00e40079007400e40020006e00e40069007400e4002000610073006500740075006b007300690061002c0020006b0075006e0020006c0075006f0074002000410064006f0062006500200050004400460020002d0064006f006b0075006d0065006e007400740065006a0061002c0020006a006f0074006b006100200073006f0070006900760061007400200079007200690074007900730061007300690061006b00690072006a006f006a0065006e0020006c0075006f00740065007400740061007600610061006e0020006e00e400790074007400e4006d0069007300650065006e0020006a0061002000740075006c006f007300740061006d0069007300650065006e002e0020004c0075006f0064007500740020005000440046002d0064006f006b0075006d0065006e00740069007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f0062006100740069006c006c00610020006a0061002000410064006f00620065002000520065006100640065007200200035002e0030003a006c006c00610020006a006100200075007500640065006d006d0069006c006c0061002egt SVE ltFEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006f006d002000640075002000760069006c006c00200073006b006100700061002000410064006f006200650020005000440046002d0064006f006b0075006d0065006e007400200073006f006d00200070006100730073006100720020006600f60072002000740069006c006c006600f60072006c00690074006c006900670020007600690073006e0069006e00670020006f006300680020007500740073006b007200690066007400650072002000610076002000610066006600e4007200730064006f006b0075006d0065006e0074002e002000200053006b006100700061006400650020005000440046002d0064006f006b0075006d0065006e00740020006b0061006e002000f600700070006e00610073002000690020004100630072006f0062006100740020006f00630068002000410064006f00620065002000520065006100640065007200200035002e00300020006f00630068002000730065006e006100720065002egt ENU (Use these settings to create Adobe PDF documents for journal articles and eBooks for online presentation Created PDF documents can be opened with Acrobat and Adobe Reader 50 and later) gtgtgtgt setdistillerparamsltlt HWResolution [2400 2400] PageSize [595276 841890]gtgt setpagedevice