Relative Termination via Dependency Pairs

A term rewrite system is terminating when no infinite reduction sequences are possible. Relative termination generalizes termination by permitting infinite reductions as long as some distinguished rules are not applied infinitely many times. Relative termination is thus a fundamental notion that has been used in a number of different contexts, like analyzing the confluence of rewrite systems or the termination of narrowing. In this work, we introduce a novel technique to prove relative termination by reducing it to dependency pair problems. To the best of our knowledge, this is the first significant contribution to Problem #106 of the RTA List of Open Problems. We first present a general approach that is then instantiated to provide a concrete technique for proving relative termination. The practical significance of our method is illustrated by means of an experimental evaluation.


Introduction
Analyzing whether a program terminates or not is a fundamental problem that has been extensively studied in almost all programming paradigms. For term rewrite systems (TRSs), termination analysis has attracted considerable attention (see, e.g., the survey by Zantema [37] and the termination portal 1 ), and various automated termination provers for TRSs have been developed: AProVE [11], T T T 2 [24], NaTT [34], etc. Among them the dependency pair (DP) method [2,13] and its successor the DP framework [12] became a modern standard.
Termination of a TRS is usually checked for all possible reduction sequences. In some cases, however, one is interested in a generalized notion, called relative termination [9,21]. Roughly speaking, a TRS R is relatively terminating w.r.t. another TRS B, which we call the base in this paper, when any infinite reduction using both systems contains only a finite number of steps given with rules from R. For instance, consider the following base: B comlist = { cons(x, cons(y, ys)) → cons(y, cons(x, ys)) } which specifies the property of commutative lists (i.e., that the order of elements is irrelevant). Termination of operations on commutative lists, described by a TRS R, can be analyzed as the relative termination of R w.r.t. B comlist . Note also that the base B comlist is clearly nonterminating.
In this paper, we present a new technique for proving relative termination by reducing it to the finiteness of dependency pair problems. To the best of our knowledge, we provide the first significant contribution to Problem #106 of the RTA List of Open Problems 2 : Can we use the dependency pair method to prove relative termination?
Relative termination has already been used in various contexts: proving confluence of a rewrite system [9,16]; liveness properties in the presence of fairness [23]; and termination of narrowing [18,29,33], an extension of rewriting to deal with non-ground terms (see, e.g., [17]). Moreover, analyzing relative termination can also be useful for other purposes, like dealing with random values or considering rewrite systems with so-called extra-variables (i.e., variables that occur in the right-hand side of a rule but not in the corresponding left-hand side). For instance, the following base B rand specifies a random number generator: We have rand(0) → * B rand s n (0) for arbitrary n ∈ N. Now, consider s(x) − s(y) → x − y, quot(0, s(y)) → 0, quot(s(x), s(y)) → s(quot(x − y, s(y))) } from Arts and Giesl [2]. Termination of R quot can be shown using the DP method [2]. However, using previously known techniques, it is not possible to prove that R quot is relatively terminating w.r.t. B rand . Note also that the relative termination of R quot w.r.t. B rand is not at all obvious, since R quot is not relatively terminating w.r.t. the following similar variant B gen : which is considered in the context of termination of narrowing [18,29,33]. Indeed, we can construct the following infinite reduction sequence using B gen : s(gen) − s(gen) → R quot gen − gen → * B gen s(gen) − s(gen) → R quot · · · We expect our technique to be also useful to deal with TRSs with extra-variables. In principle, these systems are always non-terminating, since extra-variables can be replaced by any term. However, one can still consider an interesting termination property: Is the system terminating if the extra-variables can only be instantiated with terms built from a restricted signature? Consider, e.g., the following TRS from [28]: This system is clearly non-terminating due to the extra variable in the second rewrite rule. However, by assuming that y can only take values built from constructor symbols (e.g., natural numbers), one can reformulate these rewrite rules as follows: using B gen above. Obviously, R ∪ B gen is still non-terminating, since B gen is already nonterminating. Nevertheless, one can still prove the relative termination of R w.r.t. B gen , which is an interesting property since one can ensure terminating derivations by using an appropriate heuristics to instantiate extra-variables.
Another interesting application of relative termination is test case generation. For example, in the QuickCheck tool for property-based testing, lists over, e.g., natural numbers are generated randomly. Assume f and g are defined externally by a TRS R fg , and consider the TRS R test consisting of the following rules: eq(x, x) → true rands(s(x), y) → rands(x, cons(rand(0), y)) where lists are built from nil and cons. Execution of tests(s n (0)) tests the equivalence between f and g by feeding them random inputs n times. Even when f and g are defined by f (x) → x and g(x) → x, AProVE fails to prove the relative termination of R test ∪ R fg w.r.t. B rand . In this paper, we propose a method to prove relative termination using the dependency pair framework. We implemented the proposed method in the termination tool NaTT 3 and show its significance through experiments. Using results of this paper and [35], NaTT can prove the relative termination of R quot w.r.t. B rand , and that of R test ∪ R fg w.r.t. B rand for, e.g., naive and tail recursive definitions of summation as f and g, respectively.
This paper is organized as follows. In Sect. 2, we briefly review some notions and notations of term rewriting. In Sects. 3-5, we present our main contributions for reducing relative termination to a dependency pair problem. In Sect. 6, we show that the subterm criterion and the usable rule argument is applicable under certain conditions. Then, Sect. 7 describes implementation issues , and presents selected results from an experimental evaluation. Finally, Sect. 8 compares our technique with some related work, and Sect. 9 concludes and points out some directions for future research.

Preliminaries
We assume some familiarity with basic concepts and notations of term rewriting. We refer the readers to, e.g., [4] for further details. Here we recall some fundamental notions needed in this paper.
A signature F is a set of function symbols. Given a set of variables V with F ∩ V = ∅, we denote the domain of terms by T (F, V). We use f, g, . . . to denote function symbols and x, y, . . . to denote variables. The root symbol of a term t = f (t 1 , . . . , t n ) is f and denoted by root(t). We assume an extra fresh constant called a hole. A context is a term C[ ] where the hole occurs exactly once. We write C[t] to denote the result of placing t in the hole of A position p in a term t is represented by a finite sequence of natural numbers, where denotes the root position. We let t| p denote the subterm of t at position p, and t[s] p the result of replacing the subterm t| p by the term s. We denote by s t that t is a subterm of s, and by s t that it is a proper subterm.
We write Var(t) to denote the set of variables appearing in a term t. A substitution is a mapping σ : V → T (F, V), which is extended to a morphism from T (F, V) to T (F, V) in the natural way. We denote the application of a substitution σ to a term t by tσ .
A rewrite rule l → r is a pair of terms such that l / ∈ V and Var(l) ⊇ Var(r ). The terms l and r are called the left-hand side and the right-hand side of the rule, respectively. A term rewrite system (TRS) is a set of rewrite rules. Given a TRS R, we write F R for the set of function symbols appearing in R, D R for the set of the defined symbols, i.e., the root symbols of the left-hand sides of the rules, and C R for the set of constructors; For a TRS R, we define the associated rewrite relation − → R as follows: given terms s, t ∈ T (F, V), s − → R t holds iff there exist a position p in s, a rewrite rule l → r ∈ R and a substitution σ with s| p = lσ and t = s[r σ ] p ; the rewrite step is often denoted by s p − → R t to make the rewritten position explicit, and s > − → R t if the position is strictly below the root.
Given a binary relation R, we denote its transitive closure by R + and reflexive transitive closure by R * . We use the following generalized notion of orders.

Definition 1 (order pair)
We say that ( , ) is a (well-founded) order pair on carrier A if is a quasi-order on A, is a (well-founded) strict order on A, and they are compatible, i.e., • • ⊆ .

The Dependency Pair Framework
The dependency pair (DP) method [2,13] and its successor, the DP framework [12], enables analyzing cyclic dependencies between rewrite rules, and has become one of the most popular approaches to proving termination in term rewriting. Indeed, it underlies virtually all modern termination tools for TRSs.
Let us briefly recall the fundamentals of the DP framework. Here, we consider that the signature F is implicitly extended with fresh function symbols f for each defined function f ∈ D R . Also, given a term t = f (t 1 , . . . , t n ) with f ∈ D R , we let t denote f (t 1 , . . . , t n ). If l → r ∈ R and t is a subterm of r with a defined root symbol, then the rule l → t is a dependency pair of R. The set of all dependency pairs of R is denoted by DP(R). Note that DP(R) is also a TRS.
A key ingredient in the DP framework is the notion of a DP problem, which is a pair (P, R) of a set P of dependency pairs and a TRS R. The DP problem (P, R) is called finite if there is no infinite (P, R)-chain: A (P, R)-chain (à la [13]) is a possibly infinite rewrite sequence of the form: informally represents a sequence of calls that can occur during a reduction. Then the basic result of Arts and Giesl [2] is formulated as follows: To prove DP problems finite, various techniques have been proposed and implemented in current termination tools, e.g., AProVE, T T T 2 , NaTT, and so on. Among them, reduction pairs [2] constitute a fundamental technique: A reduction pair is a well-founded order pair ( , >) on terms such that is closed under contexts and substitutions, and > is closed under substitutions.

Relative Termination
Given two relations R and B, we denote the relation B * · R · B * by R/B. In particular, for two TRSs R and B, we denote Let us now recall the formal definition of relative termination: Definition 2 (relative termination [21]) Let R and B be TRSs. We say that R relatively terminates w.r.t. B, or simply that R/B is terminating, if the relation − → R/B is terminating. We say that a term t is R/B-nonterminating if it starts an infinite − → R/B derivation, and R/B-terminating otherwise.
In other words, R/B is terminating if every (possibly infinite) → R∪B derivation contains only finitely many → R steps. Note that sequences of → B steps are "collapsed" and seen as a single − → R/B step. Hence, an infinite − → R/B derivation must contain an infinite number of → R steps and thus only finite → B subderivations. Geser [9] proposed a technique to reduce relative termination of TRSs to relative termination of simpler TRSs. This technique is later reformulated in the DP framework for proving standard termination, as rule removal processors [12]. We say a reduction pair ( , >) is monotone if > is closed under contexts.

Relative Termination as a Dependency Pair Problem
The main goal of this paper is to introduce a counterpart of Proposition 1 for proving relative termination. In this section, we present a general approach that depends on the existence of a proof ordering 4 (see below) for the given TRSs. In the next section, we will focus on providing syntactic conditions that guarantee the existence of such a proof ordering.
Let us start with some basic conditions for relative termination in terms of DP problems. First, it is folklore that, given two TRSs R and B, termination of R ∪ B implies termination of R/B. Therefore, an obvious sufficient condition for relative termination can be stated as follows: is not always true when there are shared symbols.
On the other hand, using a proof technique from the standard DP framework, we can easily prove the following necessary condition for relative termination.
For every i = 1, 2, . . . , there is a dependency pair l i → u i ∈ DP(R) and a substitution σ i such that s i = l i σ i and t i = u i σ i . As every dependency pair l i → u i corresponds to a rule which is an infinite − → R/B derivation. This concludes the proof. Now, we aim at finding more precise characterizations of relative termination in terms of DP problems. We introduce the multisets that we will use to prove our main results.

Definition 3
Let R be a TRS and t a term. The multiset R (t) of maximal R-defined subterms of t is defined as follows: It is well known that a well-founded order pair can be extended to a well-founded order pair over multisets [32].

Definition 4 (multiset extension)
The multiset extension of an order pair ( , ) on A is the order pair ( mul , mul ) on multisets over A which is defined as follows: We have X mul Y if it also holds that X = ∅.
Our main result in this section requires a particular order pair that satisfies the following property: Definition 5 Let R and B be TRSs. We say that a pair ( , ) of relations is a proof ordering for R/B, if it is a well-founded order pair on R/B-terminating terms, and satisfies the following assumptions: In the following, we say that R and B admits a proof ordering if there exists at least one proof ordering for R/B.
A natural question is whether such a proof ordering exists for some given TRSs R and B. We will investigate this question in the next section. Now, we can show the following auxiliary result, which is an easy consequence of the fact that the multiset extension preserves well-foundedness.

Lemma 1 Let R and B be TRSs that admit a proof ordering. A term s is
Proof We prove the claim by contradiction. Assume that all elements in R (s) are R/Bterminating but s is not R/B-terminating. Hence there exists an infinite sequence of the following form: Using Assumptions 1 and 2, we obtain the following sequence for the proof ordering ( , ): According to Thiemann et al. [32,Section 3] and the assumption that ( , ) is a well-founded order pair on R/B-terminating terms, the multiset extension ( mul , mul ) is a well-founded order pair on multisets of R/B-terminating terms. Hence, R (s) cannot start such an infinite mul -reduction sequence, which contradicts our assumption. Hence the infinite sequence (1) cannot exist and thus s is R/B-terminating.
Following the common practice in the termination literature, we say that an R/Bnonterminating term is minimal if all its proper subterms are R/B-terminating. It is clear that any R/B-nonterminating term has some minimal R/B-nonterminating subterm. The following lemma proves an essential result in our approach.

Lemma 2 Let R and B be TRSs that admit a proof ordering. If t is a minimal
Proof We prove the claim by contradiction. Consider a minimal R/B-nonterminating term s such that root(s) / ∈ D R . Since root(s) / ∈ D R , all elements in R (s) are proper subterms of s, which are R/B-terminating due to minimality. Lemma 1 implies that s is R/B-terminating, and hence we have a contradiction.
Using the previous result, we can state the following sufficient condition which states that termination of R/B coincides with the finiteness of the DP problem (DP(R), R ∪ B), even if B is non-terminating. Here, we further impose that R and B share no defined symbol, i.e., D R ∩ D B = ∅.

Theorem 1 Let R and B be TRSs that admit a proof ordering. Let
Proof The "only-if" direction follows from Proposition 5. We show the "if" direction by constructing an infinite chain from an arbitrary infinite − → R/B sequence: W.l.o.g., we consider s 1 to be minimal. By Lemma 2, we have root(s 1 ) ∈ D R . Due to the assumption D R ∩ D B = ∅, a → B -reduction cannot occur at the root position unless an → R -reduction rewrites the root symbol. Thus, due to minimality, there exists some n such that Let t n = lσ and s n+1 = r σ for l → r ∈ R, and consider a minimal R/B-nonterminating subterm u of s n+1 . Here, t n is minimal since s 1 is. Thus, there must exist a non-variable subterm v of r such that u = vσ . Again by Lemma 2, we have root(v) ∈ D R and thus l → v ∈ DP(R). We obtain Continuing the construction from u, we obtain an infinite (DP(R), R ∪ B)-chain.
The condition D R ∩D B = ∅ will be lifted in Sect. 5. However, at this point, it is necessary as the following example illustrates: Example 1 Consider the following TRSs: Here, we can define a proof ordering ( , ) for R/B as follows: = → + R/B and = → * B ; note that is well-founded on R/B-terminating terms, i.e., variables. Here, the DP problem (DP(R), R ∪ B) is trivially finite as DP(R) = ∅, but R/B is not terminating (consider, e.g., the infinite derivation We note that, to make Theorem 1 applicable in practice, we must find a feasible way to check if R and B admit a proof ordering. In the next section, we introduce syntactic conditions on R and B for this purpose.

Syntactic Conditions for Admitting a Proof Ordering
In this section, given TRSs R and B, we focus on providing syntactic conditions on R and B such that they admit a proof ordering.
First, we consider satisfying Assumption 1. To this goal, we have the following simple sufficient condition: Lemma 3 Let R be a TRS and ( , ) an order pair. 5 Proof Let s p − → R t and q be the shortest prefix of p such that root(s| q ) ∈ D R , that is, From s → R t we get s| q t| q by the assumption, and thus R (s) mul R (t).
have s| p → R t| p t and thus s| p t by the assumption. We conclude R (s) mul R (t).
On the other hand, satisfying Assumption 2 is not that easy. For this purpose, we require B to be non-duplicating, i.e., no variable has more occurrences in the right-hand side of a rule than in the left-hand side, together with the following condition: Definition 6 (dominance) We say that a TRS R dominates a TRS B iff the right-hand sides of all rules in B contain no symbol from D R .
Under these assumptions, we will show that the following definition yields indeed a proof ordering for R/B.

Definition 7
For two TRSs R and B, the pair ( R/B , R/B ) of relations on terms is defined as follows: Here, R is defined as follows: The relations R/B and R/B enjoy the following key property:

Lemma 4 Let R and B be TRSs such that B is non-duplicating and R dominates B. Then ( R/B , R/B ) is a well-founded order pair on R/B-terminating terms.
Proof Trivially R/B is a quasi-order, and R/B is transitive. Compatibility is also clear from the definition. The remaining goal is to prove that R/B is well-founded on R/Bterminating terms. To this end, suppose on the contrary that there exists an infinite R/Bsequence, that is, starting from R/B-terminating term s 1 . Note that (2) is actually an infinite (→ R ∪→ B ∪ )sequence. Since s 1 is R/B-terminating, (2) cannot contain infinitely many → R -steps. Hence there must be some k such that

x∈MVar(t) R (xσ ).
Proof We prove the claim by structural induction on t. It is trivial if t is a variable. Hence, we assume t = f (t 1 , . . . , t n ). We proceed by case analysis on whether f ∈ D R or not.
-If f ∈ D R , then we have R (tσ ) = {tσ }. For every x ∈ MVar(t), we have tσ R xσ and hence tσ R/B xσ . Thus we conclude the claim.
The following lemma is the key result of this section: for arbitrary terms s and t and a position p. We distinguish the following two cases: -First, assume that p has a proper prefix q such that s| q ∈ R (s). We have -Assume now that s q / ∈ R (s) for any proper prefix q of p. Let l → r ∈ B, s| p = lσ , and t = s[r σ ] p . In this case, we have and x∈MVar(l) R (xσ ). Since R dominates B, r cannot contain symbols from D R . Therefore, and R (r σ ) = x∈MVar(r ) R (xσ ) Since B is non-duplicating, we have MVar(l) ⊇ MVar(r ) and thus R (lσ ) ⊇ R (r σ ). Therefore, we conclude R (s) mul R/B R (t).
Finally, since the premise of Lemma 3 trivially holds for the order pair of Definition 7, the following result is a direct consequence of Theorem 1, Lemma 3, and Lemma 6.

Corollary 1 Let R and B be TRSs such that B is non-duplicating, R dominates B, and
The following simple example illustrates that Corollary 1 indeed advances the state of the art in proving relative termination.
Example 2 Consider the following two TRSs: Since they satisfy the conditions of Corollary 1, we obtain the DP problem (DP(R), R ∪ B), where DP(R) = { g (s(x), y) → g (f(x, y), y) }. The DP problem can be proved finite using classic techniques, e.g., polynomial interpretation Pol such that f Pol (x, y) = x. On the other hand, all the previous tools we know that support relative termination, namely AProVE (ver 2014), T T T 2 (ver 1.15), Jambox (ver 2006) [8], and TPA (ver 1.1) [22], fail on this problem.
The dominance condition and the non-duplication condition are indeed necessary for Corollary 1 to hold. It is easy to see that the former condition is necessary: Example 3 Consider the two TRSs R = { a → b } and B = { b → a }, which violates the dominance condition. Obviously, R/B is not terminating. However, (DP(R), R ∪ B) is trivially finite since DP(R) = ∅.
The following example illustrates that the latter condition is also necessary: Example 4 Consider the following two TRSs: which violates the non-duplication condition. The DP problem (DP(R), R ∪ B) is trivially finite since DP(R) = ∅. However, we have the following infinite − → R/B -derivation: Note that this is a counterexample against [18, Theorem 5].

Improving Applicability
When dominance and non-duplication are assumed, the condition D R ∩ D B = ∅ is not necessary anymore. In order to show that this is indeed the case, let us recall the following result by Geser [9]: Luckily, we can employ again Proposition 6 to relax the conditions, at the cost of losing completeness. More precisely, we use the following corollary of Proposition 6: Consider TRSs R and B, and that we want to prove termination of R/B but the conditions of Theorem 2 do not hold. Then, we might still find a partition B = B B such that R ∪ B and B satisfy the conditions. If we succeed, then we can prove termination of R/B as follows: First, we obtain termination of (R ∪ B )/B by Theorem 2, and then that of R/(B ∪ B ), i.e., R/B by Corollary 2.

Corollary 3 Let R and B be TRSs. If B is split into
Example 5 Consider the following TRSs R and B: The first rule of B is duplicating, and hence Theorem 2 does not apply. However, we can split B into the following TRSs B and B : c(y, z)) → c(y, c(x, z)) } so that Corollary 3 applies. Now, we have DP(R ∪ B ) = { f (s(x)) → f (x) }, whose finiteness can be proved using standard techniques.
To show termination of R/B by Corollary 3, two kinds of B-rules must not be used infinitely many times, namely, duplicating ones (1), and those which violate the dominance condition (2). This is not overly restrictive; intuitively speaking, the rules of the first kind often (not always) duplicate an R-redex infinitely many times, and those of the second kind often generate infinitely many R-redexes.
Example 6 Consider the following TRSs R and B: is trivially finite since DP(R) = ∅. However, R is not relatively terminating w.r.t. B, as the following infinite derivation exists: There is no partition of B, i.e., B = B B such that R ∪ B dominates B and, thus, Corollary 3 is not applicable, as expected.
Example 7 Consider an arbitrary nonempty TRS R together with a TRS B of the form f(x)) }, which is duplicating and non-terminating (so Corollary 3 does not apply). Here, regardless of the rules of R and B , we can always construct an infinite → R/B -reduction as in Example 4. Thus, R is not relatively terminating w.r.t. B.

Relative Termination and Minimality
A DP chain s 1 − → P t 1 − → * R s 2 − → P t 2 − → * R · · · is said to be minimal if every t i is terminating w.r.t. R. It is well known that absence of infinite minimal (DP(R), R)-chains implies absence of infinite (DP(R), R)-chains and thus termination of R. A couple of techniques, namely usable rules and the subterm criterion, have been proposed to prove absence of infinite minimal chains [13].
Unfortunately, the minimality property (in terms of the standard DP framework) cannot be assumed on DP problems produced by our relative termination criteria. Therefore, usable rules and subterm criterion are not generally applicable.
Example 8 Consider the following TRSs R and B: , which satisfies the subterm criterion in the argument of f . Moreover, since no rule is usable from the dependency pair f (s(x)) → f (x), the usable rule technique would yield the DP problem ({f (s(x)) → f (x)}, ∅), which any standard technique proves finite. However, R/B is not terminating as the following infinite reduction exists: Nonetheless, we will show that both the subterm criterion and usable rules are still applicable when B satisfies the following condition: Definition 8 (quasi-termination [7]) We say that a TRS R is quasi-terminating iff the set {t | s − → * R t} is finite for every term s.
First, we naturally extend the notion of minimality to relative termination.
Definition 9 (relative DP problem) A relative DP problem is a triple of TRSs, written (P, R/B). A (P, R/B)-chain is a possibly infinite sequence and is called minimal if every t i is R/B-terminating. The relative DP problem is finite if it admits no infinite minimal chain.
Clearly, finiteness of (DP(R), R/B) is equivalent to that of (DP(R), R ∪ B). Hence our previous results hold as well for the corresponding relative DP problems.

Relative Subterm Criterion
The subterm criterion is applicable when the base B is quasi-terminating. More precisely, we require that /→ B is terminating, i.e., there exist no infinite sequence of the following form:

Lemma 7
If B is quasi-terminating, then /→ B is terminating.
Proof We prove the claim by contradiction. Assume that there is an infinite sequence of form (3). Since is well-founded, the sequence must also contain infinitely many → B reductions. We obtain an infinite sequence (note that is transitive): By the definition of , u i = C i [v i ] for some nonempty context C i . We obtain the following infinite → B sequence: which yields infinitely many different B-reducts of u 1 . This contradicts the assumption that B is quasi-terminating.
Now we introduce some notions which are needed to formally describe the subterm criterion.
Definition 10 (simple projection) A simple projection π is a mapping that assigns each n-ary symbol f one of its argument position i ∈ {1, . . . , n}. For a term t = f (t 1 , . . . , t n ), we denote by π(t ) the term t i with i = π( f ). For a relation on terms, π is defined as follows: s π t iff π(s) π(t).
Theorem 3 (relative subterm criterion) Let (P, R/B) be a relative DP problem such that /→ B is terminating, and let π be a simple projection such that P ⊆ π . Then, Proof We prove the claim by contradiction. Assume that there exists a minimal infinite chain of the form: such that π(s i ) π(t i ) for infinitely many choices of i. Using the discussion in [13,Theorem11], we obtain the following infinite sequence: Since every proper subterm of t is R/B-terminating, so is π(t ). Moreover, preserves the termination property. Hence, the infinite sequence (4) cannot contain infinitely many → R steps, and thus we obtain an infinite · → * B sequence. This contradicts the assumption that /→ B is terminating.

Relative Usable Rules
Now we prove that the quasi-termination condition also enables the usable rules technique. We roughly follow the proof by Hirokawa and Middeldorp [15] for the non-relative case, but in the following definition we introduce a trick to handle B-reductions, and use more convenient notations.

Definition 11
Let R be a finite TRS, B a quasi-terminating TRS, and U F a set of function symbols. For an R/B-terminating term s, we define s and s as follows: s = s = s if s is a variable, and for s = f (s 1 , . . . , s n ), Here, list({s 1 , . . . , s n }) denotes the term s 1 • · · · • s n , where • / ∈ F is a fresh binary symbol and elements are sorted w.r.t. an arbitrary but fixed total order on terms.
It is easy to see that s and s are well defined for every R/B-terminating s. Note also that s is a finite term due to the assumption that B is quasi-terminating. To ease readability, the rest of this section assumes R to be finite and B quasi-terminating, without explicitly stating it.
A key property of Definition 11 is that Rand B-reductions below a non U F symbol can be simulated by the following TRS, which is traditionally called C E (w.r.t. •).
Hence, by properly applying C E rules we obtain In this case, we have The following auxiliary result for substitutions is analogous to Hirokawa and Middeldorp [15], but the proof needs a little modification for the distinction of s and s. We say that a substitution σ is R/B-terminating if xσ is R/Bterminating for every variable x. For an R/Bterminating substitution σ , σ denotes the substitution that maps each x to xσ .

Definition 12
Let U ⊆ R ∪ B and U F ⊆ F . Elements in U (U F ) are called usable rules (usable symbols) in a relative DP problem (P, R/B), if the following conditions hold: Let us say that a position p in a term s is usable if root(s| q ) ∈ U F for every proper prefix q of p. The following lemma is straightforward, which is also a corollary of Hirokawa and Middeldorp [15,Lemma 18]. -Suppose that p has a usable prefix q such that root(s| q ) / ∈ U F . We have s| q − → R∪B t| q , and Lemma 8 entails s| q − → * C E t| q . Using Lemma 10, we get

Lemma 10 If p is a usable position in s and s[t] p is
-Otherwise, p is a usable position and root(l) ∈ U F . By condition 1 we have l → r ∈ U. By Lemma 9, we have lσ − → * C E lσ . Further, we know r ∈ T (U F , V) by condition 2 of Definition 12. Hence, by Lemma 9, we have r σ = r σ . Finally, using Lemma 10, we obtain Finally, we present the main result of this section. Using the preceding lemmas, the main theorem is proven analogously to the standard case.
Theorem 4 (relative usable rules) Let (P, R/B) be a relative DP problem such that R is finite and B is quasi-terminating. Let U satisfy the conditions of Definition 12,and ( ,) be a reduction pair such that P ∪ U ∪ C E ⊆ . Then, (P, R/B) is finite if and only if the relative DP problem (P \ , R/B) is finite.
For i = 1, 2, . . . , we have l i σ i − → * C E l i σ i by Lemma 9. By condition 2 of Definition 12 we know r i ∈ T (U F , V) and hence r i σ i = r i σ i by Lemma 9. We obtain l 1 σ 1 − → P r 1 σ 1 l 2 σ 2 − → P r 2 σ 2 · · · Since ( , ) is a reduction pair, we cannot have l i r i for infinitely many i. Thus, after some point (5) contains no − → P∩ steps, which is a desired minimal infinite It is well known that, unfortunately, the quasi-termination condition is undecidable [7]. In our implementation, we only use a trivial sufficient condition, non-size increasingness. We admit that this is quite restrictive, and thus leave it for future work to find a more useful syntactic condition for this purpose.
From Example 8, it is clear that the usable rule argument does not apply to the rules in B if they are not quasi-terminating. Nonetheless, we conjecture that the usable rule argument may be still applicable to the rules in R.

Experimental Evaluation
We implemented our technique into the termination prover NaTT (since ver. 1.2). The implementation works as follows: It first checks if the rules in B satisfy the two conditions of Theorem 2. If there is a rule that violates the conditions, then it moves the rule into B , and repeats the procedure until a partition satisfying the conditions of Corollary 3 is obtained. Then it enables the usable rules technique 6 if the remaining B rules are non-size increasing, although it is not often the case for the present benchmarks.
Afterwards, we obtain a standard dependency pair problem, on which existing reduction pair processors can be applied. In the experiments, we use the following reduction pairs for Proposition 2: polynomial interpretations [2,26], extended for a limited form of negative coefficients [14], -the lexicographic path order [20] with argument filtering [2], -the weighted path order with partial status [35], and -(2-or 3-dimensional) matrix interpretations [8].
As monotone reduction pairs for Proposition 3, we use polynomial and matrix interpretations with top-left elements of coefficients being at least 1 [8].
In the following, we show the significance of our technique through an experimental evaluation. The experiments were run on a server equipped with a quad-core Intel Xeon E5-3407v2 processor running at a clock rate of 2.40 GHz and 32 GB of main memory. NaTT uses z3 4.3.2 7 as a back-end SMT solver.
The first test set consists of the 44 examples in the "TRS Relative" category of the termination problem database (TPDB) 9.0. 8 The results are presented in the left half of Table 1. The "yes" column indicates the number of successful termination proofs, "maybe" indicates the number of failures, "T.O." indicates the number of timeouts, which is set to 60 s, and "time" indicates the total run time. In the first two rows, we directly apply Theorem 2 and Corollary 3, and then apply the aforementioned reduction pairs. We observe that they are of limited applicability on this set of problems due to the non-duplication and dominance conditions. Nonetheless, Corollary 3 could prove the relative termination of two problems 9 that no tools participating in the Termination Competition 2015 were able to prove. For comparison, we include results for rule removal processors by matrix interpretations in the third row.
We also prepared 44 examples by extending benchmarks by Arts and Giesl [3] with the random number generator B rand or the commutative list specification B comlist , which is added to TPDB 10.0. The results are presented in the right half of The DP framework allows the combination of termination proving techniques. In the fourth row, we combine the rule removal processors and the technique presented in this paper. This combination indeed boosts the power of NaTT; e.g., by combining Proposition 3 and Corollary 3, NaTT can prove relative termination for a total of 60 examples (out of 88), while AProVE can only prove it for 41 examples. 10 Therefore, we conclude that our technique improves the state-of-the-art methods for proving relative termination.
Although NaTT won the "TRS Relative" category in the Termination Competition 2015, it is clear that the mostly artificially crafted 88 examples in the category are limited as a fair benchmark set (especially compared to the "TRS Standard" category containing almost 1500 examples). We hope that new relative termination problems stemming from different applications will alleviate this problem in the near future.

Related Work
One of the most comprehensive works on relative termination is Geser's Ph.D. thesis [9]. Indeed, one of his main results is formulated in Proposition 3 of Sect. 2. A similar technique has been used, e.g., to prove confluence in [16]. Of course dependency pairs are not considered in [9] since they were introduced almost a decade later. Dependency pairs are considered in [8], but they are mainly used to prove termination of a TRS R by proving termination of DP(R)/R, which is quite a different purpose from ours. Giesl and Kapur [10] adapted the dependency pair method for proving termination of equational rewriting, a special case of relative termination where the base is symmetric (B = B −1 ). For more specific associative-commutative (AC) rewriting, a number of papers exist ( [1,25,27], etc.). The key technique behind them is to compute an extension of R w.r.t. the considered equations. This operation allows symbols in B (e.g., AC symbols) to be defined also in R, and hence no counterpart of the dominance condition is required. However, such extensions are computable only for certain equations (e.g., AC), and thus they are not appropriate in our setting, where an arbitrary base B is considered.
The closer approach is Iborra et al. [18], where the main aim was proving termination of narrowing [17,31] by proving relative termination of a corresponding rewrite relation, similarly to [29,33]. In [18], a first attempt to reduce relative termination to a DP problem is made by requiring R and B to form a so-called hierarchical combination (HC) [30], i.e., D R ∩ F B = ∅. Unfortunately, we found that Iborra et al. [18,Theorem 5] was incorrect since requiring B to be non-duplicating is also necessary. In fact, Example 4 is a counterexample to Iborra et al. [18,Theorem 5]. The present paper corrects and significantly extends [18]; namely, all results in Sects. 3, 5, and 6 are new, and those in Sect. 4 correct and extend the previous result of Iborra et al. [18]. Note also that the HC condition of Iborra et al. [18] is a special case of our dominance condition. Moreover, we developed an implementation that allowed us to experimentally verify that our technique indeed pays off in practice.
This paper is a revised and extended version of [19]. Besides adding more explanations and missing proofs (most notably in Sect. 6.2), we found and filled a gap in the original proofs. 11 To elegantly correct it, we now present Sect. 3 in a more essential way, and reformulate the original claims in Sects. 4 and 5 accordingly. Moreover, we improved the claim of the main result (Theorem 2) in order to show soundness and completeness (before only soundness was considered).

Conclusion
In this paper, we have introduced a new approach to proving relative termination by reducing it to DP problems. The relevance of such a result should be clear, since it allows one to prove relative termination by reusing many existing techniques and tools for proving termination within the DP framework. Indeed, such an approach was included in the RTA List of Open Problems (Problem #106). To the best of our knowledge, this work makes the first significant contribution to positively answering this problem. Moreover, as shown in Sect. 7, our method is competitive w.r.t. state-of-the-art provers for the problems in the TPDB, and is clearly superior for examples including the generation of random values or the simulation of extravariables, as discussed in Sect. 1.
As future work, we plan to improve the precision of our technique by extending the DP framework to be more suitable for proving relative termination. We will also continue the research on finding less restrictive conditions on R and B so that the technique becomes more widely applicable.
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.