Manuscript Offprint
arXiv:2610.02973An Applicative Multiset Path Order (Extended Version)
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
1 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:
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) .
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 append (cons ) (append ) id
map nil nil map (cons nil) cons nil
map id id map (append ) append (map ) (map )
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
N. Hirokawa et al.
application like map f and f 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.
Let be an infinite set of variables, and a set of function symbols with . Terms are inductively defined as follows: all variables are terms; and if is an -ary function symbol in and are terms then is a term. We simply write for . Ground terms are terms that do not contain variables. A substitution is a mapping from variables to terms such that for only finitely many variables . In particular, we write for the substitution that maps to and other variables to itself. Given a term and a substitution , we write for the term obtained by replacing every variable occurring in with . A context is a term containing exactly one hole , which is a constant not in . The term obtained by replacing in by a term is denoted by . Ground contexts are contexts that do not contain variables. The set of variables occurring in a term is written as . A rewrite rule is a pair of terms such that is not a variable and . A set of rewrite rules is called a term rewrite system (TRS). We write if and for some rewrite rule , context , and substitution .
A TRS is terminating if there is no infinite sequence with respect to . Alternatively, it means that the relation 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 whenever and is a substitution. Similarly, > is said to be closed under (ground) contexts if whenever and is a (ground) context, respectively. Reduction orders characterize termination of term rewrite systems.
Proposition 1. A TRS is terminating if and only if there exists a reduction order > with .
Fig. 1. Derivations of MPO (left) and AMPO (right)
A key ingredient of the multiset path order is multiset extension. Let > be a binary relation on a set . We write for the set of all finite multisets over . The multiset extension of > is defined on as follows: if there exist multisets such that , , and every admits an element with . It is known that 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 on a signature is a quasi-order on . We denote the strict part of by , and the equivalence part by . We call well-founded if is. The reflexive closure and the reflexive and transitive closure of a relation are denoted by and , respectively.
Definition 2. Let be a precedence. The multiset path order is inductively defined on terms as follows: if and one of the following conditions holds.
-
for some .
-
, , and for all .
-
, , and .
Theorem 3 ([11]). The relation is a reduction order if the precedence is well-founded.
It is worth noting that the MPO has the subterm property, i.e., for all terms and contexts .
Example 4. Consider the TRS R for addition and multiplication:
By taking a precedence with mult add s the relation holds for all . For instance, add(s(x), y) >_{\text{mpo}} s(add(x, y)) is verified by the derivation on the left of Figure 1. Hence, the termination of is concluded by Proposition 1 together with Theorem 3.
An applicative signature consists of constants and a single binary symbol called application. Terms over an applicative signature are called applicative
N. Hirokawa et al.
terms. Using juxtaposition as in combinatory logic, is abbreviated to . For example, is written as (map ). 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 . Currying [19] recursively transforms a term over a (possibly non-applicative) signature into an applicative term as follows: if , and if . (Strictly speaking, the signature after currying is obtained by regarding each as a constant and adding a fresh binary symbol .)
Example 5. The curried version of the addition TRS (Example 4) is as follows:
As mentioned in the introduction, the sufficient condition for termination cannot be satisfied by any reduction order > having the subterm property, including MPO. If so, for the last rule and we have , which leads to a contradiction:
Here, the decreases with respect to > by chopping the underlined symbols are guaranteed by the subterm property and the closure under contexts of >.
3 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 is an applicative signature, and that it contains a special fresh constant @. We write for the set of all constants in . Observe that an arbitrary applicative term can be written in the form with . When , the term is said to be reifiable and the term @ is denoted by . The term is called the reification of . Arity assignments are functions from to with . Let be an arity assignment. A term is full if and , and partial if and . Note that a term can be neither full nor partial.
Example 6. Let be the arity assignment with , , and . The term map nil is full, map id is partial, and both map and are neither full nor partial. These four terms are reifiable, while and map are not. The reification of is @ .
Definition 7. Let be an arity assignment and a precedence on . The relation is inductively defined on terms over as follows: if and one of the following conditions holds.
-
for some .
-
s and are full, , and for all .
-
s and are full, , and .
-
s is full, t is reifiable and not full, and .
-
s is reifiable and not full, and .
The first three cases 1, 2, and 3 are from the original multiset path order.
Example 8 (continued from Example 5). Let be the arity assignment such that , , and , and let be the same precedence as before. Then holds for all . For example, add is verified by the second derivation in Figure 1. Remark that the subterm property does not hold for . In fact, does not hold.
The last two cases 4 and 5 in Definition 7 are used for resolving non-fullness.
Example 9. Let be the arity assignment of Example 6, and let be the precedence with @ map cons nil. For the terms (cons ) and we have the following derivation:
The next two derivations illustrate case 5:
\begin{array}{r l r}&{\frac{\textcircled{a}\succ@}&{\{\mathrm{m a p},\mathrm{i d}f\}\triangleright^{\mathrm{m u l}}\{\mathrm{m a p},f\}}\\ &{}&{\frac{\textcircled{a}\mathrm{m a p}(\mathrm{i d}f)\triangleright\textcircled{a}\mathrm{m a p}f}{\textcircled{a}\mathrm{m a p}(\mathrm{i d}f)\triangleright\mathrm{m a p}f}}\\ &{}&{\frac{\textcircled{a}\mathrm{m a p}(\mathrm{i d}f)\triangleright\mathrm{m a p}f}{\mathrm{m a p}(\mathrm{i d}f)\triangleright\mathrm{m a p}f}}\end{array}3While the former shows usefulness of reification in handling partial application, the latter pathological derivation in fact suggests that is not closed under substitutions, cf. Example 29.
We prove that ▷ is a well-founded order. To this end we introduce two measures for induction. Let α be an arity assignment and ∼ a precedence. Given a term with , we define and as follows:
N. Hirokawa et al.
The first function counts the number of symbols except @ occurring in the form @ , while the second function computes the sum of the numbers of arguments not headed by @.
Example 10. For and we have:
Lemma 11. Let with .
(1)
(2) for all .
(3) and if is reifiable but not full.
Proof. Easy induction on proves the first claim, from which the second claim follows. To prove the third claim, consider a term with that is reifiable and not full. From the conditions and follow. Therefore, the desired inequalities
hold.
We note that in the case of (3) does not always hold. This can be exemplified by for which holds.
Although 4 and 5 increase sizes of terms by reification, the measures serve as decreasing measures for induction.
Lemma 12. The relation ▷ is transitive.
Proof. Suppose , where , , and . We show by induction on with respect to lexicographic comparison of pairs of natural numbers. We distinguish several cases depending on how and are derived, where we apply the induction hypothesis with decreases in the first component using Lemma 11(2) unless otherwise stated.
(i) Suppose is derived by 1. Then holds for some . As we have , the induction hypothesis yields . Thus, follows by 1.
(ii) Suppose is derived by 2 or 3 and is derived by 1. First, observe that holds for all , even when is derived by 3: from we obtain for some , so follows by 1. Now we prove . From we have for some . If then holds. Otherwise, , from which follows by the induction hypothesis.
(iii) Suppose and are derived by 2 or 3. Then is of the form with for all .
– If both are due to 3, then the relations
hold. As follows by the induction hypothesis, we obtain by 3.
– Otherwise, holds. Again, we can show for all . Since we have , the induction hypothesis yields for all . Hence, we obtain by 2.
(iv) Suppose is derived by 2 or 3 and is by 4. Then is full, is reifiable and not full, and holds. Since and by Lemma 11(3), the induction hypothesis with a decrease in the second component leads to . Therefore, is derived by 4.
(v) Suppose is derived by 2 or 3 and is by 5. Then is full and not full. So this case never happens.
(vi) Suppose is derived by 4. Then is full, is reifiable and not full, and holds. Since and by Lemma 11(3), the induction hypothesis applies to (with a decrease in the second component). Therefore, holds.
(vii) Suppose is derived by 5. Then is reifiable and not full, and . Again, with a decrease in the second component the induction hypothesis applies to . Thus, we have from which follows by 5.
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 be a set. Consider quasi-orders on sets , respectively. Their lexicographic product is the relation on defined as follows: if there exists an index such that and for all . It is known that is a well-founded order if every is a well-founded order, where is the strict part of .
Below, we assume well-foundedness of . Let denote the set of all terms that have no infinite descending sequence with respect to . We define the set of tuples as and the relation on as the lexicographic product of , the reflexive closure of , and two copies of the ordinary order on . Then is a well-founded order on . For a full term with and a term we define as . Note that belongs to whenever .
Lemma 13. Let be a full term with . If and then .
Proof. Suppose and . We show by well-founded induction on . Depending on how is derived, we distinguish cases.
- If is derived by 1 then or holds. In either case, the claim follows from .
N. Hirokawa et al.
-
If is derived by 2 then is a full term with and , and for all . Since with a decrease at the third, for each . In order to show it is enough to show that whenever . So suppose . We have as . Hence, the claim follows by the induction hypothesis.
-
If 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 .
-
If is derived by 4 then is reifiable and not full, and . Note that is of the form with and . In order to show it is enough to show that whenever . So suppose . Using Lemma 11(3) we have as the fourth component decreases. So, by the induction hypothesis. Thus, is concluded if we show . Since is not full, is derived by 1 or 5. In the latter case, is immediate. In the former case holds for some . If then . If then . So holds.
-
If is derived by 5 then is not full, which contradicts the assumption.
Lemma 14. The relation ▷ is well-founded.
Proof. Let with . We show by induction on . By the induction hypothesis we have . It follows if we prove for all terms with . Let be a term with . If is full, then we conclude by Lemma 13. Suppose that is not full. Then is due to 1 or 5. In the former case we have . Since , we obtain . In the latter case is reifiable and not full and holds. Because by the induction hypothesis, follows by Lemma 13.
By combining the lemma with Lemma 12 the announced claim is concluded.
Theorem 15. The relation ▷ is a well-founded order if ▷ is well-founded.
4 Eta-Restriction
The order ▷ is not closed under contexts.
Example 16. Let be the arity assignment with and .
(a) Assume . As holds, follows by 4. However, does not hold as follows by 4.
(b) Assume . Then holds by 1. However, does not hold. In fact, 1 does not apply because neither nor holds.
Note that the right-hand side of is partial, while the left-hand side of is partial.
The example (a) is avoided by imposing maximality of @ on the precedence. We address (b) by a technique akin to -saturation [15].
Definition 17. The -restriction of is recursively defined as follows: if holds, and when is partial additionally holds. Here is a fresh variable not in .
If with is partial, by definition if and only if and for all , where are distinct fresh variables not occurring in . We can see that Example 16(b) does not go for : The inequality does not hold because does not.
The rest of the section is for proving that is closed under contexts and is a well-founded order if @ is maximum in the precedence. First, we prove a key lemma using the assumption.
Lemma 18. Suppose @ is maximum in the precedence. If a term of the form st is full then @st ▷ st.
Proof. Suppose is full, where with . We show that @ is derived by 3. As @ is maximum, @ holds. It remains to show . If then . If then 1 derives for all . Thus, .
When is partial, demands and for some variable not in . Due to the next property, is equivalent to .
Lemma 19. If then .
We show that with a fresh variable is equivalent to for all terms . Although is not closed under substitutions (see Examples 9 and 29), it is closed under head-preserving substitutions. For a term we define
Variables in are called head variables [1]. We say that a substitution is head-preserving for if for all . For example, for (map ). So is head-preserving for , but is not.
Lemma 20. Suppose is head-preserving for and . If then .
Proof. The claim is shown by easy induction on the derivation of .
For a term with , we define as if , and 0 otherwise. If is partial then . This measure indicates the number of arguments to make non-partial.
Lemma 21. Suppose is head-preserving for and . If then .
N. Hirokawa et al.
Proof. Suppose with . We show by induction on . By Lemma 20 we have . If is not partial then we immediately conclude . Otherwise, we have to show for a variable not in . Since is partial and is head preserving for , the term must be partial too. So from we have for some variable . By Lemma 19 we have . Define the substitution as follows: and for other variables . Clearly, is head-preserving for and , and moreover, since occurs in neither nor , we obtain and . Finally, as , the induction hypothesis for yields . Hence, is concluded.
The technical lemma below allows us to conclude (without ) from (with ).
Lemma 22. Suppose @ is maximum in the precedence. Let u be a term. If then .
Proof. Suppose and with .
– If is partial then yields for some variable not in . According to Lemma 19, the variable is neither in . So the substitution is head-preserving for and . Therefore, is obtained by Lemma 20.
– If is not partial then is reifiable and not full. By 1 we can derive @ from and @ . Moreover, holds. Thus, @ follows by 3. If is not full, the claim follows by 4 and 5. Otherwise, according to Lemma 18, @ holds, so @ follows by transitivity (Lemma 12). Therefore, is derived by 5.
Lemma 23. Let u be a term. If then .
Proof. Suppose and with .
– If s is full then by 1 we can derive and for all . Moreover, holds. Thus, follows by 3.
– Otherwise, s and t are reifiable and not full. By 1 we can derive @ from and @ . Moreover, holds. Thus, @ follows by 3. Therefore, is obtained by 4 and 5.
As a consequence of Lemma 23, if (with ) then .
Lemma 24. Suppose @ is maximum in the precedence. Let C be a context. If then .
Proof. Easy induction on C with using Lemmata 22 and 23.
Now we are ready to show that is closed under contexts.
Theorem 25. Suppose @ is maximum in the precedence and C is a context. If then .
Proof. Suppose . We show by induction on . Suppose . By Lemma 24 we have . When is partial, we have to show for , where is a variable not in . As , the induction hypothesis applies.
Using Theorem 25, we can prove that the transitivity of (Lemma 12) carries over to .
Lemma 26. The relation is transitive, provided that @ is maximum in the precedence.
Proof. Suppose . We prove by induction on . The transitivity of (Lemma 12) yields . When is partial, we also have to show for some . By Theorem 25 the relations follow from the assumption. As we have , the induction hypothesis yields .
The well-foundedness of (Lemma 14) also carries over to as is a subrelation of .
Lemma 27. The relation is a well-founded order if is well-founded.
Hence, the following corollary is obtained.
Corollary 28. The relation is a well-founded order that is closed under contexts, if @ is maximum in the precedence and is well-founded.
5 Reduction Order
The relation is not closed under substitutions.
Example 29 (continued from Example 9). Although holds, does not hold for . As is not partial, we conclude that 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 grounding for a set of terms if is ground for all .
Definition 30. Let be an arity assignment and a precedence. The relation on terms is defined as follows: t if for all grounding substitutions for .
The relation is our applicative multiset path order (AMPO).
N. Hirokawa et al.
Theorem 31. Assume @ is maximum in the precedence. The relation >ampo is a reduction order if 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.
We need a method to check if holds for given terms and . We present a sufficient condition for based on absence of head variables in . A term is head variable free if . For example, the left-hand side of the rule map (map ) is head variable free, while the right-hand side is not because of the subterm .
Below, we assume that @ is maximum in the precedence.
Lemma 32. Let be a substitution. If and is head variable free then .
Proof. Suppose and is head variable free. We show by induction on the derivation of . Since is head variable free, can be written as with . So .
-
If is derived by 1 then for some . Since is head variable free, the subterm is head variable free too. By the induction hypothesis or stability of = we obtain . Therefore, is derived by 1.
-
If is derived by 2 then follows from the induction hypothesis and 2.
-
If is derived by 3 then follows from the induction hypothesis and 3.
-
If is derived by 4 then is full, is reifiable and not full, and . If is full then the inequalities by the induction hypothesis and Lemma 18. Thus, follows by transitivity (Lemma 12). Otherwise, the induction hypothesis yields . Thus, is derived by 4.
-
If is derived by 5 then is reifiable and not full, and . Because is head variable free, is also head variable free. So the induction hypothesis yields . Therefore, is derived by 5.
Lemma 33. Let be a substitution. If and is head variable free then .
Proof. Suppose and is head variable free. By induction on we show . As , by definition holds. Thus, follows by Lemma 32. If is not partial then we are done. When is partial, we have to show . Since is head variable free, is of the form with . So . As is partial, is partial too. Thus, follows from . Here is a variable not in , and thus is neither in by Lemma 19. Define the substitution as follows:
Here we also use the assumption to ensure existence of a ground term.
and for other variables . Since is head variable free and , the induction hypothesis yields . Hence, follows.
Theorem 34. Assume that @ is maximum in the precedence. If and is head variable free then .
Proof. Immediate from Lemma 33.
We relate Dershowitz's multiset path order and ours using currying. Consider an MPO and functional terms and . If we set (by a slight abuse of notation) for every -ary function , the curried terms and are full and head variable free. For the AMPO induced by and the corresponding precedence, we show the gracefulness property [5,7]:
Theorem 35. If then .
Proof. The relation is proved by straightforward induction on the derivation of . As is full, holds by definition. Consider an arbitrary grounding substitution for . Since is head variable free, is head-preserving for . So follows by Lemma 20. Hence, .
6 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 is well-founded and has @ as maximum. A left head variable free ATRS is terminating if for induced from an arity assignment and .
By examples, we demonstrate termination proving with our order.
Example 37. First, consider the left head variable free ATRS
append nil ys → ys append (cons x xs) ys → cons x (append xs ys) id x → x
map f nil → nil map f (cons x xs) → cons (f x) (map f xs)
map id → id map f (append xs ys) → append (map f xs) (map f ys)
which is a complete ATRS for the equational system in the introduction. (Here, the equation of map for cons x nil is generalized to a rule for cons x xs.) The termination is shown by taking , , and as well as . Note that map id id is equivalent to map id id and map id id , the latter of which uses map id.
N. Hirokawa et al.
Example 38. Next, consider the ATRS for the filter function:
The termination is shown by taking , , , and as well as .
Below is an example in which choice of arity assignment matters.
Example 39. Finally, consider the ATRS for the zip-with function:
The termination is shown by , and as well as . Note that the second rule cannot be ordered if we modify to . The reason is that with the modified assignment does not hold, as it requires the impossible multiset comparison . On the other hand, with the requirement changes to the possible one . Applying reification to the left-hand side is a key to handle the variable application .
Let us take a look at limitations of AMPOs, too.
Example 40. The one-rule ATRS f (f x) → f (g (f x)) is beyond the realm of our order, because the opposite orientation f (g (f x)) > ampo f (f x) follows from g x > ampo x. Similarly, the one-rule ATRS a → f f cannot be handled by our order: If α(f) = 0 then f f > ampo a holds. Otherwise, we do not have a > 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 to the ATRS, the termination is no longer shown by AMPO: To orient it, the precedence must satisfy mapid ↘ @, 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. 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.
The full experimental data, including those of LPO, EPO, and uncurrying (see Section 7), are available at https://www.jaist.ac.jp/~hirokawa/26ijcar/.
7 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 in which no variable occurs more in than in . 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 , and then and are incomparable with and also with . 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
and the uncurrying rules:
The termination of the above TRS is shown by the multiset path order with the precedence ○ ~ map ↘ append ↘ id ↘ cons ↘ nil and for all function symbol and its indexed copies . Here ○ being a maximum is used for orienting the uncurrying rules. If we identify ○ with @ and each indexed copy with the original symbol , 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 consid-
N. Hirokawa et al.
ered 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 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.
References
-
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.
-
Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press (1998). https://doi.org/10.1017/CB09781139172752
-
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)
-
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
-
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
-
Bentkamp, A.: The embedding path order for lambda-free higher-order terms. Journal of Applied Logics 8(10), 2447–2470 (2021)
-
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-54458-7_27
-
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
-
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
-
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
-
Dershowitz, N.: Orderings for term-rewriting systems. Theoretical Computer Science 17, 279–301 (1982). https://doi.org/10.1016/0304-3975(82)90026-3
-
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
-
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
-
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
-
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
-
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
-
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
-
Kamin, S., Lévy, J.: Two generalizations of the recursive path ordering. Tech. rep., University of Illinois (1980), unpublished manuscript.
-
Kennaway, R., Klop, J., Sleep, R., de Fries, F.J.: Comparing curried and uncurried rewriting. Journal of Symbolic Computation 21(1), 15–39 (1998). https://doi.org/10.1006/jsco.1996.0002
-
Knuth, D.E., Bendix, P.B.: Simple word problems in universal algebras. In: Computational Problems in Abstract Algebra, pp. 263–297. Pergamon Press (1970)
-
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
-
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
-
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
-
Reddy, U.S.: Term rewriting induction. In: Proc. 10th International Conference on Automated Deduction. LNCS, vol. 449, pp. 162–177 (1990)
-
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-24364-6_17
-
Terese: Term Rewriting Systems. Cambridge University Press (2003)
-
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
N. Hirokawa et al.
-
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
-
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
A Omitted Proofs
Recall the statement of Lemma 19: If then .
Proof (of Lemma 19). Suppose . We show by induction on the derivation of .
-
If is derived by 1 then or for some . In the former case holds. In the latter case the induction hypothesis yields . So in either case follows.
-
If is derived by 2 then is of the form with and for all . By the induction hypothesis for all . Thus, the claim holds.
-
If is derived by 3 then is of the form with and . For every there exists an such that or holds. For the former case holds. For the latter case holds by the induction hypothesis. So in either case follows. Thus, the claim follows.
-
If is derived by 4 then . By the induction hypothesis holds. As , the claim follows.
-
If is derived by 5 then . By the induction hypothesis holds. As , the claim follows.
Recall the statement of Lemma 20: Suppose is head-preserving for and . If then .
Proof (of Lemma 20). Suppose . We show by induction on the derivation of . Note that is head-preserving for all subterms in and .
-
If is derived by 1 then or holds for some . In the former case holds trivially. In the latter case follows from the induction hypothesis. Therefore, is derived by 1.
-
If is derived by 2 then is a full term with and , and for all . By the induction hypothesis for all . Therefore, is derived by 2.
-
If is derived by 3 then the proof is analogous to the last case.
-
If is derived by 4 then is reifiable and not full, and . As is head-preserving for , the instance is reifiable and not full. So the claim is immediate from the induction hypothesis.
-
If 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 be a finite ATRS. The applicative arity of a constant is defined as follows [15]:
N. Hirokawa et al.
Here consists of all subterms occurring in and max is assumed to be 0. We write for the set and is reifiable}. Given a rule , the derivation of uses terms in only. We define the arity assignment as .
Lemma 42. A term in is full with respect to if and only if it is full with respect to .
Proof. Consider a term in of the form with . If is full with respect to then . So we obtain . Thus, is full with respect to . Conversely, if is full with respect to then , from which follows. Thus, , and therefore is full with respect to .
Therefore, in any derivation of for fullness with respect to is indistinguishable from fullness with respect to . Since the only role of an arity assignment in Definition 7 is to determine fullness of terms, with carries over to with .
Lemma 43. Let be an arity assignment and let .
(1) If with respect to then with respect to .
(2) If with respect to then with respect to .
(3) If with respect to then with respect to .
Hence, if with respect to then with respect to .
Proof. The first claim is shown by straightforward induction on the derivation of 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 and a precedence > that satisfy , one may assume for all . So existence of a suitable arity assignment and precedence can be found by enumeration.
Theorem 44. Given a finite LATRS , whether holds for some arity assignment and precedence is decidable.