Abstract 1 Introduction 2 Preliminaries 3 The Transformation of Call-By-Value Systems 4 Static Dependency Pairs and Chains 5 The Innermost DP Framework 6 Universal Computability with Usable Rules 7 Implementation and Evaluation 8 Related Work 9 Conclusion and Future Work References Appendix A Full Proofs

An Innermost DP Framework for Constrained Higher-Order Rewriting

Carsten Fuhs ORCID Birkbeck, University of London, UK Liye Guo ORCID Radboud University, Nijmegen, The Netherlands Cynthia Kop ORCID Radboud University, Nijmegen, The Netherlands
Abstract

Logically constrained simply-typed term rewriting systems (LCSTRSs) are a higher-order formalism for program analysis with support for primitive data types. The termination problem of LCSTRSs has been studied so far in the setting of full rewriting. This paper modifies the higher-order constrained dependency pair framework to prove innermost termination, which corresponds to the termination of programs under call by value. We also show that the notion of universal computability with respect to innermost rewriting can be effectively handled in the modified, innermost framework, which lays the foundation for open-world termination analysis of programs under call by value via LCSTRSs.

Keywords and phrases:
Higher-order term rewriting, constrained rewriting, innermost termination, call by value, open-world analysis, dependency pairs
Funding:
Liye Guo: NWO VI.Vidi.193.075, project “CHORPE”.
Cynthia Kop: NWO VI.Vidi.193.075, project “CHORPE”.
Copyright and License:
[Uncaptioned image] © Carsten Fuhs, Liye Guo, and Cynthia Kop; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation → Equational logic and rewriting
; Theory of computation → Logic and verification
Supplementary Material:
Software  (Source Code): https://github.com/hezzel/cora [27]
Software  (Source Code): https://zenodo.org/records/15318964 [28]
Acknowledgements:
We thank the reviewers for helpful comments that allowed us to improve the presentation.
Editors:
Maribel Fernández

1 Introduction

In the study of term rewriting, termination has been an active area of research for decades. Hundreds of different termination techniques have been developed, along with a variety of (fully automatic) termination analyzers that compete against each other in an annual competition [6]. Many of those techniques have been adapted to different styles of term rewriting (e.g., context-sensitive, relative, constrained and higher-order).

In a recent work [22], we have introduced logically constrained simply-typed term rewriting systems (LCSTRSs): a variant of term rewriting that incorporates both higher-order terms and primitive data types such as integers and bit vectors. This formalism is proposed to be a stepping stone toward functional programming languages: by adapting analysis techniques from traditional term rewriting to LCSTRSs, we obtain many of the ingredients needed by the analysis of functional programs, without limiting ourselves to a particular language.

Our long-term goal is to use LCSTRSs as an intermediate verification language in a two-step process to prove correctness properties (e.g., termination, reachability and equivalence) of a program P written in a real-world programming language with higher-order features (e.g., OCaml and Scala): (1) soundly translate P to an LCSTRS ℛP (i.e., if ℛP is, say, terminating, then so is P), and (2) analyze ℛP. This approach has been successfully applied across paradigms to multiple languages, such as Prolog [44, 17], Haskell [16], Java [39] and C [14], via various flavors of term rewriting. We consider LCSTRSs a highly suitable intermediate language that allows for a direct representation of many programming language features. We particularly study termination, both for its own relevance, and due to the fact that it allows the reduction relation to be used as a decreasing measure in induction, which is a powerful aid to proving many other properties.

Most modern termination techniques for term rewriting are defined within the dependency pair (DP) framework [3, 18], which essentially studies groups of recursive function calls. In [21], a higher-order variant of this framework [35, 36, 34, 13] has been adapted to LCSTRSs, and its usefulness in open-world termination analysis has also been established through the notion of universal computability. However, this method still faces limitations: many commonly used DP processors (termination techniques within the DP framework) have not yet been extended to the higher-order and constrained setting, and whereas the first-order DP framework can deal with both full rewriting and innermost rewriting, most higher-order versions – including the one for LCSTRSs – only concern full rewriting. The incapability to handle innermost rewriting is particularly unfortunate since many functional languages use call-by-value evaluation, which largely corresponds to innermost rewriting.

In this paper, we define the first innermost DP framework for LCSTRSs. We shall present DP processors that explicitly benefit from innermost or call-by-value rewriting.

Contributions.

We start in Section 2 with the preliminaries on LCSTRSs and the notion of computability, which is fundamental to static dependency pairs. Then this paper’s contributions follow:

  • ■

    In Section 3, we discuss the innermost and the call-by-value strategies, and present a transformation that allows us to better utilize the call-by-value setting.

  • ■

    In Section 4, we recall the notion of a static dependency pair for LCSTRSs [21], and extend it by introducing call-by-value dependency pairs and innermost chains.

  • ■

    In Section 5, we present an innermost DP framework, which can be used to prove innermost (and call-by-value) termination through the use of various DP processors. We first review three classes of existing DP processors defined for full rewriting, and see how they adapt to the innermost setting. Then we define three more, specifically for the innermost DP framework:

    • –

      In Section 5.2, following the idea of chaining from first-order rewriting with integer constraints [10, 11, 15], we propose a class of DP processors that merge call-by-value dependency pairs. These DP processors can be particularly useful in the analysis of automatically generated systems, which often give rise to a large body of dependency pairs representing intermediate steps of computation.

    • –

      In Section 5.3, we extend the idea of usable rules [3, 19, 24]. While this idea has been applied to higher-order rewriting [2, 40], logical constraints still pose challenges. In the innermost setting, we are able to define this class of DP processors in their most powerful form, which permanently removes rewrite rules from a DP problem.

    • –

      In Section 5.4, we show how usable rules with respect to an argument filtering may be defined, and how this technique makes first-order reduction pairs applicable. This way a large number of first-order techniques can be employed for higher-order termination without a higher-order modification; to be applied to LCSTRSs, those reduction pairs only need to adapt to logical constraints.

  • ■

    In Section 6, we discuss the notion of universal computability [21] with respect to innermost rewriting. We will see that the employment of usable rules significantly increases the potential of the innermost DP framework to analyze universal computability: now we can use fully-fledged reduction pair processors for open-world termination analysis, and thereby harness one of the main benefits of the DP framework in this practical setting.

  • ■

    We have implemented all the results in our open-source analyzer Cora. The implementation and the evaluation thereof are described in Section 7.

2 Preliminaries

This section collects the preliminaries from the literature. First, we recall the definition of an LCSTRS [22].111In contrast to [22] and following [21], we assume that ℓ is a pattern in every rewrite rule ℓ→r⁢[φ]. For notational convenience, we also assume that Var⁡(r)∖Var⁡(ℓ)⊆Var⁡(φ), which can be guaranteed by a simple transformation and is also adopted in the second half of [22]. Then, we recollect from [13] the definition of computability (with accessibility), particularly under the strategies. We borrow several definitions from the phrasing in [21].

2.1 Logically Constrained STRSs

Terms Modulo Theories.

Given a non-empty set 𝒮 of sorts (or base types), the set 𝒯 of (simple) types over 𝒮 is generated by the grammar 𝒯⩴𝒮∣(𝒯→𝒯). Right-associativity is assigned to → so we can omit some parentheses. Given disjoint sets ℱ and 𝒱, whose elements we call function symbols and variables, respectively, the set 𝔗 of pre-terms over ℱ and 𝒱 is generated by the grammar 𝔗⩴ℱ⁢∣𝒱∣⁢(𝔗⁢𝔗). Left-associativity is assigned to the juxtaposition operation, called application, so for instance t0⁢t1⁢t2 stands for ((t0⁢t1)⁢t2).

We assume every function symbol and variable is assigned a unique type. Typing works as expected: if pre-terms t0 and t1 have types A→B and A, respectively, t0⁢t1 has type B. The set T⁢(ℱ,𝒱) of terms over ℱ and 𝒱 consists of pre-terms that have a type. We write t:A if a term t has type A. We assume there are infinitely many variables of each type.

The set Var⁡(t) of variables in t∈T⁢(ℱ,𝒱) is defined by Var⁡(𝖿)=∅ for 𝖿∈ℱ, Var⁡(x)={x} for x∈𝒱 and Var⁡(t0⁢t1)=Var⁡(t0)∪Var⁡(t1). A term t is called ground if Var⁡(t)=∅.

For constrained rewriting, we make further assumptions. First, we assume there is a distinguished subset 𝒮ϑ of 𝒮, called the set of theory sorts. The grammar 𝒯ϑ⩴𝒮ϑ∣(𝒮ϑ→𝒯ϑ) generates the set 𝒯ϑ of theory types over 𝒮ϑ. Note that a theory type is essentially a non-empty list of theory sorts. Next, we assume there is a distinguished subset ℱϑ of ℱ, called the set of theory symbols, and the type of every theory symbol is in 𝒯ϑ, which means the type of any argument passed to a theory symbol is a theory sort. Theory symbols whose type is a theory sort are called theory values.222Such theory symbols are simply called values in [22]. In this paper, we call them differently so that they are not to be confused with term values as in call by value. Elements of T⁢(ℱϑ,𝒱) are called theory terms.

Theory symbols are interpreted in an underlying theory: given an 𝒮ϑ-indexed family of sets (𝔛A)A∈𝒮ϑ, we extend it to a 𝒯ϑ-indexed family by letting 𝔛A→B be the set of mappings from 𝔛A to 𝔛B; an interpretation of theory symbols is a 𝒯ϑ-indexed family of mappings ([[⋅]]A)A∈𝒯ϑ where [[⋅]]A assigns to each theory symbol of type A an element of 𝔛A and is bijective if A∈𝒮ϑ. Given an interpretation of theory symbols ([[⋅]]A)A∈𝒯ϑ, we extend each indexed mapping [[⋅]]B to one that assigns to each ground theory term of type B an element of 𝔛B by letting [[t0⁢t1]]B be [[t0]]A→B⁢([[t1]]A). We write just [[⋅]] when the type can be deduced.

Example 1.

Let 𝒮ϑ be {𝗂𝗇𝗍}. Then 𝗂𝗇𝗍→𝗂𝗇𝗍→𝗂𝗇𝗍 is a theory type over 𝒮ϑ while (𝗂𝗇𝗍→𝗂𝗇𝗍)→𝗂𝗇𝗍 is not. Let ℱϑ be {−}∪ℤ where −:𝗂𝗇𝗍→𝗂𝗇𝗍→𝗂𝗇𝗍 and n:𝗂𝗇𝗍 for all n∈ℤ. The theory values are the elements of ℤ. Let 𝔛𝗂𝗇𝗍 be ℤ, [[⋅]]𝗂𝗇𝗍 be the identity mapping and [[−]] be the mapping λ⁢m.λ⁢n.m−n. The interpretation of (−)⁢ 1 is the mapping λ⁢n⁢. 1−n (note that functions in our setting are curried).

Type-preserving mappings from 𝒱 to T⁢(ℱ,𝒱) are called substitutions. The domain of a substitution σ is the set dom⁡(σ)={x∈𝒱|σ⁢(x)≠x}. Let [x1≔t1,…,xn≔tn] denote the substitution σ such that dom⁡(σ)⊆{x1,…,xn} and σ⁢(xi)=ti for all i. Every substitution σ extends to a type-preserving mapping σ¯ from T⁢(ℱ,𝒱) to T⁢(ℱ,𝒱). We write t⁢σ for σ¯⁢(t) and define it as follows: 𝖿⁢σ=𝖿 for 𝖿∈ℱ, x⁢σ=σ⁢(x) for x∈𝒱 and (t0⁢t1)⁢σ=(t0⁢σ)⁢(t1⁢σ).

A context is a term containing a hole. That is, if we let □ be a special symbol and assign to it a type A, a context C⁢[] is an element of T⁢(ℱ,𝒱∪{□}) such that □ occurs in C⁢[] exactly once. Given a term t:A, let C⁢[t] denote the term produced by replacing □ in C⁢[] with t.

A term t is called a (maximally applied) subterm of a term s, written as s⁢⊵⁢t, if either s=t, s=s0⁢s1 where s1⁢⊵⁢t, or s=s0⁢s1 where s0⁢⊵⁢t and s0≠t; i.e., s=C⁢[t] for C⁢[] that is not of form C′⁢[□⁢t1]. We write s⁢⊳⁢t and call t a proper subterm of s if s⁢⊵⁢t and s≠t.

Constrained Rewriting.

Constrained rewriting requires the theory sort 𝖻𝗈𝗈𝗅: we henceforth assume that 𝖻𝗈𝗈𝗅∈𝒮ϑ, {𝔣,𝔱}⊆ℱϑ, 𝔛𝖻𝗈𝗈𝗅={ 0,1}, [[𝔣]]𝖻𝗈𝗈𝗅=0 and [[𝔱]]𝖻𝗈𝗈𝗅=1. Moreover, we require that ℱϑ includes symbols ∧:𝖻𝗈𝗈𝗅→𝖻𝗈𝗈𝗅→𝖻𝗈𝗈𝗅, and for each sort A∈𝒮ϑ also a symbol ≡A:A→A→𝖻𝗈𝗈𝗅, interpreted respectively as conjunction and equality operators.

A logical constraint is a theory term φ such that φ has type 𝖻𝗈𝗈𝗅 and the type of each variable in Var⁡(φ) is a theory sort. A (constrained) rewrite rule is a triple ℓ→r⁢[φ] where ℓ and r are terms which have the same type, φ is a logical constraint, Var⁡(r)∖Var⁡(ℓ)⊆Var⁡(φ), and ℓ is a pattern that takes the form 𝖿⁢t1⁢⋯⁢tn for some 𝖿∈ℱ and contains at least one function symbol in ℱ∖ℱϑ. Here a pattern is a term whose subterms are either 𝖿⁢t1⁢⋯⁢tn for some 𝖿∈ℱ or a variable.333As usual in term rewriting, we do not require that each variable occurs at most once in a pattern. A substitution σ is said to respect a logical constraint φ if σ⁢(x) is a theory value for all x∈Var⁡(φ) and [[φ⁢σ]]=1; σ respects the rule ℓ→r⁢[φ] if it respects φ.

A logically constrained simply-typed term rewriting system (LCSTRS) collects the above data – 𝒮, 𝒮ϑ, ℱ, ℱϑ, 𝒱, (𝔛A) and [[⋅]] – along with a set ℛ of rewrite rules. We usually let ℛ alone stand for the system. The set ℛ induces the rewrite relation →ℛ over terms: t→ℛt′ if and only if there exists a context C⁢[] such that one of the following holds:

  1. (1)

    t=C⁢[ℓ⁢σ] and t′=C⁢[r⁢σ] for some ℓ→r⁢[φ]∈ℛ and substitution σ which respects φ, or

  2. (2)

    t=C⁢[𝖿⁢v1⁢⋯⁢vn] and t′=C⁢[v′] for some theory symbol 𝖿 and some theory values v1,…,vn,v′ with n>0 and [[𝖿⁢v1⁢⋯⁢vn]]=[[v′]].

If t→ℛt′ due to the second condition, we also write t→κt′ and call it a calculation step. Theory symbols that are not a theory value are called calculation symbols. Let t↓κ denote the (unique) κ-normal form of t, i.e., the term t′ such that t→κ∗t′ and t′↛κt′′ for any t′′. For example, (𝖿(7∗(3∗2)))↓κ=𝖿 42 if 𝖿 is not a calculation symbol, or if 𝖿:𝗂𝗇𝗍→A→B.

A term t is in normal form if there is no term t′ such that t→ℛt′. Given an LCSTRS ℛ, the set 𝒩⁢ℱ⁢(ℛ) contains all terms that are in normal form with respect to →ℛ.

Given an LCSTRS ℛ, 𝖿 is called a defined symbol if there is at least one rewrite rule of the form 𝖿⁢t1⁢⋯⁢tn→r⁢[φ]. Let 𝒟 denote the set of defined symbols. Theory values and function symbols in ℱ∖(ℱϑ∪𝒟) are called constructors.

Example 2.

Consider the following LCSTRS ℛ, where 𝗀𝖼𝖽𝗅𝗂𝗌𝗍:𝗂𝗇𝗍𝗅𝗂𝗌𝗍→𝗂𝗇𝗍, 𝖿𝗈𝗅𝖽:(𝗂𝗇𝗍→𝗂𝗇𝗍→𝗂𝗇𝗍)→𝗂𝗇𝗍→𝗂𝗇𝗍𝗅𝗂𝗌𝗍→𝗂𝗇𝗍 and 𝗀𝖼𝖽:𝗂𝗇𝗍→𝗂𝗇𝗍→𝗂𝗇𝗍:

We use infix notation for some binary operators, and omit logical constraints that are 𝔱. Here is a rewrite sequence: 𝗀𝖼𝖽𝗅𝗂𝗌𝗍⁢(𝖼𝗈𝗇𝗌⁢(1+1)⁢𝗇𝗂𝗅)→ℛ𝖿𝗈𝗅𝖽⁢𝗀𝖼𝖽⁢ 0⁢(𝖼𝗈𝗇𝗌⁢(1+1)⁢𝗇𝗂𝗅)→ℛ𝗀𝖼𝖽⁢(1+1)⁢(𝖿𝗈𝗅𝖽⁢𝗀𝖼𝖽⁢ 0⁢𝗇𝗂𝗅)→ℛ𝗀𝖼𝖽⁢(1+1)⁢ 0→κ𝗀𝖼𝖽⁢ 2 0→ℛ2.

Innermost Rewriting.

The innermost rewrite relation →iℛ requires all the proper subterms of a redex to be in normal form: t→iℛt′ if and only if either (1) there exist a context C⁢[], a substitution σ and a rewrite rule ℓ→r⁢[φ]∈ℛ such that t=C⁢[ℓ⁢σ], s↛ℛs′ for any proper subterm s of ℓ⁢σ and any s′, t′=C⁢[r⁢σ] and σ respects φ, or (2) t→κt′.

Similarly, for an LCSTRS 𝒬 we define the relation →𝒬ℛ as reduction using →ℛ where all proper subterms of a redex are in →𝒬-normal form: t→𝒬ℛt′ if and only if either (1) there exist C⁢[], σ and ℓ→r⁢[φ]∈ℛ such that t=C⁢[ℓ⁢σ], s↛𝒬s′ for any proper subterm s of ℓ⁢σ and any s′, t′=C⁢[r⁢σ] and σ respects φ, or (2) t→κt′. Note that →iℛ is the same as →ℛℛ.

Call-By-Value Rewriting.

We may further restrict a redex by requiring each proper subterm to be a ground term value. Here a term value is either a variable or a term 𝖿⁢v1⁢⋯⁢vn where 𝖿 is a function symbol, vi is a term value for all i, and (1) if there is a rule 𝖿⁢t1⁢⋯⁢tk→r⁢[φ]∈ℛ, then k>n; (2) if 𝖿 is a calculation symbol, then it takes at least n+1 arguments (i.e., 𝖿:A1→⋯→An+1→B). In this paper, we will typically refer to term values as just values. By definition, all theory values are values, and all values are in normal form.

The definition of the call-by-value rewrite relation →vℛ follows the pattern of →iℛ: t→vℛt′ if and only if either (1) there exist a context C⁢[], a substitution σ and a rewrite rule ℓ→r⁢[φ]∈ℛ such that t=C⁢[ℓ⁢σ], s is a ground value for each proper subterm s of ℓ⁢σ, t′=C⁢[r⁢σ] and σ respects φ, or (2) t→κt′.

Example 3.

The rewrite sequence in Example 2 is not innermost (and therefore not call-by-value). An example of a call-by-value rewrite sequence is:

Note that the redex in the first step is 𝗀𝖼𝖽𝗅𝗂𝗌𝗍, which does not have 1+1 as subterm.

Example 4.

Consider the LCSTRS ℛ={𝗁𝖽⁢(𝖼𝗈𝗇𝗌⁢x⁢l)→x,𝗍𝗅⁢(𝖼𝗈𝗇𝗌⁢x⁢l)→l}. Then the rewrite step 𝗁𝖽⁢(𝖼𝗈𝗇𝗌⁢ 42⁢(𝗍𝗅⁢𝗇𝗂𝗅))→iℛ42 is an innermost step, but not a call-by-value step. The reason is that the subterm 𝗍𝗅⁢𝗇𝗂𝗅 of the redex is in normal form, but not a value: innermost rewriting also allows for rewriting above function calls that are not defined on the given arguments; in a language like OCaml, the computation would abort with an error.

2.2 Accessibility and Computability

Accessibility.

Assume given a sort ordering – a quasi-ordering ≿ over 𝒮 whose strict part ≻⁣=⁣≿⁣∖⁣≾ is well-founded. We inductively define two relations ≿+ and ≻− over 𝒮 and 𝒯: for a sort A and a type B=B1→⋯→Bn→C where C is a sort and n≥0, A≿+B if A≿C and A≻−Bi for all i, and A≻−B if A≻C and A≿+Bi for all i.

Given a function symbol 𝖿:A1→⋯→An→B where B is a sort, the set Acc⁡(𝖿) of the accessible argument positions of 𝖿 is defined as {i|B≿+Ai}. A term t is called an accessible subterm of a term s, written as s⁢⊵acc⁢t, if either s=t, or s=𝖿⁢s1⁢⋯⁢sn for some 𝖿∈ℱ and there exists k∈Acc⁡(𝖿) such that sk⁢⊵acc⁢t. An LCSTRS ℛ is called accessible function passing (AFP) if there exists a sort ordering such that for all 𝖿⁢s1⁢⋯⁢sn→r⁢[φ]∈ℛ where 𝖿∈ℱ and x∈Var⁡(r)∖Var⁡(φ), there exists k such that sk⁢⊵acc⁢x.

Example 5.

An LCSTRS ℛ is AFP (with ≿ equating all the sorts) if for all 𝖿⁢s1⁢⋯⁢sn→r⁢[φ]∈ℛ where 𝖿∈ℱ and i∈{ 1,…,n}, the type of each proper subterm of si is a sort. This is typical for many common examples of higher-order programs manipulating first-order data; e.g., integer recursion or list folding, mapping or filtering; hence, Example 2 is AFP.

Consider {𝖼𝗈𝗆𝗉𝗅𝗌𝗍⁢𝖿𝗇𝗂𝗅⁢x→x,𝖼𝗈𝗆𝗉𝗅𝗌𝗍⁢(𝖿𝖼𝗈𝗇𝗌⁢f⁢l)⁢x→𝖼𝗈𝗆𝗉𝗅𝗌𝗍⁢l⁢(f⁢x)}, where 𝖼𝗈𝗆𝗉𝗅𝗌𝗍:𝖿𝗎𝗇𝗅𝗂𝗌𝗍→𝗂𝗇𝗍→𝗂𝗇𝗍 composes a list of functions. This system is AFP with 𝖿𝗎𝗇𝗅𝗂𝗌𝗍≻𝗂𝗇𝗍.

Consider {𝖺𝗉𝗉⁢(𝗅𝖺𝗆⁢f)→f} where 𝖺𝗉𝗉:𝗈→𝗈→𝗈 and 𝗅𝖺𝗆:(𝗈→𝗈)→𝗈. This system encodes the untyped lambda-calculus, with 𝖺𝗉𝗉 serving as the application symbol and 𝗅𝖺𝗆 as a wrapper for abstractions. It is not AFP since 𝗈≻𝗈 cannot be true.

Computability.

A term is called neutral if it takes the form x⁢t1⁢⋯⁢tn for some variable x. A set of reducibility candidates, or an RC-set, for a type-preserving relation → over terms – which may stand for →ℛ, →iℛ, but also →vℛ – is an 𝒮-indexed family of sets (IA)A∈𝒮 (let I denote ⋃AIA) satisfying the following conditions:

  1. (1)

    Each element of IA is a terminating (with respect to →) term of type A.

  2. (2)

    Given terms s and t such that s→t, if s is in IA, so is t.

  3. (3)

    Given a neutral term s, if t is in IA for all t such that s→t, so is s.

A term t0 is called I-computable if either the type of t0 is a sort and t0∈I, or the type of t0 is A→B and t0⁢t1 is I-computable for all I-computable t1:A.

We are interested in a specific RC-set ℂ:

Theorem 6 (see [13]).

Given a sort ordering and an RC-set I for →, let ⇛I be the relation over terms such that s⇛It if and only if both s and t have a base type, s=𝖿⁢s1⁢⋯⁢sm for some function symbol 𝖿, t=sk⁢t1⁢⋯⁢tn for some k∈Acc⁡(𝖿) and ti is I-computable for all i.

Given an LCSTRS ℛ with a sort ordering, there exists an RC-set ℂ for → such that t∈ℂA if and only if t:A is terminating with respect to →⁣∪⁣⇛ℂ, and for all t′ such that t→∗t′, if t′=𝖿⁢t1⁢⋯⁢tn for some function symbol 𝖿, ti is ℂ-computable for all i∈Acc⁡(𝖿).

ℂ-computability with respect to the innermost reduction relation →iℛ is at the heart of the soundness proofs for the DP framework defined in this paper (Theorems 14 and 36).

3 The Transformation of Call-By-Value Systems

Let us reflect on the shape of call-by-value LCSTRSs. First, we observe that if a pattern t is not a value, neither are its instances, i.e., t⁢σ is not a value for any substitution σ. Hence, under call by value, a rewrite rule ℓ→r⁢[φ] where not all the proper subterms of ℓ are values is never applicable, and we can exclude such rewrite rules without loss of generality.

Second, programming languages hardly allow the addition of constructors to pre-defined (in particular, primitive) data types, such as integers. Given an LCSTRS, in practice, we would also expect, for example, that integer literals are the only constructors for 𝗂𝗇𝗍. Formally, we call a theory sort B inextensible if every function symbol 𝖿:A1→⋯→An→B is a theory symbol or a defined symbol. We do not require that all theory sorts are inextensible; rather, we assume that for each rewrite rule ℓ→r⁢[φ], all the variables in Var⁡(ℓ) whose type is an inextensible theory sort are also in Var⁡(φ). We can do so without loss of generality because such a variable can only be instantiated to a theory value under call by value. We only consider inextensible theory sorts in examples below.

We write φ,x1,…,xn for φ∧x1≡x1∧⋯∧xn≡xn, and conclude the above discussion:

Lemma 7.

We apply the below transformation to an LCSTRS ℛ and let ℛ′ be the outcome.

  1. (1)

    Remove all ℓ→r⁢[φ] where ℓ has a proper subterm that is not a value.

  2. (2)

    Replace all remaining ℓ→r⁢[φ] with ℓ→r⁢[φ,x1,…,xn] where x1,…,xn are the variables in Var⁡(ℓ)∖Var⁡(φ) whose type is an inextensible theory sort.

Then t→vℛt′ if and only if t→vℛ′t′ for all t and t′.

Example 8.

The LCSTRS ℛ from Example 2 is transformed as follows: (1) no rewrite rules are removed, and (2) four rewrite rules are replaced by the ones below.

𝖿𝗈𝗅𝖽⁢f⁢y⁢𝗇𝗂𝗅 →y [𝔱,y] 𝗀𝖼𝖽⁢m⁢n →𝗀𝖼𝖽⁢(−m)⁢n [m<0,n]
𝖿𝗈𝗅𝖽⁢f⁢y⁢(𝖼𝗈𝗇𝗌⁢x⁢l) →f⁢x⁢(𝖿𝗈𝗅𝖽⁢f⁢y⁢l) [𝔱,x,y] 𝗀𝖼𝖽⁢m⁢n →𝗀𝖼𝖽⁢m⁢(−n) [n<0,m]

We will refer to the result of the transformation as ℛ𝗀𝖼𝖽.

We are particularly interested in call-by-value termination. However, innermost termination is more commonly considered in the term rewriting community, and has been studied extensively for first-order term rewriting. In practice, its difference from call-by-value termination is often irrelevant, and their respective techniques are generally similar. Since all values are in normal form, →vℛ is terminating if →iℛ′ is. Hence, we shall formulate our results in terms of innermost rewriting, for the sake of more generality and less bookkeeping.

4 Static Dependency Pairs and Chains

The dependency pair method [3] analyzes the recursive structure of function calls. Its variants are at the heart of most modern automatic termination analyzers for various styles of term rewriting. Static dependency pairs [35, 13], a higher-order generalization of the method, are adapted to LCSTRSs in [21]. Now we extend this adaptation for the evaluation strategies.

First, we recall a notation:

Definition 9.

Given an LCSTRS ℛ, let ℱ♯ be ℱ⊎{𝖿♯|𝖿∈𝒟} where 𝒟 is the set of defined symbols in ℛ and 𝖿♯ is a fresh function symbol for all 𝖿. Let 𝖽𝗉 be a fresh sort, and for each defined symbol 𝖿:A1→⋯→An→B where B∈𝒮, we assign 𝖿♯:A1→⋯→An→𝖽𝗉. Given a term t=𝖿⁢t1⁢⋯⁢tn∈T⁢(ℱ,𝒱) where 𝖿∈𝒟, let t♯ denote 𝖿♯⁢t1⁢⋯⁢tn∈T⁢(ℱ♯,𝒱).

The definition of a static dependency pair is adapted as follows:

Definition 10.

A static dependency pair (SDP) is a triple s♯⇒t♯⁢[φ] where s♯ and t♯ are terms of type 𝖽𝗉, and φ is a logical constraint. This SDP is considered call-by-value if all the proper subterms of s♯ are values. For a rewrite rule ℓ→r⁢[φ], let SDP⁡(ℓ→r⁢[φ]) denote the set of SDPs of form ℓ♯⁢x1⁢⋯⁢xm⇒𝗀♯⁢t1⁢⋯⁢tq⁢yq+1⁢⋯⁢yn⁢[φ] such that

  1. (1)

    ℓ♯:A1→⋯→Am→𝖽𝗉 with fresh variables x1,…,xm,

  2. (2)

    r⁢x1⁢⋯⁢xm⁢⊵⁢𝗀⁢t1⁢⋯⁢tq for 𝗀∈𝒟, and

  3. (3)

    𝗀♯:B1→⋯→Bn→𝖽𝗉 with fresh variables yq+1,…,yn.

Let SDP⁡(ℛ) be ⋃ℓ→r⁢[φ]∈ℛSDP⁡(ℓ→r⁢[φ]). For s♯⇒t♯⁢[𝔱], we just write s♯⇒t♯.

Compared to the quadruple definition in [21], this definition omits the L component, because here its bookkeeping role can be assumed by the logical constraint.

Intuitively, every dependency pair in SDP⁡(ℛ) represents a function call in ℛ. If ℛ is non-terminating, there must be an infinite “chain” of function calls whose arguments are terminating (in other words, the chain is “minimal”: all the proper subterms are terminating). To distinguish the head symbols of those minimal potentially non-terminating terms, we write 𝖿♯ instead of 𝖿 at head positions in SDPs. Then calls to a defined symbol 𝖿 (the original) can be assumed to terminate, which is shown separately via 𝖿♯. And the non-existence of an infinite chain starting from a call to any 𝖿♯ in SDP⁡(ℛ) implies the termination of ℛ.

Example 11.

Following Example 8, SDP⁡(ℛ𝗀𝖼𝖽) consists of the following SDPs:

  1. (1)

    𝗀𝖼𝖽𝗅𝗂𝗌𝗍♯⁢l′⇒𝗀𝖼𝖽♯⁢m′⁢n′

  2. (2)

    𝗀𝖼𝖽𝗅𝗂𝗌𝗍♯⁢l′⇒𝖿𝗈𝗅𝖽♯⁢𝗀𝖼𝖽⁢ 0⁢l′

  3. (3)

    𝗀𝖼𝖽♯⁢m⁢n⇒𝗀𝖼𝖽♯⁢(−m)⁢n⁢[m<0,n]

  4. (4)

    𝗀𝖼𝖽♯⁢m⁢n⇒𝗀𝖼𝖽♯⁢m⁢(−n)⁢[n<0,m]

  5. (5)

    𝗀𝖼𝖽♯⁢m⁢n⇒𝗀𝖼𝖽♯⁢n⁢(mmodn)⁢[m≥0∧n>0]

  6. (6)

    𝖿𝗈𝗅𝖽♯⁢f⁢y⁢(𝖼𝗈𝗇𝗌⁢x⁢l)⇒𝖿𝗈𝗅𝖽♯⁢f⁢y⁢l⁢[𝔱,x,y]

In this paper, a set ℛ of rewrite rules plays two roles: (1) it specifies how to rewrite arguments in SDPs, and (2) it determines which rewrite steps are innermost and which terms are values. In Sections 5 and 6, a given set ℛ in its first role may be modified (with rewrite rules removed). In this process, if we do not keep the original set, there can be unintended consequences for its second role. For example, consider ℛ={𝖿⁢x→r1,𝖺→r2}. Note that the first rewrite rule is not applicable to 𝖿⁢𝖺 with respect to innermost rewriting. Now if we remove the second rewrite rule from ℛ and consider the new set, the remaining rewrite rule will be applicable, and the term 𝖺 will be a value, which is generally an unwanted change.

Hence, we keep a copy of the original set ℛ of rewrite rules to faithfully determine which rewrite steps are innermost and which terms are values. Following [18, 41], we let 𝒬 denote this copy. In contrast to the literature, we consider 𝒬 fixed throughout the analysis of a given system.444A fixed set 𝒬 suffices in this paper because our DP processors may remove rewrite rules, but may not add new rewrite rules or change the signature (e.g., with semantic labeling [45]). Now we formalize the idea of a chain of function calls in the innermost setting:

Definition 12.

Given a set 𝒫 of SDPs and a set ℛ of rewrite rules, an innermost (𝒫,ℛ)-chain is a (finite or infinite) sequence (s0♯⇒t0♯⁢[φ0],σ0),(s1♯⇒t1♯⁢[φ1],σ1),… such that for all i, si♯⇒ti♯⁢[φi]∈𝒫, σi is a substitution which respects φi, si♯⁢σi is in normal form with respect to →𝒬, and ti−1♯⁢σi−1→𝒬ℛ∗si♯⁢σi if i>0.

Example 13.

Following Example 11, (1,[l′≔𝗇𝗂𝗅,m′≔24,n′≔18]),(5,[m≔24,n≔18]),(5,[m≔18,n≔6]) is an innermost (SDP⁡(ℛ𝗀𝖼𝖽),ℛ𝗀𝖼𝖽)-chain.

In the above definition, the requirement that si♯⁢σi is in normal form implies that σi⁢(x) is in normal form for all x∈Var⁡(si♯), including fresh variables such as l′ in SDP (1). Hence, the call-by-value (and therefore innermost) rewrite sequence in Example 3 does not directly translate to an innermost (SDP⁡(ℛ),ℛ)-chain. Nevertheless, we have the following result:

Theorem 14.

An AFP system ℛ is innermost (and therefore call-by-value) terminating if there exists no infinite innermost (SDP⁡(ℛ),ℛ)-chain.

Proof Idea.

The full proof is in Section A.2, and is very similar to its counterpart for termination with respect to full rewriting [21]: in a non-terminating LCSTRS, we can always identify a non-terminating base-type term t=𝖿⁢t1⁢⋯⁢tn such that all ti are ℂ-computable; and from an infinite reduction t→iℛt′→iℛt′′→iℛ… we can find s,u such that s=𝖿(t1↓ℛ)⋯(tn↓ℛ), (s♯,u♯) is an instance of a dependency pair, and u is again non-terminating with ℂ-computable arguments. The primary difference from [21] is the need to ensure all variables are instantiated to normal forms, which for the fresh variables discussed above means that we must choose the right normal form that still yields non-termination. ◀

5 The Innermost DP Framework

In this section, we modify the constrained DP framework [21] to prove innermost termination. The DP framework is a collection of DP processors, each of which represents a technique.

Definition 15.

A DP problem is a pair (𝒫,ℛ) where 𝒫 is a set of SDPs and ℛ is a set of rewrite rules. If no infinite innermost (𝒫,ℛ)-chain exists, (𝒫,ℛ) is called finite. A DP processor is a partial mapping which possibly assigns to a DP problem a set of DP problems. A DP processor ρ is called sound if (𝒫,ℛ) is finite whenever all the elements of ρ⁢(𝒫,ℛ) are.

Theorem 14 tells us that an AFP system ℛ is innermost terminating if (SDP⁡(ℛ),ℛ) is a finite DP problem. Given a collection of sound DP processors, we have the following procedure: (1) 𝒬≔ℛ, S≔{(SDP⁡(ℛ),ℛ)}; (2) while S contains a DP problem (𝒫,ℛ) to which some sound DP processor ρ is applicable, S≔(S∖{(𝒫,ℛ)})∪ρ⁢(𝒫,ℛ). If this procedure ends with S=∅, we can conclude that ℛ is innermost terminating.

5.1 Graph, Subterm Criterion and Integer Mapping Processors

Three classes of DP processors in [21] remain essentially unchanged in the innermost setting. Let us review their application to the system ℛ𝗀𝖼𝖽 from Example 8, which is discussed by [21] in the form of Example 2. First, we consider a graph approximation for (SDP⁡(ℛ𝗀𝖼𝖽),ℛ𝗀𝖼𝖽):

Definition 16.

For a DP problem (𝒫,ℛ), a graph approximation (G,θ) consists of a finite directed graph G and a mapping θ from 𝒫 to the vertices of G such that there is an edge from θ⁢(p0) to θ⁢(p1) whenever (p0,σ0),(p1,σ1) is an innermost (𝒫,ℛ)-chain for some σ0 and σ1.

Compared to [21], the main change is that we now check for innermost (𝒫,ℛ)-chains to determine which edges must exist. A graph approximation for (SDP⁡(ℛ𝗀𝖼𝖽),ℛ𝗀𝖼𝖽) is in Figure 1. Despite the slightly different SDPs (due to the transformation of the call-by-value system), this graph approximation is the same as the one in [21].

Figure 1: A graph approximation for (SDP⁡(ℛ𝗀𝖼𝖽),ℛ𝗀𝖼𝖽).

Given a graph approximation, we can decompose the DP problem:

Definition 17.

Given a DP problem (𝒫,ℛ), a graph processor computes a graph approximation (G,θ) for (𝒫,ℛ) and the strongly connected components (SCCs) of G, then returns {({p∈𝒫|θ⁢(p)⁢ belongs to ⁢S},ℛ)|S⁢ is a non-trivial SCC of ⁢G}.

If a graph processor produces the graph approximation in Figure 1, it will return the set {({6},ℛ𝗀𝖼𝖽),({3,4},ℛ𝗀𝖼𝖽),({5},ℛ𝗀𝖼𝖽)}. Next, we observe that 𝖿𝗈𝗅𝖽 is defined by structural recursion, which can be handled by subterm criterion processors. Let heads⁡(𝒫) denote the set of function symbols heading either side of an SDP in 𝒫, and we have the following definition:

Definition 18.

A projection ν for a set 𝒫 of SDPs is a mapping from heads⁡(𝒫) to integers such that 1≤ν⁢(𝖿♯)≤n if 𝖿♯:A1→⋯→An→𝖽𝗉. Let ν¯⁢(𝖿♯⁢t1⁢⋯⁢tn) denote tν⁢(𝖿♯). A projection ν is said to ⊳-orient a subset 𝒫′ of 𝒫 if ν¯⁢(s♯)⁢⊳⁢ν¯⁢(t♯) for all s♯⇒t♯⁢[φ]∈𝒫′ and ν¯⁢(s♯)=ν¯⁢(t♯) for all s♯⇒t♯⁢[φ]∈𝒫∖𝒫′. A subterm criterion processor maps (𝒫,ℛ) to {(𝒫∖𝒫′,ℛ)} for some non-empty 𝒫′⊆𝒫 which is ⊳-oriented by some projection for 𝒫.

Choosing ν⁢(𝖿𝗈𝗅𝖽♯)=3, we have ν¯⁢(𝖿𝗈𝗅𝖽♯⁢f⁢y⁢(𝖼𝗈𝗇𝗌⁢x⁢l))=𝖼𝗈𝗇𝗌⁢x⁢l⁢⊳⁢l=ν¯⁢(𝖿𝗈𝗅𝖽♯⁢f⁢y⁢l), so a subterm criterion processor maps ({6},ℛ𝗀𝖼𝖽) to {(∅,ℛ𝗀𝖼𝖽)}, and (∅,ℛ𝗀𝖼𝖽) can (trivially) be removed by a graph processor. Now we are left with ({3,4},ℛ𝗀𝖼𝖽) and ({5},ℛ𝗀𝖼𝖽), which involve recursion over integers. We deal with those by means of integer mappings:

Definition 19.

Given a set 𝒫 of SDPs, for all 𝖿♯∈heads⁡(𝒫) where 𝖿♯:A1→⋯→An→𝖽𝗉, let ι⁢(𝖿♯) be the subset of { 1,…,n} such that i∈ι⁢(𝖿♯) if and only if Ai∈𝒮ϑ and the i-th argument of any occurrence of 𝖿♯ in an SDP s♯⇒t♯⁢[φ]∈𝒫 is in T⁢(ℱϑ,Var⁡(φ)). Let 𝒳⁢(𝖿♯) be a set of fresh variables {xi|i∈ι⁢(𝖿♯)} where xi:Ai for all i. An integer mapping 𝒥 for 𝒫 is a mapping from heads⁡(𝒫) to theory terms such that for all 𝖿♯, 𝒥⁢(𝖿♯):𝗂𝗇𝗍 and Var⁡(𝒥⁢(𝖿♯))⊆𝒳⁢(𝖿♯). Let 𝒥¯⁢(𝖿♯⁢t1⁢⋯⁢tn) denote 𝒥⁢(𝖿♯)⁢[xi≔ti]i∈ι⁢(𝖿♯).

Integer mapping processors handle decreasing integer values:

Definition 20.

Given a set 𝒫 of SDPs, an integer mapping 𝒥 is said to >-orient a subset 𝒫′ of 𝒫 if φ⊧𝒥¯⁢(s♯)≥0∧𝒥¯⁢(s♯)>𝒥¯⁢(t♯) for all s♯⇒t♯⁢[φ]∈𝒫′, and φ⊧𝒥¯⁢(s♯)≥𝒥¯⁢(t♯) for all s♯⇒t♯⁢[φ]∈𝒫∖𝒫′, where φ⊧φ′ denotes that [[φ⁢σ]]=1 implies [[φ′⁢σ]]=1 for each substitution σ which maps variables in Var⁡(φ)∪Var⁡(φ′) to theory values. An integer mapping processor maps (𝒫,ℛ) to {(𝒫∖𝒫′,ℛ)} for some non-empty 𝒫′⊆𝒫 which is >-oriented by some integer mapping for 𝒫.

To deal with ({5},ℛ𝗀𝖼𝖽), let 𝒥⁢(𝗀𝖼𝖽♯) be x2 so 𝒥¯⁢(𝗀𝖼𝖽♯⁢m⁢n)=n, 𝒥¯⁢(𝗀𝖼𝖽♯⁢n⁢(mmodn))=mmodn and m≥0∧n>0⊧n≥0∧n>mmodn. Then an integer mapping processor returns {(∅,ℛ𝗀𝖼𝖽)}, and (∅,ℛ𝗀𝖼𝖽) can (trivially) be removed by a graph processor.

Unlike [21], here an integer mapping processor is applicable to ({3,4},ℛ𝗀𝖼𝖽): 𝒥⁢(𝗀𝖼𝖽♯)=−x1 and the processor returns {({4},ℛ𝗀𝖼𝖽)}. Then ({4},ℛ𝗀𝖼𝖽) can be removed by a graph processor. This simpler proof is due to the transformation of the call-by-value system; in both SDPs, m and n can be instantiated only to theory values, which is not the case in [21], and a theory argument processor is needed there. To elaborate, we consider the system ℛ:

𝖿⁢x⁢y⁢z→𝖿⁢x⁢(x+1)⁢(x−1)[y<z]𝖼⁢x⁢y→x𝖼⁢x⁢y→y

We have 𝖿⁢(𝖼⁢ 0 3)⁢ 1 2→ℛ𝖿⁢(𝖼⁢ 0 3)⁢((𝖼⁢ 0 3)+1)⁢((𝖼⁢ 0 3)−1)→ℛ+𝖿⁢(𝖼⁢ 0 3)⁢ 1 2, and therefore ℛ is not terminating with respect to full rewriting. Under call by value, ℛ is terminating: the first rewrite rule with x appended to the logical constraint gives the only SDP 𝖿♯⁢x⁢y⁢z⇒𝖿♯⁢x⁢(x+1)⁢(x−1)⁢[y<z,x], then let 𝒥⁢(𝖿♯) be x3−x2. Here we benefit from call by value.

5.2 The Chaining of Call-By-Value SDPs

Another benefit of call by value is that we may chain together consecutive SDPs, e.g., 𝖿𝖺𝖼𝗍♯⁢x⇒𝗎1♯⁢x⁢ 1⁢[𝔱,x] and 𝗎1♯⁢x⁢z⇒𝗎2♯⁢x⁢z⁢ 1⁢[𝔱,x,z] may merge to form 𝖿𝖺𝖼𝗍♯⁢x⇒𝗎2♯⁢x⁢ 1 1⁢[𝔱,x]. This capability can be important for automatically generated systems.

Definition 21.

Given SDPs p0=(s0♯⇒𝖿♯⁢t′1⁢⋯⁢t′n⁢[φ0]) and p1=(𝖿♯⁢s′1⁢⋯⁢s′n⇒t1♯⁢[φ1]) where 𝖿∈𝒟 and variables are renamed if necessary to avoid name collisions, p0 and p1 are called chainable if p1 is a call-by-value SDP and there exists a substitution σ such that dom⁡(σ)=⋃i=1nVar⁡(si′), ti′=si′⁢σ for all i, and σ⁢(x)∈T⁢(ℱϑ,Var⁡(φ0)) for all x∈dom⁡(σ)∩Var⁡(φ1). The chaining ch⁡(p0,p1) of p0 and p1 is s0♯⇒t1♯⁢σ⁢[φ0∧(φ1⁢σ)].

Note that in the context of call-by-value rewriting, all SDPs can be assumed to be call-by-value, and therefore it is not particularly restrictive to so require p1 above. To see the importance of this requirement, consider the DP problem ({𝖿♯⁢𝖺⁢𝖻⇒𝗀♯⁢(𝗁⁢𝖻⁢𝖺),𝗀♯⁢(𝗁⁢x⁢y)⇒𝖿♯⁢x⁢y},{𝗁⁢𝖻⁢𝖺→𝗁⁢𝖺⁢𝖻}). If we dropped the call-by-value requirement for the second SDP, the two SDPs would be chainable and yield 𝖿♯⁢𝖺⁢𝖻⇒𝖿♯⁢𝖻⁢𝖺. However, 𝖿♯⁢𝖻⁢𝖺 is not reachable from 𝖿♯⁢𝖺⁢𝖻 initially, and replacing the original SDPs with the new one is not sound.

Definition 22.

Given a set 𝒫 of SDPs and 𝖿∈𝒟 such that 𝒫𝖿ℓ≠∅, 𝒫𝖿r≠∅, 𝒫𝖿ℓ∩𝒫𝖿r=∅ and every pair in 𝒫𝖿r×𝒫𝖿ℓ is chainable where 𝒫𝖿ℓ={s♯⇒t♯⁢[φ]∈𝒫|s♯=𝖿♯⁢s1⁢⋯⁢sn} and 𝒫𝖿r={s♯⇒t♯⁢[φ]∈𝒫|t♯=𝖿♯⁢t1⁢⋯⁢tn}, a chaining processor assigns to a DP problem (𝒫,ℛ) the singleton {((𝒫∖(𝒫𝖿ℓ∪𝒫𝖿r))∪𝒫′,ℛ)} where 𝒫′={ch⁡(p0,p1)|p0∈𝒫𝖿r⁢ and ⁢p1∈𝒫𝖿ℓ}.

Example 23.

Consider the below set 𝒫 of SDPs generated from an imperative program [14]:

𝖿𝖺𝖼𝗍♯⁢x ⇒𝗎1♯⁢x⁢ 1 [𝔱,x] 𝗎1♯⁢x⁢z ⇒𝗎2♯⁢x⁢z⁢ 1 [𝔱,x,z]
𝗎2♯⁢x⁢z⁢i ⇒𝗎3♯⁢x⁢z⁢i [i≤x,z] 𝗎3♯⁢x⁢z⁢i ⇒𝗎4♯⁢x⁢(z∗i)⁢i [𝔱,x,z,i]
𝗎2♯⁢x⁢z⁢i ⇒𝗎5♯⁢x⁢z [¬(i≤x),z] 𝗎4♯⁢x⁢z⁢i ⇒𝗎2♯⁢x⁢z⁢(i+1) [𝔱,x,z,i]

Chaining processors can iteratively remove the occurrences of 𝗎1♯, 𝗎3♯ and 𝗎4♯, and end with (1) 𝖿𝖺𝖼𝗍♯⁢x⇒𝗎2♯⁢x⁢ 1 1⁢[𝔱,x], (2) 𝗎2♯⁢x⁢z⁢i⇒𝗎2♯⁢x⁢(z∗i)⁢(i+1)⁢[i≤x,z], and (3) 𝗎2♯⁢x⁢z⁢i⇒𝗎5♯⁢x⁢z⁢[¬(i≤x),z]. Note that a chaining processor for 𝖿∈𝒟 removes all the occurrences of 𝖿♯ in 𝒫, and therefore the process of iteratively applying chaining processors always terminates (on the assumption that heads⁡(𝒫) is finite). In this example, the above outcome cannot be further chained; there is no chaining processor for 𝗎2 because 𝒫𝗎2ℓ∩𝒫𝗎2r contains SDP (23).

Example 24.

Consider the following set 𝒫 of SDPs:

𝖿♯⁢x⁢y ⇒𝗀♯⁢(𝖼𝗈𝗆𝖻⁢x⁢y) [x≥0,y] 𝗀♯⁢(𝖼𝗈𝗆𝖻⁢z⁢w) ⇒𝗁♯⁢(z+w) [w≥0,z]
𝖿♯⁢x⁢y ⇒𝗀♯⁢(𝖼𝗈𝗆𝖻⁢(−x)⁢y) [x<0,y] 𝗀♯⁢(𝖼𝗈𝗆𝖻⁢z⁢w) ⇒𝗁♯⁢(z−w) [w<0,z]

where 𝖼𝗈𝗆𝖻:𝗂𝗇𝗍→𝗂𝗇𝗍→𝗂𝗇𝗍𝗉𝖺𝗂𝗋 is a constructor. Note that 𝖼𝗈𝗆𝖻⁢z⁢w is a value. Chaining processors can remove the occurrences of 𝗀♯, and end with (1) 𝖿♯⁢x⁢y⇒𝗁♯⁢(x+y)⁢[x≥0∧y≥0], (2) 𝖿♯⁢x⁢y⇒𝗁♯⁢(x−y)⁢[x≥0∧y<0], (3) 𝖿♯⁢x⁢y⇒𝗁♯⁢(−x+y)⁢[x<0∧y≥0], and (4) 𝖿♯⁢x⁢y⇒𝗁♯⁢(−x−y)⁢[x<0∧y<0].

5.3 Usable Rules

A key processor in the DP framework for full rewriting, which also applies in the innermost setting, is the reduction pair processor [21, Definition 25]. This processor is so powerful because it can potentially be used with a wide variety of different reduction pairs and does not require ≻ to be monotonic: we must show s♯≻φt♯ or s♯⪰φt♯ for all SDPs s♯⇒t♯⁢[φ], and s⪰φt for all rules s→t⁢[φ], and we may then remove the SDPs oriented with ≻.

The challenge is that, no matter how small 𝒫, we must orient all rules ℛ in the DP problem – and all processors considered so far only modify the set 𝒫 of SDPs. Fortunately, in the innermost setting, we can see that only some of the rules could potentially be relevant.

To illustrate the idea, consider a system ℛ𝖽𝗋𝗈𝗉 which includes at least the following rewrite rules and no other defining 𝖽𝗋𝗈𝗉, 𝖽𝖿𝗈𝗅𝖽𝗋, 𝖼𝗈𝗇𝗌, or 𝗇𝗂𝗅:

𝖽𝗋𝗈𝗉⁢n⁢l→l⁢[n≤0]𝖽𝗋𝗈𝗉⁢n⁢𝗇𝗂𝗅→𝗇𝗂𝗅⁢[𝔱,n]𝖽𝗋𝗈𝗉⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)→𝖽𝗋𝗈𝗉⁢(n−1)⁢l⁢[n>0]
𝖽𝖿𝗈𝗅𝖽𝗋⁢f⁢y⁢n⁢𝗇𝗂𝗅→y[𝔱,n]𝖽𝖿𝗈𝗅𝖽𝗋⁢f⁢y⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)→f⁢x⁢(𝖽𝖿𝗈𝗅𝖽𝗋⁢f⁢y⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l))[𝔱,n]

where 𝖽𝗋𝗈𝗉:𝗂𝗇𝗍→𝖺𝗅𝗂𝗌𝗍→𝖺𝗅𝗂𝗌𝗍 and 𝖽𝖿𝗈𝗅𝖽𝗋:(𝖺→𝖻→𝖻)→𝖻→𝗂𝗇𝗍→𝖺𝗅𝗂𝗌𝗍→𝖻. To deal with the SDP ({𝖽𝖿𝗈𝗅𝖽𝗋♯⁢f⁢y⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)⇒𝖽𝖿𝗈𝗅𝖽𝗋♯⁢f⁢y⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l)⁢[𝔱,n]},ℛ𝖽𝗋𝗈𝗉), we need a reduction pair processor; roughly, we should show that 𝖼𝗈𝗇𝗌⁢x⁢l is somehow “greater” than 𝖽𝗋𝗈𝗉⁢n⁢l, which cannot be done by a subterm criterion or an integer mapping processor. However, since the variables are to be instantiated to normal forms, any rules other than the ones defining 𝖽𝗋𝗈𝗉 would not be used in a chain for this problem. Hence, only these three rules need to be oriented. This observation leads to the notion of usable rules [3, 13]. We base our formulation on a higher-order version [26] and start with two auxiliary definitions:

Definition 25.

For ℓ→r⁢[φ] where ℓ:A1→⋯→An→B for B∈𝒮, let (ℓ→r⁢[φ])ex be {ℓ→r⁢[φ],ℓ⁢x1→r⁢x1⁢[φ],…,ℓ⁢x1⁢⋯⁢xn→r⁢x1⁢⋯⁢xn⁢[φ]} where x1,…,xn are fresh variables. Let ℛex denote ⋃ℓ→r⁢[φ]∈ℛ(ℓ→r⁢[φ])ex.

Definition 26.

The set of usable symbols in a term t with respect to a logical constraint φ, denoted by 𝒰ℱ⁢(t)⁢[φ], is defined inductively as follows:

  1. (1)

    Suppose t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ♯. If t∈T⁢(ℱϑ,Var⁡(φ)), then 𝒰ℱ⁢(t)⁢[φ]=∅; otherwise 𝒰ℱ⁢(t)⁢[φ]={(𝖿,n)}∪⋃i=1n𝒰ℱ⁢(ti)⁢[φ].

  2. (2)

    Suppose t=x⁢t1⁢⋯⁢tn for x∈𝒱. If n=0, then 𝒰ℱ⁢(t)⁢[φ]=∅; otherwise 𝒰ℱ⁢(t)⁢[φ]={⊥}.

Here ⊥ is a special symbol indicating that potentially any symbol could be usable.

The set of usable symbols for a set 𝒫 of SDPs and a set ℛ of rewrite rules, denoted by 𝒰ℱ⁢(𝒫,ℛ), is the smallest set U such that (1) 𝒰ℱ⁢(t♯)⁢[φ]⊆U for all s♯⇒t♯⁢[φ]∈𝒫, and (2) 𝒰ℱ⁢(r)⁢[φ]⊆U for all (𝖿,n)∈U and 𝖿⁢t1⁢⋯⁢tn→r⁢[φ]∈ℛex. Then 𝒰ℱ⁢(𝒫,ℛ) exists because it is the least pre-fixed point of an order-preserving mapping on a complete lattice.

We present usable rules as a class of DP processors:

Definition 27.

Given sets 𝒫 of SDPs and ℛ of rules: if ⊥∉𝒰ℱ(𝒫,ℛ), the set 𝒰⁢(𝒫,ℛ) of usable rules is defined as {𝖿⁢t1⁢⋯⁢tk→r⁢[φ]∈ℛ|(𝖿,n)∈𝒰ℱ⁢(𝒫,ℛ)⁢ and ⁢k≤n}; otherwise, 𝒰⁢(𝒫,ℛ) is undefined. A usable-rules processor assigns to a DP problem (𝒫,ℛ) with 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ) the singleton {(𝒫,𝒰⁢(𝒫,ℛ))}.

Example 28.

We continue the discussion about 𝖽𝗋𝗈𝗉 and 𝖽𝖿𝗈𝗅𝖽𝗋. Consider the DP problem (𝒫,ℛ𝖽𝗋𝗈𝗉) where 𝒫={𝖽𝖿𝗈𝗅𝖽𝗋♯⁢f⁢y⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)⇒𝖽𝖿𝗈𝗅𝖽𝗋♯⁢f⁢y⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l)⁢[𝔱,n]}. We have 𝒰ℱ⁢(𝖽𝖿𝗈𝗅𝖽𝗋♯⁢f⁢y⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l))⁢[𝔱,n]={(𝖽𝖿𝗈𝗅𝖽𝗋♯,4),(𝖽𝗋𝗈𝗉,2)} and can derive 𝒰ℱ⁢(𝒫,ℛ)={(𝖽𝖿𝗈𝗅𝖽𝗋♯,4),(𝖽𝗋𝗈𝗉,2),(𝗇𝗂𝗅,0)}. Hence, 𝒰⁢(𝒫,ℛ) consists of the three rules defining 𝖽𝗋𝗈𝗉.

5.4 Argument Filterings

Let us consider the role of ⊥ in the definition of usable rules: 𝒰⁢(𝒫,ℛ) is undefined if ⊥∈𝒰ℱ(𝒫,ℛ) – which occurs if the right-hand side of some SDP in 𝒫, or the right-hand side of any rule 𝖿⁢t1⁢⋯⁢tn→r⁢[φ]∈ℛex with (𝖿,n)∈𝒰ℱ⁢(𝒫,ℛ), is not a pattern. This is not a rare occasion in higher-order rewriting. For example, let us rework 𝖽𝖿𝗈𝗅𝖽𝗋 into 𝖽𝖿𝗈𝗅𝖽𝗅:

𝖽𝖿𝗈𝗅𝖽𝗅⁢f⁢y⁢n⁢𝗇𝗂𝗅→y⁢[𝔱,n]𝖽𝖿𝗈𝗅𝖽𝗅⁢f⁢y⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)→𝖽𝖿𝗈𝗅𝖽𝗅⁢f⁢(f⁢y⁢x)⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l)⁢[𝔱,n]

where 𝖽𝗋𝗈𝗉 is defined by the same rules as before. Now we have 𝖽𝖿𝗈𝗅𝖽𝗅♯⁢f⁢y⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)⇒𝖽𝖿𝗈𝗅𝖽𝗅♯⁢f⁢(f⁢y⁢x)⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l)⁢[𝔱,n], which produces ⊥.

However, observe that the problematic subterm f⁢y⁢x and the decreasing subterm 𝖽𝗋𝗈𝗉⁢n⁢l occur in different arguments of 𝖽𝖿𝗈𝗅𝖽𝗅♯. If we use a reduction pair that considers only the fourth argument, intuitively we can disregard any rules that may be used to reduce the second. This is formalized via an argument filtering [3, 26], which temporarily removes certain subterms from both sides of an ordering requirement before computing usable rules, often drastically reducing the number of usable rules that the reduction pair must consider.

Traditionally, argument filterings are defined for function symbols with a fixed number of arguments. Extending this notion to our curried setting imposes new technical challenges; e.g., if we filter away the second argument of 𝖿:A→B→C, what type to use for the filtering of 𝖿⁢x, C or B→C? Fortunately, this problem is solvable if we do not allow variables to occur at the head of an application in the result of a filtering. This is very different from the approach in [2], which heavily restricts what filtering can be used, to ensure that a variable of higher type and all its possible instances have the same filtering applied to them.

Definition 29.

We assume given a set 𝒮1 of sorts such that 𝒮ϑ⊆𝒮1, and a mapping μ from 𝒯 to 𝒮1 such that μ⁢(A)=A for all A∈𝒮ϑ. In addition, for each function symbol 𝖿:A1→⋯→An→B with B∈𝒮, we assume given a set regard⁡(𝖿)⊆{ 1,…,n}. Define:

Σ=ℱϑ∪{𝖿m:μ(Ai1)→…→μ(Aik)→μ(Am+1→…→An→B)∣𝖿:A1→⋯→An→B∈ℱ♯⁢with⁢B∈𝒮⁢and⁢ 0≤m≤n⁢andregard(𝖿)∩{ 1,…,m}={i1,…,ik}andi1<⋯<ik}∪{∙μ⁢(A):μ(A)∣A∈𝒯}

The argument filtering with respect to a logical constraint φ is a mapping πφ from T⁢(ℱ♯,𝒱) to T⁢(Σ♯,{x:μ⁢(A)∣x:A∈𝒱}), defined as follows:

  1. (1)

    πφ⁢(𝖿⁢t1⁢⋯⁢tn)=𝖿⁢t1⁢⋯⁢tn if 𝖿⁢t1⁢⋯⁢tn∈T⁢(ℱϑ,Var⁡(φ)) and has a base type

  2. (2)

    πφ⁢(𝖿⁢t1⁢⋯⁢tn)=𝖿n⁢πφ⁢(ti1)⁢⋯⁢πφ⁢(tik) otherwise, where {i1,…,ik}=regard⁡(𝖿)∩{ 1,…,n} and i1<⋯<ik

  3. (3)

    πφ⁢(x)=x for x∈𝒱; and πφ⁢(x⁢t1⁢⋯⁢tn)=∙μ⁢(A) if x∈𝒱 and n>0

By definition, πφ⁢(t):μ⁢(A) for all t:A. Moreover, no subterm of πφ⁢(t) has a variable at the head of an application, and all function symbols have a first-order type and occur maximally applied. Hence, πφ⁢(t) is a (many-sorted) first-order term, just written in applicative notation. For 𝒮1, we may for instance choose 𝒮ϑ∪{𝗈}, i.e., there is a single sort besides theory sorts.

Now we define usable rules with respect to an argument filtering:

Definition 30.

Given the mapping regard⁡(⋅), 𝒰ℱ⁢(𝖿⁢t1⁢⋯⁢tn)⁢[φ] is redefined as {(𝖿,n)}∪⋃i∈regard⁡(𝖿)∩{ 1,…,n}𝒰ℱ⁢(ti)⁢[φ] in the case where 𝖿⁢t1⁢⋯⁢tn∉T⁢(ℱϑ,Var⁡(φ)). The definition in other cases is unchanged, and so is the definition of 𝒰ℱ⁢(𝒫,ℛ).

Let U1 be {πφ⁢(𝖿⁢t1⁢⋯⁢tn)→πφ⁢(r)⁢[φ]|(𝖿,n)∈𝒰ℱ⁢(𝒫,ℛ)⁢ and ⁢𝖿⁢t1⁢⋯⁢tn→r⁢[φ]∈ℛex}, and U2 be {𝖿nxi1⋯xik→y[y=𝖿x1⋯xn]|(𝖿,n)∈𝒰ℱ(𝒫,ℛ),𝖿∈ℱϑ,n>0,𝖿:A1→⋯→An→B with B∈𝒮,regard(𝖿)={i1,…,ik} and i1<⋯<ik}.

We redefine 𝒰⁢(𝒫,ℛ) as U1∪U2 if ⊥∉𝒰ℱ(𝒫,ℛ), and p+i∈regard⁡(𝖿) for all (𝖿,n)∈𝒰ℱ⁢(𝒫,ℛ), 𝖿⁢s1⁢⋯⁢sp→𝗀⁢t1⁢⋯⁢tq⁢[φ]∈ℛ where p<n and 𝗀∈ℱ, and i∈{ 1,…,n−p} such that q+i∈regard⁡(𝗀). Otherwise, 𝒰⁢(𝒫,ℛ) is undefined.

That is, we consider usable rules only with respect to the positions that are not filtered away. The requirement that p+i∈regard⁡(𝖿) if (𝖿,n) is a usable symbol and p+i≤n is a technical limitation needed to ensure that applying a rewrite rule at the head of an application does not conflict with the argument filtering.

Next, we recall the notion of a constrained reduction pair from [21], but use a more liberal monotonicity requirement due to the first-order setting created by the filtering.

Definition 31.

A constrained relation R is a set of triples (s,t,φ) where s and t are (first-order) terms which have the same sort and φ is a logical constraint. We write s𝑅φt if (s,t,φ)∈R. A binary relation R′ over terms is said to cover a constrained relation R if s𝑅φt implies that (sσ)↓κR′(tσ)↓κ for each substitution σ which respects φ.

A constrained reduction pair (⪰,≻) is a pair of constrained relations where ⪰ is covered by some reflexive and transitive relation ⊒ such that tk⊒tk′ implies 𝖿⁢t1⁢⋯⁢tk−1⁢tk⁢tk+1⁢⋯⁢tn⊒𝖿⁢t1⁢⋯⁢tk−1⁢tk′⁢tk+1⁢⋯⁢tn (i.e., monotonicity) for all 𝖿∈Σ and k∈{ 1,…,n}, ≻ is covered by some well-founded relation ⊐, and ⊐⁣;⁣⊒⁣⊆⁣⊐+.

Having this, we can define reduction pair processors with respect to an argument filtering:

Definition 32.

A reduction pair processor with argument filterings assigns to a DP problem (𝒫,ℛ) with 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ) the singleton {(𝒫∖𝒫′,ℛ)} for some non-empty 𝒫′⊆𝒫 if there exists a mapping regard⁡(⋅) and a constrained reduction pair (⪰,≻) such that (1) πφ⁢(s♯)≻φπφ⁢(t♯) for all s♯⇒t♯⁢[φ]∈𝒫′, (2) πφ⁢(s♯)⪰φπφ⁢(t♯) for all s♯⇒t♯⁢[φ]∈𝒫∖𝒫′, and (3) ℓ⪰φr for all ℓ→r⁢[φ]∈𝒰⁢(𝒫,ℛ).

Example 33.

Consider 𝖽𝖿𝗈𝗅𝖽𝗅, with the following DP problem: ({𝖽𝖿𝗈𝗅𝖽𝗅♯⁢f⁢y⁢n⁢(𝖼𝗈𝗇𝗌⁢x⁢l)⇒𝖽𝖿𝗈𝗅𝖽𝗅♯⁢f⁢(f⁢y⁢x)⁢n⁢(𝖽𝗋𝗈𝗉⁢n⁢l)⁢[𝔱,n]},ℛ) Let regard⁡(𝖽𝖿𝗈𝗅𝖽𝗅♯) be { 4}, regard⁡(𝖽𝗋𝗈𝗉) be { 2}, and regard⁡(𝖼𝗈𝗇𝗌) be { 2}. We are obliged to prove (1) 𝖽𝖿𝗈𝗅𝖽𝗅4♯⁢(𝖼𝗈𝗇𝗌2⁢l)≻𝔱,n𝖽𝖿𝗈𝗅𝖽𝗅4♯⁢(𝖽𝗋𝗈𝗉2⁢l), (2) 𝖽𝗋𝗈𝗉2⁢l⪰n≤0l, (3) 𝖽𝗋𝗈𝗉2⁢𝗇𝗂𝗅0⪰𝔱,n𝗇𝗂𝗅0, and (4) 𝖽𝗋𝗈𝗉2⁢(𝖼𝗈𝗇𝗌2⁢l)⪰n>0𝖽𝗋𝗈𝗉2⁢l. The recursive path ordering for first-order LCTRSs [29] can be used to fulfill these obligations.

6 Universal Computability with Usable Rules

In this section, we study universal computability [21] with respect to innermost rewriting. This concept concerns a modular programming scenario where the LCSTRS represents a single module in a larger program, and corresponds to the termination of a function in all “reasonable” uses, including unknown uses. We recall the notion of a hierarchical combination [31, 32, 33, 9] rephrased in terms of LCSTRSs:

Definition 34 ([21]).

An LCSTRS ℛ1 is called an extension of a base system ℛ0 if the two systems’ interpretations of theory symbols coincide over all the theory symbols in common, and function symbols in ℛ0 are not defined by any rewrite rule in ℛ1. Given a base system ℛ0 and an extension ℛ1 of ℛ0, the system ℛ0∪ℛ1 is called a hierarchical combination.

In a hierarchical combination, function symbols in the base system can occur in the extension, but cannot be (re)defined; one may think of ℛ0 as an imported module.

Universal computability is defined on the basis of hierarchical combinations:

Definition 35 ([21]).

Given an LCSTRS ℛ0 with a sort ordering ≿, a term t is called universally computable if for each extension ℛ1 of ℛ0 and each extension ≿′ of ≿ to sorts in ℛ0∪ℛ1 (i.e., ≿′ coincides with ≿ over sorts in ℛ0), t is ℂ-computable in ℛ0∪ℛ1 with ≿′. ℛ0 is called universally computable if all its terms are.

In summary, we consider passing ℂ-computable arguments to a defined symbol in ℛ0 the “reasonable” way of calling the function. We use SDPs to establish universal computability:

Theorem 36.

An accessible function passing system ℛ0 with sort ordering ≿ is universally computable if there exists no infinite innermost (SDP⁡(ℛ0),ℛ0∪ℛ1)-chain for any extension ℛ1 of ℛ0 and extension ≿′ of ≿ to sorts in ℛ0∪ℛ1.

This is a more general version of Theorem 14 and will be proved alongside it in Appendix A.2. Note that the original set of rules, 𝒬, in the definition of innermost chain is now ℛ0∪ℛ1. We modify the DP framework to prove universal computability for a fixed base system ℛ0.

Definition 37.

A (universal) DP problem (𝒫,ℛ,𝚙) consists of a set 𝒫 of SDPs, a set ℛ of rewrite rules and a flag 𝚙∈{𝔡⁢𝔢⁢𝔣,𝔦⁢𝔫⁢𝔡} (for definite or indefinite). A DP problem (𝒫,ℛ,𝚙) is finite if either (1) 𝚙=𝔡⁢𝔢⁢𝔣 and there exists no infinite innermost (𝒫,ℛ)-chain (with 𝒬≔ℛ0), or (2) 𝚙=𝔦⁢𝔫⁢𝔡 and there exists no infinite innermost (𝒫,ℛ∪ℛ1)-chain for any extension ℛ1 of ℛ0 (with 𝒬≔ℛ0∪ℛ1).

DP processors are defined in the same way as before, now for universal DP problems. The goal is to show that (SDP⁡(ℛ0),ℛ0,𝔦⁢𝔫⁢𝔡) is finite, and the procedure for termination in Section 5 still works if we change the initialization accordingly. Unlike [21], here we have the advantage of usable rules: if 𝒰⁢(𝒫,ℛ) is defined, then 𝒰⁢(𝒫,ℛ∪ℛ1)=𝒰⁢(𝒫,ℛ) for any extension ℛ1 (provided all symbols in 𝒫 and ℛ are from ℛ0, which is typically the case as DP processors generally do not introduce new symbols). Hence a usable-rules processor assigns to a DP problem (𝒫,ℛ,𝚙) the singleton {(𝒫,𝒰⁢(𝒫,ℛ),𝔡⁢𝔢⁢𝔣)}.

Even if usable-rules processors are not applicable, we may still use a reduction pair processor with an argument filtering: we do not have to orient the rules in ℛ1 since they cannot be usable. Referring to Definition 32, a reduction pair processor now assigns to a DP problem (𝒫,ℛ,𝚙) the singleton {(𝒫∖𝒫′,ℛ,𝚙)} without changing the input flag because it does not permanently discard any rule. The other DP processors discussed in Section 5 apply to universal DP problems similarly; they just keep the input flag unchanged in the output.

7 Implementation and Evaluation

We have implemented our results in Cora [27], using a version of HORPO (based on the initial definition in [22]) and its first-order limitation RPO as the only reduction pair. Constraint validity checks are delegated to the SMT solver Z3 [8]. We also use Z3 to seek a good argument filtering and HORPO instance by encoding the requirements into an SMT problem.

Our implementation of the chaining processor from Definition 22 aims to minimize the number of DPs in the resulting problem. To this end, it chooses a function symbol 𝖿 such that the expression |𝒫′|−|𝒫𝖿ℓ∪𝒫𝖿r| with the sets defined as in Definition 22 is minimized.

We evaluated Cora on three groups of benchmarks: our own collected LCSTRS benchmarks, the lambda-free problems from the higher-order category of the TPDB [7], and problems from the first-order “integer TRS innermost” category. The results are summarized below, where “full” considers the framework for full termination with the methods from [21], and “call-by-value” does the transformation of Lemma 7 before applying the innermost framework:

Termination Universal Computability
Full Innermost Call-by-value Full Innermost Call-by-value
Total yes 171 179 182 155 179 182
Total maybe 104 96 93 116 96 93

Note that we gain significant power compared to [21] when analyzing universal computability. This is largely due to the two usable-rules processors: the reduction pair processor cannot be applied on its own in an indefinite DP problem, so either changing the flag from 𝔦⁢𝔫⁢𝔡 to 𝔡⁢𝔢⁢𝔣, or being able to omit the extra rules in a reduction pair, gives a lot of power.

However, the gains for termination are more modest. We suspect the reason is that the new processors primarily find their power in large systems (where it is essential to eliminate many rules when searching for a reduction pair), and automatically generated systems (where there are often many chainable rules), not in the handcrafted benchmarks of the TPDB.

Another observation is that there is no difference in proving power between termination or universal computability, both for innermost and for call-by-value reduction. This may be due to Cora having only one reduction pair (HORPO): on this benchmark set, when HORPO can be applied to simplify a DP problem, then it is also possible to filter away problematic subterms that would stop us from applying usable rules.

A detailed evaluation page is available through the following link:

https://www.cs.ru.nl/˜cynthiakop/experiments/fscd25/

Comparison to Other Analyzers.

While we have made progress, the additions of this paper are not yet sufficient for Cora to compete with dedicated analyzers for first-order integer rewriting, or unconstrained higher-order term rewriting.

In the “integer TRS innermost” category, AProVE [15] can prove innermost termination of 102 benchmarks, while Cora can handle 72 for innermost evaluation and 73 for call-by-value. The most important difference seems to be that AProVE has a much more sophisticated implementation of what we call the integer mapping processor as a reduction pair processor with polynomial interpretations and usable rules with respect to argument filterings [12]. In addition, these benchmarks often have rules such as 𝖿⁢(x)→𝗀⁢(x>0,x),𝗀⁢(𝔱,x)→r1,𝗀⁢(𝔣,x)→r2, which would benefit from a transformation to turn the Boolean subterm x>0 into a proper constraint. Improving on these points is obvious future work.

In the “higher-order union beta” category, Wanda [25] can prove termination of full rewriting of 105 benchmarks, while Cora can handle 79 for innermost or call-by-value reduction. Since these benchmarks are unconstrained, Cora does not benefit here from any of the processors that consider the theory, while Wanda does have many more features to increase its prover ability; for example, polynomial interpretations, dynamic dependency pairs, and delegation of partial problems to a first-order termination tool.

8 Related Work

Dependency Pair frameworks are the cornerstone of most fully automated termination analysis tools for various flavors of first-order [1, 19, 23] and higher-order [2, 13, 30] rewriting. A common theme of these DP frameworks lies in the notions of a problem to be analyzed for presence of infinite chains and processors to advance the proofs of (non-)termination. The notion of DP frameworks has been lifted to constrained rewriting, both in the first-order [10, 12] and recently also in the higher-order [21] setting. The latter work also includes the notion of universal computability, allowing for termination proofs also in the presence of further library functions that are not known at the time of analysis.

Our present DP framework for innermost rewriting is specially designed with termination analysis of functional programs in call-by-value languages (e.g., Scala, OCaml) in mind as a target application. Such LCSTRSs may come from an automated syntactic translation and thus have more rewrite rules with “intermediate” defined symbols than hand-optimized rewrite systems. Our chaining processor renders the analysis of such problems feasible. This kind of program transformation is used also in other program analysis tools [4, 10, 14, 15]; here, we have adapted the technique to higher-order rewriting with constraints.

Usable rules w.r.t. an argument filtering were introduced for first-order rewriting in [19] and soon extended to simply-typed higher-order rewriting for arbitrary rewrite strategies in [2]. Our contribution here is to lift usable rules w.r.t. an argument filtering to a setting with theory constraints and to universal computability, thus opening up the door for applications in analysis of programs for real-world languages. Moreover, we adapt the technique to innermost rewriting and thus do not require that the constrained reduction pair (⪰,≻) satisfies 𝖼⁢x⁢y⪰x and 𝖼⁢x⁢y⪰y for fresh symbols 𝖼.

9 Conclusion and Future Work

In this paper, we have extended the static dependency pair framework for LCSTRSs to innermost and call-by-value evaluation strategies. In doing so, we have adapted several existing processors for full termination and proposed three processors – chaining, usable rules, reduction pairs with usable rules w.r.t. argument filterings – that were not present for the setting of full termination. These processors apply not only to conventional closed-world termination analysis, but also to open-world termination analysis via universal computability, where the presence of further rewrite rules for library functions is assumed, thus broadening the set of potential start terms that must be considered. Our experimental results on several benchmark collections indicate improvements over the state of the art by exploiting the evaluation strategy via the new processors, most pronounced for universal computability.

There are several directions for future work. Our chaining processors could be improved, e.g., by using unification instead of matching, thus defining a form of narrowing for our constrained DPs in the higher-order setting. Moreover, so far our implementation prohibits chaining a DP with itself to prevent non-termination of repeated applications of the chaining processors. We might loosen this restriction via appropriate heuristics to detect cases in which such self-chaining could be beneficial. In addition, we could investigate chaining not just for DPs, but also for rewrite rules. The integer mapping processor could be improved by lifting polynomial interpretations [43] for higher-order rewriting to the constrained setting of LCSTRSs. Another improvement would consist of moving Boolean expressions from the right-hand side of rewrite rules into their constraints. Techniques like the integer mapping processor or the subterm criterion, which establish weak or strict decrease between certain arguments of dependency pairs, could also be improved by combining them with the size-change termination principle [37]. Size-change termination has been integrated into the first-order DP framework [42, 5], and a natural next step would be to lift this integration to the higher-order DP framework for LCSTRSs, both for innermost and for full termination.

A different avenue could be to research to what extent the termination analysis techniques in this paper can be ported from innermost or call-by-value evaluation to arbitrary evaluation strategies, or to lazy evaluation, as used in Haskell. For the latter, we might consider an approximation of lazy evaluation via a higher-order form of context-sensitive rewriting [1, 38].

Finally, to go back to one of the main motivations of this work, we could devise translations from higher-order functional programming languages with call-by-value semantics (e.g., Scala, OCaml) to LCSTRSs. This would allow for applying the contributions of this paper to prove termination of programs written in these languages, a long-term goal of this line of research.

References

  • [1] B. Alarcón, R. Gutiérrez, and S. Lucas. Context-sensitive dependency pairs. IC, 208(8):922–968, 2010. doi:10.1016/J.IC.2010.03.003.
  • [2] T. Aoto and T. Yamada. Argument filterings and usable rules for simply typed dependency pairs. In S. Ghilardi and R. Sebastiani, editors, Proc. FroCoS, pages 117–132, 2009. doi:10.1007/978-3-642-04222-5_7.
  • [3] T. Arts and J. Giesl. Termination of term rewriting using dependency pairs. TCS, 236(1–2):133–178, 2000. doi:10.1016/S0304-3975(99)00207-8.
  • [4] D. Beyer, A. Cimatti, A. Griggio, M. E. Keremoglu, and R. Sebastiani. Software model checking via large-block encoding. In A. Biere and C. Pixley, editors, Proc. FMCAD, pages 25–32, 2009. doi:10.1109/FMCAD.2009.5351147.
  • [5] M. Codish, C. Fuhs, J. Giesl, and P. Schneider-Kamp. Lazy abstraction for size-change termination. In C. G. Fermüller and A. Voronkov, editors, Proc. LPAR (Yogyakarta), pages 217–232, 2010. doi:10.1007/978-3-642-16242-8_16.
  • [6] Community. Termination competition (TermCOMP). URL: https://termination-portal.org/wiki/Termination_Competition.
  • [7] Community. The termination problem database (TPDB). URL: https://github.com/TermCOMP/TPDB.
  • [8] L. de Moura and N. Bjørner. Z3: An efficient SMT solver. In C.R. Ramakrishnan and J. Rehof, editors, Proc. TACAS, pages 337–340, 2008. doi:10.1007/978-3-540-78800-3_24.
  • [9] N. Dershowitz. Hierarchical termination. In N. Dershowitz and N. Lindenstrauss, editors, Proc. CTRS, pages 89–105, 1995. doi:10.1007/3-540-60381-6_6.
  • [10] S. Falke and D. Kapur. A term rewriting approach to the automated termination analysis of imperative programs. In R. A. Schmidt, editor, Proc. CADE, pages 277–293, 2009. doi:10.1007/978-3-642-02959-2_22.
  • [11] S. Falke, D. Kapur, and C. Sinz. Termination analysis of C programs using compiler intermediate languages. In M. Schmidt-Schauß, editor, Proc. RTA, pages 41–50, 2011. doi:10.4230/LIPIcs.RTA.2011.41.
  • [12] C. Fuhs, J. Giesl, M. Plücker, P. Schneider-Kamp, and S. Falke. Proving termination of integer term rewriting. In R. Treinen, editor, Proc. RTA, pages 32–47, 2009. doi:10.1007/978-3-642-02348-4_3.
  • [13] C. Fuhs and C. Kop. A static higher-order dependency pair framework. In L. Caires, editor, Proc. ESOP, pages 752–782, 2019. doi:10.1007/978-3-030-17184-1_27.
  • [14] C. Fuhs, C. Kop, and N. Nishida. Verifying procedural programs via constrained rewriting induction. ACM TOCL, 18(2):14:1–14:50, 2017. doi:10.1145/3060143.
  • [15] J. Giesl, C. Aschermann, M. Brockschmidt, F. Emmes, F. Frohn, C. Fuhs, J. Hensel, C. Otto, M. Plücker, P. Schneider-Kamp, T. Ströder, S. Swiderski, and R. Thiemann. Analyzing program termination and complexity automatically with AProVE. JAR, 58(1):3–31, 2017. doi:10.1007/s10817-016-9388-y.
  • [16] J. Giesl, M. Raffelsieper, P. Schneider-Kamp, S. Swiderski, and R. Thiemann. Automated termination proofs for Haskell by term rewriting. ACM TOPLAS, 33(2):7:1–7:39, 2011. doi:10.1145/1890028.1890030.
  • [17] J. Giesl, T. Ströder, P. Schneider-Kamp, F. Emmes, and C. Fuhs. Symbolic evaluation graphs and term rewriting: a general methodology for analyzing logic programs. In A. King, editor, Proc. PPDP, pages 1–12, 2012. doi:10.1145/2370776.2370778.
  • [18] J. Giesl, R. Thiemann, and P. Schneider-Kamp. The dependency pair framework: combining techniques for automated termination proofs. In F. Baader and A. Voronkov, editors, Proc. LPAR, pages 301–331, 2005. doi:10.1007/978-3-540-32275-7_21.
  • [19] J. Giesl, R. Thiemann, P. Schneider-Kamp, and S. Falke. Mechanizing and improving dependency pairs. JAR, 37(3):155–203, 2006. doi:10.1007/s10817-006-9057-7.
  • [20] L. Guo, K. Hagens, C. Kop, and D. Vale. Higher-order constrained dependency pairs for (universal) computability. pre-publication Arxiv copy of [21] with additional appendix. doi:10.48550/arXiv.2406.19379.
  • [21] L. Guo, K. Hagens, C. Kop, and D. Vale. Higher-order constrained dependency pairs for (universal) computability. In R. Královič and A. Kučera, editors, Proc. MFCS, pages 57:1–57:15, 2024. doi:10.4230/LIPIcs.MFCS.2024.57.
  • [22] L. Guo and C. Kop. Higher-order LCTRSs and their termination. In S. Weirich, editor, Proc. ESOP, pages 331–357, 2024. doi:10.1007/978-3-031-57267-8_13.
  • [23] N. Hirokawa and A. Middeldorp. Automating the dependency pair method. IC, 199(1-2):172–199, 2005. doi:10.1016/J.IC.2004.10.004.
  • [24] N. Hirokawa and A. Middeldorp. Tyrolean Termination Tool: techniques and features. IC, 205(4):474–511, 2007. doi:10.1016/j.ic.2006.08.010.
  • [25] C. Kop. WANDA – a higher order termination tool (system description). In Z. M. Ariola, editor, Proc. FSCD, pages 36:1–36:19, 2020. doi:10.4230/LIPICS.FSCD.2020.36.
  • [26] C. Kop. Cutting a proof into bite-sized chunks: incrementally proving termination in higher-order term rewriting. In A. P. Felty, editor, Proc. FSCD, pages 1:1–1:17, 2022. doi:10.4230/LIPIcs.FSCD.2022.1.
  • [27] C. Kop et al. The Cora analyzer. URL: https://github.com/hezzel/cora.
  • [28] C. Kop et al. hezzel/cora: FSCD 2025. doi:10.5281/zenodo.15318964.
  • [29] C. Kop and N. Nishida. Term rewriting with logical constraints. In P. Fontaine, C. Ringeissen, and R. A. Schmidt, editors, Proc. FroCoS, pages 343–358, 2013. doi:10.1007/978-3-642-40885-4_24.
  • [30] C. Kop and F. van Raamsdonk. Dynamic dependency pairs for algebraic functional systems. LMCS, 8(2), 2012. doi:10.2168/LMCS-8(2:10)2012.
  • [31] M. R. K. Krishna Rao. Completeness of hierarchical combinations of term rewriting systems. In R. K. Shyamasundar, editor, Proc. FSTTCS, pages 125–138, 1993. doi:10.1007/3-540-57529-4_48.
  • [32] M. R. K. Krishna Rao. Simple termination of hierarchical combinations of term rewriting systems. In M. Hagiya and J. C. Mitchell, editors, Proc. TACS, pages 203–223, 1994. doi:10.1007/3-540-57887-0_97.
  • [33] M. R. K. Krishna Rao. Semi-completeness of hierarchical and super-hierarchical combinations of term rewriting systems. In P. D. Mosses, M. Nielsen, and M. I. Schwartzbach, editors, Proc. CAAP, pages 379–393, 1995. doi:10.1007/3-540-59293-8_208.
  • [34] K. Kusakari, Y. Isogai, M. Sakai, and F. Blanqui. Static dependency pair method based on strong computability for higher-order rewrite systems. IEICE Trans. Inf. Syst., E92.D(10):2007–2015, 2009. doi:10.1587/transinf.E92.D.2007.
  • [35] K. Kusakari and M. Sakai. Enhancing dependency pair method using strong computability in simply-typed term rewriting. AAECC, 18(5):407–431, 2007. doi:10.1007/s00200-007-0046-9.
  • [36] K. Kusakari and M. Sakai. Static dependency pair method for simply-typed term rewriting and related techniques. IEICE Trans. Inf. Syst., E92.D(2):235–247, 2009. doi:10.1587/transinf.E92.D.235.
  • [37] C. S. Lee, N. D. Jones, and A. M. Ben-Amram. The size-change principle for program termination. In C. Hankin and D. Schmidt, editors, Proc. POPL, pages 81–92, 2001. doi:10.1145/360204.360210.
  • [38] S. Lucas. Context-sensitive computations in functional and functional logic programs. JFLP, 1998(1), 1998. URL: http://danae.uni-muenster.de/lehre/kuchen/JFLP/articles/1998/A98-01/A98-01.html.
  • [39] C. Otto, M. Brockschmidt, C. von Essen, and J. Giesl. Automated termination analysis of Java bytecode by term rewriting. In C. Lynch, editor, Proc. RTA, pages 259–276, 2010. doi:10.4230/LIPIcs.RTA.2010.259.
  • [40] S. Suzuki, K. Kusakari, and F. Blanqui. Argument filterings and usable rules in higher-order rewrite systems. IPSJ Online Trans., 4:114–125, 2011. doi:10.2197/ipsjtrans.4.114.
  • [41] R. Thiemann. The DP framework for proving termination of term rewriting. PhD thesis, RWTH Aachen University, Germany, 2007. URL: http://darwin.bth.rwth-aachen.de/opus3/volltexte/2007/2066/.
  • [42] R. Thiemann and J. Giesl. The size-change principle and dependency pairs for termination of term rewriting. AAECC, 16(4):229–270, 2005. doi:10.1007/S00200-005-0179-7.
  • [43] J. van de Pol. Termination proofs for higher-order rewrite systems. In J. Heering, K. Meinke, B. Möller, and T. Nipkow, editors, Proc. HOA, pages 305–325, 1993. doi:10.1007/3-540-58233-9_14.
  • [44] F. van Raamsdonk. Translating logic programs into conditional rewriting systems. In L. Naish, editor, Proc. ICLP, pages 168–182, 1997. doi:10.7551/mitpress/4299.003.0018.
  • [45] H. Zantema. Termination of term rewriting by semantic labelling. FI, 24(1/2):89–105, 1995. doi:10.3233/FI-1995-24124.

Appendix A Full Proofs

A.1 Soundness for Section 5

For soundness of the graph, subterm criterion and integer mapping processors, we refer to Appendix A.2 in [20]; only minimal changes are needed. Below we address the rest.

Theorem 38.

Chaining processors are sound.

Proof of Theorem 38.

Given a DP problem (𝒫,ℛ), a defined symbol 𝖿 with the said properties and an infinite innermost (𝒫,ℛ)-chain (s0♯⇒t0♯⁢[φ0],σ0),(s1♯⇒t1♯⁢[φ1],σ1),… where variables are renamed to avoid name collisions between any two of the SDPs and dom⁡(σi)⊆Var⁡(si♯)∪Var⁡(ti♯)∪Var⁡(φi) for all i, we consider k>0 such that tk−1♯=𝖿♯⁢t′1⁢⋯⁢t′n and sk♯=𝖿♯⁢s′1⁢⋯⁢s′n. By definition, ti′⁢σk−1→𝒬ℛ∗si′⁢σk for all i. Because sk−1♯⇒tk−1♯⁢[φk−1] and sk♯⇒tk♯⁢[φk] are chainable, there exists a substitution σ′ such that dom⁡(σ′)=⋃i=1nVar⁡(si′), si′⁢σ′=ti′ for all i and σ′⁢(x)∈T⁢(ℱϑ,Var⁡(φk−1)) for all x∈dom⁡(σ′)∩Var⁡(φk). Hence, si′⁢σ′⁢σk−1→𝒬ℛ∗si′⁢σk for all i. Since si′ is a value for all i, σk−1⁢(σ′⁢(x))→𝒬ℛ∗σk⁢(x) for all x∈⋃i=1nVar⁡(si′). Now we show that replacing (sk−1♯⇒tk−1♯⁢[φk−1],σk−1) and (sk♯⇒tk♯⁢[φk],σk) by (sk−1♯⇒tk♯⁢σ′⁢[φk−1∧(φk⁢σ′)],σk−1∪σk) yields an infinite innermost chain. First, it is routine to verify that σk−1∪σk respects φk−1∧(φk⁢σ′). Next, sk−1♯⁢(σk−1∪σk)=sk−1♯⁢σk−1 so it is in normal form. Last, tk♯⁢σ′⁢(σk−1∪σk)→𝒬ℛ∗tk♯⁢σk→𝒬ℛ∗sk+1♯⁢σk+1. ◀

We present some auxiliary results for the two classes of DP processors based on usable rules in a unified way, regardless of whether an argument filtering is applied. When no filtering is applied, let regard⁡(𝖿)={ 1,…,n} for each 𝖿:A1→⋯→An→B with B∈𝒮.

Definition 39.

The set 𝒰ℱ𝔞⁢(t) of actually usable symbols in a term t is (1) {(𝖿,n)}∪⋃i∈regard⁡(𝖿)∩{ 1,…,n}𝒰ℱ𝔞⁢(ti) if t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ♯, t is not a ground theory term, and is not in normal form (with respect to 𝒬), or (2) ∅ otherwise.

Lemma 40.

Given a constraint φ and a substitution σ such that σ⁢(x) is in normal form for all x and is a theory value if x∈Var⁡(φ): 𝒰ℱ𝔞⁢(t⁢σ)⊆𝒰ℱ⁢(t)⁢[φ] for all t with ⊥∉𝒰ℱ(t)[φ].

Proof of Lemma 40.

By induction on t. If t=x⁢t1⁢⋯⁢tn with x∈𝒱, then n=0 because ⊥∉𝒰ℱ(t)[φ]. Hence, t⁢σ=σ⁢(x) is in normal form, and therefore 𝒰ℱ𝔞⁢(t⁢σ)=∅. Otherwise, t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ♯. If t⁢σ=𝖿⁢(t1⁢σ)⁢⋯⁢(tn⁢σ) is not a ground theory term, t∉T⁢(ℱϑ,Var⁡(φ)) because σ⁢(x) is a theory value for all x∈Var⁡(φ). So if 𝒰ℱ𝔞⁢(t⁢σ)≠∅, 𝒰ℱ⁢(t)⁢[φ]={(𝖿,n)}∪⋃i∈regard⁡(𝖿)∩{ 1,…,n}𝒰ℱ⁢(ti)⁢[φ], and therefore ⊥∉𝒰ℱ(ti)[φ] for each such i. By induction, 𝒰ℱ𝔞⁢(ti⁢σ)⊆𝒰ℱ⁢(ti)⁢[φ]. Hence, 𝒰ℱ𝔞⁢(t⁢σ)⊆𝒰ℱ⁢(t)⁢[φ]. ◀

Lemma 41.

Given a set 𝒫 of SDPs and a set ℛ of rules such that 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ) and 𝒰⁢(𝒫,ℛ) is defined: for all terms t, t′, if 𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ) and t→𝒬ℛt′, 𝒰ℱ𝔞⁢(t′)⊆𝒰ℱ⁢(𝒫,ℛ).

Proof of Lemma 41.

By induction on t.

  1. (1)

    t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ, and there exist a rewrite rule ℓ→r⁢[φ]∈ℛ, substitution σ and number p≤n such that 𝖿⁢t1⁢⋯⁢tp=ℓ⁢σ, t′=(r⁢σ)⁢tp+1⁢⋯⁢tn, σ⁢(x) is in normal form for all x and σ respects φ. Since 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ), t is not in 𝒬-normal form, so (𝖿,n)∈𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ), and therefore 𝒰ℱ⁢(r⁢xp+1⁢⋯⁢xn)⁢[φ]⊆𝒰ℱ⁢(𝒫,ℛ) where xp+1,…,xn are fresh variables. Since 𝒰⁢(𝒫,ℛ) is defined, ⊥∉𝒰ℱ(𝒫,ℛ), and therefore ⊥∉𝒰ℱ(rxp+1⋯xn)[φ]. If p=n, due to Lemma 40, 𝒰ℱ𝔞⁢(t′)=𝒰ℱ𝔞⁢(r⁢σ)⊆𝒰ℱ⁢(r)⁢[φ]⊆𝒰ℱ⁢(𝒫,ℛ). Otherwise, r=𝗀⁢r1⁢⋯⁢rq for 𝗀∈ℱ. Then 𝒰ℱ𝔞⁢(t′)=𝒰ℱ𝔞⁢((r⁢σ)⁢tp+1⁢⋯⁢tn)⊆{(𝗀,q+n−p)}∪⋃{𝒰ℱ𝔞⁢(ri⁢σ)∣1≤i≤q,i∈regard⁡(𝗀)}∪⋃{𝒰ℱ𝔞⁢(tp+j)∣1≤j≤n−p,q+j∈regard⁡(𝗀)} and 𝒰ℱ⁢(r⁢xp+1⁢⋯⁢xn)⁢[φ]={(𝗀,q+n−p)}∪⋃{𝒰ℱ⁢(ri)⁢[φ]∣1≤i≤q,i∈regard⁡(𝗀)}. Since ⊥∉𝒰ℱ(rxp+1⋯xn)[φ], for each such i, 𝒰ℱ𝔞⁢(ri⁢σ)⊆𝒰ℱ⁢(ri)⁢[φ] due to Lemma 40. Since 𝒰⁢(𝒫,ℛ) is defined, each p+j∈regard⁡(𝖿), and therefore 𝒰ℱ𝔞⁢(tp+j)⊆𝒰ℱ𝔞⁢(t). Hence, 𝒰ℱ𝔞⁢(t′)⊆𝒰ℱ⁢(r⁢xp+1⁢⋯⁢xn)⁢[φ]∪𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ).

  2. (2)

    t=𝖿⁢v1⁢⋯⁢vn where 𝖿 is a calculation symbol and v1,…,vn are theory values, and t has a base type. Then t→κt′ and t′ is a theory value. Hence, 𝒰ℱ𝔞⁢(t′)=∅.

  3. (3)

    t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ♯, and t′=𝖿⁢t1⁢⋯⁢tk−1⁢tk′⁢tk+1⁢⋯⁢tn for some k with tk→𝒬ℛtk′. If t is a ground theory term, so is t′, hence 𝒰ℱ𝔞⁢(t′)=∅; so assume otherwise. If k∉regard⁡(𝖿), 𝒰ℱ𝔞⁢(t′)⊆𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ). If k∈regard⁡(𝖿), 𝒰ℱ𝔞⁢(tk)⊆𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ). By induction, 𝒰ℱ𝔞⁢(tk′)⊆𝒰ℱ⁢(𝒫,ℛ). Then 𝒰ℱ𝔞⁢(t′)⊆𝒰ℱ𝔞⁢(t)∪𝒰ℱ𝔞⁢(tk′)⊆𝒰ℱ⁢(𝒫,ℛ).

  4. (4)

    t=x⁢t1⁢⋯⁢tn for x∈𝒱, and t′=x⁢t1⁢⋯⁢tk−1⁢tk′⁢tk+1⁢⋯⁢tn; then 𝒰ℱ𝔞⁢(t′)=∅.

◀

Theorem 42.

Usable-rules processors are sound.

Proof of Theorem 42.

Given a DP problem (𝒫,ℛ) such that 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ) and 𝒰⁢(𝒫,ℛ) is defined, and an infinite innermost (𝒫,ℛ)-chain (s0♯⇒t0♯⁢[φ0],σ0),(s1♯⇒t1♯⁢[φ1],σ1),…: for all i, since 𝒰ℱ⁢(ti♯)⁢[φi]⊆𝒰ℱ⁢(𝒫,ℛ), ⊥∉𝒰ℱ(ti♯)[φi], and due to Lemma 40, 𝒰ℱ𝔞⁢(ti♯⁢σi)⊆𝒰ℱ⁢(ti♯)⁢[φi]⊆𝒰ℱ⁢(𝒫,ℛ). Now due to Lemma 41, for all t′ such that ti♯⁢σi→𝒬ℛ∗t′, 𝒰ℱ𝔞⁢(t′)⊆𝒰ℱ⁢(𝒫,ℛ), so any →𝒬ℛ-step from t′ is a →𝒬𝒰⁢(𝒫,ℛ)-step, given the definition of 𝒰ℱ𝔞⁢(). ◀

Below we let π denote π𝔱 – the argument filtering with respect to the Boolean 𝔱 – and define σπ for each substitution σ by letting σπ⁢(x) be π⁢(σ⁢(x)).

Lemma 43.

Given a logical constraint φ and a substitution σ such that σ⁢(x) is a theory value for all x∈Var⁡(φ), πφ⁢(t)⁢σπ=π⁢(t⁢σ) for each pattern t such that all the variables in Var⁡(t) whose type is a theory sort are also in Var⁡(φ).

Proof of Lemma 43.

By induction on t. If t=x⁢t1⁢⋯⁢tn with x∈𝒱, then n=0 because t is a pattern. Hence, πφ⁢(t)⁢σπ=σπ⁢(x)=π⁢(σ⁢(x))=π⁢(t⁢σ). Otherwise, t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ♯. If t is in T⁢(ℱϑ,Var⁡(φ)) and has a base type, πφ⁢(t)⁢σπ=t⁢σπ=t⁢σ=π⁢(t⁢σ) because σ⁢(x) is a theory value for all x∈Var⁡(t) and π⁢(v)=v for each theory value v. Otherwise, if regard⁡(𝖿)∩{ 1,…,n}={i1,…,ik} (with i1<⋯<ik), πφ⁢(t)⁢σπ=𝖿n⁢(πφ⁢(ti1)⁢σπ)⁢⋯⁢(πφ⁢(tik)⁢σπ) and π⁢(t⁢σ)=𝖿n⁢π⁢(ti1⁢σ)⁢⋯⁢π⁢(tik⁢σ). By induction, πφ⁢(tij)⁢σπ=π⁢(tij⁢σ) for all j∈{ 1,…,k}. ◀

Lemma 44.

Given a set 𝒫 of SDPs, a set ℛ of rewrite rules and a constrained relation ⪰ such that 𝒰⁢(𝒫,ℛ) is defined, ℓ⪰φr for all ℓ→r⁢[φ]∈𝒰⁢(𝒫,ℛ) and ⪰ is covered by some reflexive, transitive and monotonic relation ⊒: if 𝒰ℱ⁢(t)⁢[φ]⊆𝒰ℱ⁢(𝒫,ℛ) and σ⁢(x) is a theory value for all x∈Var⁡(φ), πφ(t)σπ↓κ⊒π(tσ)↓κ.

Proof of Lemma 44.

By induction on t. If t=x⁢t1⁢⋯⁢tn with x∈𝒱 then n=0 because ⊥∉𝒰ℱ(t)[φ]. Hence, πφ⁢(t)⁢σπ=σπ⁢(x)=π⁢(σ⁢(x))=π⁢(t⁢σ). Otherwise, t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ♯. If t is in T⁢(ℱϑ,Var⁡(φ)) and has a base type, πφ⁢(t)⁢σπ=t⁢σπ=t⁢σ=π⁢(t⁢σ) because each σ⁢(x) is a theory value so π⁢(σ⁢(x))=σ⁢(x). Otherwise, we have πφ⁢(t)⁢σπ=𝖿n⁢(πφ⁢(ti1)⁢σπ)⁢⋯⁢(πφ⁢(tik)⁢σπ) where regard⁡(𝖿)∩{ 1,…,n}={i1,…,ik} and i1<⋯<ik. By induction, πφ(tij)σπ↓κ⊒π(tijσ)↓κ for all j∈{ 1,…,k}, and therefore πφ(t)σπ↓κ⊒𝖿nπ(ti1σ)↓κ⋯π(tikσ)↓κ. If t⁢σ is a ground theory term with a base type, 𝖿n⁢xi1⁢⋯⁢xik→y⁢[y=𝖿⁢x1⁢⋯⁢xn]∈𝒰⁢(𝒫,ℛ); because ⊒ covers ⪰, 𝖿nπ(ti1σ)↓κ⋯π(tikσ)↓κ=𝖿n(ti1σ)↓κ⋯(tikσ)↓κ⊒(tσ)↓κ=π(tσ)↓κ. Otherwise, we have π⁢(t⁢σ)=𝖿n⁢π⁢(ti1⁢σ)⁢⋯⁢π⁢(tik⁢σ). ◀

Lemma 45.

Given a set 𝒫 of SDPs, a set ℛ of rules and a constrained relation ⪰ where (1) 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ), (2) 𝒰⁢(𝒫,ℛ) is defined, (3) for all ℓ→r⁢[φ]∈ℛ, all x∈Var⁡(ℓ) whose type is a theory sort, x∈Var⁡(φ), (4) ℓ⪰φr for all ℓ→r⁢[φ]∈𝒰⁢(𝒫,ℛ) and (5) ⪰ is covered by a reflexive, transitive, monotonic ⊒: if 𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ) and t→𝒬ℛt′, π(t)↓κ⊒π(t′)↓κ.

Proof of Lemma 45.

By induction on t.

  1. (1)

    t is a base-type ground theory term; then so is t′, and t→κt′. Hence, π(t)↓κ=π(t′)↓κ.

  2. (2)

    t=𝖿⁢t1⁢⋯⁢tn for 𝖿∈ℱ, and there exist a number p≤n, substitution σ and rule ℓ→r⁢[φ]∈ℛ such that ℓ=𝖿⁢ℓ1⁢⋯⁢ℓp, ti=ℓi⁢σ for all i∈{ 1,…,p}, t′=(r⁢σ)⁢tp+1⁢⋯⁢tn, σ⁢(x) is in normal form for all x and σ respects φ. Since 𝒩⁢ℱ⁢(𝒬)⊆𝒩⁢ℱ⁢(ℛ), (𝖿,n)∈𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ), and therefore 𝒰ℱ⁢(r⁢xp+1⁢⋯⁢xn)⁢[φ]⊆𝒰ℱ⁢(𝒫,ℛ) and πφ⁢(ℓ⁢xp+1⁢⋯⁢xn)→πφ⁢(r⁢xp+1⁢⋯⁢xn)⁢[φ]∈𝒰⁢(𝒫,ℛ) for xp+1,…,xn fresh variables. We have π⁢(t)=𝖿n⁢π⁢(ti1)⁢⋯⁢π⁢(tik) where regard⁡(𝖿)∩{ 1,…,n}={i1,…,ik} and i1<⋯<il≤p<il+1<⋯<ik. By Lemma 43, πφ⁢(ℓj)⁢σπ=π⁢(ℓj⁢σ)=π⁢(tj) for all j∈{ 1,…,l}. Since πφ⁢(xj)⁢([xi≔ti]i=p+1n)π=π⁢(tj) for all j∈{l+1,…,k}, π⁢(t)=πφ⁢(ℓ⁢xp+1⁢⋯⁢xn)⁢(σ∪[xi≔ti]i=p+1n)π. Due to Lemma 44, πφ(rxp+1⋯xn)(σ∪[xi≔ti]i=p+1n)π↓κ⊒π(t′)↓κ. Because ⊒ covers ⪰ and (σ∪[xi≔ti]i=p+1n)π respects φ, π(t)↓κ⊒π(t′)↓κ.

  3. (3)

    t=𝖿⁢t1⁢⋯⁢tn (𝖿∈ℱ♯) is not a base-type ground theory term, and there is m such that t′=𝖿⁢t1⁢⋯⁢tm−1⁢tm′⁢tm+1⁢⋯⁢tn and tm→𝒬ℛtm′. Then π⁢(t)=𝖿n⁢π⁢(ti1)⁢⋯⁢π⁢(tik) where regard⁡(𝖿)∩{ 1,…,n}={i1,…,ik} and i1<⋯<ik. Let ti′ be ti for all i∈{ 1,…,n}∖{m}. By induction, π(tm)↓κ⊒π(tm′)↓κ, and therefore π(t)↓κ⊒𝖿nπ(ti1′)↓κ⋯π(tik′)↓κ. If t′ is a ground theory term that has a base type, since (𝖿,n)∈𝒰ℱ𝔞⁢(t)⊆𝒰ℱ⁢(𝒫,ℛ), we have 𝖿n⁢xi1⁢⋯⁢xik→y⁢[y=𝖿⁢x1⁢⋯⁢xn]∈𝒰⁢(𝒫,ℛ); because ⊒ covers ⪰, 𝖿nπ(ti1′)↓κ⋯π(tik′)↓κ=𝖿nti1′↓κ⋯tik′↓κ⊒t′↓κ=π(t′)↓κ. Otherwise, π(t′)↓κ=𝖿nπ(ti1′)↓κ⋯π(tik′)↓κ.

  4. (4)

    t=x⁢t1⁢⋯⁢tk⁢⋯⁢tn for x∈𝒱, and t′=x⁢t1⁢⋯⁢tk′⁢⋯⁢tn; then π(t)=∙μ⁢(A)=π(t′).

◀

Theorem 46.

If the rewrite rules are preprocessed by Lemma 7, and all theory sorts are inextensible, then reduction pair processors with an argument filtering are sound.

Proof of Theorem 46.

Following Theorem 42, for all i and t′ such that ti♯⁢σi→𝒬ℛ∗t′, 𝒰ℱ𝔞⁢(t′)⊆𝒰ℱ⁢(𝒫,ℛ). Due to Lemma 45, π(ti♯σi)↓κ⊒π(si+1♯σi+1)↓κ for all i. For all i, if si♯⇒ti♯⁢[φi]∈𝒫′, due to Lemmas 43 and 44, π(si♯σi)↓κ=πφi(si♯)σiπ↓κ⊐πφi(ti♯)σiπ↓κ⊒π(ti♯σi)↓κ; if si♯⇒ti♯⁢[φi]∈𝒫∖𝒫′, similarly π(si♯σi)↓κ⊒π(ti♯σi)↓κ. Since ⊐ is well-founded, an infinite innermost (𝒫,ℛ)-chain leads to an infinite innermost (𝒫∖𝒫′,ℛ)-chain. ◀

A.2 The Proofs of Theorems 14 and 36

For the properties of ℂ-computability, see Appendix A in the extended version of [13]. The following proofs are largely based on Appendix A.3 in [20]; here the novelty lies on the innermostness of chains. Note that undefined function symbols are ℂ-computable (see [20]).

Lemma 47.

Assume given an AFP system ℛ0 with sort ordering ≿, an extension ℛ1 of ℛ0 and a sort ordering ≿′ which extends ≿ over sorts in ℛ0∪ℛ1. For each defined symbol 𝖿:A1→⋯→Am→B in ℛ0 where B is a sort, if 𝖿⁢s1⁢⋯⁢sm is not ℂ-computable in ℛ0∪ℛ1 with ≿′ but si is for all i, then there exist an SDP 𝖿♯⁢s′1⁢⋯⁢s′m⇒𝗀♯⁢t1⁢⋯⁢tn⁢[φ]∈SDP⁡(ℛ0), a substitution σ and a natural number p such that (1) si→iℛ0∪ℛ1∗si′⁢σ and si′⁢σ is in normal form for all i≤p, (2) si′ is a fresh variable (si′ does not occur in sj′ for any j≠i) and σ⁢(si′)=si for all i>p, (3) σ respects φ, and (4) (𝗀⁢t1⁢⋯⁢tn)⁢σ=𝗀⁢(t1⁢σ)⁢⋯⁢(tn⁢σ) is not ℂ-computable in ℛ0∪ℛ1 with ≿′ but u⁢σ is for each proper subterm u of 𝗀⁢t1⁢⋯⁢tn.

Proof.

If the only reducts of 𝖿⁢s1⁢⋯⁢sm were values or 𝖿⁢s′1⁢⋯⁢s′m with si→iℛ0∪ℛ1∗si′ for all i then 𝖿⁢s1⁢⋯⁢sm would be computable. Hence, there exist 𝖿⁢s′1⁢⋯⁢s′p→r⁢[φ]∈ℛ0 (𝖿 cannot be defined in ℛ1) and σ′ such that si→iℛ0∪ℛ1∗si′⁢σ′ and si′⁢σ′ is in normal form for all i≤p, and σ′ respects φ; (r⁢σ′)⁢sp+1⁢⋯⁢sm is thus a reduct of 𝖿⁢s1⁢⋯⁢sm. At least one such reduct is uncomputable. Let (r⁢σ′)⁢sp+1⁢⋯⁢sm be uncomputable, and therefore so is r⁢σ′. Also all σ′⁢(x) are computable, since these are accessible subterms of some si′, since ℛ0 is AFP.

Take a minimal subterm a⁢t1⁢⋯⁢tq of r such that t⁢σ′ is uncomputable. By minimality, each ti⁢σ′ is computable. Hence, a cannot be a variable, value or constructor, as then σ′⁢(x) would be computable, implying computability of t⁢σ′. Hence, a is a defined symbol 𝗀.

We have 𝖿♯⁢s′1⁢⋯⁢s′p⁢xp+1⁢⋯⁢xm⇒𝗀♯⁢t1⁢⋯⁢tq⁢yq+1⁢⋯⁢yn⁢[φ]∈SDP⁡(ℛ0). Because t⁢σ′ is uncomputable, there exist computable terms t′q+1,…,t′n such that (t⁢σ′)⁢t′q+1⁢⋯⁢t′n=𝗀⁢(t1⁢σ′)⁢⋯⁢(tq⁢σ′)⁢t′q+1⁢⋯⁢t′n is uncomputable. Let σ be such that σ⁢(xi)=si for all i>p, σ⁢(yi)=ti′ for all i>q, and σ⁢(z)=σ′⁢(z) for any other z. Let si′ denote xi for i>p and ti denote yi for i>q; then 𝖿♯⁢s′1⁢⋯⁢s′m⇒𝗀♯⁢t1⁢⋯⁢tn⁢[φ], σ and p satisfy all requirements. ◀

Corollary 48.

Given an AFP system ℛ0 with sort ordering ≿, an extension ℛ1 of ℛ0 and a sort ordering ≿′ which extends ≿ over sorts in ℛ0∪ℛ1, for each defined symbol 𝖿:A1→⋯→Am→B in ℛ0 (B a sort), if 𝖿⁢s1⁢⋯⁢sm is not ℂ-computable in ℛ0∪ℛ1 with ≿′ but each si is, there exists an infinite innermost (SDP⁡(ℛ0),ℛ0∪ℛ1)-chain (𝖿♯⁢s′1⁢⋯⁢s′m⇒t♯⁢[φ],σ),…

Proof.

Repeatedly applying Lemma 47 (on 𝖿⁢s1⁢⋯⁢sm, then on 𝗀⁢(t1⁢σ)⁢⋯⁢(tn⁢σ) and so on) we get three infinite sequences: one of SDPs in SDP⁡(ℛ0) (𝖿i♯⁢si,1⁢⋯⁢si,mi⇒𝖿i+1♯⁢ti,1⁢⋯⁢ti,ni⁢[φi])i where 𝖿0=𝖿, one of substitutions (σi)i and one of natural numbers (pi)i. Since →iℛ0∪ℛ1 is exactly →ℛ0∪ℛ1ℛ0∪ℛ1, combining the SDPs and the substitutions almost gives us an infinite innermost (SDP⁡(ℛ0),ℛ0∪ℛ1)-chain, except that si,j⁢σi may not be in normal form if j>pi.

We define (σi′)i so that, together with the SDPs, we obtain an infinite chain. For all i,j with pi<j≤mi, si,j is a fresh variable and σi⁢(si,j) is ℂ-computable. Let σi′⁢(x) be σi⁢(x) for x∈𝒱∖{si,pi+1,…,si,mi}. To define σi′⁢(si,j) for j>pi, let k0 be j and for l≥0, if kl exists and kl>pi+l, let kl+1 be the index (if any) with si+l,kl=ti+l,kl+1. There are two options:

  1. (1)

    If kl>pi+l for all l such that kl is defined, regardless of whether the sequence is finite, σi+l⁢(si+l,kl)=σi+l⁢(ti+l,kl+1)=σi+l+1⁢(si+l+1,kl+1) for all l such that kl+1 is defined. Let u be an arbitrary normal form of σi⁢(si,j), and let σi+l′⁢(si+l,kl) be u for all l where kl is defined.

  2. (2)

    Otherwise, the sequence (kl)l is finite, and kq≤pi+q where kq is the last in the sequence. Then si+q,kq⁢σi+q is in normal form. Let σi+l′⁢(si+l,kl) be si+q,kq⁢σi+q for all l<q.

Hence, we have built an infinite innermost (SDP⁡(ℛ0),ℛ0∪ℛ1)-chain. ◀

Theorem 14. [Restated, see original statement.]

An AFP system ℛ is innermost (and therefore call-by-value) terminating if there exists no infinite innermost (SDP⁡(ℛ),ℛ)-chain.

Proof.

Towards a contradiction, assume that ℛ is not innermost terminating. Then there is an uncomputable (not ℂ-computable) term u. Take a minimal subterm s of u that is uncomputable; then u=𝖿⁢s1⁢⋯⁢sk where 𝖿 is defined and each si is computable. Let 𝖿:A1→⋯→Am→B for B∈𝒮. Since s=𝖿⁢s1⁢⋯⁢sk is uncomputable, there exist computable sk+1,…,sm with s⁢sk+1⁢⋯⁢sm=𝖿⁢s1⁢⋯⁢sm uncomputable. By Corollary 48 (with ℛ1=∅), there is an infinite innermost (SDP⁡(ℛ),ℛ)-chain, giving the required contradiction. ◀

Theorem 36. [Restated, see original statement.]

An accessible function passing system ℛ0 with sort ordering ≿ is universally computable if there exists no infinite innermost (SDP⁡(ℛ0),ℛ0∪ℛ1)-chain for any extension ℛ1 of ℛ0 and extension ≿′ of ≿ to sorts in ℛ0∪ℛ1.

Proof.

Towards a contradiction, assume that ℛ0 is not universally computable. There exist an extension ℛ1 of ℛ0, sort ordering ≿′ which extends ≿ over sorts in ℛ0∪ℛ1 and term u of ℛ0 that is not ℂ-computable in ℛ0∪ℛ1 with ≿′. We consider ℂ-computability in ℛ0∪ℛ1. Take a minimal uncomputable subterm s of u; then s must take the form 𝖿⁢s1⁢⋯⁢sk with 𝖿 a defined symbol in ℛ0 and each si computable. Let 𝖿:A1→⋯→Am→B. Because s is uncomputable, there exist computable sk+1,…,sm of ℛ0∪ℛ1 with s⁢sk+1⁢⋯⁢sm=𝖿⁢s1⁢⋯⁢sm uncomputable. Corollary 48 gives the required chain to obtain a contradiction. ◀