betaFeedback

WorksComputer Science

An Applicative Multiset Path Order (Extended Version)

Abstract

We present a variant of the multiset path order for untyped applicative term rewriting. Compared to existing work, our variant incorporates two distinctive features, dubbed arity assignment and reification, to overcome difficulties in handling partial and variable application.

Introduction

Dershowitz’s multiset path order [11] (originally called recursive path order) is a popular reduction order for proving termination of first-order term rewriting. This paper presents an extension of the order to untyped applicative term rewriting [19] which allows us to model lambda-free higher-order functions with first-order terms. For example, the higher-order function map is represented by:

map⁡ f nil⁡→nil⁡map⁡ f (cons⁡ x xs)→cons⁡ (f x) (map⁡ f xs)\begin{aligned} \operatorname{map}\ f\ \operatorname{nil} &\to\operatorname{nil} \\ \operatorname{map}\ f\ (\operatorname{cons}\ x\ xs) &\to\operatorname{cons}\ (f\ x)\ (\operatorname{map}\ f\ xs) \end{aligned}

This expressiveness comes at the price of difficulty in proving termination. As a matter of the fact, the multiset path order (or more generally, any reduction order with the subterm property) cannot even show the termination of the one-rule rewrite system mult⁡ (s⁡ x) y→add⁡ (mult⁡ x y) y\operatorname{mult}\ (\operatorname{s}\ x)\ y \to\operatorname{add}\ (\operatorname{mult}\ x\ y)\ y.

In fact, variants of the recursive path order [6, 7] for applicative terms have already been investigated in the context of higher-order theorem proving. Our work follows this line of research. For instance, the Knuth–Bendix completion [20] with our order can transform the equations

append⁡ nil⁡ ys≈ysappend⁡ (cons⁡ x xs) ys≈cons⁡ x (append⁡ xs ys)id⁡ x≈xmap⁡ f nil⁡≈nil⁡map⁡ id⁡≈id⁡map⁡ f (append⁡ xs ys)≈append⁡ (map⁡ f xs) (map⁡ f ys)\begin{aligned} \operatorname{append}\ \operatorname{nil}\ ys &\approx ys & \operatorname{append}\ (\operatorname{cons}\ x\ xs)\ ys &\approx\operatorname{cons}\ x\ (\operatorname{append}\ xs\ ys) & \operatorname{id}\ x &\approx x \\ \operatorname{map}\ f\ \operatorname{nil} &\approx\operatorname{nil} \\ \operatorname{map}\ \operatorname{id} &\approx\operatorname{id} & \operatorname{map}\ f\ (\operatorname{append}\ xs\ ys) &\approx\operatorname{append}\ (\operatorname{map}\ f\ xs)\ (\operatorname{map}\ f\ ys) \end{aligned}

into a complete (terminating and confluent) rewrite system (see Example 37).

Technically, our variant has two distinctive features: arity assignment for constants and reification of function application. The former is used for simulating the behavior of the original multiset path order, while the latter, inspired by uncurrying [14, 15, 19], is used for handling partial application and variable application like map ff and f xf\ x. Our order forms a reduction order capable of showing termination of typical higher-order functions such as map and filter. Moreover, it satisfies the gracefulness property which states a form of correspondence between Dershowitz’s multiset path order and ours and thereby provides a minimum guarantee in termination proving.

The remaining part of the paper is organized as follows. Section 2 serves as preliminaries. We build our order in three steps: in Section 3 we define a base order which is shown transitive and well-founded; in Section 4 it is lifted to a well-founded order that is closed under contexts; and finally in Section 5 it is further lifted to a reduction order by a folklore technique. The resulting order is evaluated in Section 6. We conclude by discussing related work in Section 7.

This paper is an extended version of our conference paper [16] with omitted proofs in the appendix.

Preliminaries

Throughout the paper, we assume familiarity with term rewriting [2, 26]. Below, we briefly recall Dershowitz’s multiset path order and applicative terms.

Let V\mathcal{V} be an infinite set of variables, and F\mathcal{F} a set of function symbols with V∩F=∅\mathcal{V} \cap\mathcal{F} = \varnothing. Terms are inductively defined as follows: all variables are terms; and if ff is an nn-ary function symbol in F\mathcal{F} and t1,…,tnt_1,\ldots,t_n are terms then f(t1,…,tn)f(t_1,\ldots,t_n) is a term. We simply write ff for f()f(). Ground terms are terms that do not contain variables. A substitution σ\sigma is a mapping from variables to terms such that σ(x)≠x\sigma(x) \ne x for only finitely many variables xx. In particular, we write {x↦t}\{x \mapsto t\} for the substitution that maps xx to tt and other variables yy to yy itself. Given a term tt and a substitution σ\sigma, we write tσt\sigma for the term obtained by replacing every variable xx occurring in tt with σ(x)\sigma(x). A context CC is a term containing exactly one hole □\Box, which is a constant not in F\mathcal{F}. The term obtained by replacing □\Box in CC by a term tt is denoted by C[t]C[t]. Ground contexts are contexts that do not contain variables. The set of variables occurring in a term tt is written as Var⁡(t)\operatorname{Var}(t).

A rewrite rule ℓ→r\ell\to r is a pair (ℓ,r)(\ell,r) of terms such that ℓ\ell is not a variable and Var⁡(ℓ)⊇Var⁡(r)\operatorname{Var}(\ell) \supseteq\operatorname{Var}(r). A set R\mathcal{R} of rewrite rules is called a term rewrite system (TRS). We write s→Rts \to_{\mathcal{R}} t if s=C[ℓσ]s = C[\ell\sigma] and t=C[rσ]t = C[r\sigma] for some rewrite rule ℓ→r∈R\ell\to r \in\mathcal{R}, context CC, and substitution σ\sigma.

A TRS R\mathcal{R} is terminating if there is no infinite sequence t0→Rt1→R⋯t_0 \to_{\mathcal{R}} t_1 \to_{\mathcal{R}} \cdots with respect to →R\to_{\mathcal{R}}. Alternatively, it means that the relation →R\to_{\mathcal{R}} is well-founded. A basic method for proving termination is reduction orders, which are well-founded orders on terms that is closed under substitutions and contexts. Here >> is said to be closed under substitutions if σ>τ\sigma> \tau whenever s>ts > t and σ\sigma is a substitution. Similarly, >> is said to be closed under (ground) contexts if C[s]>C[t]C[s] > C[t] whenever s>ts > t and CC is a (ground) context, respectively. Reduction orders characterize termination of term rewrite systems.

Proposition 1. A TRS R\mathcal{R} is terminating if and only if there exists a reduction order >> with R⊆>\mathcal{R} \subseteq>.

A key ingredient of the multiset path order is multiset extension. Let >> be a binary relation on a set AA. We write M(A)\mathcal{M}(A) for the set of all finite multisets over AA. The multiset extension >mul>_{\mathrm{mul}} of >> is defined on M(A)\mathcal{M}(A) as follows: M>mulNM >_{\mathrm{mul}} N if there exist multisets X,Y∈M(A)X,Y \in\mathcal{M}(A) such that N=(M−X)⊎YN=(M-X)\mathbin{\uplus}Y, ∅≠X⊆M\varnothing\ne X \subseteq M, and every b∈Yb \in Y admits an element a∈Xa \in X with a>ba>b. It is known that >mul>_{\mathrm{mul}} is a well-founded order if >> is a well-founded order [12].

Now we recall the multiset path order (MPO for short) [11]. A precedence ⪰\succeq on a signature F\mathcal{F} is a quasi-order on F\mathcal{F}. We denote the strict part ⪰∖⪯\succeq\setminus\preceq of ⪰\succeq by ≻\succ, and the equivalence part ⪰∩⪯\succeq\cap\preceq by ∼\sim. We call ⪰\succeq well-founded if ≻\succ is. The reflexive closure and the reflexive and transitive closure of a relation ⇝\rightsquigarrow are denoted by ⇝=\rightsquigarrow^{=} and ⇝∗\rightsquigarrow^{*}, respectively.

Definition 2. Let ⪰\succeq be a precedence. The multiset path order >mpo>_{\mathrm{mpo}} is inductively defined on terms as follows: s>mpots >_{\mathrm{mpo}} t if s=f(s1,…,sm)s=f(s_1,\ldots,s_m) and one of the following conditions holds.

  1. si≥mpots_i \mathrel{\geq_{\mathrm{mpo}}} t for some ii.

  2. t=g(t1,…,tn)t=g(t_1,\ldots,t_n), f≻gf \succ g, and s>mpotjs >_{\mathrm{mpo}} t_j for all jj.

  3. t=g(t1,…,tn)t=g(t_1,\ldots,t_n), f⪰gf \succeq g, and {s1,…,sm}>mpomul{t1,…,tn}\{s_1,\ldots,s_m\} >_{\mathrm{mpo}}^{\mathrm{mul}} \{t_1,\ldots,t_n\}.

Theorem 3 ([11]). The relation >mpo>_{\mathrm{mpo}} is a reduction order if the precedence ⪰\succeq is well-founded.

It is worth noting that the MPO has the subterm property, i.e., C[t]≥mpotC[t] \mathrel{\geq_{\mathrm{mpo}}} t for all terms tt and contexts CC.

Example 4. Consider the TRS R\mathcal{R} for addition and multiplication:

add⁡(0,y)→ymult⁡(0,y)→0add⁡(s(x),y)→s(add⁡(x,y))mult⁡(s(x),y)→add⁡(mult⁡(x,y),y)\begin{aligned} \operatorname{add}(0,y)&\to y & \operatorname{mult}(0,y)&\to0\\ \operatorname{add}(s(x),y)&\to s(\operatorname{add}(x,y)) & \operatorname{mult}(s(x),y)&\to\operatorname{add}(\operatorname{mult}(x,y),y) \end{aligned}

By taking a precedence ⪰\succeq with mult⁡≻add⁡≻s\operatorname{mult} \succ\operatorname{add} \succ s the relation ℓ>mpor\ell>_{\mathrm{mpo}} r holds for all ℓ→r∈R\ell\to r \in\mathcal{R}. For instance, add⁡(s(x),y)>mpos(add⁡(x,y))\operatorname{add}(s(x),y) >_{\mathrm{mpo}} s(\operatorname{add}(x,y)) is verified by the derivation on the left of Figure 1. Hence, the termination of R\mathcal{R} is concluded by Proposition 1 together with Theorem 3.

Derivations of MPO (left) and AMPO (right): $x \mathrel{\geq_{\mathrm{mpo}}} x$; $\frac{s(x) >_{\mathrm{mpo}} x}{\{s(x),y\} >_{\mathrm{mpo}} \{x,y\}}$; $\frac{\{s(x),y\} >_{\mathrm{mpo}} \{x,y\}}{\operatorname{add}(s(x),y) >_{\mathrm{mpo}} \operatorname{add}(x,y)}$; $\frac{\operatorname{add} \succ s}{\operatorname{add}(s(x),y) >_{\mathrm{mpo}} s(\operatorname{add}(x,y))}$; and on the right, $x \mathrel{\trianglerighteq} x$; $\frac{s\,x \triangleright x}{\{s\,x,y\} \triangleright \{x,y\}}$; $\frac{\{s\,x,y\} \triangleright \{x,y\}}{\operatorname{add}(s\,x,y) \triangleright \operatorname{add}\,x\,y}$; $\frac{\operatorname{add} \succ s}{\operatorname{add}(s\,x,y) \triangleright s(\operatorname{add}\,x\,y)}$

Figure 1. Derivations of MPO (left) and AMPO (right)

An applicative signature consists of constants and a single binary symbol ∘\circ called application. Terms over an applicative signature are called applicative terms. Using juxtaposition as in combinatory logic, ∘(…∘(t1,t2)…,tn)\circ(\ldots\circ(t_1,t_2)\ldots,t_n) is abbreviated to t1t2⋯tnt_1t_2\cdots t_n. For example, ∘(∘(cons,∘(f,x)),∘(∘(map,f),xs))\circ(\circ(\mathrm{cons},\circ(f,x)),\circ(\circ(\mathrm{map},f),xs)) is written as cons (f x) (map f xs)\mathrm{cons}\ (f\ x)\ (\mathrm{map}\ f\ xs). An applicative TRS (ATRS) is a TRS over an applicative signature, whereas TRSs/terms over ordinary signatures are sometimes called functional TRSs/terms. The TRS for map in the introduction is an ATRS over {nil,cons,map,∘}\{\mathrm{nil},\mathrm{cons},\mathrm{map},\circ\}. Currying [19] recursively transforms a term tt over a (possibly non-applicative) signature F\mathcal{F} into an applicative term t∘t^\circ as follows: t∘=tt^\circ=t if t∈Vt\in\mathcal{V}, and f t1∘⋯tn∘f\ t_1^\circ\cdots t_n^\circ if t=f(t1,…,tn)t=f(t_1,\ldots,t_n). (Strictly speaking, the signature after currying is obtained by regarding each f∈Ff\in\mathcal{F} as a constant and adding a fresh binary symbol ∘\circ.)

Example 5. The curried version of the addition TRS (Example 4) is as follows:

add 0 y→ymult 0 y→0add (s x) y→s (add x y)mult (s x) y→add (mult x y) y\begin{aligned} \mathrm{add}\ 0\ y &\to y & \mathrm{mult}\ 0\ y &\to0 \\ \mathrm{add}\ (s\ x)\ y &\to s\ (\mathrm{add}\ x\ y) & \mathrm{mult}\ (s\ x)\ y &\to\mathrm{add}\ (\mathrm{mult}\ x\ y)\ y \end{aligned}

As mentioned in the introduction, the sufficient condition R⊆>\mathcal{R}\subseteq> for termination cannot be satisfied by any reduction order >> having the subterm property, including MPO. If so, for the last rule ℓ→r\ell\to r and σ={y↦s x}\sigma=\{y\mapsto s\ x\} we have ℓσ>rσ\ell\sigma>r\sigma, which leads to a contradiction:

ℓσ>rσ=add‾ (mult x (s x)) (s x)>mult x‾ (s x) (s x)>mult (s x) (s x)=ℓσ\ell\sigma> r\sigma= \underline{\mathrm{add}}\ (\mathrm{mult}\ x\ (s\ x))\ (s\ x) > \mathrm{mult}\ \underline{x}\ (s\ x)\ (s\ x) > \mathrm{mult}\ (s\ x)\ (s\ x)=\ell\sigma

Here, the decreases with respect to >> by chopping the underlined symbols are guaranteed by the subterm property and the closure under contexts of >>.

Base Order

Toward the goal of devising a reduction order for applicative terms, we begin with the definition of a base order which forms a well-founded order.

From now on, we assume that F\mathcal{F} is an applicative signature, and that it contains a special fresh constant @\mathord{@}. We write F0\mathcal{F}_0 for the set of all constants in F\mathcal{F}. Observe that an arbitrary applicative term tt can be written in the form f t1⋯tnf\ t_1\cdots t_n with f∈F0∪Vf\in\mathcal{F}_0\cup\mathcal{V}. When n>0n>0, the term tt is said to be reifiable and the term @(f t1⋯tn−1)tn\mathord{@}(f\ t_1\cdots t_{n-1})t_n is denoted by t^\hat{t}. The term t^\hat{t} is called the reification of tt. Arity assignments are functions from F0\mathcal{F}_0 to N\mathbb{N} with α(@)=2\alpha(\mathord{@})=2. Let α\alpha be an arity assignment. A term t=f t1⋯tnt=f\ t_1\cdots t_n is full if f∈F0f\in\mathcal{F}_0 and α(f)=n\alpha(f)=n, and partial if f∈F0f\in\mathcal{F}_0 and α(f)>n\alpha(f)>n. Note that a term can be neither full nor partial.

Example 6. Let α\alpha be the arity assignment with α(@)=α(map)=α(cons)=2\alpha(\mathord{@})=\alpha(\mathrm{map})=\alpha(\mathrm{cons})=2, α(id)=1\alpha(\mathrm{id})=1, and α(nil)=0\alpha(\mathrm{nil})=0. The term map f nil\mathrm{map}\ f\ \mathrm{nil} is full, map id\mathrm{map}\ \mathrm{id} is partial, and both map f x y\mathrm{map}\ f\ x\ y and f xf\ x are neither full nor partial. These four terms are reifiable, while xx and map are not. The reification of f xf\ x is @ f x\mathord{@}\ f\ x.

Definition 7. Let α\alpha be an arity assignment and ≽\succcurlyeq a precedence on F0\mathcal{F}_0. The relation ▹\triangleright is inductively defined on terms over F0\mathcal{F}_0 as follows: s▹ts\triangleright t if s=f s1⋯sms=f\ s_1\cdots s_m and one of the following conditions holds.

  1. si▹ts_i \triangleright t for some ii.

  1. ss and t=gt1⋯tnt = g t_1 \cdots t_n are full, f≻gf \succ g, and s▹tjs \triangleright t_j for all jj.

  1. ss and t=gt1⋯tnt = g t_1 \cdots t_n are full, f⪰gf \succeq g, and {s1,…,sm}▹mul{t1,…,tn}\{s_1,\ldots,s_m\} \mathrel{\triangleright^{\mathrm{mul}}} \{t_1,\ldots,t_n\}.

  1. ss is full, tt is reifiable and not full, and s▹t^s \triangleright\hat{t}.

  1. ss is reifiable and not full, and s^▹t\hat{s} \triangleright t.

The first three cases 1, 2, and 3 are from the original multiset path order.

Example 8 (continued from Example 5). Let α\alpha be the arity assignment such that α(add⁡)=2\alpha(\operatorname{add}) = 2, α(s)=1\alpha(s) = 1, and α(0)=0\alpha(0) = 0, and let ⪰\succeq be the same precedence as before. Then ℓ▹r\ell\triangleright r holds for all ℓ→r∈R\ell\to r \in\mathcal{R}. For example, add⁡ (s x) y▹s (add⁡ x y)\operatorname{add}\ (s\ x)\ y \triangleright s\ (\operatorname{add}\ x\ y) is verified by the second derivation in Figure 1. Remark that the subterm property does not hold for ▹\triangleright. In fact, s x▹ss\ x \triangleright s does not hold.

The last two cases 4 and 5 in Definition 7 are used for resolving non-fullness.

Example 9. Let α\alpha be the arity assignment of Example 6, and let ⪰\succeq be the precedence with @ ∼\sim map ≻\succ cons ≻\succ nil. For the terms s=map⁡ f (cons⁡ x xs)s = \operatorname{map}\ f\ (\operatorname{cons}\ x\ xs) and s′=cons⁡ x xss' = \operatorname{cons}\ x\ xs we have the following derivation:

\begin{aligned} x &\triangleright x \\ s' &\triangleright x \\ \operatorname{map} &\succeq@ \\ \{f,s'\} &\mathrel{\triangleright^{\mathrm{mul}}} \{f,x\} \\ s &\triangleright@\ f\ x \\ s &\triangleright f\ x \\ \operatorname{map} &\succ\operatorname{cons} \\ s &\triangleright f\ x \\ s &\triangleright\operatorname{cons}\ (f\ x)\ (\operatorname{map}\ f\ xs) \end{aligned}
xs▹xss′▹xsmap⁡⪰map⁡{f,s′}▹mul{f,xs}s▹map⁡ f xss▹cons⁡ (f x) (map⁡ f xs)\begin{aligned} xs &\triangleright xs \\ s' &\triangleright xs \\ \operatorname{map} &\succeq\operatorname{map} \\ \{f,s'\} &\mathrel{\triangleright^{\mathrm{mul}}} \{f,xs\} \\ s &\triangleright\operatorname{map}\ f\ xs \\ s &\triangleright\operatorname{cons}\ (f\ x)\ (\operatorname{map}\ f\ xs) \end{aligned}

The next two derivations illustrate case 5:

\begin{aligned} @ &\succeq@ \qquad\{\operatorname{map},\operatorname{id}\ f\} \mathrel{\triangleright^{\mathrm{mul}}} \{\operatorname{map},f\} \\ @ \ \operatorname{map}\ (\operatorname{id}\ f) &\triangleright@\ \operatorname{map}\ f \\ @ \ \operatorname{map}\ (\operatorname{id}\ f) &\triangleright\operatorname{map}\ f \\ \operatorname{map}\ (\operatorname{id}\ f) &\triangleright\operatorname{map}\ f \end{aligned}
@≻id⁡x▹x@ x y▹x@ x y▹id⁡ xx y▹id⁡ x\begin{aligned} @ &\succ\operatorname{id} \qquad x \triangleright x \\ @ \ x\ y &\triangleright x \\ @ \ x\ y &\triangleright\operatorname{id}\ x \\ x\ y &\triangleright\operatorname{id}\ x \end{aligned}

While the former shows usefulness of reification in handling partial application, the latter pathological derivation in fact suggests that ▹\triangleright is not closed under substitutions, cf. Example 29.

We prove that ▹\triangleright is a well-founded order. To this end we introduce two measures for induction. Let α\alpha be an arity assignment and ⪰\succeq a precedence. Given a term t=f t1⋯tnt = f\ t_1 \cdots t_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}, we define ∥t∥1\lVert t\rVert_1 and ∥t∥2\lVert t\rVert_2 as follows:

∥t∥1={∥t1∥1+∥t2∥1if f=@ and n=2,∥t1∥1+⋯+∥tn∥1+1otherwise.\lVert t\rVert_1 = \begin{cases} \lVert t_1\rVert_1 + \lVert t_2\rVert_1 & \text{if } f = @ \text{ and } n = 2,\\ \lVert t_1\rVert_1 + \cdots+ \lVert t_n\rVert_1 + 1 & \text{otherwise.} \end{cases}
∥t∥2={∥t1∥2+∥t2∥2if f=@ and n=2,∥t1∥2+⋯+∥tn∥2+notherwise.\lVert t\rVert_2 = \begin{cases} \lVert t_1\rVert_2 + \lVert t_2\rVert_2 & \text{if } f = @ \text{ and } n = 2,\\ \lVert t_1\rVert_2 + \cdots+ \lVert t_n\rVert_2 + n & \text{otherwise.} \end{cases}

The first function counts the number of symbols except @ occurring in the form @ t1t2t_1 t_2, while the second function computes the sum of the numbers of arguments not headed by @.

Example 10. For t=map⁡ f xst = \operatorname{map}\ f\ xs and t^=@ (map⁡ f) xs\hat{t} = @\ (\operatorname{map}\ f)\ xs we have:

∥t∥1=∥f∥1+∥xs∥1+1=3∥t^∥1=∥map⁡ f∥1+∥xs∥1=3\lVert t\rVert_1 = \lVert f\rVert_1 + \lVert xs\rVert_1 + 1 = 3 \qquad\lVert\hat{t}\rVert_1 = \lVert\operatorname{map}\ f\rVert_1 + \lVert xs\rVert_1 = 3
∥t∥2=∥f∥2+∥xs∥2+2=2∥t^∥2=∥map⁡ f∥2+∥xs∥2+0=1\lVert t\rVert_2 = \lVert f\rVert_2 + \lVert xs\rVert_2 + 2 = 2 \qquad\lVert\hat{t}\rVert_2 = \lVert\operatorname{map}\ f\rVert_2 + \lVert xs\rVert_2 + 0 = 1

Lemma 11. Let t=f t1⋯tnt = f\ t_1 \cdots t_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}.

(1) ∥t∥1>0\lVert t\rVert_1 > 0.

(2) ∥t∥1>∥ti∥1\lVert t\rVert_1 > \lVert t_i\rVert_1 for all 1≤i≤n1 \le i \le n.

(3) ∥t∥1≥∥t^∥1\lVert t\rVert_1 \ge\lVert\hat{t}\rVert_1 and ∥t∥2>∥t^∥2\lVert t\rVert_2 > \lVert\hat{t}\rVert_2 if tt is reifiable but not full.

Proof. Easy induction on tt proves the first claim, from which the second claim follows. To prove the third claim, consider a term t=f t1⋯tnt = f\ t_1 \cdots t_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V} that is reifiable and not full. From the conditions n>0n > 0 and (f,n)≠(@,2)(f,n) \ne(@,2) follow. Therefore, the desired inequalities

∥t∥1=(∥t1∥1+⋯+∥tn−1∥1+1)+∥tn∥1≥∥f t1⋯tn−1∥1+∥tn∥1=∥t^∥1\lVert t\rVert_1 = (\lVert t_1\rVert_1 + \cdots+ \lVert t_{n-1}\rVert_1 + 1) + \lVert t_n\rVert_1 \ge\lVert f\ t_1 \cdots t_{n-1}\rVert_1 + \lVert t_n\rVert_1 = \lVert\hat{t}\rVert_1
∥t∥2=∥t1∥2+⋯+∥tn∥2+n>∥t1∥2+⋯+∥tn−1∥2+n−1+∥tn∥2=∥t^∥2\lVert t\rVert_2 = \lVert t_1\rVert_2 + \cdots+ \lVert t_n\rVert_2 + n > \lVert t_1\rVert_2 + \cdots+ \lVert t_{n-1}\rVert_2 + n - 1 + \lVert t_n\rVert_2 = \lVert\hat{t}\rVert_2

hold. □\square

We note that in the case of (3) ∥t∥1=∥t^∥1\lVert t\rVert_1 = \lVert\hat{t}\rVert_1 does not always hold. This can be exemplified by t=@ @ @ @t = @\ @\ @\ @ for which ∥t∥1=4>3=∥t^∥1\lVert t\rVert_1 = 4 > 3 = \lVert\hat{t}\rVert_1 holds. Although 4 and 5 increase sizes of terms by reification, the measures serve as decreasing measures for induction.

Lemma 12. The relation ▹\triangleright is transitive.

Proof. Suppose s▹t▹us \triangleright t \triangleright u, where s=f s1⋯sks = f\ s_1 \cdots s_k, t=g t1⋯tmt = g\ t_1 \cdots t_m, and f,g∈F0∪Vf,g \in\mathcal{F}_0 \cup\mathcal{V}. We show s▹us \triangleright u by induction on (∥s∥1+∥t∥1+∥u∥1,∥s∥2+∥t∥2+∥u∥2)(\lVert s\rVert_1 + \lVert t\rVert_1 + \lVert u\rVert_1, \lVert s\rVert_2 + \lVert t\rVert_2 + \lVert u\rVert_2) with respect to lexicographic comparison of pairs of natural numbers. We distinguish several cases depending on how s▹ts \triangleright t and t▹ut \triangleright u are derived, where we apply the induction hypothesis with decreases in the first component using Lemma 11(2) unless otherwise stated.

(i) Suppose s▹ts \triangleright t is derived by 1. Then si▹ts_i \triangleright t holds for some ii. As we have si▹t▹us_i \triangleright t \triangleright u, the induction hypothesis yields si▹us_i \triangleright u. Thus, s▹us \triangleright u follows by 1.

(ii) Suppose s▹ts \triangleright t is derived by 2 or 3 and t▹ut \triangleright u is derived by 1. First, observe that s▹tjs \triangleright t_j holds for all jj, even when s▹ts \triangleright t is derived by 3: from {s1,…,sk}▹mul{t1,…,tm}\{s_1,\ldots,s_k\} \mathrel{\triangleright^{\mathrm{mul}}} \{t_1,\ldots,t_m\} we obtain si⊵tjs_i \trianglerighteq t_j for some ii, so s▹tjs \triangleright t_j follows by 1. Now we prove s▹us \triangleright u. From s▹us \triangleright u we have tj⊵ut_j \trianglerighteq u for some jj. If tj=ut_j = u then s▹us \triangleright u holds. Otherwise, s▹tj▹us \triangleright t_j \triangleright u, from which s▹us \triangleright u follows by the induction hypothesis.

(iii) Suppose s▹ts \triangleright t and t▹ut \triangleright u are derived by 2 or 3. Then uu is of the form h u1⋯unh\ u_1 \cdots u_n with t▹ujt \triangleright u_j for all jj.

  • If both are due to 3, then the relations

f⪰g⪰h{s1,…,sk}▹mul{t1,…,tm}▹mul{u1,…,un}f \succeq g \succeq h \qquad\{s_1,\ldots,s_k\} \mathrel{\triangleright^{\mathrm{mul}}} \{t_1,\ldots,t_m\} \mathrel{\triangleright^{\mathrm{mul}}} \{u_1,\ldots,u_n\}

hold. As {s1,…,sk}▹mul{u1,…,un}\{s_1,\ldots,s_k\} \mathrel{\triangleright^{\mathrm{mul}}} \{u_1,\ldots,u_n\} follows by the induction hypothesis, we obtain s▹us \triangleright u by 3.

  • Otherwise, f≻hf \succ h holds. Again, we can show t▹ujt \triangleright u_j for all jj. Since we have s▹t▹ujs \triangleright t \triangleright u_j, the induction hypothesis yields s▹ujs \triangleright u_j for all jj. Hence, we obtain s▹us \triangleright u by 2.

(iv) Suppose s▹ts \triangleright t is derived by 2 or 3 and t▹ut \triangleright u is by 4. Then ss is full, uu is reifiable and not full, and t▹u^t \triangleright\hat{u} holds. Since ∥u∥1≥∥u^∥1\lVert u\rVert_1 \ge\lVert\hat{u}\rVert_1 and ∥u∥2>∥u^∥2\lVert u\rVert_2 > \lVert\hat{u}\rVert_2 by Lemma 11(3), the induction hypothesis with a decrease in the second component leads to s▹u^s \triangleright\hat{u}. Therefore, s▹us \triangleright u is derived by 4.

(v) Suppose s▹ts \triangleright t is derived by 2 or 3 and t▹ut \triangleright u is by 5. Then tt is full and not full. So this case never happens.

(vi) Suppose s▹ts \triangleright t is derived by 4. Then ss is full, tt is reifiable and not full, and s▹t^▹us \triangleright\hat{t} \triangleright u holds. Since ∥t∥1≥∥t^∥1\lVert t\rVert_1 \ge\lVert\hat{t}\rVert_1 and ∥t∥2>∥t^∥2\lVert t\rVert_2 > \lVert\hat{t}\rVert_2 by Lemma 11(3), the induction hypothesis applies to s▹t^▹us \triangleright\hat{t} \triangleright u (with a decrease in the second component). Therefore, s▹us \triangleright u holds.

(vii) Suppose s▹ts \triangleright t is derived by 5. Then ss is reifiable and not full, and s^▹t\hat{s} \triangleright t. Again, with a decrease in the second component the induction hypothesis applies to s^▹t▹u\hat{s} \triangleright t \triangleright u. Thus, we have s^▹u\hat{s} \triangleright u from which s▹us \triangleright u follows by 5. □\square

Well-foundedness of MPO was originally shown by the Kruskal Tree Theorem [11]. However, it relies on the subterm property of the order. Thus, we employ the alternative proof method by Buchholz [9].

Recall the notion of lexicographic product. Let AA be a set. Consider nn quasi-orders ⪰1,…,⪰n\succeq_1,\ldots,\succeq_n on sets A1,…,AnA_1,\ldots,A_n, respectively. Their lexicographic product is the relation ≫\gg on A1×⋯×AnA_1 \times\cdots\times A_n defined as follows: (a1,…,an)≫(b1,…,bn)(a_1,\ldots,a_n) \gg(b_1,\ldots,b_n) if there exists an index 1≤k≤n1 \le k \le n such that ak≻kbka_k \succ_k b_k and ai⪰ibia_i \succeq_i b_i for all i<ki < k. It is known that ≫\gg is a well-founded order if every ≻i\succ_i is a well-founded order, where ≻i\succ_i is the strict part ⪰i∖⪯i\succeq_i \setminus\preceq_i of ⪰i\succeq_i.

Below, we assume well-foundedness of ≻\succ. Let SN\mathrm{SN} denote the set of all terms that have no infinite descending sequence with respect to ▹\triangleright. We define the set UU of tuples as F0×M(SN)×N×N\mathcal{F}_0 \times\mathcal{M}(\mathrm{SN}) \times\mathbb{N} \times\mathbb{N} and the relation ≫\gg on UU as the lexicographic product of ⪰\succeq, the reflexive closure of ▹mul\triangleright^{\mathrm{mul}}, and two copies of the ordinary order on N\mathbb{N}. Then ≫\gg is a well-founded order on UU. For a full term s=fs1⋯sns = f s_1 \cdots s_n with f∈F0f \in\mathcal{F}_0 and a term tt we define ϕ(s,t)\phi(s,t) as ϕ(s,t)=(f,{s1,…,sn},∥t∥1,∥t∥2)\phi(s,t) = (f,\{s_1,\ldots,s_n\},\lVert t\rVert_1,\lVert t\rVert_2). Note that ϕ(s,t)\phi(s,t) belongs to UU whenever s1,…,sn∈SNs_1,\ldots,s_n \in\mathrm{SN}.

Lemma 13. Let s=fs1⋯sms = f s_1 \cdots s_m be a full term with f∈F0f \in\mathcal{F}_0. If s1,…,sm∈SNs_1,\ldots,s_m \in\mathrm{SN} and s▹ts \triangleright t then t∈SNt \in\mathrm{SN}.

Proof. Suppose s1,…,sm∈SNs_1,\ldots,s_m \in\mathrm{SN} and s▹ts \triangleright t. We show t∈SNt \in\mathrm{SN} by well-founded induction on ϕ(s,t)\phi(s,t). Depending on how s▹ts \triangleright t is derived, we distinguish cases.

  1. If s▹ts \triangleright t is derived by 1 then si=ts_i = t or si▹ts_i \triangleright t holds. In either case, the claim follows from si∈SNs_i \in\mathrm{SN}.

  1. If s▹ts \triangleright t is derived by 2 then tt is a full term gt1⋯tng t_1 \cdots t_n with g∈F0g \in\mathcal{F}_0 and f≻gf \succ g, and s▹tjs \triangleright t_j for all jj. Since ϕ(s,t)≫ϕ(s,tj)\phi(s,t) \gg\phi(s,t_j) with a decrease at the third, tj∈SNt_j \in\mathrm{SN} for each jj. In order to show t∈SNt \in\mathrm{SN} it is enough to show that u∈SNu \in\mathrm{SN} whenever t▹ut \triangleright u. So suppose t▹ut \triangleright u. We have ϕ(s,t)≫ϕ(t,u)\phi(s,t) \gg\phi(t,u) as f≻gf \succ g. Hence, the claim follows by the induction hypothesis.

  1. If s▹ts \triangleright t is derived by 3 then we apply an argument similar to the previous case, using a decrease in the second component of the induction measure ϕ(s,t)\phi(s,t).

  1. If s▹ts \triangleright t is derived by 4 then tt is reifiable and not full, and s▹t^s \triangleright\hat{t}. Note that tt is of the form gt1⋯tng t_1 \cdots t_n with g∈F0∪Vg \in\mathcal{F}_0 \cup\mathcal{V} and n>0n > 0. In order to show t∈SNt \in\mathrm{SN} it is enough to show that u∈SNu \in\mathrm{SN} whenever t▹ut \triangleright u. So suppose t▹ut \triangleright u. Using Lemma 11(3) we have ϕ(s,t)≫ϕ(s,t^)\phi(s,t) \gg\phi(s,\hat{t}) as the fourth component decreases. So, t^∈SN\hat{t} \in\mathrm{SN} by the induction hypothesis. Thus, u∈SNu \in\mathrm{SN} is concluded if we show t▹∗ut \triangleright^{*} u. Since tt is not full, t▹ut \triangleright u is derived by 1 or 5. In the latter case, t▹u^t \triangleright\hat{u} is immediate. In the former case tj⊵ut_j \trianglerighteq u holds for some jj. If j<nj < n then t▹g t1⋯tn−1▹tj⊵ut \triangleright g\,t_1 \cdots t_{n-1} \triangleright t_j \trianglerighteq u. If j=nj = n then t▹t^j⊵ut \triangleright\hat{t}_j \trianglerighteq u. So t▹∗ut \triangleright^{*} u holds.

  1. If s▹ts \triangleright t is derived by 5 then ss is not full, which contradicts the assumption. □\square

Lemma 14. The relation ▹\triangleright is well-founded.

Proof. Let s=fs1⋯sns = f s_1 \cdots s_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}. We show s∈SNs \in\mathrm{SN} by induction on ∣s∣|s|. By the induction hypothesis we have s1,…,sn∈SNs_1,\ldots,s_n \in\mathrm{SN}. It follows if we prove t∈SNt \in\mathrm{SN} for all terms tt with s▹ts \triangleright t. Let tt be a term with s▹ts \triangleright t. If ss is full, then we conclude by Lemma 13. Suppose that ss is not full. Then s▹ts \triangleright t is due to 1 or 5. In the former case we have si⊵ts_i \trianglerighteq t. Since si∈SNs_i \in\mathrm{SN}, we obtain t∈SNt \in\mathrm{SN}. In the latter case ss is reifiable and not full and s^=@(fs1⋯sn−1)sn▹t\hat{s} = @ (f s_1 \cdots s_{n-1})s_n \triangleright t holds. Because fs1⋯sn−1∈SNf s_1 \cdots s_{n-1} \in\mathrm{SN} by the induction hypothesis, t∈SNt \in\mathrm{SN} follows by Lemma 13. □\square

By combining the lemma with Lemma 12 the announced claim is concluded.

Theorem 15. The relation ▹\triangleright is a well-founded order if ≻\succ is well-founded.

Eta-Restriction

The order ▹\triangleright is not closed under contexts.

Example 16. Let α\alpha be the arity assignment with α(@)=α(g)=2\alpha(@) = \alpha(g) = 2 and α(f)=1\alpha(f) = 1.

(a) Assume f \sim g \succ@. As f g \triangleright@ g g holds, fg▹ggf g \triangleright g g follows by 4. However, fgx▹ggxf g x \triangleright g g x does not hold as ggx▹fgxg g x \triangleright f g x follows by 4.

(b) Assume f≻gf \succ g. Then gf▹fg f \triangleright f holds by 1. However, gfx▹fxg f x \triangleright f x does not hold. In fact, 1 does not apply because neither f⊵fxf \trianglerighteq f x nor x⊵fxx \trianglerighteq f x holds.

Note that the right-hand side of fg▹ggf g \triangleright g g is partial, while the left-hand side of gf▹fg f \triangleright f is partial.

The example (a) is avoided by imposing maximality of @ on the precedence. We address (b) by a technique akin to η\eta-saturation [15].

Definition 17. The η\eta-restriction ▹η\triangleright_{\eta} of ▹\triangleright is recursively defined as follows: s▹ηts \triangleright_{\eta} t if s▹ts \triangleright t holds, and when ss is partial s x▹ηt xs\,x \triangleright_{\eta} t\,x additionally holds. Here xx is a fresh variable not in Var⁡(s)\operatorname{Var}(s).

If s=f s1⋯sns = f\,s_1 \cdots s_n with f∈F0f \in\mathcal{F}_0 is partial, by definition s▹ηts \triangleright_{\eta} t if and only if s▹ts \triangleright t and s xn+1⋯xk▹t xn+1⋯xks\,x_{n+1} \cdots x_k \triangleright t\,x_{n+1} \cdots x_k for all n+1≤k≤α(f)n+1 \leq k \leq\alpha(f), where xn+1,…,xα(f)x_{n+1}, \ldots, x_{\alpha(f)} are distinct fresh variables not occurring in Var⁡(s)\operatorname{Var}(s). We can see that Example 16(b) does not go for ▹η\triangleright_{\eta}: The inequality g f▹ηfg\,f \triangleright_{\eta} f does not hold because g f x▹f xg\,f\,x \triangleright f\,x does not.

The rest of the section is for proving that ▹η\triangleright_{\eta} is closed under contexts and is a well-founded order if @\mathord{@} is maximum in the precedence. First, we prove a key lemma using the assumption.

Lemma 18. Suppose @\mathord{@} is maximum in the precedence. If a term of the form s ts\,t is full then @ s t▹s t\mathord{@}\,s\,t \triangleright s\,t.

Proof. Suppose s ts\,t is full, where s=f s1⋯sns = f\,s_1 \cdots s_n with f∈F0f \in\mathcal{F}_0. We show that @ s t▹s t\mathord{@}\,s\,t \triangleright s\,t is derived by 3. As @\mathord{@} is maximum, @⪰f\mathord{@} \succeq f holds. It remains to show {s,t}▹mul{s1,…,sn,t}\{s,t\} \triangleright^{\mathrm{mul}} \{s_1,\ldots,s_n,t\}. If n=0n = 0 then {s,t}={f,t}▹mul{t}\{s,t\} = \{f,t\} \triangleright^{\mathrm{mul}} \{t\}. If n>0n > 0 then 1 derives s=f s1⋯sn▹sis = f\,s_1 \cdots s_n \triangleright s_i for all ii. Thus, {s,t}▹mul{s1,…,sn,t}\{s,t\} \triangleright^{\mathrm{mul}} \{s_1,\ldots,s_n,t\}. □\square

When ss is partial, s▹ηts \triangleright_{\eta} t demands s▹ts \triangleright t and s x▹ηt xs\,x \triangleright_{\eta} t\,x for some variable xx not in Var⁡(s)\operatorname{Var}(s). Due to the next property, x∉Var⁡(s)x \notin\operatorname{Var}(s) is equivalent to x∉Var⁡(s)∪Var⁡(t)x \notin\operatorname{Var}(s) \cup\operatorname{Var}(t).

Lemma 19. If s▹ts \triangleright t then Var⁡(s)⊇Var⁡(t)\operatorname{Var}(s) \supseteq\operatorname{Var}(t).

We show that s x▹t xs\,x \triangleright t\,x with a fresh variable xx is equivalent to s u▹t us\,u \triangleright t\,u for all terms uu. Although ▹\triangleright is not closed under substitutions (see Examples 9 and 29), it is closed under head-preserving substitutions. For a term tt we define

HV(t)={x∈V∣t=C[x u] for some context C and term u}.\mathit{HV}(t) = \{x \in\mathcal{V} \mid t = C[x\,u]\text{ for some context }C\text{ and term }u\}.

Variables in HV(t)\mathit{HV}(t) are called head variables [1]. We say that a substitution σ\sigma is head-preserving for tt if σ(x)=x\sigma(x) = x for all x∈HV(t)x \in\mathit{HV}(t). For example, HV(t)={f}\mathit{HV}(t) = \{f\} for t=cons⁡(f x)(map⁡ f xs)t = \operatorname{cons}(f\,x)(\operatorname{map}\,f\,xs). So {xs↦nil⁡}\{xs \mapsto\operatorname{nil}\} is head-preserving for tt, but {f↦id⁡}\{f \mapsto\operatorname{id}\} is not.

Lemma 20. Suppose σ\sigma is head-preserving for ss and tt. If s▹ts \triangleright t then sσ▹tσs\sigma\triangleright t\sigma.

Proof. The claim is shown by easy induction on the derivation of s▹ts \triangleright t. □\square

For a term s=f s1⋯sns = f\,s_1 \cdots s_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}, we define ∥s∥η\lVert s\rVert_{\eta} as max⁡{0,α(f)−n}\max\{0,\alpha(f)-n\} if f∈F0f \in\mathcal{F}_0, and 0 otherwise. If ss is partial then ∥s∥η>∥s x∥η\lVert s\rVert_{\eta} > \lVert s\,x\rVert_{\eta}. This measure ∥s∥η\lVert s\rVert_{\eta} indicates the number of arguments to make ss non-partial.

Lemma 21. Suppose σ\sigma is head-preserving for ss and tt. If s▹ηts \triangleright_{\eta} t then sσ▹ηtσs\sigma\triangleright_{\eta} t\sigma.

Proof. Suppose s=f s1⋯sn▹ηts = f\ s_1 \cdots s_n \mathrel{\triangleright_\eta} t with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}. We show sσ▹ηtσs\sigma\mathrel{\triangleright_\eta} t\sigma by induction on ∥s∥η\lVert s\rVert_\eta. By Lemma 20 we have sσ▹tσs\sigma\mathrel{\triangleright} t\sigma. If sσs\sigma is not partial then we immediately conclude sσ▹ηtσs\sigma\mathrel{\triangleright_\eta} t\sigma. Otherwise, we have to show (sσ)x▹η(tσ)x(s\sigma)x \mathrel{\triangleright_\eta} (t\sigma)x for a variable xx not in Var⁡(sσ)\operatorname{Var}(s\sigma). Since sσs\sigma is partial and σ\sigma is head preserving for ss, the term ss must be partial too. So from s▹ηts \mathrel{\triangleright_\eta} t we have sy▹ηtysy \mathrel{\triangleright_\eta} ty for some variable y∉Var⁡(s)y \notin\operatorname{Var}(s). By Lemma 19 we have y∉Var⁡(t)y \notin\operatorname{Var}(t). Define the substitution τ\tau as follows: τ(y)=x\tau(y) = x and τ(z)=σ(z)\tau(z) = \sigma(z) for other variables zz. Clearly, τ\tau is head-preserving for sysy and tyty, and moreover, since yy occurs in neither ss nor tt, we obtain sτ=sσs\tau= s\sigma and tτ=tσt\tau= t\sigma. Finally, as ∥s∥η>∥sy∥η\lVert s\rVert_\eta> \lVert sy\rVert_\eta, the induction hypothesis for sy▹ηtysy \mathrel{\triangleright_\eta} ty yields (sσ)x=(sy)τ▹η(ty)τ=(tσ)x(s\sigma)x = (sy)\tau\mathrel{\triangleright_\eta} (ty)\tau= (t\sigma)x. Hence, sσ▹ηtσs\sigma\mathrel{\triangleright_\eta} t\sigma is concluded. □\square

The technical lemma below allows us to conclude su▹tusu \mathrel{\triangleright} tu (without η\eta) from s▹ηts \mathrel{\triangleright_\eta} t (with η\eta).

Lemma 22. Suppose @ is maximum in the precedence. Let uu be a term. If s▹ηts \mathrel{\triangleright_\eta} t then su▹tusu \mathrel{\triangleright} tu.

Proof. Suppose s▹ηts \mathrel{\triangleright_\eta} t and s=f s1⋯sns = f\ s_1 \cdots s_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}.

  • If ss is partial then s▹ηts \mathrel{\triangleright_\eta} t yields sx▹txsx \mathrel{\triangleright} tx for some variable xx not in Var⁡(s)\operatorname{Var}(s). According to Lemma 19, the variable xx is neither in Var⁡(t)\operatorname{Var}(t). So the substitution σ={x↦u}\sigma= \{x \mapsto u\} is head-preserving for sxsx and txtx. Therefore, su=(sx)σ▹(tx)σ=tusu = (sx)\sigma\mathrel{\triangleright} (tx)\sigma= tu is obtained by Lemma 20.

  • If ss is not partial then susu is reifiable and not full. By 1 we can derive @su▹t\mathord{@}su \mathrel{\triangleright} t from s▹ts \mathrel{\triangleright} t and @su▹u\mathord{@}su \mathrel{\triangleright} u. Moreover, {s,u}▹mul{t,u}\{s,u\} \mathrel{\triangleright^{\mathrm{mul}}} \{t,u\} holds. Thus, @su▹@tu\mathord{@}su \mathrel{\triangleright} \mathord{@}tu follows by 3. If tutu is not full, the claim follows by 4 and 5. Otherwise, according to Lemma 18, @tu▹tu\mathord{@}tu \mathrel{\triangleright} tu holds, so @su▹tu\mathord{@}su \mathrel{\triangleright} tu follows by transitivity (Lemma 12). Therefore, su▹tusu \mathrel{\triangleright} tu is derived by 5. □\square

Lemma 23. Let uu be a term. If s▹ts \mathrel{\triangleright} t then us▹utus \mathrel{\triangleright} ut.

Proof. Suppose s▹ts \mathrel{\triangleright} t and u=f u1⋯unu = f\ u_1 \cdots u_n with f∈F0∪Vf \in\mathcal{F}_0 \cup\mathcal{V}.

  • If usus is full then by 1 we can derive us▹tus \mathrel{\triangleright} t and us▹uius \mathrel{\triangleright} u_i for all ii. Moreover, {u1,…,un,s}▹mul{u1,…,un,t}\{u_1,\ldots,u_n,s\} \mathrel{\triangleright^{\mathrm{mul}}} \{u_1,\ldots,u_n,t\} holds. Thus, us▹utus \mathrel{\triangleright} ut follows by 3.

  • Otherwise, usus and utut are reifiable and not full. By 1 we can derive @us▹t\mathord{@}us \mathrel{\triangleright} t from s▹ts \mathrel{\triangleright} t and @us▹u\mathord{@}us \mathrel{\triangleright} u. Moreover, {u,s}▹mul{u,t}\{u,s\} \mathrel{\triangleright^{\mathrm{mul}}} \{u,t\} holds. Thus, @us▹@ut\mathord{@}us \mathrel{\triangleright} \mathord{@}ut follows by 3. Therefore, us▹utus \mathrel{\triangleright} ut is obtained by 4 and 5. □\square

As a consequence of Lemma 23, if s▹ηts \mathrel{\triangleright_\eta} t (with η\eta) then us▹utus \mathrel{\triangleright} ut.

Lemma 24. Suppose @ is maximum in the precedence. Let CC be a context. If s▹ηts \mathrel{\triangleright_\eta} t then C[s]▹C[t]C[s] \mathrel{\triangleright} C[t].

Proof. Easy induction on CC with using Lemmata 22 and 23.

Now we are ready to show that ▹η\mathrel{\triangleright_\eta} is closed under contexts.

Theorem 25. Suppose @ is maximum in the precedence and CC is a context. If s▹ηts \triangleright_{\eta} t then C[s]▹ηC[t]C[s] \triangleright_{\eta} C[t].

Proof. Suppose s▹ηts \triangleright_{\eta} t. We show C[s]▹ηC[t]C[s] \triangleright_{\eta} C[t] by induction on ∥C[s]∥η\lVert C[s]\rVert_{\eta}. Suppose s▹ts \triangleright t. By Lemma 24 we have C[s]▹C[t]C[s] \triangleright C[t]. When C[s]C[s] is partial, we have to show C[s]▹ηC′[t]C[s] \triangleright_{\eta} C'[t] for C′=CxC' = C x, where xx is a variable not in Var⁡(C[s])\operatorname{Var}(C[s]). As ∥C[s]∥η>∥C′[s]∥η\lVert C[s]\rVert_{\eta} > \lVert C'[s]\rVert_{\eta}, the induction hypothesis applies.

Using Theorem 25, we can prove that the transitivity of ▹\triangleright (Lemma 12) carries over to ▹η\triangleright_{\eta}.

Lemma 26. The relation ▹η\triangleright_{\eta} is transitive, provided that @ is maximum in the precedence.

Proof. Suppose s▹ηt▹ηus \triangleright_{\eta} t \triangleright_{\eta} u. We prove s▹ηus \triangleright_{\eta} u by induction on ∥s∥η\lVert s\rVert_{\eta}. The transitivity of ▹\triangleright (Lemma 12) yields s▹us \triangleright u. When ss is partial, we also have to show sx▹ηuxs x \triangleright_{\eta} u x for some x∈V∖Var⁡(s)x \in V \setminus\operatorname{Var}(s). By Theorem 25 the relations sx▹ηtx▹ηuxs x \triangleright_{\eta} t x \triangleright_{\eta} u x follow from the assumption. As we have ∥s∥η>∥sx∥η\lVert s\rVert_{\eta} > \lVert s x\rVert_{\eta}, the induction hypothesis yields sx▹ηuxs x \triangleright_{\eta} u x.

The well-foundedness of ▹\triangleright (Lemma 14) also carries over to ▹η\triangleright_{\eta} as ▹η\triangleright_{\eta} is a subrelation of ▹\triangleright.

Lemma 27. The relation ▹η\triangleright_{\eta} is a well-founded order if ≻\succ is well-founded.

Hence, the following corollary is obtained.

Corollary 28. The relation ▹η\triangleright_{\eta} is a well-founded order that is closed under contexts, if @ is maximum in the precedence and ≻\succ is well-founded.

Reduction Order

The relation ▹η\triangleright_{\eta} is not closed under substitutions.

Example 29 (continued from Example 9). Although xy▹idyx y \triangleright i d y holds, idy=(xy)σ▹(idy)σ=idyi d y = (x y)\sigma\triangleright(i d y)\sigma= i d y does not hold for σ={x↦id}\sigma= \{x \mapsto i d\}. As xyx y is not partial, we conclude that ▹η\triangleright_{\eta} is not closed under substitutions and therefore not a reduction order.

We overcome the problem using an existing technique to construct a reduction order from a well-founded order >> on ground terms that is closed under ground contexts. We call a substitution σ\sigma grounding for a set TT of terms if tσt\sigma is ground for all t∈Tt \in T.

Definition 30. Let α\alpha be an arity assignment and ⪰\succeq a precedence. The relation >ampo>_{\mathrm{ampo}} on terms is defined as follows: s>ampots >_{\mathrm{ampo}} t if sσ▹ηtσs\sigma\triangleright_{\eta} t\sigma for all grounding substitutions σ\sigma for {s,t}\{s,t\}.

The relation >ampo>_{\mathrm{ampo}} is our applicative multiset path order (AMPO).

Theorem 31. Assume @ is maximum in the precedence. The relation >ampo>_{\mathrm{ampo}} is a reduction order if ≻\succ is well-founded.

Proof. According to [2 Exercise 5.6], the relation defined as in Definition 30 forms a reduction order if the underlying relation is a well-founded order that is closed under ground contexts. Thus, Corollary 28 entails the claim.1

We need a method to check if s>ampots >_{\mathrm{ampo}} t holds for given terms ss and tt. We present a sufficient condition for s>ampots >_{\mathrm{ampo}} t based on absence of head variables in ss. A term tt is head variable free if HV(t)=∅HV(t) = \varnothing. For example, the left-hand side of the rule map⁡ f (cons⁡ x xs)→cons⁡ (f x) (map⁡ f xs)\operatorname{map}\ f\ (\operatorname{cons}\ x\ xs) \to\operatorname{cons}\ (f\ x)\ (\operatorname{map}\ f\ xs) is head variable free, while the right-hand side is not because of the subterm f xf\ x.

Below, we assume that @ is maximum in the precedence.

Lemma 32. Let σ\sigma be a substitution. If s▹ts \triangleright t and ss is head variable free then sσ▹tσs\sigma\triangleright t\sigma.

Proof. Suppose s▹ts \triangleright t and ss is head variable free. We show sσ▹tσs\sigma\triangleright t\sigma by induction on the derivation of s▹ts \triangleright t. Since ss is head variable free, ss can be written as f s1⋯smf\ s_1 \cdots s_m with f∈F0f \in\mathcal{F}_0. So sσ=f (s1σ)⋯(smσ)s\sigma= f\ (s_1\sigma)\cdots(s_m\sigma).

  1. If s▹ts \triangleright t is derived by 1 then si⊵ts_i \trianglerighteq t for some ii. Since ss is head variable free, the subterm sis_i is head variable free too. By the induction hypothesis or stability of == we obtain siσ▹tσs_i\sigma\triangleright t\sigma. Therefore, sσ▹tσs\sigma\triangleright t\sigma is derived by 1.

  2. If s▹ts \triangleright t is derived by 2 then sσ▹tσs\sigma\triangleright t\sigma follows from the induction hypothesis and 2.

  3. If s▹ts \triangleright t is derived by 3 then sσ▹tσs\sigma\triangleright t\sigma follows from the induction hypothesis and 3.

  4. If s▹ts \triangleright t is derived by 4 then ss is full, tt is reifiable and not full, and s▹t^s \triangleright\hat{t}. If tσt\sigma is full then the inequalities sσ▹tσ^▹tσs\sigma\triangleright\widehat{t\sigma} \triangleright t\sigma by the induction hypothesis and Lemma 18. Thus, sσ▹tσs\sigma\triangleright t\sigma follows by transitivity (Lemma 12). Otherwise, the induction hypothesis yields sσ▹tσ^s\sigma\triangleright\widehat{t\sigma}. Thus, sσ▹tσs\sigma\triangleright t\sigma is derived by 4.

  5. If s▹ts \triangleright t is derived by 5 then ss is reifiable and not full, and s▹t^s \triangleright\hat{t}. Because ss is head variable free, s^\hat{s} is also head variable free. So the induction hypothesis yields s^σ▹tσ\hat{s}\sigma\triangleright t\sigma. Therefore, sσ▹tσs\sigma\triangleright t\sigma is derived by 5. □\square

Lemma 33. Let σ\sigma be a substitution. If s▹ηts \triangleright_{\eta} t and ss is head variable free then sσ▹ηtσs\sigma\triangleright_{\eta} t\sigma.

Proof. Suppose s▹ηts \triangleright_{\eta} t and ss is head variable free. By induction on ∥s∥η\lVert s\rVert_{\eta} we show sσ▹ηtσs\sigma\triangleright_{\eta} t\sigma. As s▹ηts \triangleright_{\eta} t, by definition s▹ts \triangleright t holds. Thus, sσ▹tσs\sigma\triangleright t\sigma follows by Lemma 32. If sσs\sigma is not partial then we are done. When sσs\sigma is partial, we have to show (sσ)x▹η(tσ)x(s\sigma)x \triangleright_{\eta} (t\sigma)x. Since ss is head variable free, ss is of the form f s1⋯snf\ s_1 \cdots s_n with f∈F0f \in\mathcal{F}_0. So sσ=f (s1σ)⋯(snσ)s\sigma= f\ (s_1\sigma)\cdots(s_n\sigma). As sσs\sigma is partial, ss is partial too. Thus, sx▹ηtxsx \triangleright_{\eta} tx follows from s▹ηts \triangleright_{\eta} t. Here xx is a variable not in Var⁡(s)\operatorname{Var}(s), and thus xx is neither in Var⁡(t)\operatorname{Var}(t) by Lemma 19. Define the substitution τ\tau as follows:

τ(x)=x\tau(x)=x and τ(y)=σ(y)\tau(y)=\sigma(y) for other variables yy. Since s xs\ x is head variable free and ∥s x∥η>∥s∥η\lVert s\ x\rVert_{\eta}>\lVert s\rVert_{\eta}, the induction hypothesis yields (sσ) x=(s x)τ▹η(t x)τ=(tσ) x(s\sigma)\ x=(s\ x)\tau\mathrel{\triangleright_{\eta}}(t\ x)\tau=(t\sigma)\ x. Hence, sσ▹ηtσs\sigma\mathrel{\triangleright_{\eta}}t\sigma follows.

Theorem 34. Assume that @ is maximum in the precedence. If s▹ηts\mathrel{\triangleright_{\eta}}t and ss is head variable free then s>ampots\mathrel{>_{\mathrm{ampo}}}t.

Proof. Immediate from Lemma 33.

We relate Dershowitz’s multiset path order and ours using currying. Consider an MPO >mpo>_{\mathrm{mpo}} and functional terms ss and tt. If we set α(f)=n\alpha(f)=n (by a slight abuse of notation) for every nn-ary function ff, the curried terms s∘s^{\circ} and t∘t^{\circ} are full and head variable free. For the AMPO >ampo>_{\mathrm{ampo}} induced by α\alpha and the corresponding precedence, we show the gracefulness property [5, 7]:

Theorem 35. If s>mpots>_{\mathrm{mpo}}t then s∘>ampot∘s^{\circ}>_{\mathrm{ampo}}t^{\circ}.

Proof. The relation s∘▹t∘s^{\circ}\mathrel{\triangleright}t^{\circ} is proved by straightforward induction on the derivation of s>mpots>_{\mathrm{mpo}}t. As ss is full, s∘▹ηt∘s^{\circ}\mathrel{\triangleright_{\eta}}t^{\circ} holds by definition. Consider an arbitrary grounding substitution σ\sigma for {s∘,t∘}\{s^{\circ},t^{\circ}\}. Since s∘s^{\circ} is head variable free, σ\sigma is head-preserving for s∘s^{\circ}. So s∘σ▹ηt∘σs^{\circ}\sigma\mathrel{\triangleright_{\eta}}t^{\circ}\sigma follows by Lemma 20. Hence, s∘>ampot∘s^{\circ}>_{\mathrm{ampo}}t^{\circ}.

Evaluation

We evaluate our applicative multiset path order by examples and experimental data. An ATRS is said to be left head variable free if the left-hand side of every rule is head variable free. The next termination criterion is an immediate consequence of Proposition 1 and Theorems 31 and 34 and is decidable, see Theorem 44 in Section A.

Corollary 36. Suppose that a precedence ⪰\succeq is well-founded and has @ as maximum. A left head variable free ATRS RR is terminating if R⊆▹ηR\subseteq\mathrel{\triangleright_{\eta}} for ▹η\mathrel{\triangleright_{\eta}} induced from an arity assignment α\alpha and ⪰\succeq.

By examples, we demonstrate termination proving with our order.

Example 37. First, consider the left head variable free ATRS

append nil ys→ysappend (cons x xs) ys→cons x (append xs ys)id x→xmap f nil→nilmap f (cons x xs)→cons (f x) (map f xs)map id→idmap f (append xs ys)→append (map f xs) (map f ys)\begin{aligned} \mathrm{append}\ \mathrm{nil}\ ys &\to ys & \mathrm{append}\ (\mathrm{cons}\ x\ xs)\ ys &\to\mathrm{cons}\ x\ (\mathrm{append}\ xs\ ys) & \mathrm{id}\ x &\to x \\ \mathrm{map}\ f\ \mathrm{nil} &\to\mathrm{nil} & \mathrm{map}\ f\ (\mathrm{cons}\ x\ xs) &\to\mathrm{cons}\ (f\ x)\ (\mathrm{map}\ f\ xs) \\ \mathrm{map}\ \mathrm{id} &\to\mathrm{id} & \mathrm{map}\ f\ (\mathrm{append}\ xs\ ys) &\to\mathrm{append}\ (\mathrm{map}\ f\ xs)\ (\mathrm{map}\ f\ ys) \end{aligned}

which is a complete ATRS for the equational system in the introduction. (Here, the equation of map for cons xx nil is generalized to a rule for cons xx xs.) The termination is shown by taking α(@)=α(cons)=α(append)=α(map)=2\alpha(@)=\alpha(\mathrm{cons})=\alpha(\mathrm{append})=\alpha(\mathrm{map})=2, α(id)=1\alpha(\mathrm{id})=1, and α(nil)=0\alpha(\mathrm{nil})=0 as well as @ ∼\sim map ≻\succ append ≻\succ id ≻\succ cons ≻\succ nil. Note that map id ▹η\mathrel{\triangleright_{\eta}} id is equivalent to map id ▹\mathrel{\triangleright} id and map id x▹x\mathrel{\triangleright} id xx, the latter of which uses map ≻\succ id.

Example 38. Next, consider the ATRS for the filter function:

filter f nil→nilif true x y→xfilter f (cons x xs)→if (f x) (cons x (filter f xs)) (filter f xs)if false x y→y\begin{aligned} \mathit{filter}\ f\ \mathit{nil} &\to\mathit{nil} & \mathit{if}\ \mathit{true}\ x\ y &\to x \\ \mathit{filter}\ f\ (\mathit{cons}\ x\ xs) &\to\mathit{if}\ (f\ x)\ (\mathit{cons}\ x\ (\mathit{filter}\ f\ xs))\ (\mathit{filter}\ f\ xs) & \mathit{if}\ \mathit{false}\ x\ y &\to y \end{aligned}

The termination is shown by taking α(@)=2\alpha(@) = 2, α(if)=3\alpha(\mathit{if}) = 3, α(cons)=α(filter)=2\alpha(\mathit{cons}) = \alpha(\mathit{filter}) = 2, and α(nil)=α(true)=α(false)=0\alpha(\mathit{nil}) = \alpha(\mathit{true}) = \alpha(\mathit{false}) = 0 as well as @∼filter≻if≻cons≻nil@ \sim\mathit{filter} \succ\mathit{if} \succ\mathit{cons} \succ\mathit{nil}.

Below is an example in which choice of arity assignment matters.

Example 39. Finally, consider the ATRS for the zip-with function:

zip f nil nil→nilzip f (cons x xs) (cons y ys)→cons (f x y) (zip f xs ys)\begin{aligned} \mathit{zip}\ f\ \mathit{nil}\ \mathit{nil} &\to\mathit{nil} \\ \mathit{zip}\ f\ (\mathit{cons}\ x\ xs)\ (\mathit{cons}\ y\ ys) &\to\mathit{cons}\ (f\ x\ y)\ (\mathit{zip}\ f\ xs\ ys) \end{aligned}

The termination is shown by α(@)=α(cons)=2\alpha(@) = \alpha(\mathit{cons}) = 2, and α(nil)=α(zip)=0\alpha(\mathit{nil}) = \alpha(\mathit{zip}) = 0 as well as @∼zip≻cons∼nil@ \sim\mathit{zip} \succ\mathit{cons} \sim\mathit{nil}. Note that the second rule cannot be ordered if we modify α(zip)=0\alpha(\mathit{zip}) = 0 to α(zip)=3\alpha(\mathit{zip}) = 3. The reason is that with the modified assignment zip f (cons x xs) (cons y ys)▹f x y\mathit{zip}\ f\ (\mathit{cons}\ x\ xs)\ (\mathit{cons}\ y\ ys) \mathrel{\triangleright} f\ x\ y does not hold, as it requires the impossible multiset comparison {f,cons x xs,cons y ys}▹mul{f x,y}\{f,\mathit{cons}\ x\ xs,\mathit{cons}\ y\ ys\} \mathrel{\triangleright_{\mathrm{mul}}} \{f\ x,y\}. On the other hand, with α(zip)=0\alpha(\mathit{zip}) = 0 the requirement changes to the possible one {zip f (cons x xs),cons y ys}▹mul{f x,y}\{\mathit{zip}\ f\ (\mathit{cons}\ x\ xs),\mathit{cons}\ y\ ys\} \mathrel{\triangleright_{\mathrm{mul}}} \{f\ x,y\}. Applying reification to the left-hand side is a key to handle the variable application f xf\ x.

Let us take a look at limitations of AMPOs, too.

Example 40. The one-rule ATRS f (f x)→f (g (f x))f\ (f\ x) \to f\ (g\ (f\ x)) is beyond the realm of our order, because the opposite orientation f (g (f x))>ampof (f x)f\ (g\ (f\ x)) \mathrel{>_{\mathrm{ampo}}} f\ (f\ x) follows from g x>ampoxg\ x \mathrel{>_{\mathrm{ampo}}} x. Similarly, the one-rule ATRS a→f fa \to f\ f cannot be handled by our order: If α(f)=0\alpha(f) = 0 then f f>ampoaf\ f \mathrel{>_{\mathrm{ampo}}} a holds. Otherwise, we do not have a>ampofa \mathrel{>_{\mathrm{ampo}}} f.

These limitations are essentially due to the inductive definition of the base order. The next example shows a limitation on precedences for AMPO.

Example 41 (continued from Example 37). If we add the rule mapid→map id\mathit{mapid} \to\mathit{map}\ \mathit{id} to the ATRS, the termination is no longer shown by AMPO: To orient it, the precedence must satisfy \mathit{mapid} \succ@, which contradicts the maximality of @@.

We have evaluated Corollary 36 on 202 ATRSs in the Termination Problem Database (TPDB). Suitable arity assignments and precedences are searched by the SMT solver Z3 [23]; see [10, 29] for the encoding techniques.2 Out of the 202 ATRSs, 143 are left head variable free, and 24 are shown terminating by AMPO, while 2 are shown by MPO. Note that the termination tools AProVE [13] and NaTT [28] prove termination of 165 and 148 ATRSs, respectively. Both subsume the results of AMPOs.

Conclusion

Although there are many variants [8, 17, 21, 22, 27] of the recursive/multiset path order for higher-order rewriting, here we compare ours with ones having close relationship. The lambda-free recursive path order by Blanchette et al. [7] has been developed for automated theorem proving. It satisfies almost all properties for being a reduction order, but it is not closed under contexts. Recently, Bentkamp introduced the embedding path order (EPO) [6]. As a family of MPO, this is the first reduction order. It can only orient non-duplicating rules ℓ→r\ell\to r in which no variable occurs more in rr than in ℓ\ell. Thus, termination of higher-order recursive functions like map and filter (Examples 37 and 38) cannot be shown by the order. It should be noted that the lambda-free RPO and the EPO satisfies totality on ground terms, which guarantees refutational completeness of ordered completion [3] as well as of superposition calculus [4]. Unfortunately, our order does not enjoy the property: if α(f)=1\alpha(f) = 1, α(a)=0\alpha(a) = 0 and f≻af \mathrel{\succ} a then f af\ a and ff are incomparable with ▹\mathrel{\triangleright} and also with >ampo>_{\mathrm{ampo}}. Jouannaud and Rubio [17] developed the higher-order recursive path order on typed terms. Due to differences in term structure it is hard to relate their work to ours, but it is worth noting that Buchholz’s method [9] is an untyped version of their well-foundedness proof.

Uncurrying [15, 25] transforms left head variable free ATRSs into functional TRSs in a termination reflecting manner. For example, the termination of the map ATRS in Example 37 follows from that of the functional TRS consisting of the uncurried rules

append⁡2(cons⁡2(x,xs),ys)→cons⁡2(x,append⁡2(xs,ys))append⁡2(nil⁡,ys)→ysmap⁡2(f,cons⁡2(x,xs))→cons⁡2(∘(f,x),map⁡2(f,xs))map⁡2(f,nil⁡)→nil⁡map⁡2(f,append⁡2(xs,ys))→append⁡2(map⁡2(f,xs),map⁡2(f,ys))id⁡1(x)→xmap⁡2(id⁡,xs)→id⁡1(xs)map⁡1(id⁡)→id⁡\begin{aligned} \operatorname{append}_2(\operatorname{cons}_2(x,xs),ys) &\to\operatorname{cons}_2(x,\operatorname{append}_2(xs,ys)) & \operatorname{append}_2(\operatorname{nil},ys) &\to ys \\ \operatorname{map}_2(f,\operatorname{cons}_2(x,xs)) &\to\operatorname{cons}_2(\circ(f,x),\operatorname{map}_2(f,xs)) & \operatorname{map}_2(f,\operatorname{nil}) &\to\operatorname{nil} \\ \operatorname{map}_2(f,\operatorname{append}_2(xs,ys)) &\to\operatorname{append}_2(\operatorname{map}_2(f,xs),\operatorname{map}_2(f,ys)) & \operatorname{id}_1(x) &\to x \\ \operatorname{map}_2(\operatorname{id},xs) &\to\operatorname{id}_1(xs) & \operatorname{map}_1(\operatorname{id}) &\to\operatorname{id} \end{aligned}

and the uncurrying rules:

∘(append⁡,xs)→append⁡1(xs)∘(append⁡1(xs),ys)→append⁡2(xs,ys)∘(map⁡,f)→map⁡1(f)∘(map⁡1(f),xs)→map⁡2(f,xs)∘(cons⁡,x)→cons⁡1(x)∘(cons⁡1(x),xs)→cons⁡2(x,xs)∘(id⁡,x)→id⁡1(x)\begin{aligned} \circ(\operatorname{append},xs) &\to\operatorname{append}_1(xs) & \circ(\operatorname{append}_1(xs),ys) &\to\operatorname{append}_2(xs,ys) \\ \circ(\operatorname{map},f) &\to\operatorname{map}_1(f) & \circ(\operatorname{map}_1(f),xs) &\to\operatorname{map}_2(f,xs) \\ \circ(\operatorname{cons},x) &\to\operatorname{cons}_1(x) & \circ(\operatorname{cons}_1(x),xs) &\to\operatorname{cons}_2(x,xs) \\ \circ(\operatorname{id},x) &\to\operatorname{id}_1(x) \end{aligned}

The termination of the above TRS is shown by the multiset path order with the precedence ∘∼map⁡≻append⁡≻id⁡≻cons⁡≻nil⁡\circ\sim\operatorname{map} \succ\operatorname{append} \succ\operatorname{id} \succ\operatorname{cons} \succ\operatorname{nil} and f∼fif \sim f_i for all function symbol ff and its indexed copies fif_i. Here ∘\circ being a maximum is used for orienting the uncurrying rules. If we identify ∘\circ with @ and each indexed copy fif_i with the original symbol ff, the precedence is the same as the one in Example 37. We anticipate that the applicative multiset path order can be simulated by a combination of generalized uncurrying [25] and the original multiset path order.

The lexicographic path order (LPO) [18] is a famous variant of MPO which compares arguments lexicographically. Of course, such a version could be considered in a similar fashion. However, if we adopt left-to-right lexicographic comparison, Lemma 18 (a key lemma) fails to hold. We expect that right-to-left lexicographic comparison is a viable alternative.

Last but not least, because of the construction used in Definition 30 (by considering all grounding substitutions), it is obscure if the relation s>ampots >_{\mathrm{ampo}} t is decidable for a fixed pair of precedence and arity assignment. Developing a decision procedure or finding a generalization of Theorem 34 would enable us to use completion [20] and rewriting induction [24] more effectively.

Acknowledgments. We are grateful to the reviewers for their valuable suggestions. This research was supported by JSPS KAKENHI Grant Numbers JP22K11900 and JP25KJ1363.

Disclosure of Interests. The authors have no competing interests to declare that are relevant to the content of this article.

Omitted Proofs

Recall the statement of Lemma 19: If s▹ts \triangleright t then Var⁡(s)⊇Var⁡(t)\operatorname{Var}(s) \supseteq\operatorname{Var}(t).

Proof (of Lemma 19). Suppose s=f s1⋯sm▹ts = f\ s_1 \cdots s_m \triangleright t. We show Var⁡(s)⊇Var⁡(t)\operatorname{Var}(s) \supseteq\operatorname{Var}(t) by induction on the derivation of s▹ts \triangleright t.

  1. If s▹ts \triangleright t is derived by 1 then si=ts_i = t or si▹ts_i \triangleright t for some ii. In the former case Var⁡(si)=Var⁡(t)\operatorname{Var}(s_i) = \operatorname{Var}(t) holds. In the latter case the induction hypothesis yields Var⁡(si)⊇Var⁡(t)\operatorname{Var}(s_i) \supseteq\operatorname{Var}(t). So in either case Var⁡(s)⊇Var⁡(si)⊇Var⁡(t)\operatorname{Var}(s) \supseteq\operatorname{Var}(s_i) \supseteq\operatorname{Var}(t) follows.

  1. If s▹ts \triangleright t is derived by 2 then tt is of the form g t1⋯tng\ t_1 \cdots t_n with g∈F0g \in\mathcal{F}_0 and s▹tjs \triangleright t_j for all jj. By the induction hypothesis Var⁡(s)⊇Var⁡(tj)\operatorname{Var}(s) \supseteq\operatorname{Var}(t_j) for all jj. Thus, the claim holds.

  1. If s▹ts \triangleright t is derived by 3 then tt is of the form g t1⋯tng\ t_1 \cdots t_n with g∈F0g \in\mathcal{F}_0 and {s1,…,sm}▹mul{n1,…,nn}\{s_1, \ldots, s_m\} \mathrel{\triangleright^{\mathrm{mul}}} \{n_1, \ldots, n_n\}. For every jj there exists an ii such that si=tjs_i = t_j or si▹tjs_i \triangleright t_j holds. For the former case Var⁡(si)=Var⁡(tj)\operatorname{Var}(s_i) = \operatorname{Var}(t_j) holds. For the latter case Var⁡(si)⊇Var⁡(tj)\operatorname{Var}(s_i) \supseteq\operatorname{Var}(t_j) holds by the induction hypothesis. So in either case Var⁡(s)⊇Var⁡(tj)\operatorname{Var}(s) \supseteq\operatorname{Var}(t_j) follows. Thus, the claim follows.

  1. If s▹ts \triangleright t is derived by 4 then s▹t^s \triangleright\hat{t}. By the induction hypothesis Var⁡(s)⊇Var⁡(t^)\operatorname{Var}(s) \supseteq\operatorname{Var}(\hat{t}) holds. As Var⁡(t^)=Var⁡(t)\operatorname{Var}(\hat{t}) = \operatorname{Var}(t), the claim follows.

  1. If s▹ts \triangleright t is derived by 5 then s^▹t\hat{s} \triangleright t. By the induction hypothesis Var⁡(s^)⊇Var⁡(t)\operatorname{Var}(\hat{s}) \supseteq\operatorname{Var}(t) holds. As Var⁡(s)=Var⁡(s^)\operatorname{Var}(s) = \operatorname{Var}(\hat{s}), the claim follows.

Recall the statement of Lemma 20: Suppose σ\sigma is head-preserving for ss and tt. If s▹ts \triangleright t then sσ▹tσs\sigma\triangleright t\sigma.

Proof (of Lemma 20). Suppose s=f s1⋯sm▹ts = f\ s_1 \cdots s_m \triangleright t. We show sσ▹tσs\sigma\triangleright t\sigma by induction on the derivation of s▹ts \triangleright t. Note that σ\sigma is head-preserving for all subterms in ss and tt.

  1. If s▹ts \triangleright t is derived by 1 then si=ts_i = t or si▹ts_i \triangleright t holds for some ii. In the former case siσ=tσs_i\sigma= t\sigma holds trivially. In the latter case siσ▹tσs_i\sigma\triangleright t\sigma follows from the induction hypothesis. Therefore, sσ▹tσs\sigma\triangleright t\sigma is derived by 1.

  1. If s▹ts \triangleright t is derived by 2 then tt is a full term g t1⋯tng\ t_1 \cdots t_n with g∈F0g \in\mathcal{F}_0 and f≻gf \succ g, and s▹tjs \triangleright t_j for all jj. By the induction hypothesis sσ▹tjσs\sigma\triangleright t_j\sigma for all jj. Therefore, sσ▹tσs\sigma\triangleright t\sigma is derived by 2.

  1. If s▹ts \triangleright t is derived by 3 then the proof is analogous to the last case.

  1. If s▹ts \triangleright t is derived by 4 then tt is reifiable and not full, and s▹t^s \triangleright\hat{t}. As σ\sigma is head-preserving for tt, the instance tσt\sigma is reifiable and not full. So the claim is immediate from the induction hypothesis.

  1. If s▹ts \triangleright t is derived by 5 then the proof is analogous to the last case.

In the remaining part of the appendix we show that orientability of a finite LATRS with AMPO is decidable. We use the notion of applicative arity [15]. Let R\mathcal{R} be a finite ATRS. The applicative arity aa⁡R(f)\operatorname{aa}_{\mathcal{R}}(f) of a constant f∈F0f \in\mathcal{F}_0 is defined as follows [15]:

aa⁡R(f)=max⁡{n∣f t1⋯tn∈SR}\operatorname{aa}_{\mathcal{R}}(f) = \max\{n \mid f\ t_1 \cdots t_n \in S_{\mathcal{R}}\}

Here SRS_{\mathcal R} consists of all subterms occurring in R\mathcal R and max⁡∅\max\varnothing is assumed to be 00. We write TRT_{\mathcal R} for the set SR∪{t^∣t∈SR and t is reifiable}S_{\mathcal R} \cup\{\hat{t} \mid t \in S_{\mathcal R}\text{ and }t\text{ is reifiable}\}. Given a rule ℓ→r∈R\ell\to r \in\mathcal R, the derivation of ℓ▹r\ell\triangleright r uses terms in TRT_{\mathcal R} only. We define the arity assignment β\beta as β(f)=min⁡{α(f),aa⁡R(f)+1}\beta(f) = \min\{\alpha(f), \operatorname{aa}_{\mathcal R}(f) + 1\}.

Lemma 42. A term in TRT_{\mathcal R} is full with respect to α\alpha if and only if it is full with respect to β\beta.

Proof. Consider a term tt in TRT_{\mathcal R} of the form f t1⋯tnf\,t_1\cdots t_n with f∈F0f \in\mathcal F_0. If tt is full with respect to α\alpha then α(f)=n≤aa⁡R(f)\alpha(f) = n \leq\operatorname{aa}_{\mathcal R}(f). So we obtain β(f)=α(f)\beta(f) = \alpha(f). Thus, tt is full with respect to β\beta. Conversely, if tt is full with respect to β\beta then β(f)=n<n+1≤aa⁡R(f)+1\beta(f) = n < n + 1 \leq\operatorname{aa}_{\mathcal R}(f) + 1, from which β(f)≠aa⁡R(f)\beta(f) \ne\operatorname{aa}_{\mathcal R}(f) follows. Thus, n=β(f)=α(f)n = \beta(f) = \alpha(f), and therefore tt is full with respect to α\alpha.

Therefore, in any derivation of ℓ▹r\ell\triangleright r for ℓ→r∈R\ell\to r \in\mathcal R fullness with respect to α\alpha is indistinguishable from fullness with respect to β\beta. Since the only role of an arity assignment in Definition 7 is to determine fullness of terms, ℓ▹r\ell\triangleright r with α\alpha carries over to ℓ▹r\ell\triangleright r with β\beta.

Lemma 43. Let α\alpha be an arity assignment and let s,t∈TRs,t \in T_{\mathcal R}.

  1. If s▹ts \triangleright t with respect to α\alpha then s▹ts \triangleright t with respect to β\beta.

  2. If s▹ηts \triangleright_\eta t with respect to α\alpha then s▹ηts \triangleright_\eta t with respect to β\beta.

  3. If s>ampots >_{\mathrm{ampo}} t with respect to α\alpha then s>ampots >_{\mathrm{ampo}} t with respect to β\beta.

Hence, if R⊆>ampo\mathcal R \subseteq>_{\mathrm{ampo}} with respect to α\alpha then R⊆>ampo\mathcal R \subseteq>_{\mathrm{ampo}} with respect to β\beta.

Proof. The first claim is shown by straightforward induction on the derivation of s▹ts \triangleright t with using Lemma 42. The second and third claims are immediate from the first and the second, respectively.

Lemma 43 states that, when finding an arity assignment α\alpha and a precedence >> that satisfy R⊆>ampo\mathcal R \subseteq>_{\mathrm{ampo}}, one may assume α(f)≤aa⁡R(f)+1\alpha(f) \leq\operatorname{aa}_{\mathcal R}(f) + 1 for all f∈F0f \in\mathcal F_0. So existence of a suitable arity assignment and precedence can be found by enumeration.

Theorem 44. Given a finite LATRSLATRS R\mathcal R, whether R⊆>ampo\mathcal R \subseteq>_{\mathrm{ampo}} holds for some arity assignment and precedence is decidable.

References

  1. [1]Aoto, T., Yamada, T.: Termination of simply-typed applicative term rewriting systems. In: Proc. 2nd International Workshop on Higher-Order Rewriting. pp. 61–65 (2004), technical Report 2004-03, Department of Computer Science, RWTH Aachen.
  2. [2]Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press (1998). https://doi.org/10.1017/CBO9781139172752
  3. [3]Bachmair, L., Dershowitz, N., Plaisted, D.A.: Completion without failure. In: Resolution of Equations in Algebraic Structures, Progress in Theoretical Computer Science, vol. 2: Rewriting Techniques, pp. 1–30. Academic Press (1989)
  4. [4]Bachmair, L., Ganzinger, H.: Rewrite-based equational theorem proving with selection and simplification. Journal of Logic and Computation 4(3), 217–247 (1994). https://doi.org/10.1093/LOGCOM/4.3.217
  5. [5]Becker, H., Blanchette, J., Waldmann, U., Wand, D.: A transfinite Knuth–Bendix order for lambda-free higher-order terms. In: Proc. 26th International Conference on Automated Deduction. LNCS, vol. 10395, pp. 432–453 (2017). https://doi.org/10.1007/978-3-319-63046-5_27
  6. [6]Bentkamp, A.: The embedding path order for lambda-free higher-order terms. Journal of Applied Logics 8(10), 2447–2470 (2021)DOI
  7. [7]Blanchette, J., Waldmann, U., Wand, D.: A lambda-free higher-order recursive path order. In: Proc. 20th International Conference on Foundations of Software Science and Computation Structures. LNCS, vol. 10203, pp. 461–479 (2017). https://doi.org/10.1007/978-3-662-54558-7_27
  8. [8]Blanqui, F., Jouannaud, J.P., Rubio, A.: The computability path ordering. Logical Methods in Computer Science 11(4) (2015). https://doi.org/10.2168/LMCS-11(4:3)2015
  9. [9]Buchholz, W.: Proof-theoretic analysis of termination proofs. Annals of Pure and Applied Logic 75(1–2), 57–65 (1995). https://doi.org/10.1016/0168-0072(94)00056-9
  10. [10]Codish, M., Giesl, J., Schneider-Kamp, P., Thiemann, R.: SAT solving for termination proofs with recursive path orders and dependency pairs. Journal of Automated Reasoning 49, 53–93 (2012). https://doi.org/10.1145/1890028.1890030
  11. [11]Dershowitz, N.: Orderings for term-rewriting systems. Theoretical Computer Science 17, 279–301 (1982). https://doi.org/10.1016/0304-3975(82)90026-3
  12. [12]Dershowitz, N., Manna, Z.: Proving termination with multiset orderings. Communications of the ACM 22(8), 465–476 (1979). https://doi.org/10.1145/359138.359142
  13. [13]Giesl, J., Aschermann, C., Brockschmidt, M., Emmes, F., Frohn, F., Fuhs, C., Hensel, J., Otto, C., Plücker, M., Schneider-Kamp, P., Ströder, T., Swiderski, S., Thiemann, R.: Analyzing program termination and complexity automatically with AProVE. Journal of Automated Reasoning 58, 3–31 (2017). https://doi.org/10.1007/s10817-016-9388-y
  14. [14]Giesl, J., Thiemann, R., Schneider-Kamp, P.: Proving and disproving termination of higher-order functions. In: Proc. 5th International Symposium on Frontiers of Combining Systems. LNCS (LNAI), vol. 3717, pp. 216–231 (2005). https://doi.org/10.1007/11559306_12
  15. [15]Hirokawa, N., Middeldorp, A., Zankl, H.: Uncurrying for termination and complexity. Journal of Automated Reasoning 50, 279–315 (2013). https://doi.org/10.1007/s10817-012-9248-3
  16. [16]Hirokawa, N., Saito, T., Tanaka, T., Yachi, W.: An applicative multiset path order. In: Proc. 13th International Joint Conference on Automated Reasoning. LNCS, vol. 16689, pp. 251–268 (2026). https://doi.org/10.1007/978-3-032-32592-1_15
  17. [17]Jouannaud, J.P., Rubio, A.: Polymorphic higher-order recursive path orderings. Journal of the ACM 54(1) (2007). https://doi.org/10.1145/1206035.1206037
  18. [18]Kamin, S., Lévy, J.: Two generalizations of the recursive path ordering. Tech. rep., University of Illinois (1980), unpublished manuscript.
  19. [19]Kennaway, R., Klop, J., Sleep, R., de Vries, F.J.: Comparing curried and uncurried rewriting. Journal of Symbolic Computation 21(1), 15–39 (1998). https://doi.org/10.1006/jsco.1996.0002
  20. [20]Knuth, D.E., Bendix, P.B.: Simple word problems in universal algebras. In: Computational Problems in Abstract Algebra, pp. 263–297. Pergamon Press (1970)
  21. [21]Kop, C., van Raamsdonk, F.: A higher-order iterative path ordering. In: Proc. 15th International Conference on Logic Programming and Automated Reasoning. LNCS, vol. 5330, pp. 697–711 (2008). https://doi.org/10.1007/978-3-540-89439-1_48
  22. [22]Lifantsev, M., Bachmair, L.: An LPO-based termination ordering for higher-order terms without λ-abstraction. In: Proc. 11th International Conference on Theorem Proving in Higher Order Logics. LNCS, vol. 1479, pp. 277–293 (1998). https://doi.org/10.1007/BFb0055142
  23. [23]de Moura, L.M., Bjørner, N.S.: Z3: an efficient SMT solver. In: Proc. 14th International Conference on Tools and Algorithms for the Construction and Analysis of Systems. LNCS, vol. 4963, pp. 337–340 (2008). https://doi.org/10.1007/978-3-540-78800-3_24
  24. [24]Reddy, U.S.: Term rewriting induction. In: Proc. 10th International Conference on Automated Deduction. LNCS, vol. 449, pp. 162–177 (1990)DOI
  25. [25]Sternagel, C., Thiemann, R.: Generalized and formalized uncurrying. In: Proc. 8th International Symposium on Frontiers of Combining Systems. pp. 243–258. LNCS (2011). https://doi.org/10.1007/978-3-642-24346-6_17
  26. [26]Terese: Term Rewriting Systems. Cambridge University Press (2003)
  27. [27]Toyama, Y.: Termination of S-expression rewriting systems: Lexicographic path ordering for higher-order terms. In: Proc. 15th International Conference on Rewriting Techniques and Applications. LNCS, vol. 3091, pp. 40–54 (2004). https://doi.org/10.1007/978-3-540-25979-4_3
  28. [28]Yamada, A., Kusakari, K., Sakabe, T.: Nagoya Termination Tool. In: Proc. Joint 25th International Conference on Rewriting Techniques and Applications and 12th International Conference on Typed Lambda Calculi and Applications. vol. 8560, pp. 466–475 (2014). https://doi.org/10.1007/978-3-319-08918-8_32
  29. [29]Zankl, H., Hirokawa, N., Middeldorp, A.: KBO orientability. Journal of Automated Reasoning 43, 173–201 (2009). https://doi.org/10.1007/s10817-009-9131-z

Paper details

vlnc:W_sts9emft
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 9

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents