Available online at www.sciencedirect.com

V ScienceDirect

Electronic Notes in Theoretical Computer Science 188 (2007) 91-103

www.elsevier.com/locate/entcs

Improving the Context-sensitive Dependency Graph

Beatriz Alarcon, Raúl Gutiérrez, and Salvador Lucas

Departamento de Sistemas Informáticos y Computación Universidad Politécnica de Valencia Valencia, Spain

Abstract

The dependency pairs method is one of the most powerful technique for proving termination of rewriting and it is currently central in most automatic termination provers. Recently, it has been adapted to be used in proofs of termination of context-sensitive rewriting. The use of collapsing dependency pairs i.e., having a single variable in the right-hand side is a novel and essential feature to obtain a correct framework in this setting. Unfortunately, dependency pairs behave as a kind of glue in the context-sensitive dependency graph which makes the cycles bigger, thus making some proofs of termination harder. In this paper we show that this effect can be safely mitigated by removing some arcs from the graph, thus leading to faster and easier proofs. Narrowing dependency pairs is also introduced and used here to eventually simplify the treatment of the context-sensitive dependency graph. We show the practicality of the new techniques with some benchmarks.

Keywords: Dependency pairs, term rewriting, program analysis, termination.

1 Introduction

Termination is one of the most interesting problems when dealing with context-sensitive rewrite systems. With context-sensitive rewriting (CSR [10,11]) we can achieve a terminating behavior with non-terminating Term Rewriting Systems (TRSs [14,15]), by pruning (all) infinite rewrite sequences. In CSR we only rewrite ^-replacing subterms. Here, ^ is a replacement map, i.e., a mapping ^ : F ^ P(N) satisfying y(f) C {1,... ,k}, for each k-ary symbol f of the signature F [10]. We use them to discriminate the argument positions on which the rewriting steps are allowed. Then, ti is a ^-replacing subterm of f(t1,... ,tk) if i E fi(f); every term t (as a whole) is ^-replacing by definition. For other subterms we proceed inductively

1 This work has been partially supported by the EU (FEDER) and the Spanish MEC, under grants TIN 2004-7943-C04-02 and HA 2006-0007, the Generalitat Valenciana under grant GV06/285, and the ICT for EU-India Cross-Cultural Dissemination ALA/95/23/2003/077-054 project. Beatriz Alarcon was partially supported by the Spanish MEC under FPU grant AP2005-3399.

2 Email: {balarcon,rgutierrez,slucas}@dsic.upv.es

1571-0661/$ - see front matter © 2007 Elsevier B.V. All rights reserved. doi:10.1016/j.entcs.2007.05.040

in this way. Then, for a given TRS, we obtain a restriction of rewriting which we call context-sensitive rewriting. Proving termination of CSR is an interesting problem with several applications in the fields of term rewriting and programming languages (see [5,6,8,11,13] for further motivation).

The dependency pairs method [1] is one of the most powerful techniques for proving termination of rewriting. Roughly speaking, given a TRS R, the dependency pairs associated to R conform a new TRS DP(R) which (together with R) determines the so-called dependency chains whose finiteness characterizes termination of R. The dependency pairs can be presented as a dependency graph, where the absence of infinite chains can be analyzed by considering the cycles in the graph. In [3], the dependency pairs method has been adapted to be used in proofs of termination of CSR. The technique has been implemented in the tool mu-term [2,12]. Basically, the non-variable subterms in the right-hand sides of the rules which are considered to build the CS-dependency pairs must be replacing terms. Nevertheless such 'standard' dependency pairs do not suffice to obtain a correct method for proving termination of CSR.

Example 1.1 [3, Example 2] Consider the following TRS R:

a -> c(f(a))

f(c(X)) -> X

together with ^(c) = 0 and ^(f) = {1}. There is no ^-replacing subterm s in the right-hand sides of the rules which is rooted by a defined symbol. Thus, there is no 'standard' dependency pair. We could wrongly conclude that R is ^-terminating, which is not true:

f(a) f (c(f (a))) f (a) • • •

Indeed, as shown in [3], we must add the following dependency pair

F(c(X)) -> X

which would not be allowed in Arts and Giesl's approach [1] because the right-hand side is a variable. In this paper, we call collapsing to such kind of dependency pairs.

As in Arts and Giesl's approach, the analysis of infinite sequences of context-sensitive dependency pairs can be made by looking at (the cycles C of) the context-sensitive dependency graph associated to the CS-TRS R. The nodes of the dependency graph are the dependency pairs in DP(R,^). A disappointing aspect of collapsing context-sensitive dependency pairs (as F(c(X)) -> X above) is that they are connected to every other dependency pair in the context-sensitive dependency graph [3]. Intuitively, this is because the variable X in the right-hand side of the dependency pair could be instantiated to anything, thus being potentially able to 'connect' to every other dependency pair.

In this paper, we show that we can restrict the number of outcoming links of collapsing dependency pairs to dependency pairs headed by the so-called hidden symbols which are defined symbols that occur in non-replacing positions in the right-hand sides of some rule in the TRS. This leads to a new definition of the context-sensitive dependency graph which greatly improves the performance of the original method.

Example 1.2 Consider the following non-terminating TRS R which can be used to compute the list of prime numbers [7] :

primes -> sieve(from(s(s(0)))) tail(cons(X,Y)) -> Y

from(X) -> cons(X,from(s(X))) if(true,X,Y) -> X

head(cons(X,Y)) -> X if(false,X,Y) -> Y

filter(s(s(X)),cons(Y,Z)) ->

if(divides(s(s(X)),Y),filter(s(s(X)),Z),cons(Y,filter(X,sieve(Y)))) sieve(cons(X,Y)) -> cons(X,filter(X,sieve(Y)))

together with ^(cons) = ^(if) = {1} and ) = {1,...,ar(/)} for any other symbols /. No (automatic or manual) proof of termination for this CS-TRS has been reported to date. By using the dependency graph as defined in [3] we were not able to find a proof with mu-term 4.3 [2].

In contrast, with the new definition in this paper, we have no cycles! Thus, a direct (and automatic) proof of ^-termination of R is easy now.

Narrowing dependency pairs was also introduced by Arts and Giesl to improve the efficiency of the dependency pairs technique in proofs of termination [1]. Roughly speaking, under some conditions, a dependency pair can be replaced by a set of pairs which could simplify or restructure the dependency graph and eventually simplify the proof of termination. We also investigate this technique for dealing with the context-sensitive dependency graph.

After some preliminary definitions in Section 2, Section 3 introduces the notion of hidden symbol and investigates its properties in proofs of termination of CSR. Section 4 shows how to use it to improve the context-sensitive dependency graph. Section 5 adapts narrowing of dependency pairs to context-sensitive dependency pairs. Section 6 provides an experimental evaluation of our techniques. Section 7 concludes.

2 Preliminaries

Throughout the paper, X denotes a countable set of variables and F denotes a signature, i.e., a set of function symbols {f, g,...}, each having a fixed arity given by a mapping ar : F ^ N. The set of terms built from F and X is T(F, X). Positions p, q,... are represented by chains of positive natural numbers used to address subterms of t. Given positions p, q, we denote its concatenation as p.q. If p is a position, and Q is a set of positions, p.Q = {p.q | q £ Q}. We denote the empty chain by A. The set of positions of a term t is Pos(t). The subterm at position p of t is denoted as t|p and t[s]p is the term t with the subterm at position p replaced by s. We write t > s if s = t|p for some p £ Pos(t) and t > s if t > s and t = s. The symbol labelling the root of t is denoted as root(t). A context is a term C £ T(F U {□}, X) with zero or more 'holes' □ (a fresh constant symbol).

A rewrite rule is an ordered pair (¿,r), written I ^ r, with ¿,r £ T(F, X), I £ X and Var(r) C Var(l). The left-hand side (lhs) of the rule is I and r is the right-hand side (rhs). A TRS is a pair R = (F, R) where R is a set of rewrite rules. Given R = (F,R), we consider F as the disjoint union F = CaD of symbols c £ C, called constructors and symbols / £ D, called defined functions, where

94 B. Alarcon et al. / Electronic Notes in Theoretical Computer Science 188 (2007) 91—103

D = {root(l) | l ^ r G R} and C = F - D.

Context-sensitive rewriting.

A mapping j : F — P(N) is a replacement map (or F-map) if Vf G F, j(f) C {1,...,ar(f)} [10]. Let Mf be the set of all F-maps (or Mr for the F-maps of a TRS (F, R)). A binary relation R on terms is j-monotonic if t R s implies f (ti,...,ti_i,t, ...,tk) Rf(ti,...,ti_i,s, ...,tk) for every t, s,ti ,...,t G T (F, X). The set of j-replacing positions Posp(t) of t G T(F, X) is: Posp(t) = {a}, if t G X and Posp(t) = {a}uUie^(root(t)) i.P°sM(t|i), if t G X. The set of replacing variables of t is VarM(t) = {x G Var(t) | 3p G Posp(t),t|p = x}. The ¡-replacing subterm relation is given by t s if there is p G Posp(t) such that s = t|p. We write t s if t s and t = s. In context-sensitive rewriting (CSR [10]), we (only) contract replacing redexes: t ¡-rewrites to s, written t c—> p s (or t —r)/U. s), if t ——r s and p G Posp(t). A TRS R is ¡-terminating if ■—M is terminating. A term t is ¡-terminating if there is no infinite ¡-rewrite sequence t = t1 — p t2 — p ■ ■ ■ — p tn —> ''' starting from t. A pair (R,j) where R is a TRS and j G Mr is often called a CS-TRS.

Dependency pairs.

Given a TRS R = (F, R) = (C i±i D,R) a new TRS DP(R) = (F",D(R)) of dependency pairs for R is given as follows: if f(t1,...,tm) — r G R and r = C[g(s1,...,sn)] for some defined symbol g G D and s1,...,sn G T(F,X), then f "(t 1 ,...,tm) — gB(si,...,sn) G D(R), where f" and g" are new fresh symbols (called tuple symbols) associated to defined symbols f and g respectively [1]. Let D" be the set of tuple symbols associated to symbols in D and F" = FUD". As usual, for t = f (t1,...,tk) G T(F, X), we write t" to denote the marked term f"(t1,..., t). Conversely, given a marked term t = f "(t1,...,tk), where t1,...,tk G T(F, X), we write t* to denote the term f (ti,...,tk) G T (F, X). Given T C T (F, X), let T" be the set {t" | t G T}.

3 Structure of infinite ^-rewrite sequences

Let MTO)/U, be a set of minimal non-¡-terminating terms in the following sense: t belongs to MTO)iU, if t is non-j-terminating and every strict ¡-replacing subterm s of t (i.e., t s) is ¡-terminating. Obviously, if t G then root(t) is a defined

symbol. Furthermore, since ¡-terminating terms are preserved under ¡-rewriting, it follows that MTO)/U, is also preserved under inner ¡-rewritings.

Lemma 3.1 Let R be a TRS and j G MR. Let t G If t —■* s, then

The following proposition establishes that, given t G there are two ways

for an infinite ¡-rewrite sequence to proceed. The first one is by using 'visible' parts of the rules which correspond to ¡-replacing subterms in the right-hand sides which

are rooted by a defined symbol. The second one is by showing up 'hidden' non-i-terminating subterms which are activated by migrating variables in a rule l ^ r, i.e., variables x G VarM(r) — VarM(l) which are not ¡-replacing in the left-hand side l but become ¡-replacing in the right-hand side r.

Proposition 3.2 [3] Let R = (C i±i D,R) be a TRS and i G Mr. For all t G there exist l ^ r G R, a substitution a and a term u G such that

t^* a(l) ^ a(r) u and either (1) there is a ¡-replacing subterm s of r such that u = a(s), or (2) there is x G VarM(r) — VarM(l) such that a(x) u.

Now we investigate the structure of such sequences in more detail. In the following, we write t s to denote that s is a non-replacing (hence strict!) subterm of t: t s if there is p G Pos(t) — PosM(t) such that s = t|p.

Definition 3.3 [Hidden symbol] Let R = (F,R) be a TRS and i G Mr. We say that f G F is a hidden symbol if there is a rule l ^ r G R and t G T (F, X ) such that r t and root(t) = f. Let H(R,i) (or just H, if R and i are clear for the context) be the set of all hidden symbols in (R,i).

Lemma 3.4 Let R = (F ,R) be a TRS and i G Mr. Let t G T (F, X ) and a be a substitution. If there is a rule l ^ r G R such that a(l) ^ t and a(r) t, then there is no x G V ar(r) such that a(x) > t. Furthermore, there is a term t' G T (F, X ) such that r t', a(t') = t and root(t) = root(t') G H.

Proof. By contradiction. If there is x G Var(r) such that a(x) > t, then since variables in l are always below some function symbol we have a(l) > t, leading to a contradiction.

Since there is no x G Var(r) such that a(x) > t but we have that a(r) t, then there is a non-variable and non-replacing position p G Posf(r) — PosM(r), such that root(r|p) = root(t) G H(R,i) and a(r|p) = t. Then, we let t' = r|p. □

The following lemma establishes that minimal non-i-terminating and non-i-replacing subterms occurring in a i-rewrite sequence involving only minimal terms directly come from the first term in the sequence or are rooted by a hidden symbol.

Lemma 3.5 Let R = (F,R) be a TRS and i G Mr. Let A be a finite ¡-rewrite sequence t\ ^ t2 ^ ••• tn with ti G for all i, 1 < i < n and n > 1. If

there is a term t G such that t\ ^ t and tn t, then root(t) G H.

Proof. By induction on n:

(i) If n = 1, then it is vacuously true.

(ii) If n > 1, then we assume that ti ^ t and tn t. Let l ^ r G R be such that tn-i = C[a(l)] and tn = C[a(r)] for some context C[]. We consider two cases: either tn-i t holds or not.

(a) If tn-i t, then by the induction hypothesis we have that root(t) G H.

(b) If tn-i t does not hold, then one of the following cases holds:

(1) tn-i t; then tn-i G implies that t / leading to a contra-

diction.

(2) tn_1 ^ t (in particular, a(/) ^ t); then, since tn t there must be a(r) t. Thus, by Lemma 3.4 we conclude that root(t) £ H.

Now we use the previous lemmas to investigate infinite sequences that mix rewriting steps on minimal non-i-terminating terms and the extraction of such subterms as ¡-replacing subterms of (instances of) right-hand sides of rules.

Proposition 3.6 Let R = (F,R) be a TRS and i £ Mr. Let A be an infinite

£ >£ £ >£ sequence of the form t1 ^ s1 t2 ^ * t2 ^ s2 t3 ^ * t3 ••• with U, ti £

for all i > 1. If there is a term t £ such that ti t for some i > 1, then

root(t) £ H n D or t1 t.

Proof. By induction on i:

(i) If i = 1, it is trivial.

(ii) If i > 1 and ti t, then we consider two cases: either ti_1 t holds or not.

(a) If ti_1 t, then by the induction hypothesis we get t1 t or root(t) £ HnD, as desired.

(b) If ti_1 t does not hold, then let I ^ r £ R be such that ti_1 = a(i) and si_1 = a(r) ti. We consider two cases:

(1) if ti_1 t then being ti_1 £ it would imply that t £ thus leading to a contradiction.

(2) If ti_1 ^ t, then we consider two cases: either ti > t or ti ^ t.

(A) If ti > t, since ti,t £ the case ti t is excluded and the only possibility is that ti t. Then, since a(i) = ti_1 ^ t and a(r) ti t, i.e. a(r) t, by Lemma 3.4 we conclude that root(t) £ H. Since t £ we have root(t) £ H n D

(B) If ti ^ t, then, by applying Lemma 3.1 and Lemma 3.5 to the ¡-rewrite

sequence ti^ *ti we conclude root(t) £ H n D.

As an immediate consequence of Proposition 3.6, we have the following result which we will use later.

Corollary 3.7 Let (R,l) be a CS-TRS, A be an infinite sequence of the form, £ >£ £ >£

t1 ^ s1 t'2 ^* t2 ^ s2 t'3 ^* t3 ••• with ti, ti £ for all i > 1. If there is

a term t £ such that ti t for some i > 1 and root(t) £ D — H, then t1 t.

4 Revised context-sensitive dependency graph

Proposition 3.2 motivates the definition of context-sensitive dependency pair(s) and chain of context-sensitive dependency pairs.

Definition 4.1 [CS-dependency pairs [3]] Let R = (F,R) = (C W D,R) be a TRS and i £ MR. We define DP(R,i) = DPF(R,i) U DPX (R,i) to be the set of

context-sensitive dependency pairs (CS-DPs) where:

DPf(R,l) = {lf ^ sf | l ^ r G R, r s, root(s) G D,l s}

and DPX(R,i) = {lf ^ x | l ^ r G R,x G Var^(r) —Var^(l)}. We extend i G MF into G Mf» by if(f) = i(f) if f G F, and if(ff) = i(f) if f G D.

Example 4.2 Consider the CS-TRS (R,i) in Example 1.2. There are six context-sensitive dependency pairs:

1: PRIMES -> SIEVE(from(s(s(0))))

2: PRIMES -> FR0M(s(s(0)))

3: TAIL(cons(X,Y)) -> Y

4: IF(true,X,Y) -> X

5: IF(false,X,Y) -> Y

6: FILTER(s(s(X)),cons(Y,Z)) ->

IF(divides(s(s(X)),Y),filter(s(s(X)),Z),cons(Y,filter(X,sieve(Y))))

Note the three collapsing dependency pairs: (3), (4), and (5).

Definition 4.3 [Chain of CS-DPs [3]] Let (R,i) be a CS-TRS. Given P Ç DP(R,i), an (R, P )-chain is a finite or infinite sequence of pairs ui ^ vi G P, for i > 1 such that there is a substitution a satisfying both:

(i) a(vi) a(ui+i), if ui ^ v G DPf(R,i), and

(ii) if ui ^ vi = ui ^ xi G DPx (R,i), then there is si G T(F, X) such that a(xi) si and sf a(ui+i).

Here, as usual we assume that different occurrences of dependency pairs do not share any variable (renamings are used if necessary). An (R, P)-chain is called minimal if for all i > 1 a(ui)^ G si G (whenever they occur in the

chain) and all dependency pairs in P occur infinitely often.

Remark 4.4 When an (R, DP(R,i))-chain is written for a given substitution a, we write a(u) a(v) for steps which use a dependency pair u ^ v G

DPf(R,i) but we rather write a(u) sf for steps which use a dependency

pair u ^ x G DPx(R,i), where s is as in Definition 4.3.

Theorem 4.5 (Correctness and completeness [3]) Let R be a TRS and i G

Mr. R is ^-terminating if and only if there is no infinite (R, DP(R,i),if) -chain.

An essential aspect of the mechanization of the dependency pairs approach is the analysis of infinite sequences of dependency pairs by looking at (the cycles C of) the dependency graph associated to the TRS R. In [3],he context-sensitive dependency graph, is defined as follows:

(i) There is an arc from a dependency pair u ^ v G DPf(R,i) to a dependency pair u' ^ v' G DP(R,i) if there is a substitutions a such that a(v) ^R »

a(u').

(ii) There is an arc from a dependency pair u ^ v G DPx(R,i) to each dependency pair u' ^ v' G DP(R,i).

Connecting each collapsing dependency pair with every other dependency pair

makes the cycles bigger, thus making some proofs of termination harder. Thanks to the results in the previous section, we can prove the following.

Theorem 4.6 There is no infinite minimal (R,P, 1 )-chain involving an infinite number of dependency pairs ui a vi £ DPx(R,l) such that roo t(ui+1)b £ H.

Proof. By contradiction. Let A be an infinite (R, P, 1 )-minimal chain of CS-DPs characterized by the CS-DPs ui a vi for i > 1:

a(u) Ap s1 a(u2) s2 ■ ■ ■

where, = a(vi) if ui a vi £ DPf(R,l) and a(xi) si if ui a vi = ui a xi £ DPx (R,i). Let I be the infinite set of indices satisfying that for all i £ I, ui a vi £ DPx(R,i) and root(ui+1 £ H. Given i £ I, let n(i) be the 'next' positive integer in I: n(i) = min({j £ I | j > i}). Obviously, for all i £ I, n(i) £ I. Now consider the following sequence which is obtained from A by 'unsharping' the tuple symbols and using the rules ¿i a ri which originate the dependency pairs ui a vi which are used in A:

AR a(ri) si aR AR ^2) S2 r '*

R ■■■

which corresponds to A above: by minimality of A (see Definition 4.3), we have that a(ui)^,si £ for all i > 1. By definition of I, for all i £ I, vi = xi £ X. By

definition of collapsing dependency pair, xi £ Pos(ui) — PosM(ui) and a(xi) si. Thus, a(ui) si for all i £ I .By repeatedly applying Corollary 3.7, we have that a(ui) ), i.e., a(u) > a(un^)) for all i £ I. Thus, we obtain an infinite

t>-sequence which contradicts well-foundedness of t>. □

As a consequence of this result, we can dismiss the arcs of the dependency graph which connect collapsing dependency pairs u a v and dependency pairs u' a v' such that root(u')^ £ H. This leads to a new definition of the context-sensitive dependency graph:

Definition 4.7 [Context-Sensitive Dependency Graph] Let R be a TRS and i £ Mr. The context-sensitive dependency graph consists of the set DP(R,i) of context-sensitive dependency pairs together with arcs which connect them as follows:

(i) There is an arc from a dependency pair u a v £ DPf(R,l) to a dependency pair u' a v' £ DP(R,i) if there is a substitutions a such that a(v) ar t a(u').

(ii) There is an arc from a dependency pair u a v £ DPx(R,l) to a dependency pair u' a v' £ DP(R,i) if root(u')^ £ H(R,i).

Example 4.8 Consider again the TRS R in Example 1.2. The hidden defined symbols are filter, from and sieve. The dependency graph which corresponds to this example is shown in Figure 1 (right). Note that, in contrast to the situation

Fig. 1. Dependency graphs for Example 1.2: according to [3] (left) and according to Definition 4.7 (right)

with the old dependency graph (Figure 1, left) the new dependency graph has no cycle!

As noticed by Arts and Giesl, the presence of an infinite chain of dependency pairs corresponds to a cycle in the dependency graph (but not vice-versa). In the dependency graph this is true in the following sense: for each infinite chain of dependency pairs there is a suffix of the chain which corresponds to a cycle in the new dependency graph.

On the other hand, the treatment of cycles of the context-sensitive dependency graph for concluding termination by means of orderings remains as described in [3], but using the dependency graph in Definition 4.7.

Example 4.9 Consider the following TRS R [16, Example 4]

f(X) -> cons(X,f(g(X))) g(0) -> s(0) g(s(X)) -> s(s(g(X))) sel(0,cons(X,Y)) -> X sel(s(X),cons(Y,Z)) -> sel(X,Z)

with ^(0) = 0, ^(f) = ^(g) = ^(s) = ^(cons) = {1}, and ^(sel) = {1, 2}. Then, DP(R,^) is:

G(s(X)) -> G(X)

SEL(s(X),cons(Y,Z)) -> SEL(X,Z) SEL(s(X),cons(Y,Z)) -> Z

The set of hidden symbols is H = {f, g} and there are two cycles:

(i) G(s(X)) -> G(X) (ii) SEL(s(X),cons(Y,Z)) -> SEL(X,Z)

By using the subterm criterion [3, Section 5] we can easily prove that the system is ^-terminating.

100 B. Alarcon et al. / Electronic Notes in Theoretical Computer Science 188 (2007) 91—103

5 Narrowing context-sensitive dependency pairs

There are examples where the automation of the CS-DP method can fail or be more difficult due to the estimation of the arcs that connect two CS-dependency pairs (by means of functions Capm and Renm , see [3]).

Example 5.1 Consider the following example [13, Proposition 7]

f(0) -> cons(0,f(s(0)))

f(s(0)) -> f(p(s(0)))

p(s(X)) -> X

together with ¡(f) = ¡(p) = ¡(s) = ¡(cons) = {1} and ¡(0) = 0. Then DP(R,i) is:

F(s(0)) -> F(p(s(0)))

F(s(0)) -> P(s(0))

The estimated CS-dependency graph contains one cycle consisting of the CS-depen-dency pair

F(s(0)) -> F(p(s(0)))

However, this cycle does not belong to the CS-dependency graph because there is no way to ¡-rewrite F(p(s(0))) into F(s(0))!

The problem is that with the estimated CS-dependency graph, we connect more dependency pairs than needed. The over-estimation eventually comes when a CS-dependency pair u a v is is connected to u' a v' in the estimated dependency graph and v and u' do not unify, i.e. at least a rewriting step with some rule of R is needed to reduce (some instance of) v to (the corresponding instance of) u'. It is then possible that, after performing such a necessary ¡-rewriting step, the connection between them gets clearly lost, i.e, the nodes were not really connected in the graph. This is missed in the estimated dependency graph due to the use of Capm and Renm. We can use context-sensitive narrowing to avoid this problem.

Definition 5.2 [Context-sensitive narrowing [10]] Let (R,!) be a CS-TRS. A term t ¡-narrows to a term s (written t s ), if there exists a non-variable position p £ PosM(t), 9 is the most general unifier of t|p and I for a rewrite rule I a r in R (sharing no variable with t), and s = 9(t[r]p).

To achieve more precision when connecting two CS-DPs in a (R, DP(R,l),¡')-chain, we may perform all possible ¡-narrowings steps on v in order to develop the reductions from (instances of) v to (instances of) u'.Then, we obtain new terms v1, ..., vn which are ¡-narrowings of v with unifier 9i for i £ {1,...,n} and can be used instead of v. Not only the right-hand sides of the CS-dependency pairs are ¡-narrowed: the unifier which used in the narrowing step should also be applied on the left-hand sides of the ¡-narrowed pairs. Therefore, we can replace a CS-dependency pair u a v by all new ¡-narrowed pairs 91(u) a v1,... ,9n(u) a vn. The next result shows that under those conditions, the set of CS-dependency pairs can be replaced by their narrowings without losing correctness or completeness.

Theorem 5.3 (Narrowing refinement for CS-termination) Let R be a TRS

and let P be a set of CS-dependency pairs. Let u ^ v £ P such that v is linear and for all u' ^ v' £P (with renamed variables) the terms v and uU are not unifiable. Let

P' = (P — {u ^ v}) U {u' ^ v' | u' ^ v' is a narrowing of u ^ v}. There exists an infinite (R,P,)-chain iff there exists an infinite (R, P' chain.

Proof. The proof of this theorem corresponds to the proof of Theorem 25 in [1] . Note that only dependency pairs in DPf(R,^) can be narrowed. As in Arts and Giesl's proof, requiring the no-unification between the CS-dependency pair to narrow and the rest of the set; the linearity of v; and the renaming of the variables of the different (occurrences of) dependency pairs is still necessary to guarantee that narrowing CS-dependency pairs do not miss any chain from P. The main difference is that the reductions between dependency pairs are ^-reductions, but since we are using ^-narrowing, the whole proof is adapted without loss of generality. □

Thus, after narrowing the dependency pairs in DP(R,^) we can build a narrowed dependency graph. Afterwards, we can use it to check termination as usual.

Example 5.4 (Continuing Example 5.1) Since the right-hand side of the CS-de-pendency pair in Example 5.1 does not unify with any left-hand side of a dependency pair, (including itself) and it can be ^-narrowed at position 1 (notice that ^(f)={1}) by using the rule

p(s(X)) -> X

we can replace it by its ^-narrowed CS-dependency pair: F(s(0)) -> F(0)

The narrowed pair does not form any cycle in the estimated narrowed graph and termination is easily proved now.

6 Experiments

The techniques described in the previous sections have been implemented as part of the tool mu-term [2,12]. We have used our new implementation to compare with the last version of the tool: mu-term 4.3. The benchmarks were executed in a completely automatic way (see [2] for a description of mu-term's termination expert) and with a timeout of 1 minute on the 90 examples in the Context-Sensitive Rewriting subcategory of the 2006 Termination Competition, available through the URL:

http://www.lri.fr/~marche/termination-competition/2006

As remarked above, our termination expert works as explained in [2] for version 4.3 of mu-term. For the new version 4.4 of mu-term, we have just used the new definition of the (eventually narrowed) dependency graph. We have compared our new implementation with the previous version of mu-term (corresponding to [3]).

Termination Tool Total GS-DPs CSRPO Tra.nsf. Average time

MU-TERM (prole'06) 66 65 0 1 1.68s

MU-TERM (fst&tcs'06) 56 45 7 4 4.55s

AProVE 56 0 0 56 4.74s

Table 1

We have also used AProVE for proving termination of the examples. AProVE [9] is currently the most powerful tool for proving termination of TRSs and implements most existing results and techniques regarding DPs and related techniques. AProVE is also able to prove termination of Context-Sensitive Rewriting by using transformations. Such transformations obtain a proof of the ¡-termination of a TRS R as a proof of termination of a transformed TRS RQ (where © represents the transformation). If we are able to prove termination of RQ (using the standard methods), then the ¡-termination of R is ensured (see [13] for a recent survey).

A complete account of our experiments can be found here:

http://www.dsic.upv.es/~rgutierrez/muterm/prole/benchmarks.html

Table 1 summarizes our bechmarks. As shown in Table 1, the results make clear the advantages of the new refinement: we are able to prove 10 additional examples and the proofs are almost three times faster (in the average).

Furthermore, we can say that the new refinement developed for the CS-DP approach greatly improves on the use of other techniques: the use of transformations and other (also powerful) techniques like CSRPO [4] becomes now anecdotic or null.

7 Conclusions

We have introduced a simplification of the context-sensitive dependency graph by restricting the outcoming links of collapsing dependency pairs to dependency pairs headed by the so-called hidden symbols. Hidden symbols are defined symbols that occur in non-replacing positions in the right-hand sides of some rule in the TRS. This greatly improves the performance of termination proofs based on the dependency graph proposed in [3]. Narrowing context-sensitive dependency pairs has also been investigated. It can also be helpful to simplify or restructure the dependency graph and eventually simplify the proof of termination. Regarding the practical use of the (refinements on the) new CS-dependency graph in proofs of termination of CSR, we have implemented these ideas as part of the termination tool mu-term and we have obtained quite good results in terms of new examples which could be proved, and also regarding the time for achieving the proofs.

Since the state-of-the-art of DP-based techniques for proving termination of CSR which has been introduced in this paper corresponds to the developement of DPs in the late nineties, we can conclude that further improvements of CS-DPs will evolve in such a way that the CS-dependency pairs approach can play for CSR the (practical and theoretical) role than dependency pairs play in rewriting.

Many other aspects of the dependency pairs approach are also worth to be considered and extended to CSR (modularity issues, innermost computations, usable rules,...). They provide an interesting subject for future work.

References

[1] T. Arts and J. Giesl. Termination of Term Rewriting Using Dependency Pairs Theoretical Computer Science, 236:133-178, 2000.

[2] B. Alarcon, R. Gutierrez, J. Iborra, and S. Lucas. Proving Termination of Context-Sensitive Rewriting with MU-TERM. Electronic Notes in Theoretical Computer Science, to appear, 2007.

[3] B. Alarcon, R. Gutierrez, and S. Lucas. Context-Sensitive Dependency Pairs. In N. Garg and S. Arun-Kumar, editors Proc. of the 26th Conference on Foundations of Software Technology and Theoretical Computer Science, FSTTCS'06, LNCS 4337:297-308, Springer-Verlag, Berlin, 2006.

[4] C. Borralleras, S. Lucas, and A. Rubio. Recursive Path Orderings can be Context-Sensitive. In A. Voronkov, editor Proc. of 18th International Conference on Automated Deduction, CADE'02, LNAI 2392:314-331, Springer-Verlag, Berlin, 2002.

[5] F. Duran, S. Lucas, J. Meseguer, C. Marche, and X. Urbain. Proving Termination of Membership Equational Programs. In P. Sestoft and N. Heintze, editors, Proc. of PEPM'04, pages 147-158, ACM

Press, New York, 2004.

[6] F. Duran, S. Lucas, J. Meseguer, C. Marche, and X. Urbain. Proving Operational Termination of Membership Equational Programs. Higher-Order and Symbolic Computation, to appear, 2006.

[7] J. Giesl and A. Middeldorp. Transforming Context-Sensitive Rewrite Systems. In P. Narendran and M. Rusinowitch, editors, Proc. of 10th International Conference on Rewriting Techniques and Applications, RTA'99, LNCS 1631:271-285, Springer-Verlag, Berlin, 1999.

[8] J. Giesl and A. Middeldorp. Transformation techniques for context-sensitive rewrite systems. Journal of Functional Programming, 14(4): 379-427, 2004.

[9] J. Giesl, P. Schneider-Kamp, and R. Thiemann. AProVE 1.2: Automatic Termination Proofs in the Dependency Pair Framework. In U. Furbach and N. Shankar, editors, Proc. of Third International Joint Conference on Automated Reasoning, IJCAR'06, LNAI 4130:281-286, Springer-Verlag, Berlin, 2006. Available at http://www-i2.informatik.rwth-aachen.de/AProVE.

[10] S. Lucas. Context-sensitive computations in functional and functional logic programs. Journal of Functional and Logic Programming, 1998(1):1-61, January 1998.

[11] S. Lucas. Context-sensitive rewriting strategies. Information and Computation, 178(1):293-343, 2002.

[12] S. Lucas. MU-TERM: A Tool for Proving Termination of Context-Sensitive Rewriting In V. van Oostrom, editor, Proc. of RTA'04, LNCS 3091:200-209, Springer-Verlag, Berlin, 2004. Available at http://www.dsic.upv.es/~ slucas/csr/termination/muterm.

[13] S. Lucas. Proving termination of context-sensitive rewriting by transformation. Information and Computation, 204(12):1782-1846, 2006.

[14] E. Ohlebusch. Advanced Topics in Term Rewriting. Springer-Verlag, Berlin, 2002.

[15] TeReSe, editor, Term Rewriting Systems, Cambridge University Press, 2003.

[16] H. Zantema. Termination of Context-Sensitive Rewriting. In H. Comon, editor, Proc. of RTA'97, LNCS 1232:172-186, Springer-Verlag, Berlin, 1997.