1 Introduction

Term rewriting [2] is a formalism for reasoning about function definitions or functional programs. For instance, a term rewrite system (TRS) \(\mathcal {R}_\mathtt{fact}\) [7] consisting of the following rewrite rules defines the factorial function:

$$\begin{aligned} \mathtt{fact}(\mathtt{0})&\rightarrow \mathtt{s}(\mathtt{0})&\mathtt{fact}(\mathtt{s}(x))&\rightarrow \mathtt{mul}(\mathtt{s}(x), \mathtt{fact}(\mathtt{p}(\mathtt{s}(x))))&\mathtt{p}(\mathtt{s}(x))&\rightarrow x \end{aligned}$$

assuming that \(\mathtt{s}\), \(\mathtt{p}\), and \(\mathtt{mul}\) are interpreted respectively as the successor, predecessor, and multiplication functions.

Analyzing whether a TRS terminates, meaning that the corresponding functional program responds or the function is well defined, has been an active research area for decades. Consequently, several fully automatic termination provers have been developed, e.g., AProVE  [10],  [20], CiME  [5], MU-TERM  [23], and NaTT  [34], and have been competing in the annual Termination Competitions (TermCOMP) [11].

Throughout their history, interpretation methods [25] have been foundational in termination analysis. They are categorized by the choice of well-founded carriers and the class of functions as which symbols are interpreted. Polynomial interpretations [22] use the natural numbers \(\mathbb {N}\) as the carrier and interpretations are monotone polynomials, i.e., every variable has coefficient at least 1. Weakly monotone polynomials, i.e., zero coefficients, are allowed in the dependency pair method [1]. Negative constants are allowed using the max operator [15]. General combinations of polynomials and the max operator are proposed in both the standard [37] and the dependency pair settings [9]. Negative coefficients and thus non-monotone polynomials are also allowed, but in a more elaborated theoretical framework [9, 15].

These methods share the common carrier \(\mathbb {N}\). In contrast, matrix interpretations [8, 16] choose vectors over \(\mathbb {N}\) as the carrier, and interpret symbols as affine maps over it. Although the carrier is generalized, matrix interpretations do not properly generalize polynomial interpretations, since not all polynomials are affine. This gap can be filled by improved matrix interpretations, that further generalize the carrier to square matrices [6], so that natural polynomial interpretations can be subsumed by matrix polynomials over \(1\times 1\) matrices. In arctic interpretations [19], the carrier consists of vectors over arctic naturals (\(\mathbb {N}\cup \{-\infty \}\)) or integers (\(\mathbb {Z}\cup \{-\infty \}\)), and interpretations are affine maps over it, where affinity is with respect to the max/plus semiring.

Having this many variations would be welcome if you are a user of a termination tool in which someone else has already implemented all of them. It would not be so if you are the developer of a termination tool in which you will have to implement all of them. Also, to ultimately trust termination tools, one needs to formalize proof methods using proof assistants and obtain trusted certifier that validates outputs of termination tools, see, e.g., IsaFoR/CeTA  [31] or CoLoR/Rainbow [4] frameworks. Although some interpretation methods have already been formalized [28, 30], adding missing variants one by one would cost a significant effort.

In this paper, we introduce a general framework for interpretation methods, which subsumes most of the above-mentioned methods as instances, namely, (max-)polynomial interpretations (with negative constants), (improved) matrix interpretations, and arctic interpretations, as well as a syntactic method called argument filtering [1, 21]. Moreover, we obtain a bunch of previously unexplored interpretation methods as other instances.

After preliminaries, we start with a convenient fact about reduction pairs, a central tool in termination proving with dependency pairs (Section 3).

The first step to the main contribution is the use of derivers [24, 33], which allow us to abstract away the mathematical details of polynomials or max-polynomials. We will obtain a key soundness result that derivers derive monotone interpretations from monotone interpretations (Section 4).

The second step is to extend derivers to multi-dimensional ones. This setting further generalizes (improved) matrix interpretations, so that max-polynomials, negative constants, and negative entries are allowed (Section 5). It will also be hinted that multi-dimensional derivers can emulate the effect of negative coefficients, although theoretical comparison is left for future work. We also show that our approach subsumes arctic interpretations by adding a treatment for \(-\infty \) (Section 6). Although the original formulation by Koprowski and Waldmann [19] has some trickiness, we will show that our simpler formulation is sufficient.

As strict monotonicity is crucial for proving termination without dependency pairs, and is still useful with dependency pairs, we will see how to ensure strict monotonicity (Section 7). At this point, the convenient fact we have seen in Section 3 becomes crucial.

Finally, the proposed method is implemented in the termination prover NaTT, and experimental results are reported (Section 8). We evaluate various instances of our method, some corresponding to known interpretation methods and many others not. We choose two new instances to integrate to the NaTT strategy. The new strategy proved the termination of 20 more benchmarks than the old one, and five of them were not proved by any tool in TermCOMP 2020.

2 Preliminaries

We start with order-sorted algebras. Let \(\mathcal {S}= \langle S,\sqsubseteq \rangle \) be a partially ordered set, where elements in S are called sorts and \(\sqsubseteq \) is called the subsort relation. An \(\mathcal {S}\)-sorted set is an S-indexed family \(A = \{A^\sigma \}{}_{\sigma \in S}\) such that \(\sigma \sqsubseteq \tau \) implies \(A^\sigma \subseteq A^\tau \). We write \(A^{(\sigma _1,\dots ,\sigma _n)}\) for the set \(A^{\sigma _1}\times \dots \times A^{\sigma _n}\). A sorted map between \(\mathcal {S}\)-sorted sets X and A is a mapping f, written \(f : X \rightarrow A\), such that \(x \in X^\sigma \) implies \(f(x) \in A^\sigma \).

An \(\mathcal {S}\)-sorted signature is an \(S^*\times S\)-indexed family \(\mathcal {F}= \{\mathcal {F}_{\vec \sigma ,\tau }\}{}_{\langle \vec \sigma ,\tau \rangle \in S^*\times S}\) of function symbols.Footnote 1 When \(f \in \mathcal {F}_{(\sigma _1,\dots ,\sigma _n),\tau }\), we say f has rank \((\sigma _1,\dots ,\sigma _n)\rightarrow \tau \) and arity n in \(\mathcal {F}\). We may also view sorted sets and signatures as sets: having \(a : \sigma \in A\) means \(a \in A^\sigma \), and \(f: \vec \sigma \rightarrow \tau \in \mathcal {F}\) means \(f \in \mathcal {F}_{\vec \sigma ,\tau }\).

Example 1

Consider sort \(\mathtt{Nat}\). We define the following \(\{\mathtt{Nat}\}\)-sorted signatures:

  • \(\mathcal {N}\mathrel {\,:=\,}\{ \mathtt{0}: () \rightarrow \mathtt{Nat},\ \mathtt{1}: () \rightarrow \mathtt{Nat},\ \mathtt{2}: () \rightarrow \mathtt{Nat},\ \dots \}\)

  • \(\mathcal {N}_\mathtt{*}\mathrel {\,:=\,}\mathcal {N}\cup \{{\mathbin {\mathtt{*}}} : (\mathtt{Nat},\mathtt{Nat}) \rightarrow \mathtt{Nat}\}\)

  • \(\mathcal {N}_\mathtt{+}\mathrel {\,:=\,}\mathcal {N}\cup \{{\mathbin {\mathtt{+}}} : (\mathtt{Nat},\mathtt{Nat}) \rightarrow \mathtt{Nat}\}\)

  • \(\mathcal {N}_\mathtt{max}\mathrel {\,:=\,}\mathcal {N}\cup \{{\mathtt{max}} : (\mathtt{Nat},\mathtt{Nat}) \rightarrow \mathtt{Nat}\}\)

Let us abbreviate unions of signatures by concatenations of subscripts: for instance \(\mathcal {N}_\mathtt{*+max}\) denotes \(\mathcal {N}_\mathtt{*}\cup \mathcal {N}_\mathtt{+}\cup \mathcal {N}_\mathtt{max}\). Next consider sorts \(\mathtt{Neg}\) and \(\mathtt{Int}\) with \(\mathtt{Nat}, \mathtt{Neg}\sqsubseteq \mathtt{Int}\). We define the following \(\{\mathtt{Nat},\mathtt{Neg},\mathtt{Int}\}\)-sorted signatures:

  • \(\mathcal {Z}\mathrel {\,:=\,}\mathcal {N}\cup \{ \mathtt{0}: () \rightarrow \mathtt{Neg},\ \mathbin {\mathtt{-}}\mathtt{1}: () \rightarrow \mathtt{Neg},\ \mathbin {\mathtt{-}}\mathtt{2}: () \rightarrow \mathtt{Neg},\ \dots \}\)

  • \(\mathcal {Z}_\mathtt{*}\mathrel {\,:=\,}\mathcal {Z}\cup \mathcal {N}_\mathtt{*}\cup \{ {\mathbin {\mathtt{*}}} : (\mathtt{Neg},\mathtt{Neg}) \rightarrow \mathtt{Nat},\ {\mathbin {\mathtt{*}}} : (\mathtt{Int},\mathtt{Int}) \rightarrow \mathtt{Int}\}\)

  • \(\mathcal {Z}_\mathtt{+}\mathrel {\,:=\,}\mathcal {Z}\cup \mathcal {N}_\mathtt{+}\cup \{ {\mathbin {\mathtt{+}}} : (\mathtt{Neg},\mathtt{Neg}) \rightarrow \mathtt{Neg},\ {\mathbin {\mathtt{+}}} : (\mathtt{Int},\mathtt{Int}) \rightarrow \mathtt{Int}\}\)

  • \(\mathcal {Z}_\mathtt{max}\mathrel {\,:=\,}\mathcal {Z}\cup \mathcal {N}_\mathtt{max}\cup {}\) \( \{{\mathtt{max}} : (\mathtt{Nat},\mathtt{Int}) \rightarrow \mathtt{Nat},\ {\mathtt{max}} : (\mathtt{Int},\mathtt{Nat}) \rightarrow \mathtt{Nat},\ {\mathtt{max}} : (\mathtt{Int},\mathtt{Int}) \rightarrow \mathtt{Int}\} \)

For an \(\mathcal {S}\)-sorted signature \(\mathcal {F}\), an \(\mathcal {F}\)-algebra \(\langle A,[\cdot ]\rangle \) consists of an \(\mathcal {S}\)-sorted set A called the carrier and a family \([\cdot ]\) of mappings called the interpretation such that \([f] : A^{\vec \sigma } \rightarrow A^\tau \) whenever \(f \in \mathcal {F}_{\vec \sigma ,\tau }\).

Example 2

We consider the following standard interpretation \(\llbracket \cdot \rrbracket \):

$$\begin{aligned}\begin{gathered} \cdots \quad \llbracket \mathbin {\mathtt{-}}\mathtt{2}\rrbracket \mathrel {\,:=\,}-2 \quad \llbracket \mathbin {\mathtt{-}}\mathtt{1}\rrbracket \mathrel {\,:=\,}-1 \quad \llbracket \mathtt{0}\rrbracket \mathrel {\,:=\,}0 \quad \llbracket \mathtt{1}\rrbracket \mathrel {\,:=\,}1 \quad \llbracket \mathtt{2}\rrbracket \mathrel {\,:=\,}2 \quad \cdots \\ \llbracket \mathbin {\mathtt{*}}\rrbracket (a,b) \mathrel {\,:=\,}a \cdot b\qquad \llbracket \mathbin {\mathtt{+}}\rrbracket (a,b) \mathrel {\,:=\,}a + b\qquad \llbracket \mathtt{max}\rrbracket (a,b) \mathrel {\,:=\,}\max (a,b) \end{gathered}\end{aligned}$$

Notice that \(\langle \mathbb {N},\llbracket \cdot \rrbracket \rangle \) is an \(\mathcal {N}_\mathtt{*+max}\)-algebra and \(\langle \mathbb {Z},\llbracket \cdot \rrbracket \rangle \) is a \(\mathcal {Z}_\mathtt{*+max}\)-algebra. Here, the \(\{\mathtt{Nat}\}\)-sorted set \(\mathbb {N}\) is defined by \(\mathbb {N}^\mathtt{Nat}\mathrel {\,:=\,}\mathbb {N}\) and the \(\{\mathtt{Nat},\mathtt{Neg},\mathtt{Int}\}\)-sorted set \(\mathbb {Z}\) is defined by \(\mathbb {Z}^\mathtt{Nat}\mathrel {\,:=\,}\mathbb {N}\), \(\mathbb {Z}^\mathtt{Neg}\mathrel {\,:=\,}\{0,-1,-2,\dots \}\) and \(\mathbb {Z}^\mathtt{Int}\mathrel {\,:=\,}\mathbb {Z}\).

Sorted Terms: Given an \(\mathcal {S}\)-sorted signature \(\mathcal {F}\) and an \(\mathcal {S}\)-sorted set \(\mathcal {V}\) of variables, the \(\mathcal {S}\)-sorted set \(\mathcal {T}(\mathcal {F},\mathcal {V})\) of terms is inductively defined as follows:

  • \(v \in \mathcal {T}(\mathcal {F},\mathcal {V})^\sigma \) if \(v \in \mathcal {V}^\sigma \);

  • \(f(s_1,\dots ,s_n) \in \mathcal {T}(\mathcal {F},\mathcal {V})^{\rho }\) if \(f \in \mathcal {F}_{\vec \sigma ,\tau }\), \((s_1,\dots ,s_n) \in \mathcal {T}(\mathcal {F},\mathcal {V})^{\vec \sigma }\), and \(\tau \sqsubseteq \rho \).

An interpretation \([\cdot ]\) is extended over terms as follows: given \(\alpha : \mathcal {V}\rightarrow A\), \([x]\alpha \mathrel {\,:=\,}\alpha (x)\) if \(x \in \mathcal {V}^\sigma \), and \([f(s_1,\dots ,s_n)]\alpha \mathrel {\,:=\,}[f]([s_1]\alpha ,\dots ,[s_n]\alpha )\). The \(\mathcal {F}\)-algebra \(\langle \mathcal {T}(\mathcal {F},\mathcal {V}),\cdot \rangle \) (which interprets f as the mapping that takes \((s_1,\dots ,s_n)\) and returns \(f(s_1,\dots ,s_n)\)) is called the term algebra, and a sorted map \(\theta : \mathcal {V}\rightarrow \mathcal {T}(\mathcal {F},\mathcal {V})\) is called a substitution. The term obtained by replacing every variable x by \(\theta (x)\) in s is thus \(s\theta \).

Term Rewriting: This paper is concerned with termination analysis for plain term rewriting. In this setting, there is only one sort \(\mathtt {1}\), and we may identify a \(\{\mathtt {1}\}\)-sorted set A and the set \(A^\mathtt {1}\). The set of variables appearing in a term s is denoted by \(\mathsf {Var}(s)\). A context C is a term with a special variable \(\Box \) occurring exactly once. We denote by C[s] the term obtained by substituting \(\Box \) by s in C. A rewrite rule is a pair of terms l and r, written \(l \rightarrow r\), such that \(l \notin \mathcal {V}\) and \(\mathsf {Var}(l) \supseteq \mathsf {Var}(r)\). A term rewrite system (TRS) is a set \(\mathcal {R}\) of rewrite rules, which induces the root rewrite step and the rewrite step as the least relations such that and , for any rule \(l \rightarrow r \in \mathcal {R}\), substitution \(\theta \), and context C. A TRS \(\mathcal {R}\) is terminating iff no infinite rewriting is possible.

The dependency pair (DP) framework [1, 13, 14] is a de facto standard among automated termination provers for term rewriting. Here we briefly recapitulate its essence. The root symbol of a term \(s = f(s_1,\dots ,s_n)\) is f and is denoted by \(\mathsf {root}(s)\). The set of defined symbols in \(\mathcal {R}\) is \(\mathcal {D}_{\mathcal {R}} \mathrel {\,:=\,}\{\mathsf {root}(l) \mid l \rightarrow r \in \mathcal {R}\}\). We assume a fresh marked symbol \(f^\sharp \) for every \(f \in \mathcal {D}_{\mathcal {R}}\), and write \(s^\sharp \) to denote the term \(f^\sharp (s_1,\dots ,s_{n})\) for \(s = f(s_1,\dots ,s_{n})\). A dependency pair of a TRS \(\mathcal {R}\) is a rule \(l^\sharp \rightarrow r^\sharp \) such that \(\mathsf {root}(r) \in \mathcal {D}_{\mathcal {R}}\) and \(l \rightarrow C[r] \in \mathcal {R}\) for some context C. The set of all dependency pairs of \(\mathcal {R}\) is denoted by \(\mathsf {DP}_{\!\,}(\mathcal {R})\). A DP problem \(\langle \mathcal {P},\mathcal {R}\rangle \) is just a pair of TRSs.

Theorem 1

([1]). A TRS \(\mathcal {R}\) is terminating iff the DP problem \(\langle \mathsf {DP}_{\!\,}(\mathcal {R}),\mathcal {R}\rangle \) is finite, i.e., there is no infinite chain .

A number of techniques called DP processors that simplify or decompose DP problems are proposed; see [13] for a list of such processors. Among them, the central technique for concluding the finiteness of DP problems is the reduction pair processor, which will be reformulated in the next section.

3 Notes on Reduction Pairs

A reduction pair is a pair \(\langle {\succsim },{\succ }\rangle \) of order-like relations over terms with some conditions. Here we introduce two formulations of reduction pairs, one demanding natural assumptions of orderings, and the other, reduction pair seed, demanding only essential requirements. The first formulation is useful when proving properties of reduction pairs, while the latter is useful when devising new reduction pairs. We will show that the two notions are essentially equivalent: one can always extend a reduction pair seed into a reduction pair of the former sense. Existing formulations of reduction pairs lie strictly in between the two.

Definition 1

(reduction pair). A (quasi-)order pair \(\langle {\succsim },{\succ }\rangle \) is a pair of a quasi-order \({\succsim }\) and an irreflexive relation \({\succ } \subseteq {\succsim }\) satisfying compatibility: \({\succsim } ;{\succ } ;{\succsim } \subseteq {\succ }\). The order pair is well-founded if \(\succ \) is well-founded.

A reduction pair is a well-founded order pair \(\langle {\succsim },{\succ }\rangle \) on terms, such that both \(\succsim \) and \(\succ \) are closed under substitutions, and \(\succsim \) is closed under contexts. Here, a relation \(\sqsupset \) is closed under substitutions (resp. contexts) iff \(s \sqsupset t\) implies \(s\theta \sqsupset t\theta \) for every substitution \(\theta \) (resp. \(C[s] \sqsupset C[t]\) for every context C).

The above formulation of reduction pairs is strictly subsumed by standard definitions (e.g., [1, 13, 14]), where \({\succ }\) is not necessarily a subset of \({\succsim }\), and compatibility is weakened to either \({\succsim } ;{\succ } \subseteq {\succ }\) or \({\succ } ;{\succsim } \subseteq {\succ }\). Instead, \({\succ }\) is required to be transitive but this follows from our assumptions \({\succ } \subseteq {\succsim }\) and compatibility: \({\succ } ;{\succ } \subseteq {\succsim } ;{\succ } \subseteq {\succ }\). On one hand, this means that we can safely import existing results of reduction pairs into our formulation.

Theorem 2

(reduction pair processor[13, 14]). Let \(\langle \mathcal {P},\mathcal {R}\rangle \) be a DP problem and \(\langle {\succsim },{\succ }\rangle \) be a reduction pair such that \(\mathcal {P}\cup \mathcal {R}\subseteq {\succsim }\). Then the DP problem \(\langle \mathcal {P},\mathcal {R}\rangle \) is finite if and only if \(\langle \mathcal {P}\setminus {\succ },\mathcal {R}\rangle \) is.

Example 3

Consider again the TRS \(\mathcal {R}_\mathtt{fact}\) of the introduction. Proving that \(\mathcal {R}_\mathtt{fact}\) terminates in the DP framework boils down to finding a reduction pair \(\langle \succsim ,\succ \rangle \) satisfying (considering usable rules [1]):

$$\begin{aligned} \mathtt{p}(\mathtt{s}(x))&\succsim x&\mathtt{fact}^\sharp (\mathtt{s}(x))&\succ \mathtt{fact}^\sharp (\mathtt{p}(\mathtt{s}(x))) \end{aligned}$$

On the other hand, one may wonder whether Definition 1 might be too restrictive. We justify our formulation by uniformly extending general “reduction pairs” into reduction pairs that comply with Definition 1. This is possible for even more general pairs of relations than standard reduction pairs.

Definition 2

(reduction pair seed). A well-founded order seed is a pair \(\langle W,S\rangle \) of relations such that S is well-founded and \(S ;W \subseteq S^+\). A reduction pair seed is a well-founded order seed on terms such that both W and S are closed under substitutions, and W is closed under contexts.

Now we show that every reduction pair seed \(\langle W,S\rangle \) can be extended to a reduction pair \(\langle \succsim ,\succ \rangle \) such that \(W \subseteq {\succsim }\) and \(S \subseteq {\succ }\). Before that, the assumption \(S ;W \subseteq S^+\) of Definition 2 is generalized as follows.

Lemma 1

If \(\langle W,S\rangle \) is a well-founded order seed, then \(S ;W^* \subseteq S^+\).

Proof

By induction on the number of W steps.    \(\square \)

Theorem 3

Let \(\langle W,S\rangle \) be a well-founded order seed. Then \(\langle {\succsim },{\succ }\rangle \) is a well-founded order pair, where \({\succsim } \mathrel {\,:=\,}(W \cup S)^*\) and \({\succ } \mathrel {\,:=\,}(W^* ;S)^+\).

Proof

It is trivial that \(\succsim \) is a quasi-order and \({\succ } \subseteq {\succsim }\) by definition. We show the well-foundedness of \({\succ }\) as follows: Suppose on the contrary we have an infinite sequence:

$$ a_1 \mathrel {W^*} b_1 \mathrel {S} a_2 \mathrel {W^*} b_2 \mathrel {S} a_3 \mathrel {W^*} b_2 \mathrel {S}\cdots $$

Then using Lemma 1 (\(S ;W^* \subseteq S^+\)) we obtain \( a_1 \mathrel {W^*} b_1 \mathrel {S^+} b_2 \mathrel {S^+} \cdots \), which contradicts the well-foundedness of S.

Now we show compatibility. By definition we have \({\succsim } ;{\succ } \subseteq {\succ }\), so it suffices to show \({\succ } ;{\succsim } \subseteq {\succ }\). By induction we reduce the claim to \({\succ } ;(W \cup S) \subseteq {\succ }\), that is, both \({\succ } ;W \subseteq {\succ }\) and \({\succ } ;S \subseteq {\succ }\). Using \(S ;W \subseteq S^+ = S ;S^*\) we have

$$\begin{aligned} {\succ } ;W \,=\,(W^* ;S)^+ ;W \,&=\,(W^* ;S)^* ;W^* ;S ;W\\&\subseteq \,(W^* ;S)^* ;W^* ;S ;S^* \,\subseteq \,{\succ } \end{aligned}$$

The other case \({\succ } ;S \subseteq {\succ }\) is easy from the definition.    \(\square \)

Now we obtain the following corollary of Theorem 2 and Theorem 3.

Corollary 1

Let \(\langle \mathcal {P},\mathcal {R}\rangle \) be a DP problem and \(\langle W,S\rangle \) a reduction pair seed such that \(\mathcal {P}\cup \mathcal {R}\subseteq W\). Then \(\langle \mathcal {P},\mathcal {R}\rangle \) is finite if and only if \(\langle \mathcal {P}\setminus S,\mathcal {R}\rangle \) is.

Notice that Definition 2 does not demand any order-like property, most notably transitivity. This is beneficial when developing new reduction pairs; for instance, higher-order recursive path orders [17] are known to be non-transitive, but form a reduction pair seed with their reflexive closure. Throughout the paper we use Definition 1, since it provides more useful and natural properties of orderings, which becomes crucial in Section 7.

4 Interpretation Methods as Derivers

Interpretation methods construct reduction pairs from \(\mathcal {F}\)-algebras, where \(\mathcal {F}\) is the \(\{\mathtt {1}\}\)-sorted signature of an input TRS or DP problem, and the carrier is a mathematical structure where a well-founded ordering > is known. In the DP framework, weakly monotone \(\mathcal {F}\)-algebras play an important role.

Definition 3

(weakly monotone algebra). A mapping \(f : A_1\times \dots \times A_n \rightarrow A\) is monotone with respect to \(\sqsupset \) if \(f(a_1,\dots ,a_i,\dots ,a_n) \sqsupset f(a_1,\dots ,a_i',\dots ,a_n)\) whenever \(a_1 \in A_1,\dots ,a_n \in A_n\), \(a_i' \in A_i\), and \(a_i \sqsupset a_i'\). A weakly monotone \(\mathcal {F}\)-algebra \(\langle A,[\cdot ],\ge ,>\rangle \) consists of an \(\mathcal {F}\)-algebra \(\langle A,[\cdot ]\rangle \) and an order pair \(\langle \ge ,>\rangle \) such that every \([f]\) is monotone with respect to \(\ge \).

Example 4

Continuing Example 2, \(\langle \mathbb {N},\llbracket \cdot \rrbracket ,{\ge },{>}\rangle \) is a weakly monotone \(\mathcal {N}_\mathtt{*+max}\)-algebra with the standard ordering \(\langle \ge ,>\rangle \). Notice that \(\langle \mathbb {Z},\llbracket \cdot \rrbracket ,\ge ,>\rangle \) is not a weakly monotone \(\mathcal {Z}_\mathtt{*+max}\)-algebra, since multiplication on integers is not necessarily monotone. Nevertheless, it is a weakly monotone \(\mathcal {Z}_\mathtt{+max}\cup \mathcal {N}_\mathtt{*}\)-algebra.

To ease presentation, from now on we assume that \(\mathcal {F}\) is a \(\{\mathtt {1}\}\)-sorted signature, while \(\mathcal {G}\) is an \(\mathcal {S}\)-sorted signature. It is easy nevertheless to generalize our results to an arbitrary order-sorted signature \(\mathcal {F}\).

Theorem 4

([14]). Let \(\langle A,[\cdot ],{\ge },{>}\rangle \) be a weakly monotone \(\mathcal {F}\)-algebra such that > is well-founded in A. Then \(\langle [\ge ], [>]\rangle \) is a reduction pair on \(\mathcal {T}(\mathcal {F},\mathcal {V})\), where \(s \mathrel {[[]]{\sqsupset }} t \mathrel {\;:\Longleftrightarrow \;}\forall \alpha :\mathcal {V}\rightarrow A.\ [s]\alpha \sqsupset [t]\alpha \).

Moreover, using the term algebra any reduction pair \(\langle {\succsim },{\succ }\rangle \) on \(\mathcal {T}(\mathcal {F},\mathcal {V})\) can be seen as a well-founded \(\mathcal {F}\)-algebra \(\langle \mathcal {T}(\mathcal {F},\mathcal {V}),\cdot ,{\succsim },{\succ }\rangle \).

Example 5

Continuing Example 4, \(\langle \llbracket \ge \rrbracket ,\llbracket >\rrbracket \rangle \) forms a reduction pair for signature \(\mathcal {N}_\mathtt{*+max}\). Notice that it does not for \(\mathcal {Z}_\mathtt{+max}\cup \mathcal {N}_\mathtt{*}\), essentially because > is not well-founded in \(\mathbb {Z}\).

In order to prove the finiteness of a given DP problem, we need a weakly monotone \(\mathcal {F}\)-algebra for the signature \(\mathcal {F}\) indicated by this problem, rather than for a predefined signature like \(\mathcal {N}_\mathtt{*+max}\). We fill the gap by employing the notion of derivers [24, 33] to derive an \(\mathcal {F}\)-algebra from one of another signature \(\mathcal {G}\).

Definition 4

(deriver). An \(\mathcal {F}/\mathcal {G}\)-deriver is a pair of a sort \(\delta \in \mathcal {S}\) and a mapping d, such that \(d(f) \in \mathcal {T}(\mathcal {G},\{\textsf { x}_1:\delta ,\dots ,\textsf { x}_n:\delta \})^{\delta }\) when f has arity n in \(\mathcal {F}\). Given a base \(\mathcal {G}\)-algebra \(\langle A,[\cdot ]\rangle \), we define the derived \(\mathcal {F}\)-algebra \(\langle A^\delta ,d[\cdot ]\rangle \) by

$$ d[f](a_1,\dots ,a_n) \mathrel {\,:=\,}[d(f)](\textsf { x}_1\mapsto a_1,\dots ,\textsf { x}_n\mapsto a_n) $$

Example 6

Define a \(\{\mathtt{fact}^\sharp ,\mathtt{p},\mathtt{s}:\mathtt {1}\rightarrow \mathtt {1}\}\)/\(\mathcal {Z}_\mathtt{+max}\)-deriver \(\langle \mathtt{Nat},d\rangle \) by

$$\begin{aligned} d(\mathtt{fact}^\sharp )&\mathrel {\,:=\,}\textsf { x}_1&d(\mathtt{s})&\mathrel {\,:=\,}\textsf { x}_1\mathbin {\mathtt{+}}\mathtt{1}&d(\mathtt{p})&\mathrel {\,:=\,}\mathtt{max}(\textsf { x}_1\mathbin {\mathtt{-}}\mathtt{1},\mathtt{0}) \end{aligned}$$

Note that \(d(\mathtt{p})\) has sort \(\mathtt{Nat}\), thanks to the rank \((\mathtt{Int},\mathtt{Nat}) \rightarrow \mathtt{Nat}\) of \(\mathtt{max}\) in \(\mathcal {Z}_\mathtt{max}\). The order pair \(\langle d\llbracket \ge \rrbracket ,d\llbracket >\rrbracket \rangle \) satisfies the constraints given in Example 3.

Now we show that an \(\mathcal {F}/\mathcal {G}\)-deriver yields a weakly monotone \(\mathcal {F}\)-algebra if the base \(\mathcal {G}\)-algebra is known to be weakly monotone. Thus, Example 6 proves that \(\mathcal {R}_\mathtt{fact}\) is terminating. The next result about monotonicity is folklore:

Lemma 2

A mapping \(f : A^n \rightarrow A\) is monotone with respect to a quasi-order \(\ge \) if and only if \(a_1 \ge b_1, \dots , a_n \ge b_n\) implies \(f(a_1,\dots ,a_n) \ge f(b_1,\dots ,b_n)\).

Proof

The “if” direction is due to the reflexivity of \(\ge \), and the “only if” direction is easy by induction on n and the transitivity of \(\ge \).    \(\square \)

Then monotonicity is carried over to the interpretation of terms, in the following sense. For two sorted maps \(\alpha : X \rightarrow A\) and \(\beta : X \rightarrow A\), we write \(\alpha \ge \beta \) to mean that \(\alpha (x) \ge \beta (x)\) for any \(x \in X^\sigma \) and sort \(\sigma \).

Lemma 3

Let \(\langle A,[\cdot ],{\ge },{>}\rangle \) be a weakly monotone \(\mathcal {G}\)-algebra and \(s \in \mathcal {T}(\mathcal {G},\mathcal {V})^\sigma \). If \(\alpha \ge \beta \) then \([s]\alpha \ge [s]\beta \).

Proof

By structural induction on s. The claim is trivial if s is a variable. Consider \(s = f(s_1,\dots ,s_n)\). We have \([s_i]\alpha \ge [s_i]\beta \) for each \(i \in \{1,\dots ,n\}\) by induction hypothesis. With Lemma 2 and the monotonicity of \([f]\), we conclude:

$$ [s]\alpha = [f]([s_1]\alpha ,\dots ,[s_n]\alpha ) \ \ge \ [f]([s_1]\beta ,\dots ,[s_n]\beta ) = [s]\beta $$

   \(\square \)

Lemma 4

Let \(\langle \delta ,d\rangle \) be an \(\mathcal {F}/\mathcal {G}\)-deriver and \(\langle A,[\cdot ],{\ge },{>}\rangle \) a weakly monotone \(\mathcal {G}\)-algebra. Then \(\langle A^\delta ,d[\cdot ],{\ge },{>}\rangle \) is a weakly monotone \(\mathcal {F}\)-algebra.

Proof

Suppose that f has arity n in \(\mathcal {F}\), and for every \(i \in \{1,\dots ,n\}\) that \(a_i,b_i \in A^\delta \) and \(a_i \ge b_i\). Then from Lemma 3,

$$\begin{aligned} d[f](a_1,\dots ,a_n)&= [d(f)](\textsf { x}_1\mapsto a_1,\dots ,\textsf { x}_n\mapsto a_n)\\&\ge [d(f)](\textsf { x}_1\mapsto b_1,\dots ,\textsf { x}_n\mapsto b_n) = d[f](b_1,\dots ,b_n) \end{aligned}$$

With Lemma 2 we conclude that every \(d[f]\) is monotone with respect to \(\ge \), and hence \(\langle A^\delta ,d[\cdot ],{\ge },>\rangle \) is a weakly monotone \(\mathcal {F}\)-algebra.    \(\square \)

Thus we conclude the soundness of the deriver-based interpretation method:

Theorem 5

If \(\langle \delta ,d\rangle \) is a \(\mathcal {F}/\mathcal {G}\)-deriver, \(\langle A,[\cdot ],\ge ,>\rangle \) is a weakly monotone \(\mathcal {G}\)-algebra and > is well-founded in \(A^{\delta }\), then \(\langle d[\ge ], d[>]\rangle \) is a reduction pair.

Proof

Immediate consequence of Lemma 4 and Theorem 4.   \(\square \)

It should be clear that Theorem 5 with \(\mathcal {G}= \mathcal {Z}_\mathtt{+max}\cup \mathcal {N}_\mathtt{*}\) subsumes the polynomial interpretation method with negative constants [15, Lemma 4]. Their trick is to turn integers into naturals by applying \(\max (\cdot ,0)\), as demonstrated in Example 6 in a syntactic manner. Theorem 5 gives a slightly more general fact that one can mix \(\max \) and negative constants and still get a reduction pair. As far as the author knows, this fact has not been reported elsewhere, although natural max-polynomials without negative constants are known to yield reduction pairs [9, Section 4.1].

In addition, a syntactic technique known as argument filtering [1, 21] is also a special case of Theorem 5. In the context of higher-order rewriting, Kop and van Raamsdonk generalized argument filters into argument functions [18, Definition 7.7], which, in the first-order case, correspond to derivers with \(\mathcal {G}\) being a variant of \(\mathcal {F}\). In these applications, base signatures and algebras are not a priori known, but are subject to be synthesized and analyzed.

5 Multi-Dimensional Interpretations

The matrix interpretation method [8] uses a well-founded weakly monotone algebra \(\langle \mathbb {N}^m,[\cdot ]_{ \mathcal {M}at },\mathrel {\ge \!\!\ge },\gg \rangle \) over natural vectors, with an affine interpretation:

$$ [f]_{ \mathcal {M}at }(\vec a_1,\dots ,\vec a_n) = C_1\vec a_1 + \dots + C_n\vec a_n + \vec c $$

where \(C_1,\dots ,C_n \in \mathbb {N}^{m\times m}\) and \(\vec c \in \mathbb {N}^m\), and the following ordering:

Definition 5

([8, 19]). Given an order pair \(\langle {\ge },{>}\rangle \) on A and a dimension \(m \in \mathbb {N}\), we define the order pair \(\langle {\mathrel {\ge \!\!\ge }},{\gg }\rangle \) on \(A^m\) as follows:

Improved matrix interpretations [6] consider square matrices instead of vectors, and thus, in principle, matrix polynomials can be considered. Now we generalize these methods by extending derivers to multi-dimensional ones.

Definition 6

(multi-dimensional derivers). An m-dimensional \(\mathcal {F}/\mathcal {G}\)-deriver consists of an m-tuple \(\vec \delta \in \mathcal {S}^m\) of sorts and a mapping \(\vec d\) such that \(\vec d(f) \in \mathcal {T}(\mathcal {G},\mathcal {X})^{\vec \delta }\), where \(\mathcal {X}\mathrel {\,:=\,}\{\textsf { x}_{i,j} : (\vec \delta )_j \mid i \in \{1,\dots ,n\},\ j \in \{1,\dots ,m\}\}\) if f has arity n in \(\mathcal {F}\). Given a \(\mathcal {G}\)-algebra \(\langle A,[\cdot ]\rangle \), the derived \(\mathcal {F}\)-algebra \(\langle A^{\vec \delta },\vec d[\cdot ]\rangle \) is defined by

$$ \vec d[f](\vec a_1, \dots , \vec a_n) \mathrel {\,:=\,}([(\vec d(f))_1]\alpha ,\dots , [(\vec d(f))_m]\alpha ) $$

where \(\alpha \) is defined by \(\alpha (\textsf { x}_{i,j}) \mathrel {\,:=\,}(\vec a_i)_{j}\).

Example 7

([8, Example 1]).

The TRS of the single rule \(\mathtt {f}(\mathtt {f}(x)) \rightarrow \mathtt {f}(\mathtt {g}(\mathtt {f}(x)))\) can be shown terminating by the following 2-dimensional matrix interpretation:

$$\begin{aligned}{}[\mathtt {f}]_{ \mathcal {M}at }(\vec a)&= \begin{pmatrix}1&{}1\\ 0&{}0\end{pmatrix}\vec a + \begin{pmatrix}0\\ 1\end{pmatrix}&[\mathtt {g}]_{ \mathcal {M}at }(\vec a)&= \begin{pmatrix}1&{}0\\ 0&{}0\end{pmatrix}\vec a + \begin{pmatrix}0\\ 0\end{pmatrix} \end{aligned}$$

The 2-dimensional \(\{\mathtt {f},\mathtt {g}\}/\mathcal {N}_\mathtt{+}\)-deriver \(\langle (\mathtt{Nat},\mathtt{Nat}),\vec d\rangle \) defined by

$$\begin{aligned} \vec d(\mathtt {f})&= \begin{pmatrix}\textsf { x}_{11}+\textsf { x}_{12}\\ \mathtt{1}\end{pmatrix}&\vec d(\mathtt {g})&= \begin{pmatrix}\textsf { x}_{11}\\ \mathtt{0}\end{pmatrix} \end{aligned}$$

represents \([\cdot ]_{ \mathcal {M}at }\) as \(\vec d\llbracket \cdot \rrbracket \), that is, \([\mathrel {\ge \!\!\ge }]_{ \mathcal {M}at } = \vec d\llbracket \mathrel {\ge \!\!\ge }\rrbracket \) and \([\gg ]_{ \mathcal {M}at } = \vec d\llbracket \gg \rrbracket \).

Now we prove a counterpart of Theorem 5 for multi-dimensional derivers. The following lemma is one of the main results of this paper, which is somewhat surprisingly easy to prove.

Lemma 5

For an m-dimensional \(\mathcal {F}/\mathcal {G}\)-deriver \(\langle \vec \delta ,\vec d\rangle \) and a weakly monotone \(\mathcal {G}\)-algebra \(\langle A,[\cdot ],{\ge },{>}\rangle \), \(\langle A^{\vec \delta },\vec d[\cdot ],{\mathrel {\ge \!\!\ge }},{\gg }\rangle \) is a weakly monotone \(\mathcal {F}\)-algebra.

Proof

Let f have arity n in \(\mathcal {F}\) and \(\vec a_1, \dots , \vec a_n, \vec b_1,\dots , \vec b_n \in A^{\vec \delta }\) satisfy \(\vec a_i \mathrel {\ge \!\!\ge }\vec b_i\). Define \(\alpha \) and \(\beta \) by \(\alpha (\textsf { x}_{i,j}) \mathrel {\,:=\,}(\vec a_i){_{j}}\) and \(\beta (\textsf { x}_{i,j}) \mathrel {\,:=\,}(\vec b_i){_{j}}\). By assumption we have \(\alpha \ge \beta \), and with Lemma 3 we have

$$ (\vec d[f](\vec a_1,\dots ,\vec a_n))_j = [(\vec d(f))_j]\alpha \ \ge \ [(\vec d(f))_j]\beta = (\vec d[f](\vec b_1,\dots ,\vec b_n))_j $$

for every \(j \in \{1,\dots ,m\}\). Hence \(\vec d[f](\vec a_1,\dots ,\vec a_n) \mathrel {\ge \!\!\ge }\vec d[f](\vec b_1,\dots ,\vec b_n)\), and this concludes the proof due to Lemma 2.    \(\square \)

Theorem 6

For a multi-dimensional \(\mathcal {F}/\mathcal {G}\)-deriver \(\langle \vec \delta ,\vec d\rangle \) and a weakly monotone \(\mathcal {G}\)-algebra \(\langle A,[\cdot ],\ge ,>\rangle \) such that > is well-founded in \(A^{(\vec \delta )_1}\), \(\langle \vec d[\mathrel {\ge \!\!\ge }],\vec d[\gg ]\rangle \) is a reduction pair.

Proof

Thanks to Lemma 5 and Theorem 4, it suffices to show that \(\gg \) is well-founded in \(A^{\vec \delta }\). Suppose on the contrary that there exists an infinite sequence \(\vec a_1 \gg \vec a_2 \gg \cdots \) with \(\vec a_1, \vec a_2, \ldots \in A^{\vec \delta }\). Then we have \((\vec a_1)_{1}> (\vec a_2)_{1} > \cdots \) and \((\vec a_1)_{1}, (\vec a_2)_{1}, \ldots \in A^{(\vec \delta )_1}\), contradicting the well-foundedness of > in \(A^{(\vec \delta )_1}\).    \(\square \)

It should be clear that every m-dimensional (improved) matrix interpretation can be expressed as an m-dimensional (or \(m^2\)-dimensional) \({\mathcal {F}}/{\mathcal {N}_\mathtt{*+}}\)-deriver. There are two more important consequences of Theorem 6: First, we can interpret symbols as non-affine maps even including max-polynomials; and second, since > is not required to be well-founded in \(A^{(\vec \delta )_2},\dots ,A^{(\vec \delta )_m}\), examples that previously required non-monotone interpretations—and hence a stronger condition than Theorem 2—can be handled.

Example 8

(Excerpt of AProVE_08/log). Consider the TRS \(\mathcal {R}_{\mathbin {\mathtt{/}}}\) consisting of

$$\begin{aligned} x \mathbin {\mathtt{-}}\mathtt{0}&\rightarrow x&\mathtt{0}\mathbin {\mathtt{/}}y&\rightarrow \mathtt{0}\\ \mathtt{s}(x) \mathbin {\mathtt{-}}\mathtt{s}(y)&\rightarrow x \mathbin {\mathtt{-}}y&\mathtt{s}(x) \mathbin {\mathtt{/}}\mathtt{s}(y)&\rightarrow (\mathtt{s}(x)\mathbin {\mathtt{-}}\mathtt{s}(y)) \mathbin {\mathtt{/}}\mathtt{s}(y) \end{aligned}$$

which defines (for simplicity, rounded up) natural division. Proving \(\mathcal {R}_{\mathbin {\mathtt{/}}}\) terminating using dependency pairs boils down to finding a reduction pair \(\langle \succeq ,\succ \rangle \) such that (again considering usable rules)

$$\begin{aligned} x \mathbin {\mathtt{-}}\mathtt{0}&\succeq x&\mathtt{s}(x) \mathbin {\mathtt{-}}\mathtt{s}(y)&\succeq x \mathbin {\mathtt{-}}y&\mathtt{s}(x) \mathbin {\mathtt{/}}^\sharp \mathtt{s}(y)&\succ (\mathtt{s}(x)\mathbin {\mathtt{-}}\mathtt{s}(y)) \mathbin {\mathtt{/}}^\sharp \mathtt{s}(y) \end{aligned}$$

A polynomial interpretation \([\cdot ]_{{ \mathcal {P}ol }}\) with negative coefficients such that

$$\begin{aligned}{}[\mathtt{0}]_{{ \mathcal {P}ol }}&= 0&[\mathtt{s}]_{{ \mathcal {P}ol }}(x)&= x+1&[\mathbin {\mathtt{/}}^\sharp ]_{{ \mathcal {P}ol }}(x,y)&= x&[\mathbin {\mathtt{-}}]_{{ \mathcal {P}ol }}(x,y)&= \max (x - y,0) \end{aligned}$$

satisfies the above constraints, but one must validate the requirements of [15, Theorem 11]. In our setting, an \(\mathcal {F}/\mathcal {Z}_\mathtt{+max}\)-deriver \(\langle (\mathtt{Nat},\mathtt{Neg}),\vec d\rangle \) such that

$$\begin{aligned} \vec d(\mathtt{0})&= \begin{pmatrix}\mathtt{0}\\ \mathtt{0}\end{pmatrix}&\vec d(\mathtt{s})&= \begin{pmatrix}\textsf { x}_{1,1}\mathbin {\mathtt{+}}\mathtt{1}\\ \textsf { x}_{1,2}\mathbin {\mathtt{-}}\mathtt{1}\end{pmatrix}&\vec d(\mathbin {\mathtt{-}})&= \begin{pmatrix}\mathtt{max}(\textsf { x}_{1,1}\mathbin {\mathtt{+}}\textsf { x}_{2,2},\mathtt{0})\\ \mathtt{0}\end{pmatrix}&\vec d(\mathbin {\mathtt{/}}^\sharp )&= \begin{pmatrix}\textsf { x}_{1,1}\\ \mathtt{0}\end{pmatrix} \end{aligned}$$

yields a reduction pair satisfying the above constraints.

The intuition here is that the two dimensional interpretation of \(\mathtt{s}^n(\mathtt{0})\) records n in the first coordinate and \(-n\) in the second. Hence, one does not have to reconstruct \(-n\) from n using the non-monotonic minus operation.

It seems plausible to the author that negative coefficients can be eliminated using the above idea; however, the increase of the dimension leads to more freedom in variables (the variable introduced to represent \(-n\) may take values other than that) and so the ordering over terms may be different. It is left for future work to investigate whether this idea always works or not.

6 Arctic Interpretations

An arctic interpretation [19] \([\cdot ]_{\mathcal {A}}\) is a matrix interpretation on the arctic semiring; that is, every interpretation \([f]_{\mathcal {A}}(\vec x_1,\dots ,\vec x_n)\) is of the form

$$\begin{aligned} C_1\otimes \vec x_1 \oplus \cdots \oplus C_n\otimes \vec x_n \oplus \vec c \end{aligned}$$
(1)

where \(\otimes \) and \(\oplus \) denote the matrix multiplication and matrix addition in which the scalar addition is replaced by the max operation, and the scalar multiplication by addition; and entries of \(C_i\) and \(\vec c\) are arctic naturals (\(\mathbb {N}_{-\infty }\mathrel {\,:=\,}\mathbb {N}\cup \{-\infty \}\)) or arctic integers (\(\mathbb {Z}_{-\infty }\mathrel {\,:=\,}\mathbb {Z}\cup \{-\infty \}\)). In addition, (1) must be absolute positive: \((\vec c)_1 \ge 0\), so that \(\langle \mathbb {N}\times \mathbb {N}_{-\infty }^{m-1}, [\cdot ]_{\mathcal {A}}, {\mathrel {\ge \!\!\ge }}, {\gg }\rangle \) or \(\langle \mathbb {N}\times \mathbb {Z}_{-\infty }^{m-1}, [\cdot ]_{\mathcal {A}}, {\mathrel {\ge \!\!\ge }}, {\gg }\rangle \) forms a well-founded weakly monotone algebra.

The above formulation deviates from the original [19] in two ways. First, we do not introduce the special relation such that \(-\infty \gg -\infty \). Koprowski and Waldmann demanded this to ensure closure under general substitutions, but such a comparison cannot occur as we only need to consider substitutions that respect the carrier \(\mathbb {N}\times \mathbb {Z}_{-\infty }^{m-1}\). Second, for arctic natural interpretations they relax absolute positiveness to somewhere finiteness: \((\vec c)_1 \ne -\infty \) or \((C_i)_{1,1} \ne -\infty \) for some i. However, the two assumptions turn out to be equivalent.

Proposition 1

Every arctic natural interpretation of form (1) is absolute positive iff it is somewhere finite.

Proof

Clearly, absolute positiveness implies somewhere finiteness. For the other direction, since \((\vec c)_1 \ne -\infty \) trivially implies absolute positiveness, suppose that \((\vec c)_1 = -\infty \) and \((C_i)_{1,1} \ne -\infty \) for some i. We then know \((\vec y)_1 \ge 0\), where \(\vec y \mathrel {\,:=\,}C_1\otimes \vec x_1 \oplus \cdots \oplus C_n\otimes \vec x_n\). Hence, by \(\vec {c'} \mathrel {\,:=\,}(0,(\vec c)_2,\dots ,(\vec c)_m)\), we have \([f]_{\mathcal {A}}(\vec x_1, \dots , \vec x_n) = \vec y \oplus \vec {c'}\), and this representation is absolute positive.   \(\square \)

One can easily obtain arctic interpretations via multi-dimensional derivers: consider a sort \(\mathtt {ANat}\) with \(\mathtt{Nat}\sqsubseteq \mathtt {ANat}\) and \(\{\mathtt{Nat},\mathtt {ANat}\}\)-sorted signature \(\mathcal {N}_\mathtt{+max{\mathtt{-o\!o}}}\), extending \(\mathcal {N}_\mathtt{+max}\) with

$$\begin{aligned}\begin{gathered} {{\mathtt{-o\!o}}} : () \rightarrow \mathtt {ANat}\qquad {\mathbin {\mathtt{+}}} : (\mathtt {ANat},\mathtt {ANat}) \rightarrow \mathtt {ANat}\\ {\mathtt{max}} : (\mathtt{Nat},\mathtt {ANat}) \rightarrow \mathtt{Nat}\quad {\mathtt{max}} : (\mathtt {ANat},\mathtt{Nat}) \rightarrow \mathtt{Nat}\quad {\mathtt{max}} : (\mathtt {ANat},\mathtt {ANat}) \rightarrow \mathtt {ANat}\end{gathered}\end{aligned}$$

and extend the standard interpretation \(\llbracket \cdot \rrbracket \) accordingly. We omit the easy proof of the following fact and the counterpart for arctic integer interpretations.

Proposition 2

Every absolute positive arctic natural interpretation \([\cdot ]_{\mathcal {A}}\) is represented as \(\vec d\llbracket \cdot \rrbracket \) via an \(\mathcal {F}/\mathcal {N}_\mathtt{+max{\mathtt{-o\!o}}}\)-deriver \(\langle (\mathtt{Nat},\mathtt {ANat},\dots ,\mathtt {ANat}),\vec d\rangle \).

Notice that, in practice, this requires us to deal with \(-\infty \) by ourselves since there is no standard SMT theory [3] that supports arithmetic with \(-\infty \).

7 Strict Monotonicity

Before the invention of dependency pairs [1], strictly monotone algebras were necessary for proving termination by interpretation methods, and they constitute a sound and complete method for proving termination of TRSs.

Definition 7

A strictly monotone \(\mathcal {F}\)-algebra is a weakly monotone \(\mathcal {F}\)-algebra \(\langle A,[\cdot ],\ge ,>\rangle \) such that \(\langle A,[\cdot ]\rangle \) is monotone with respect to both \(\ge \) and >.

Theorem 7

(cf. [36]). A TRS \(\mathcal {R}\) is terminating if and only if there is a strictly monotone well-founded \(\mathcal {F}\)-algebra \(\langle A,[\cdot ],{\ge },{>}\rangle \) such that \(\mathcal {R}\subseteq [>]\).

Moreover, strict monotonicity is a desirable property in the DP framework as it allows one to remove not only dependency pairs but also rewrite rules.

Theorem 8

([12]). A DP problem \(\langle \mathcal {P},\mathcal {R}\rangle \) is finite if \(\langle \mathcal {P}\setminus [>], \mathcal {R}\setminus [>]\rangle \) is, where \(\langle A,[\cdot ],{\ge },{>}\rangle \) is a strictly monotone well-founded \(\mathcal {F}\)-algebra such that \(\mathcal {P}\cup \mathcal {R}\subseteq [\ge ]\).

We now state a criterion that ensures the strict monotonicity of multi-dimensional interpretation obtained via derivers. Below we write \(d_i\) to mean the mapping defined by \(d_i(f) \mathrel {\,:=\,}(\vec d(f))_i\).

Theorem 9

Let \(\langle \vec \delta ,\vec d\rangle \) be an m-dimensional \(\mathcal {F}/\mathcal {G}\)-deriver and \(\langle A,[\cdot ],{\ge },{>}\rangle \) a weakly monotone \(\mathcal {G}\)-algebra. Suppose that when f has arity n in \(\mathcal {F}\) and \(i \in \{1,\dots ,n\}\), \(\alpha (\textsf { x}_{i,1}) > a\) implies \([d_1(f)]{\alpha } > [d_1(f)]{\alpha (\textsf { x}_{i,1}\mapsto a)}\) for any \(\alpha : \mathcal {X}\rightarrow A\) and \(a \in A\). Then \(\langle A^{\vec \delta },\vec d[\cdot ],{\mathrel {\ge \!\!\ge }},{\gg }\rangle \) is a strictly monotone \(\mathcal {F}\)-algebra.

Proof

We only prove strict monotonicity as we already know weak monotonicity by Lemma 5. So suppose that f has arity n in \(\mathcal {F}\), \(\vec a_1, \dots , \vec a_i, \dots , \vec a_n, \vec a_i' \in A^{\vec \delta }\) and \(\vec a_i \gg \vec a_i'\). For the first coordinate, define \(\alpha \) by \(\alpha (\textsf { x}_{k,j}) \mathrel {\,:=\,}(\vec a_k)_j\). Then, first using the assumption, and then Lemma 3, we conclude

$$\begin{aligned} d_1[f](\vec a_1\dots ,\vec a_i,\dots ,\vec a_n)&=[d_1(f)]\alpha \\&> [d_1(f)]{\alpha (\textsf { x}_{i,1}\mapsto (\vec a_i')_1)}\\&\ge [d_1(f)]{\alpha ( \textsf { x}_{i,1}\mapsto (\vec a_i')_1, \textsf { x}_{i,2}\mapsto (\vec a_i')_2, \dots , \textsf { x}_{i,m}\mapsto (\vec a_i')_m)}\\&= d_1[f](\vec a_1,\dots ,\vec a_i',\dots ,\vec a_n) \end{aligned}$$

For the other coordinates, thanks to the “new” assumption \({>} \subseteq {\ge }\) in Definition 1 we have \(\vec a_i \mathrel {\ge \!\!\ge }\vec a_i'\). Then the weak monotonicity ensures \(\vec d[f](\vec a_1,\dots ,\vec a_i,\dots \vec a_n) \mathrel {\ge \!\!\ge }\vec d[f](\vec a_1,\dots ,\vec a_i',\dots ,\vec a_n)\), from which we deduce for each \(j \in \{2,\dots ,m\}\),

$$\begin{aligned} d_j[f](\vec a_1,\dots ,\vec a_i,\dots ,\vec a_n) \ge d_j[f](\vec a_1,\dots ,\vec a_i',\dots ,\vec a_n) \end{aligned}$$

   \(\square \)

Although the above result and proof do not look surprising, it would be worth noticing that the statement is false in the standard formulation allowing \({>} \not \subseteq {\ge }\) (as even in [8]).

Example 9

Consider the following apparently monotone matrix interpretation:

$$ [\mathtt {f}](\begin{pmatrix}a_1\\ a_2\end{pmatrix}) \mathrel {\,:=\,}\begin{pmatrix}1&{}&{}0\\ 1&{}&{}0\end{pmatrix}\begin{pmatrix}a_1\\ a_2\end{pmatrix} = \begin{pmatrix}a_1\\ a_1\end{pmatrix} $$

If one had \(a_1 > b_1\) but \(a_1 \ngeq b_1\), then

$$ [\mathtt {f}](\begin{pmatrix}a_1\\ a_2\end{pmatrix}) = \begin{pmatrix}a_1\\ a_1\end{pmatrix} \begin{matrix}>\\ \ngeq \end{matrix} \begin{pmatrix}b_1\\ b_1\end{pmatrix} = [\mathtt {f}](\begin{pmatrix}b_1\\ a_2\end{pmatrix}) \quad \text {even though}\quad \begin{pmatrix}a_1\\ a_2\end{pmatrix} \gg \begin{pmatrix}b_1\\ a_2\end{pmatrix}. $$

So \([\mathtt {f}]\) would not be monotone with respect to \(\gg \).

8 Implementation and Experiments

Multi-dimensional interpretations are implemented in the termination prover NaTT version 2.0Footnote 2, using a template-based approach.

Definition 8

An m-dimensional \(\mathcal {F}/\mathcal {G}\)-deriver template \(\langle \vec \delta ,\vec d\rangle \) with \(\mathcal {S}\)-sorted set \(\mathcal {W}\) of template variables is defined as in Definition 6, but allowing \(\vec d(f) \in \mathcal {T}(\mathcal {G},\mathcal {W}\cup \mathcal {X})^{\vec \delta }\). Its instance according to a substitution \(\theta : \mathcal {W}\rightarrow \mathcal {T}(\mathcal {G},\emptyset )\) is the \(\mathcal {F}/\mathcal {G}\)-deriver \(\langle \vec \delta ,\vec d\theta \rangle \), defined by \(\vec d\theta (f) \mathrel {\,:=\,}(d_1(f)\theta , \dots , d_m(f)\theta )\).

In the implementation, we fix \(\mathcal {G}= \mathcal {Z}_\mathtt{+max}\cup \mathcal {N}_\mathtt{*}\) and the base weakly monotone \(\mathcal {G}\)-algebra \(\langle \mathbb {Z},\llbracket \cdot \rrbracket ,\ge ,>\rangle \). Given an m-dimensional deriver template \(\langle \vec \delta ,\vec d\rangle \) with \(\mathcal {W}\), our interest is now to find \(\theta : \mathcal {W}\rightarrow \mathbb {Z}\) such that \(\vec d\theta [s] \ge \vec d\theta [t]\) for every \((s, t) \in \mathcal {P}\cup \mathcal {R}\) for the DP problem \(\langle \mathcal {P},\mathcal {R}\rangle \) of concern, thanks to Theorem 6. NaTT reduces this problem into an SMT problem and passes it to a backend SMT solver. The page limit is not enough to detail the reduction; in short, the constraint \(\vec d\theta [s] \mathrel {\ge \!\!\ge }\vec d\theta [t]\) is reduced into a Boolean formula over atoms of form \(a\mathbin {\mathtt{*}}\langle v_1,i_1\rangle \mathbin {\mathtt{*}}\dots \mathbin {\mathtt{*}}\langle v_n,i_n\rangle \ge b\mathbin {\mathtt{*}}\langle v_1,i_1\rangle \mathbin {\mathtt{*}}\dots \mathbin {\mathtt{*}}\langle v_n,i_n\rangle \), where \(a,b \in \mathcal {T}(\mathcal {G},\mathcal {W})\), and \(\langle v_1,i_1\rangle \dots ,\langle v_n,i_n\rangle \in (\mathsf {Var}(s)\cup \mathsf {Var}(t))\times \{1,\dots ,m\}\) are seen as variables. Internally NaTT uses a distribution approach [30], whose soundness crucially relies on the fact that the only rank of \(\mathbin {\mathtt{*}}\) is \((\mathtt{Nat},\mathtt{Nat}) \rightarrow \mathtt{Nat}\) in the signature \(\mathcal {G}\). Then each atom is further reduced to (1) \(a = b\) if \((\vec \delta )_{i_j} = \mathtt{Int}\) for some j, (2) \(a \ge b\) if \(\langle \{[\}]{j \mid (\vec \delta )_{i_j} = \mathtt{Neg}}\rangle \) is even, and (3) \(a \le b\) otherwise. Due to the last step, having coordinates of sort \(\mathtt{Int}\) leads to a stronger constraint when ordering terms. Finally, the resulting formula, containing only template variables, is passed to the SMT solver Z3 4.8.10  [26] and a satisfying solution \(\theta : \mathcal {W}\rightarrow \mathbb {Z}\) is a desired substitution.

To verify the practical significance of the method, we evaluated various templates in a simple dependency pair setting. For a function symbol f of arity \(n\ge 2\), the k-th coordinate of template \(\vec d(f)\) is chosen from

  • sum: \(w \mathbin {\mathtt{+}}\sum _{i=1}^n(b\mathbin {\mathtt{*}}\textsf { x}_{i,k})\),

  • max: \(\mathtt{max}_{i=1}^{n}\,b\mathbin {\mathtt{*}}(w\mathbin {\mathtt{+}}\textsf { x}_{i,k})\),

  • sum-sum: \(w \mathbin {\mathtt{+}}\sum _{i=1}^{n} \sum _{j=1}^m b\mathbin {\mathtt{*}}\textsf { x}_{i,j}\),

  • max-max: \(\mathtt{max}_{i=1}^{n}\,\mathtt{max}_{j=1}^m\,b\mathbin {\mathtt{*}}(w\mathbin {\mathtt{+}}\textsf { x}_{i,j})\),

  • sum-max: \(\sum _{i=1}^{n}\mathtt{max}_{j=1}^m\,b\mathbin {\mathtt{*}}(w\mathbin {\mathtt{+}}\textsf { x}_{i,j})\),

  • max-sum: \(\mathtt{max}_{i=1}^{n}(w\mathbin {\mathtt{+}}\sum _{j=1}^m b\mathbin {\mathtt{*}}\textsf { x}_{i,j})\), and

  • a heuristic choice [35] between sum-sum and max-sum,

where b and w introduce fresh template variables, b ranges over \(\{\mathtt{0},\mathtt{1}\}\) and the sort of w is up to further choice. The sort of the first coordinate is turned to \(\mathtt{Nat}\) by applying \(\mathtt{max}(\cdot ,\mathtt{0})\) if necessary.

Experiments are run on the StarExec environment [29], with timeout of 300 seconds. The benchmarks are the 1507 TRSs from the TRS Standard category of the termination problem database 11 [32]. Due to the huge search space, we evaluate templates of dimensions up to 2. A part of the results are summarized in Table 1. Full details of the experiments are made available at http://www.trs.cm.is.nagoya-u.ac.jp/NaTT/multi/.

Table 1. Evaluation of 2-dimensional templates.

In the table, each coordinate is represented by the template and the sort of w. In terms of the number of successful termination proofs indicated in the “YES” column, the classical matrix interpretations (row #3) are impressively strong. Nevertheless, it is worth considering a negative coordinate (#4) as it gives 10 termination proofs that the previous version of NaTT could not find, indicated in the “New” column. In contrast, considering whole integers in the second coordinate (#5) does not look promising as the runtime grows significantly. Concerning “max”, we observe that its use in the second coordinate (#6) degrades the performance. Using “max” in both coordinates a la arctic interpretations (#8, #9) gives a few new termination proofs, but the impact in the runtime is significant in the current implementation. The runtime improves by replacing some occurrences of “max” by “sum” (#10–12), while the power does not seem defected. In terms of the number of termination proofs, the heuristic choice of “sum-sum” and “max-sum” in the first coordinate (#13) performed the best among the evaluated templates.

From these experiments, we pick templates #4 and #13 to incorporate in the NaTT default strategy. The final results are summarized in Table 2. Although the runtime noticeably increases, adding both #4 and #13 gives 20 more examples solved, and five of them (AProVE_09_Inductive/log and four in Transformed_CSR_04/) were not solved by any tool in the TermCOMP 2020.

Table 2. Experiments with combined strategies

9 Conclusion

In this paper we introduced a deriver-based multi-dimensional interpretation method. The author expects that the result makes the relationships between existing interpretation methods cleaner, and eases the task of developing and maintaining termination tools. Moreover, it yields many previously unknown interpretation methods as instances, proving the termination of some standard benchmarks that state-of-the-art termination provers could not.

Theoretical comparison with negative coefficients is left for future work, and the use of \(-\infty \) is not implemented yet. Also since this work broadens the search space, it is interesting to heuristically search for derivers rather than fixing some templates. Derivers of higher dimensions seem also interesting to explore. Finally, although the proposed method is implemented in the termination prover NaTT, there is no guarantee that the implementation is correct. In order to certify termination proofs that use multi-dimensional derivers, one must formalize the proofs in this paper, extend the certifiable proof format [27], and implement a verified function to validate such proofs.