A static higher-order dependency pair framework

We revisit the static dependency pair method for proving termination of higher-order term rewriting and extend it in a number of ways: (1) We introduce a new rewrite formalism designed for general applicability in termination proving of higher-order rewriting, Algebraic Functional Systems with Meta-variables. (2) We provide a syntactically checkable soundness criterion to make the method applicable to a large class of rewrite systems. (3) We propose a modular dependency pair framework for this higher-order setting. (4) We introduce a fine-grained notion of formative and computable chains to render the framework more powerful. (5) We formulate several existing and new termination proving techniques in the form of processors within our framework. The framework has been implemented in the (fully automatic) higher-order termination tool WANDA.


Introduction
Term rewriting [3,48] is an important area of logic, with applications in many different areas of computer science [4,11,18,23,25,36,41].Higher-order term rewriting -which extends the traditional first-order term rewriting with higher-order types and binders as in the λ-calculus -offers a formal foundation of functional programming and a tool for equational reasoning in higher-order logic.A key question in the analysis of both first-and higher-order term rewriting is termination; both for its own sake, and as part of confluence and equivalence analysis.
In first-order term rewriting, a hugely effective method for proving termination (both manually and automatically) is the dependency pair (DP) approach [2].This approach has been extended to the DP framework [20,22], a highly modular methodology which new techniques for proving termination and non-termination can easily be plugged into in the form of processors.
In higher-order rewriting, two DP approaches with distinct costs and benefits are used: dynamic [45,31] and static [6,44,34,46,32,33] DPs.Dynamic DPs are more broadly applicable, yet static DPs often enable more powerful analysis techniques.Still, neither approach has the modularity and extendability of the DP framework, nor can they be used to prove non-termination.Also, these approaches consider different styles of higher-order rewriting, which means that for all results certain language features are not available.
In this paper, we address these issues for the static DP approach by extending it to a full higher-order dependency pair framework for both termination and non-termination analysis.For broad applicability, we introduce a new rewriting formalism, AFSMs, to capture several flavours of higher-order rewriting, including AFSs [26] (used in the annual Termination Competition [50]) and pattern HRSs [39,37] (used in the annual Confluence Competition [10]).To show the versatility and power of this methodology, we define various processors in the frameworkboth adaptations of existing processors from the literature and entirely new ones.
Detailed contributions.We reformulate the results of [6,44,34,46,32] into a DP framework for AFSMs.In doing so, we instantiate the applicability restriction of [32] by a very liberal syntactic condition, and add two new flags to track properties of DP problems: one completely new, one from an earlier work by the authors for the first-order DP framework [16].We give eight processors for reasoning in our framework: four translations of techniques from static DP approaches, three techniques from first-order or dynamic DPs, and one completely new.This is a foundational paper, focused on defining a general theoretical framework for higher-order termination analysis using dependency pairs rather than questions of implementation.We have, however, implemented most of these results in the fully automatic termination analysis tool WANDA [28].
Related Work.There is a vast body of work in the first-order setting regarding the DP approach [2] and framework [20,22,24].We have drawn from the ideas in these works for the core structure of the higher-order framework, but have added some new features of our own and adapted results to the higher-order setting.
There is no true higher-order DP framework yet: both static and dynamic approaches actually lie halfway between the original "DP approach" of firstorder rewriting and a full DP framework as in [20,22].Most of these works [30,31,32,34,46] prove "non-loopingness" or "chain-freeness" of a set P of DPs through a number of theorems.Yet, there is no concept of DP problems, and the set R of rules cannot be altered.They also fix assumptions on dependency chains -such as minimality [34] or being "tagged" [31] -which frustrate extendability and are more naturally dealt with in a DP framework using flags.
The static DP approach for higher-order term rewriting is discussed in, e.g., [34,44,46].The approach is limited to plain function passing (PFP) systems.The definition of PFP has been made more liberal in later papers, but always concerns the position of higher-order variables in the left-hand sides of rules.These works include non-pattern HRSs [34,46], which we do not consider, but do not employ formative rules or meta-variable conditions, or consider non-termination, which we do.Importantly, they do not consider strictly positive inductive types, which could be used to significantly broaden the PFP restriction.Such types are considered in an early paper which defines a variation of static higher-order dependency pairs [6] based on a computability closure [8,7].However, this work carries different restrictions (e.g., DPs must be type-preserving and not introduce fresh variables) and considers only one analysis technique (reduction pairs).
Definitions of DP approaches for functional programming also exist [32,33], which consider applicative systems with ML-style polymorphism.These works also employ a much broader, semantic definition than PFP, which is actually more general than the syntactic restriction we propose here.However, like the static approaches for term rewriting, they do not truly exploit the computability [47] properties inherent in this restriction: it is only used for the initial generation of dependency pairs.In the present work, we will take advantage of our exact computability notion by introducing a computable flag that can be used by the computable subterm criterion processor (Thm.63) to handle benchmark systems that would otherwise be beyond the reach of static DPs.Also in these works, formative rules, meta-variable conditions and non-termination are not considered.
Regarding dynamic DP approaches, a precursor of the present work is [31], which provides a halfway framework (methodology to prove "chain-freeness") for dynamic DPs, introduces a notion of formative rules, and briefly translates a basic form of static DPs to the same setting.Our formative reductions consider the shape of reductions rather than the rules they use, and they can be used as a flag in the framework to gain additional power in other processors.The adaptation of static DPs in [31] was very limited, and did not for instance consider strictly positive inductive types or rules of functional type.
For a more elaborate discussion of both static and dynamic DP approaches in the literature, we refer to [31] and the second author's PhD thesis [29].
Organisation of the paper.§ 2 introduces higher-order rewriting using AFSMs and recapitulates computability.In § 3 we impose restrictions on the input AFSMs for which our framework is soundly applicable.In § 4 we define static DPs for AFSMs, and derive the key results on them.§ 5 formulates the DP framework and a number of DP processors for existing and new termination proving techniques.§ 6 concludes.Detailed proofs for all results in this paper (extending [17]) and an experimental evaluation are available in the appendix.In addition, many of the results have been informally published in the second author's PhD thesis [29].

Preliminaries
In this section, we first define our notation by introducing the AFSM formalism.
Although not one of the standards of higher-order rewriting, AFSMs combine features from various forms of higher-order rewriting and can be seen as a form of IDTSs [5] which includes application.We will finish with a definition of computability, a technique often used for higher-order termination methods.

Higher-order term rewriting using AFSMs
Unlike first-order term rewriting, there is no single, unified approach to higherorder term rewriting, but rather a number of similar but not fully compatible systems aiming to combine term rewriting and typed λ-calculi.For generality, we will use Algebraic Functional Systems with Meta-variables: a formalism which admits translations from the main formats of higher-order term rewriting.
Definition 1 (Simple types).We fix a set S of sorts.All sorts are simple types, and if σ, τ are simple types, then so is σ → τ .
We let → be right-associative.Note that all types have a unique representation in the form σ 1 → . . .→ σ m → ι with ι ∈ S.
Definition 2 (Terms and meta-terms).We fix disjoint sets F of function symbols, V of variables and M of meta-variables, each symbol equipped with a type.Each meta-variable is additionally equipped with a natural number.We assume that both V and M contain infinitely many symbols of all types.The set T (F, V) of terms over F, V consists of expressions s where s : σ can be derived for some type σ by the following clauses: (V) x : σ if x : σ ∈ V (@) s t : τ if s : σ → τ and t : σ (F) f : σ if f : σ ∈ F (Λ) λx.s : σ → τ if x : σ ∈ V and s : τ Meta-terms are expressions whose type can be derived by those clauses and: (M) Z s 1 , . . ., s k : σ k+1 → . . .→ σ m → ι if Z : (σ 1 → . . .→ σ k → . . .→ σ m → ι, k) ∈ M and s 1 : σ 1 , . . ., s k : σ k The λ binds variables as in the λ-calculus; unbound variables are called free, and FV (s) is the set of free variables in s.Meta-variables cannot be bound; we write FMV (s) for the set of meta-variables occurring in s.A meta-term s is called closed if FV (s) = ∅ (even if FMV (s) = ∅).Meta-terms are considered modulo α-conversion.Application (@) is left-associative; abstractions (Λ) extend as far to the right as possible.A meta-term s has type σ if s : σ; it has base type if σ ∈ S. We define head(s) = head(s 1 ) if s = s 1 s 2 , and head(s) = s otherwise.
A (meta-)term s has a sub-(meta-)term t, notation s ¤ t, if either s = t or s £ t, where s £ t if (a) s = λx.sand s ¤ t, (b) s = s 1 s 2 and s 2 ¤ t or (c) s = s 1 s 2 and s 1 ¤ t.A (meta-)term s has a fully applied sub-(meta-)term t, notation s t, if either s = t or s t, where s t if (a) s = λx.sand s t, (b) s = s 1 s 2 and s 2 t or (c) s = s 1 s 2 and s 1 t (so if s = x s 1 s 2 , then x and x s 1 are not fully applied subterms, but s and both s 1 and s 2 are).
For Z : (σ, k) ∈ M, we call k the arity of Z, notation arity(Z).
Clearly, all fully applied subterms are subterms, but not all subterms are fully applied.Every term s has a form t s 1 • • • s n with n ≥ 0 and t = head(s) a variable, function symbol, or abstraction; in meta-terms t may also be a meta-variable application F s 1 , . . ., s k .Terms are the objects that we will rewrite; meta-terms are used to define rewrite rules.Note that all our terms (and meta-terms) are, by definition, well-typed.For rewriting, we will employ patterns: Definition 3 (Patterns).A meta-term is a pattern if it has one of the forms Z x 1 , . . ., x k with all x i distinct variables; λx. with x ∈ V and a pattern; or In rewrite rules, we will use meta-variables for matching and variables only with binders.In terms, variables can occur both free and bound, and metavariables cannot occur.Meta-variables originate in very early forms of higherorder rewriting (e.g., [1,27]), but have also been used in later formalisms (e.g., [8]).They strike a balance between matching modulo β and syntactic matching.By using meta-variables, we obtain the same expressive power as with Miller patterns [37], but do so without including a reversed β-reduction as part of matching.
Notational conventions: We will use x, y, z for variables, X, Y, Z for metavariables, b for symbols that could be variables or meta-variables, f, g, h or more suggestive notation for function symbols, and s, t, u, v, q, w for (meta-)terms.Types are denoted σ, τ , and ι, κ are sorts.We will regularly overload notation and write x ∈ V, f ∈ F or Z ∈ M without stating a type (or minimal arity).For meta-terms Z we will usually omit the brackets, writing just Z.

Definition 4 (Substitution).
A meta-substitution is a type-preserving function γ from variables and meta-variables to meta-terms.Let the domain of γ be given by: dom We assume there are infinitely many variables x of all types such that (a) x / ∈ dom(γ) and (b) for all b ∈ dom(γ): x / ∈ FV (γ(b)).A substitution is a meta-substitution mapping everything in its domain to terms.The result sγ of applying a meta-substitution γ to a term s is obtained by: FV (γ(y)) For meta-terms, the result sγ is obtained by the clauses above and: and s is not an abstraction Note that for fixed k, any term has exactly one of the two forms above (λx 1 . . .x n .swith n < k and s not an abstraction, or λx 1 . . .x k .s).
Definition 5 (Rules and rewriting).Let F, V, M be fixed sets of function symbols, variables and meta-variables respectively.A rule is a pair ⇒ r of closed meta-terms of the same type such that is a pattern of the form f 1 • • • n with f ∈ F and FMV (r) ⊆ FMV ( ).A set of rules R defines a rewrite relation ⇒ R as the smallest monotonic relation on terms which includes: and is β-normal if there is no t with s ⇒ β t.Note that we are allowed to reduce at any position of a term, even below a λ.The relation ⇒ R is terminating if all terms over F, V are terminating.The set D ⊆ F of defined symbols consists of those (f : σ) ∈ F such that a rule f 1 • • • n ⇒ r exists; all other symbols are called constructors.
Note that R is allowed to be infinite, which is useful for instance to model polymorphic systems.Also, right-hand sides of rules do not have to be in β-normal form.While this is rarely used in practical examples, non-β-normal rules may arise through transformations, and we lose nothing by allowing them.Example 6.Let F ⊇ {0 : nat, s : nat → nat, nil : list, cons : nat → list → list, map : (nat → nat) → list → list} and consider the following rules R: Then map (λy.0) (cons (s 0) nil) ⇒ R cons 0 (map (λy.0) nil) ⇒ R cons 0 nil.Note that the bound variable y does not need to occur in the body of λy.0 to match λx.Z x .However, a term like map s (cons 0 nil) cannot be reduced, because s does not instantiate λx.Z x .We could alternatively consider the rules: Where the system before had (Z : (nat → nat, 1)) ∈ M, here we assume (Z : (nat → nat, 0)) ∈ M. Thus, rather than meta-variable application Z H we use explicit application Z H. Then map s (cons 0 nil) ⇒ R cons (s 0) (map s nil).However, we will often need explicit β-reductions; e.g., map (λy.0) (cons (s 0) nil) ⇒ R cons ((λy.0)(s 0)) (map (λy.0) nil) ⇒ β cons 0 (map (λy.0) nil).

Definition 7 (AFSM).
An AFSM is a tuple (F, V, M, R) of a signature and a set of rules built from meta-terms over F, V, M; as types of relevant variables and meta-variables can always be derived from context, we will typically just refer to the AFSM (F, R).An AFSM implicitly defines the abstract reduction system (T (F, V), ⇒ R ): a set of terms and a rewrite relation on this set.An AFSM is terminating if ⇒ R is terminating (on all terms in T (F, V)).
Discussion: The two most common formalisms in termination analysis of higher-order rewriting are algebraic functional systems [26] (AFSs) and higherorder rewriting systems [39,37] (HRSs).AFSs are very similar to our AFSMs, but use variables for matching rather than meta-variables; this is trivially translated to the AFSM format, giving rules where all meta-variables have arity 0, like the "alternative" rules in Ex. 6. HRSs use matching modulo β/η, but the common restriction of pattern HRSs can be directly translated into AFSMs, provided terms are β-normalised after every reduction step.Even without this β-normalisation step, termination of the obtained AFSM implies termination of the original HRS; for second-order systems, termination is equivalent.AFSMs can also naturally encode CRSs [27] and several applicative systems (cf.[29,Chapter 3]).

Example 8 (Ordinal recursion). A running example is the AFSM (
given below.As all meta-variables have arity 0, this can be seen as an AFS. Observant readers may notice that by the given constructors, the type nat in Ex. 8 is not inhabited.However, as the given symbols are only a subset of F, additional symbols (such as constructors for the nat type) may be included.The presence of additional function symbols does not affect termination of AFSMs: Theorem 9 (Invariance of termination under signature extensions).For an AFSM (F, R) with F at most countably infinite, let funs(R) ⊆ F be the set of function symbols occurring in some rule of R.
Proof.Trivial by replacing all function symbols in F \ funs(R) by corresponding variables of the same type.
Therefore, we will typically only state the types of symbols occurring in the rules, but may safely assume that infinitely many symbols of all types are present (which for instance allows us to select unused constructors in some proofs).

Computability
A common technique in higher-order termination is Tait and Girard's computability notion [47].There are several ways to define computability predicates; here we follow, e.g., [5,8,9,7] in considering accessible meta-terms using strictly positive inductive types.The definition presented below is adapted from these works, both to account for the altered formalism and to introduce (and obtain termination of) a relation C that we will use in the "computable subterm criterion processor" of Thm.63 (a termination criterion that allows us to handle systems that would otherwise be beyond the reach of static DPs).This allows for a minimal presentation that avoids the use of ordinals that would otherwise be needed to obtain C (see, e.g., [9,7]).
To define computability, we use the notion of an RC-set: Definition 10.A set of reducibility candidates, or RC-set, for a rewrite relation ⇒ R of an AFSM is a set I of base-type terms s such that: every term in and for all t with s ⇒ R t we have t ∈ I, then s ∈ I (for any u, s 0 , . . ., s n ∈ T (F, V)).
We define I-computability for an RC-set I by induction on types.For s ∈ T (F, V), we say that s is I-computable if either s is of base type and s ∈ I; or s : σ → τ and for all t : σ that are I-computable, s t is I-computable.
The traditional notion of computability is obtained by taking for I the set of all terminating base-type terms.Then, a term s is computable if and only if (a) s has base type and is terminating; or (b) s : σ → τ and for all computable t : σ the term s t is computable.This choice is simple but, for reasoning, not ideal: we do not have a property like: "if f s 1 • • • s n is computable then so is each s i ".Such a property would be valuable to have for generalising termination proofs from first-order to higher-order rewriting, as it allows us to use computability where the first-order proof uses termination.While it is not possible to define a computability notion with this property alongside case (b) (as such a notion would not be well-founded), we can come close to this property by choosing a different set for I.To define this set, we will use the notion of accessible arguments, which is used for the same purpose also in the General Schema [8], the Computability Path Ordering [9], and the Computability Closure [7].
Definition 11 (Accessible arguments).We fix a quasi-ordering S on S with well-founded strict part S := S \ S . 3For a type σ ≡ σ 1 → . . .→ σ m → κ (with κ ∈ S) and sort ι, let ι S + σ if ι S κ and ι S − σ i for all i, and let ι S − σ if ι S κ and ι S + σ i for all i.4For f :  (sketch).Note that we cannot define C as this set, as the set relies on the notion of C-computability.However, we can define C as the fixpoint of a monotone function operating on RC-sets.This follows the proof in, e.g., [8,9].
The full proof (for the definitions in this paper) is available in Appendix A.

Restrictions
The termination methodology in this paper is restricted to AFSMs that satisfy certain limitations: they must be properly applied (a restriction on the number of terms each function symbol is applied to) and accessible function passing (a restriction on the positions of variables of a functional type in the left-hand sides of rules).Both are syntactic restrictions that are easily checked by a computer (mostly; the latter requires a search for a sort ordering, but this is typically easy).

Properly applied AFSMs
In properly applied AFSMs, function symbols are assigned a certain, minimal number of arguments that they must always be applied to.
Definition 14.An AFSM (F, R) is properly applied if for every f ∈ D there exists an integer k such that for all rules ⇒ r ∈ R: That is, every occurrence of a function symbol in the right-hand side of a rule has at least as many arguments as the occurrences in the left-hand sides of rules.This means that partially applied functions are often not allowed: an AFSM with rules such as double X ⇒ plus X X and doublelist L ⇒ map double L is not properly applied, because double is applied to one argument in the left-hand side of some rule, and to zero in the right-hand side of another.This restriction is not as severe as it may initially seem since partial applications can be replaced by λ-abstractions; e.g., the rules above can be made properly applied by replacing the second rule by: doublelist L ⇒ map (λx.double x) L. By using η-expansion, we can transform any AFSM to satisfy this restriction: Definition 15 (R ↑ ).Given a set of rules R, let their η-expansion be given by and Z 1 , . . ., Z m fresh meta-variables}, where and s↑ η = s otherwise; f = f for f ∈ F and x = x for x ∈ V, while Z s 1 , . . ., s k = Z s 1 , . . ., s k and (λx.s) = λx.(s↑η ) and s 1 s 2 = s 1 (s 2 ↑ η ).
Note that ↑ η is a pattern if is.By [29, Thm.2.16], a relation ⇒ R is terminating if ⇒ R ↑ is terminating, which allows us to transpose any methods to prove termination of properly applied AFSMs to all AFSMs.
However, there is a caveat: this transformation can introduce non-termination in some special cases, e.g., the terminating rule f X ⇒ g f with f : o → o and g : (o → o) → o, whose η-expansion f X ⇒ g (λx.(f x)) is non-terminating.Thus, for a properly applied AFSM the methods in this paper apply directly.For an AFSM that is not properly applied, we can use the methods to prove termination (but not non-termination) by first η-expanding the rules.Of course, if this analysis leads to a counterexample for termination, we may still be able to verify whether this counterexample applies in the original, untransformed AFSM.
Example 16.Both AFSMs in Ex. 6 and the AFSM in Ex. 8 are properly applied.
Example 17.Consider an AFSM (F, R) with F ⊇ {sin, cos : real → real, times : real → real → real, deriv : (real → real) → real → real} and R = {deriv (λx.sinF x ) ⇒ λy.times (deriv (λx.F x ) y) (cos F y )}.Although the one rule has a functional output type (real → real), this AFSM is properly applied, with deriv having always at least 1 argument.Therefore, we do not need to use R ↑ .However, if R were to additionally include some rules that did not satisfy the restriction (such as the double and doublelist rules above), then η-expanding all rules, including this one, would be necessary.We have: R ↑ = {deriv (λx.sinF x ) Y ⇒ (λy.times (deriv (λx.F x ) y) (cos F y )) Y }.Note that the right-hand side of the η-expanded deriv rule is not β-normal.

Accessible Function Passing AFSMs
In accessible function passing AFSMs, variables of functional type may not occur at arbitrary places in the left-hand sides of rules: their positions are restricted using the sort ordering S and accessibility relation ¤ acc from Def. 11.

Definition 18 (Accessible function passing
).An AFSM (F, R) is accessible function passing (AFP) if there exists a sort ordering S following Def.11 such that: for all f 1 • • • n ⇒ r ∈ R and all Z ∈ FMV (r): there are variables x 1 , . . ., x k and some i such that i ¤ acc Z x 1 , . . ., x k .
The key idea of this definition is that computability of each i implies computability of all meta-variables in r.This excludes cases like Example 20 below.
Many common examples satisfy this restriction, including those we saw before: Example 19.Both systems from Ex. 6 are AFP: choosing the sort ordering S that equates nat and list, we indeed have cons H T ¤ acc H and cons H T ¤ acc T (as Acc(cons) = {1, 2}) and both λx.Z x ¤ acc Z x and Z ¤ acc Z.The AFSM from Ex. 8 is AFP because we can choose ord S nat and have lim H ¤ acc H following Ex. 12 (and also s X ¤ acc X and The AFSM from Ex. 17 is AFP, because λx.sin F x ¤ acc F x for any S : λx.sin F x ¤ acc F x because sin F x ¤ acc F x because 1 ∈ Acc(sin).
In fact, all first-order AFSMs (where all fully applied sub-meta-terms of the left-hand side of a rule have base type) are AFP via the sort ordering S that equates all sorts.Also (with the same sort ordering), an AFSM (F, R) is AFP if, for all rules where n i ≥ 0 and all fully applied sub-meta-terms of have base type.
This covers many practical systems, although for Ex. 8 we need a non-trivial sort ordering.Also, there are AFSMs that cannot be handled with any S .

Example 20 (Encoding the untyped λ-calculus). Consider an AFSM with
This AFSM is not accessible function passing, because lm F ¤ acc F cannot hold for any S (as this would require o S o).
Note that this example is also not terminating.With t = lm (λx.ap x x), we get this self-loop as evidence: Intuitively: in an accessible function passing AFSM, meta-variables of a higher type may occur only in "safe" places in the left-hand sides of rules.Rules like the ones in Ex. 20, where a higher-order meta-variable is lifted out of a base-type term, are not admitted (unless the base type is greater than the higher type).
In the remainder of this paper, we will refer to a properly applied, accessible function passing AFSM as a PA-AFP AFSM.
Discussion: This definition is strictly more liberal than the notions of "plain function passing" in both [34] and [46] as adapted to AFSMs.The notion in [46] largely corresponds to AFP if S equates all sorts, and the HRS formalism guarantees that rules are properly applied (in fact, all fully applied sub-metaterms of both left-and right-hand sides of rules have base type).The notion in [34] is more restrictive.The current restriction of PA-AFP AFSMs lets us handle examples like ordinal recursion (Ex.8) which are not covered by [34,46].However, note that [34,46] consider a different formalism, which does take rules whose lefthand side is not a pattern into account (which we do not consider).Our restriction also quite resembles the "admissible" rules in [6] which are defined using a pattern computability closure [5], but that work carries additional restrictions.
In later work [32,33], K. Kusakari extends the static DP approach to forms of polymorphic functional programming, with a very liberal restriction: the definition is parametrised with an arbitrary RC-set and corresponding accessibility ("safety") notion.Our AFP restriction is actually an instance of this condition (although a more liberal one than the example RC-set used in [32,33]).We have chosen a specific instance because it allows us to use dedicated techniques for the RC-set; for example, our computable subterm criterion processor (Thm.63).

Static higher-order dependency pairs
To obtain sufficient criteria for both termination and non-termination of AFSMs, we will now transpose the definition of static dependency pairs [6,34,46,33] to AFSMs.In addition, we will add the new features of meta-variable conditions, formative reductions, and computable chains.Complete versions of all proof sketches in this section are available in Appendix B.
Although we retain the first-order terminology of dependency pairs, the setting with meta-variables makes it more suitable to define DPs as triples.

Definition 21 ((Static) Dependency Pair). A dependency pair (DP) is a triple
A substitution γ respects a set of meta-variable conditions A if for all Z : i in A we have γ(Z) = λx 1 . . .x j .twith either i > j, or i ≤ j and x i ∈ FV (t).DPs will be used only with substitutions that respect their meta-variable conditions.
For p (∅) (so a DP whose set of meta-variable conditions is empty), we often omit the third component and just write p.
Like the first-order setting, the static DP approach employs marked function symbols to obtain meta-terms whose instances cannot be reduced at the root.
Moreover, we will consider candidates.In the first-order setting, candidate terms are subterms of the right-hand sides of rules whose root symbol is a defined symbol.Intuitively, these subterms correspond to function calls.In the current setting, we have to consider also meta-variables as well as rules whose right-hand side is not β-normal (which might arise for instance due to η-expansion).
Definition 23 (β-reduced-sub-meta-term, ¤ β , ¤ A ).A meta-term s has a fully applied β-reduced-sub-meta-term t (shortly, BRSMT), notation s ¤ β t, if there exists a set of meta-variable conditions A with s ¤ A t.Here s ¤ A t holds if: Essentially, s ¤ A t means that t can be reached from s by taking β-reductions at the root and "subterm"-steps, where Z : i is in A whenever we pass into argument i of a meta-variable Z. BRSMTs are used to generate candidates: Definition 24 (Candidates).For a meta-term s, the set cand(s) of candidates of s consists of those pairs t (A) such that (a) t has the form f s Example 25.In AFSMs where all meta-variables have arity 0 and the right-hand sides of rules are β-normal, the set cand(s) for a meta-term s consists exactly of the pairs t (∅) where t has the form f s 1 • • • s minar (f) and t occurs as part of s.In Ex. 8, we thus have cand(G If some of the meta-variables do take arguments, then the meta-variable conditions matter: candidates of s are pairs t (A) where A contains exactly those pairs Z : i for which we pass through the i th argument of Z to reach t in s.
Example 26.Consider an AFSM with the signature from Ex. 8 but a rule using meta-variables with larger arities: The right-hand side has one candidate: The original static approaches define DPs as pairs p where ⇒ r is a rule and p a subterm of r of the form f r 1 • • • r m -as their rules are built using terms, not meta-terms.This can set variables bound in r free in p.In the current setting, we use candidates with their meta-variable conditions and implicit β-steps rather than subterms, and we replace such variables by meta-variables.

Definition 27 (SDP ).
Let s be a meta-term and (F, R) be an AFSM.Let metafy(s) denote s with all free variables replaced by corresponding meta-variables.
Although static DPs always have a pleasant form as opposed to the dynamic DPs of, e.g., [31], whose right-hand sides can have a meta-variable at the head, which complicates various techniques in the framework), they have two important complications not present in first-order DPs: the righthand side p of a DP p (A) may contain meta-variables that do not occur in the left-hand side -traditional analysis techniques are not really equipped for this -and the left-and right-hand sides may have different types.In § 5 we will explore some methods to deal with these features.
Example 28.For the non-η-expanded rules of Ex. 17, the set SDP (R) has one element: deriv (λx.sinF x ) deriv (λx.F x ).(As times and cos are not defined symbols, they do not generate dependency pairs.)The set SDP (R ↑ ) for the η-expanded rules is {deriv (λx.sinF x ) Y deriv (λx.F x ) Y }.To obtain the relevant candidate, we used the β-reduction step of BRSMTs.
Example 29.The AFSM from Ex. 8 is AFP following Ex.19; here SDP (R) is: Note that the right-hand side of the second DP contains a meta-variable that is not on the left.As we will see in Ex. 64, that is not problematic here.
Termination analysis using dependency pairs importantly considers the notion of a dependency chain.This notion is fairly similar to the first-order setting: Definition 30 (Dependency chain).Let P be a set of DPs and R a set of rules.A (finite or infinite) (P, R)-dependency chain (or just (P, R)-chain) is a sequence [( 0 p 0 (A 0 ), s 0 , t 0 ), ( 1 p 1 (A 1 ), s 1 , t 1 ), . ..]where each i p i (A i ) ∈ P and all s i , t i are terms, such that for all i: 1. there exists a substitution γ on domain FMV ( i ) ∪ FMV (p i ) such that s i = i γ, t i = p i γ and for all Z ∈ dom(γ): γ(Z) respects A i ; 2. we can write In the (first) AFSM from Ex. 6, we have where ρ is the one DP, s 1 = map (λx.s x) (cons 0 (cons (s 0) (map (λx.x) nil))) and t 1 = map (λx.s x) (cons (s 0) (map (λx.x) nil)) and s 2 = map (λx.s x) (cons (s 0) nil) and t 2 = map (λx.s x) nil.
Note that here t 1 reduces to s 2 in a single step (map (λx.x) nil ⇒ R nil).
We have the following key result: then there is an infinite (SDP (R), R)-dependency chain.
Proof (sketch).The proof is an adaptation of the one in [34], altered for the more permissive definition of accessible function passing over plain function passing as well as the meta-variable conditions; it also follows from Thm. 37 below.
By this result we can use dependency pairs to prove termination of a given properly applied and AFP AFSM: if we can prove that there is no infinite (SDP (R), R)-chain, then termination follows immediately.Note, however, that the reverse result does not hold: it is possible to have an infinite (SDP (R), R)dependency chain even for a terminating PA-AFP AFSM.
the second rule does not cause the addition of any dependency pairs.Although ⇒ R is terminating, there is an infinite The problem in Ex. 33 is the non-conservative DP f 0 f X, with X on the right but not on the left.Such DPs arise from abstractions in the right-hand sides of rules.Unfortunately, abstractions are introduced by the restricted η-expansion (Def.15) that we may need to make an AFSM properly applied.Even so, often all DPs are conservative, like Ex. 6 and 17.There, we do have the inverse result: The core of the dependency pair framework is to systematically simplify a set of pairs (P, R) to prove either absence or presence of an infinite (P, R)-chain, thus showing termination or non-termination as appropriate.By Theorems 32 and 34 we can do so, although with some conditions on the non-termination result.We can do better by tracking certain properties of dependency chains.
Definition 35 (Minimal and Computable chains).Let (F, U) be an AFSM and C U an RC-set satisfying the properties of Thm. 13 for (F, U).Let F contain, for every type σ, at least countably many symbols f : σ not used in U.
A (P, R)-chain [(ρ 0 , s 0 , t 0 ), (ρ 1 , s 1 , t 1 ), . ..] is U-computable if: ⇒ U ⊇ ⇒ R , and for all i ∈ N there exists a substitution γ i such that A chain is minimal if the strict subterms of all t i are terminating under ⇒ R .
In the first-order DP framework, minimal chains give access to several powerful techniques to prove absence of infinite chains, such as the subterm criterion [24] and usable rules [22,24].Computable chains go a step further, by building on the computability inherent in the proof of Thm.32 and the notion of accessible function passing AFSMs.In computable chains, we can require that (some of) the subterms of all t i are computable rather than merely terminating.This property will be essential in the computable subterm criterion processor (Thm.63).
Another property of dependency chains is the use of formative rules, which has proven very useful for dynamic DPs [31].Here we go further and consider formative reductions, which were introduced for the first-order DP framework in [16].This property will be essential in the formative rules processor (Thm.58).
Here, for a pattern , substitution γ and term s, a reduction s ⇒ * R γ is -formative if one of the following holds: is not a fully extended linear pattern; that is: some meta-variable occurs more than once in or has a sub-meta-term λx.
R γ by an -formative reduction is not a meta-variable application, and there are ⇒ r ∈ R, meta-variables The idea of a formative reduction is to avoid redundant steps: if s ⇒ * R γ by an -formative reduction, then this reduction takes only the steps needed to obtain an instance of .Suppose that we have rules plus 0 Y ⇒ Y, plus (s X) Y ⇒ s (plus X Y ).Let := g 0 X and t := plus 0 0. Then the reduction g t t ⇒ R g 0 t is -formative: we must reduce the first argument to get an instance of .The reduction g t t ⇒ R g t 0 ⇒ R g 0 0 is not -formative, because the reduction in the second argument does not contribute to the non-meta-variable positions of .This matters when we consider as the left-hand side of a rule, say g 0 X ⇒ 0: if we reduce g t t ⇒ R g t 0 ⇒ R g 0 0 ⇒ R 0, then the first step was redundant: removing this step gives a shorter reduction to the same result: g t t ⇒ R g 0 t ⇒ R 0. In an infinite reduction, redundant steps may also be postponed indefinitely.
We can now strengthen the result of Thm.32 with two new properties.
Theorem 37. Let (F, R) be a properly applied, accessible function passing AFSM.If (F, R) is non-terminating, then there is an infinite R-computable formative (SDP (R), R)-dependency chain.
Proof (sketch).We select a minimal non-computable (MNC) term s := f s 1 • • • s k (where all s i are C R -computable) and an infinite reduction starting in s.Then we stepwise build an infinite dependency chain, as follows.Since s is non-computable but each s i terminates (as computability implies termination), there exist a rule f 1 • • • k ⇒ r and substitution γ such that each s i ⇒ * R i γ and rγ is noncomputable.We can then identify a candidate t (A) of r such that γ respects A and tγ is a MNC subterm of rγ; we continue the process with tγ (or a term at its head).For the formative property, we note that if s ⇒ * R γ and u is terminating, then u ⇒ * R δ by an -formative reduction for substitution δ such that each δ(Z) ⇒ * R γ(Z).This follows by postponing those reduction steps not needed to obtain an instance of .The resulting infinite chain is R-computable because we can show, by induction on the definition of ¤ acc , that if ⇒ r is an AFP rule and γ is a MNC term, then γ(Z) is C R -computable for all Z ∈ FMV (r).
As it is easily seen that all C U -computable terms are ⇒ U -terminating and therefore ⇒ R -terminating, every U-computable (P, R)-dependency chain is also minimal.The notions of R-computable and formative chains still do not suffice to obtain a true inverse result, however (i.e., to prove that termination implies the absence of an infinite R-computable chain over SDP (R)): the infinite chain in Ex. 33 is R-computable.
To see why the two restrictions that the AFSM must be properly applied and accessible function passing are necessary, consider the following examples.
This AFSM is not properly applied; it is also not terminating, as can be seen by instantiating F with λy.y.However, it does not have any static DPs, since fix F is not a candidate.Even if we altered the definition of static DPs to admit a dependency pair fix F X fix F , this pair could not be used to build an infinite dependency chain.
Note that the problem does not arise if we study the η-expanded rules R ↑ = {fix F X ⇒ F (λz.fix F z) X}, as the dependency pair fix F X fix F Z does admit an infinite chain.Unfortunately, as the one dependency pair does not satisfy the conditions of Thm.34, we cannot use this to prove non-termination.
Example 39.The AFSM from Ex. 20 is not accessible function passing, since Acc(lm) = ∅.This is good because the set SDP (R) is empty, which would lead us to falsely conclude termination without the restriction.Discussion: Thm.37 transposes the work of [34,46] to AFSMs and extends it by using a more liberal restriction, by limiting interest to formative, R-computable chains, and by including meta-variable conditions.Both of these new properties of chains will support new termination techniques within the DP framework.
The relationship with the works for functional programming [32,33] is less clear: they define a different form of chains suited well to polymorphic systems, but which requires more intricate reasoning for non-polymorphic systems, as DPs can be used for reductions at the head of a term.It is not clear whether there are non-polymorphic systems that can be handled with one and not the other.The notions of formative and R-computable chains are not considered there; meta-variable conditions are not relevant to their λ-free formalism.

The static higher-order DP framework
In first-order term rewriting, the DP framework [20] is an extendable framework to prove termination and non-termination.As observed in the introduction, DP analyses in higher-order rewriting typically go beyond the initial DP approach [2], but fall short of the full framework.Here, we define the latter for static DPs.Complete versions of all proof sketches in this section are available in Appendix C.
We have now reduced the problem of termination to non-existence of certain chains.In the DP framework, we formalise this in the notion of a DP problem: Definition 40 (DP problem).A DP problem is a tuple (P, R, m, f ) with P a set of DPs, R a set of rules, m ∈ {minimal, arbitrary} ∪ {computable U | any set of rules U}, and f ∈ {formative, all}. 5 DP problem (P, R, m, f ) is finite if there exists no infinite or if there exists an infinite (P, R)-chain where all DPs used in the chain are conservative.
To capture the levels of permissiveness in the m flag, we use a transitivereflexive relation generated by computable U minimal arbitrary.
Thus, the combination of Theorems 37 and 34 can be rephrased as: an AFSM (F, R) is terminating if (SDP (R), R, computable R , formative) is finite, and is non-terminating if (SDP (R), R, m, f ) is infinite for some m ∈ {computable U , minimal, arbitrary} and f ∈ {formative, all}. 6he core idea of the DP framework is to iteratively simplify a set of DP problems via processors until nothing remains to be proved: Definition 41 (Processor).A dependency pair processor (or just processor) is a function that takes a DP problem and returns either NO or a set of DP problems.A processor Proc is sound if a DP problem M is finite whenever Proc(M ) = NO and all elements of Proc(M ) are finite.A processor Proc is complete if a DP problem M is infinite whenever Proc(M ) = NO or contains an infinite element.
To prove finiteness of a DP problem M with the DP framework, we proceed analogously to the first-order DP framework [22]: we repeatedly apply sound DP processors starting from M until none remain.That is, we execute the following rough procedure: (1) let A := {M }; (2) while A = ∅: select a problem Q ∈ A and a sound processor Proc with Proc(Q) = NO, and let A := (A \ {Q}) ∪ Proc(Q).If this procedure terminates, then M is a finite DP problem.
To prove termination of an AFSM (F, R), we would use as initial DP problem (SDP (R), R, computable R , formative), provided that R is properly applied and accessible function passing (where η-expansion following Def.15 may be applied first).If the procedure terminates -so finiteness of M is proved by the definition of soundness -then Thm.37 provides termination of ⇒ R .
Similarly, we can use the DP framework to prove infiniteness: (1) let A := {M }; (2) while A = NO: select a problem Q ∈ A and a complete processor Proc, and let A := NO if Proc(Q) = NO, or A := (A \ {Q}) ∪ Proc(Q) otherwise.For non-termination of (F, R), the initial DP problem should be (SDP (R), R, m, f ), where m, f can be any flag (see Thm. 34).Note that the algorithms coincide while processors are used that are both sound and complete.In a tool, automation (or the user) must resolve the non-determinism and select suitable processors.
Below, we will present a number of processors within the framework.We will typically present processors by writing "for a DP problem M satisfying X, Y , Z, Proc(M ) = . . .".In these cases, we let Proc(M ) = {M } for any problem M not satisfying the given properties.Many more processors are possible, but we have chosen to present a selection which touches on all aspects of the DP framework: processors which map a DP problem to NO (Thm.65), a singleton set (most processors) and a non-singleton set (Thm.42); changing the set R (Thm.58, 54) and various flags (Thm.54); using specific values of the f (Thm.58) and m flags (Thm.61, 54, 63); using term orderings (Thm.49, 52), a key part of many termination proofs.

The dependency graph
We can leverage reachability information to decompose DP problems.In firstorder rewriting, a graph structure is used to track which DPs can possibly follow one another in a chain [2].Here, we define this dependency graph as follows.
Definition 42 (Dependency graph).A DP problem (P, R, m, f ) induces a graph structure DG, called its dependency graph, whose nodes are the elements of P.There is a (directed) edge from ρ 1 to ρ 2 in DG iff there exist s 1 , t 1 , s 2 , t 2 such that [(ρ 1 , s 1 , t 1 ), (ρ 2 , s 2 , t 2 )] is a (P, R)-chain with the properties for m, f .Example 43.Consider an AFSM with F ⊇ {f : The dependency graph of (P, R, minimal, formative) is: There is no edge from (1) to itself or (2) because there is no substitution γ such that (λx.0)γ can be reduced to a term (λx.F x )δ where δ(F ) regards its first argument (as ⇒ * R cannot introduce new variables).
In general, the dependency graph for a given DP problem is undecidable, which is why we consider approximations.
Definition 44 (Dependency graph approximation [31]).A finite graph G θ approximates DG if θ is a function that maps the nodes of DG to the nodes of G θ such that, whenever DG has an edge from ρ 1 to ρ 2 , G θ has an edge from θ(ρ 1 ) to θ(ρ 2 ).(G θ may have edges that have no corresponding edge in DG.) Note that this definition allows for an infinite graph to be approximated by a finite one; infinite graphs may occur if R is infinite (e.g., the union of all simply-typed instances of polymorphic rules).
If P is finite, we can take a graph approximation G id with the same nodes as DG.A simple approximation may have an edge from 1 p 1 (A 1 ) to 2 p 2 (A 2 ) whenever both p 1 and 2 have the form f s 1 • • • s k for the same f and k.However, one can also take the meta-variable conditions into account, as we did in Ex. 43.

Theorem 45 (Dependency graph processor). The processor Proc
is an approximation of the dependency graph of M and C 1 , . . ., C n are the (nodes of the) non-trivial strongly connected components (SCCs) of G θ , is both sound and complete.
Example 46.Let R be the set of rules from Ex. 43 and G be the graph given there.
Example 47.Let R consist of the rules for map from Ex. 6 along with f L ⇒ map (λx.g x) L and g X ⇒ X.Then SDP (R) = {(1) map (λx.Z x ) (cons H T ) map (λx.Z x ) T, (2) f L map (λx.g x) L, (3) f L g X}.DP (3) is not conservative, but it is not on any cycle in the graph approximation G id obtained by considering head symbols as described above: As ( 1) is the only DP on a cycle, Discussion: The dependency graph is a powerful tool for simplifying DP problems, used since early versions of the DP approach [2].Our notion of a dependency graph approximation, taken from [31], strictly generalises the original notion in [2], which uses a graph on the same node set as DG with possibly further edges.One can get this notion here by using a graph G id .The advantage of our definition is that it ensures soundness of the dependency graph processor also for infinite sets of DPs.This overcomes a restriction in the literature [34,Corollary 5.13] to dependency graphs without non-cyclic infinite paths.

Processors based on reduction triples
At the heart of most DP-based approaches to termination proving lie well-founded orderings to delete DPs (or rules).For this, we use reduction triples [24,31].
Definition 48 (Reduction triple).A reduction triple ( , , ) consists of two quasi-orderings and and a well-founded strict ordering on meta-terms such that is monotonic, all of , , are meta-stable (that is, r implies γ rγ if is a closed pattern and γ a substitution on domain FMV ( )∪FMV (r), and the same for and ), ⇒ β ⊆ , and both • ⊆ and • ⊆ .
In the first-order DP framework, the reduction pair processor [20] seeks to orient all rules with and all DPs with either or ; if this succeeds, those pairs oriented with may be removed.Using reduction triples rather than pairs, we obtain the following extension to the higher-order setting: Theorem 49 (Basic reduction triple processor).Let M = (P 1 P 2 , R, m, f ) be a DP problem.If ( , , ) is a reduction triple such that 1. for all ⇒ r ∈ R, we have r; 2. for all p (A) ∈ P 1 , we have p; 3. for all p (A) ∈ P 2 , we have p; then the processor that maps M to {(P 2 , R, m, f )} is both sound and complete.
Thm. 49 is not ideal since, by definition, the left-and right-hand side of a DP may have different types.Such DPs are hard to handle with traditional techniques such as HORPO [26] or polynomial interpretations [43,15], as these methods compare only (meta-)terms of the same type (modulo renaming of sorts).

Example 51. Consider the toy AFSM with
If f and g both have a type nat → nat → nat, then in the first DP, the left-hand side has type nat while the right-hand side has type nat → nat.In the second DP, the left-hand side has type nat → nat and the right-hand side has type nat.
To be able to handle examples like the one above, we adapt [31,Thm. 5.21] by altering the ordering requirements to have base type.
Here, the elements of Bot take the role of minimal terms for the ordering.We use them to flatten the type of the right-hand sides of ordering requirements, which makes it easier to use traditional methods to generate a reduction triple.
While and may still have to orient meta-terms of distinct types, these are always base types, which we could collapse to a single sort.The only relation required to be monotonic, , regards pairs of meta-terms of the same type.This makes it feasible to apply orderings like HORPO or polynomial interpretations.
Both the basic and non-basic reduction triple processor are difficult to use for non-conservative DPs, which generate ordering requirements whose right-hand side contains a meta-variable not occurring on the left.This is typically difficult for traditional techniques, although possible to overcome, by choosing triples that do not regard such meta-variables (e.g., via an argument filtering [35,46]): Example 53.We apply Thm.52 on the DP problem (SDP (R), R, computable R , formative) of Ex. 51.This gives for instance the following ordering requirements: The right-hand side of the last DP uses a meta-variable Z that does not occur on the left.As neither nor are required to be monotonic (only is), function symbols do not have to regard all their arguments.Thus, we can use a polynomial interpretation J to N with J ⊥nat = 0, J s (n) = n + 1 and J h (n 1 , n 2 ) = n 1 for h ∈ {f, f , g, g }.The ordering requirements then translate to X + 1 ≥ X and λy.X ≥ λz.X for the rules, and X + 1 > X and X ≥ X for the DPs.All these inequalities on N are clearly satisfied, so we can remove the first DP.The remaining problem is quickly dispersed with the dependency graph processor.

Rule removal without search for orderings
While processors often simplify only P, they can also simplify R. One of the most powerful techniques in first-order DP approaches that can do this are usable rules.The idea is that for a given set P of DPs, we only need to consider a subset UR(P, R) of R. Combined with the dependency graph processor, this makes it possible to split a large term rewriting system into a number of small problems.
In the higher-order setting, simple versions of usable rules have also been defined [46,31].We can easily extend these definitions to AFSMs: Theorem 54.Given a DP problem M = (P, R, m, f ) with m minimal and R finite, let UR(P, R) be the smallest subset of R such that: if a symbol f occurs in the right-hand side of an element of P or UR(P, R), and there is a rule f 1 • • • k ⇒ r, then this rule is also in UR(P, R); if there exists ⇒ r ∈ R or r (A) ∈ P such that r¤F s 1 , . . ., s k t 1 • • • t n with s 1 , . . ., s k not all distinct variables or with n > 0, then UR(P, R) = R.
Then the processor that maps M to {(P, UR(P, R), arbitrary, all)} is sound.
For the proof we refer to the very similar proofs in [46,31].
Example 55.For the set SDP (R) of the ordinal recursion example (Ex.8 and 29), all rules are usable due to the occurrence of H M in the second DP.For the set SDP (R) of the map example (Ex.6 and 31), there are no usable rules, since the one DP contains no defined function symbols or applied meta-variables.This higher-order processor is much less powerful than its first-order version: if any DP or usable rule has a sub-meta-term of the form F s or F s 1 , . . ., s k with s 1 , . . ., s k not all distinct variables, then all rules are usable.Since applying a higher-order meta-variable to some argument is extremely common in higher-order rewriting, the technique is usually not applicable.Also, this processor imposes a heavy price on the flags: minimality (at least) is required, but is lost; the formative flag is also lost.Thus, usable rules are often combined with reduction triples to temporarily disregard rules, rather than as a way to permanently remove rules.
To address these weaknesses, we consider a processor that uses similar ideas to usable rules, but operates from the left-hand sides of rules and DPs rather than the right.This adapts the technique from [31] that relies on the new formative flag.As in the first-order case [16], we use a semantic characterisation of formative rules.In practice, we then work with over-approximations of this characterisation, analogous to the use of dependency graph approximations in Thm.45.
Definition 56.A function FR that maps a pattern and a set of rules R to a set FR( , R) ⊆ R is a formative rules approximation if for all s and γ: if s ⇒ * R γ by an -formative reduction, then this reduction can be done using only rules in FR( , R).
We let FR(P, R) Thus, a formative rules approximation is a subset of R that is sufficient for a formative reduction: if s ⇒ * R γ, then s ⇒ * FR( ,R) γ.It is allowed for there to exist other formative reductions that do use additional rules.
Example 57.We define a simple formative rules approximation: (1) The following result follows directly from the definition of formative rules.
Theorem 58 (Formative rules processor).For a formative rules approximation FR, the processor Proc FR that maps a DP problem (P, R, m, formative) to {(P, FR(P, R), m, formative)} is both sound and complete.
Proof (sketch).A processor that only removes rules (or DPs) is always complete.For soundness, if the chain is formative then each step t i ⇒ * R s i+1 can be replaced by t i ⇒ * FR(P,R) s i+1 .Thus, the chain can be seen as a (P, FR(P, R))-chain.
Example 59.For our ordinal recursion example (Ex.8 and 29), none of the rules are included when we use the approximation of Ex. 57 since all rules have output type ord.Thus, Proc FR maps (SDP (R), R, computable R , formative) to (SDP (R), ∅, computable R , formative).Note: this example can also be completed without formative rules (see Ex. 64).Here we illustrate that, even with a simple formative rules approximation, we can often delete all rules of a given type.
Formative rules are introduced in [31], and the definitions can be adapted to a more powerful formative rules approximation than the one sketched in Ex. 59.Several examples and deeper intuition for the first-order setting are given in [16].

Subterm criterion processors
Reduction triple processors are powerful, but they exert a computational price: we must orient all rules in R. The subterm criterion processor allows us to remove DPs without considering R at all.It is based on a projection function [24], whose higher-order counterpart [34,46,31] is the following: Definition 60.For P a set of DPs, let heads(P) be the set of all symbols f that occur as the head of a left-or right-hand side of a DP in P. A projection function for P is a function ν : heads(P) → N such that for all DPs p (A) ∈ P, the function ν with ν(f s 1 • • • s n ) = s ν(f) is well-defined both for and for p.
Proof (sketch).If the conditions are satisfied, every infinite (P, R)-chain induces an infinite ¤ • ⇒ * R sequence that starts in a strict subterm of t 1 , contradicting minimality unless all but finitely many steps are equality.Since every occurrence of a pair in P 1 results in a strict £ step, a tail of the chain lies in P 2 .
The subterm criterion can be strengthened, following [34,46], to also handle DPs like the one in Ex. 28.Here, we focus on a new idea.For computable chains, we can build on the idea of the subterm criterion to get something more.
Theorem 63 (Computable subterm criterion processor).The processor Proc statcrit that maps a DP problem (P 1 P 2 , R, computable U , f ) to {(P 2 , R, computable U , f )} if a projection function ν exists such that ν( ) a ν(p) for all p (A) ∈ P 1 and ν( ) = ν(p) for all p (A) ∈ P 2 , is sound and complete.Here, a is the relation on base-type terms with s a t if s = t and (a) s¤ acc t or (b) a meta-variable Z exists with s ¤ acc Z x 1 , . . ., x k and t = Z t 1 , . . ., t k s 1 • • • s n .
Proof (sketch).By the conditions, every infinite (P, R)-chain induces an infinite R sequence (where C U is defined following Thm.13).This contradicts computability unless there are only finitely many inequality steps.As pairs in P 1 give rise to a strict decrease, they may occur only finitely often.
Example 64.Following Ex. 8 and 29, consider the projection function ν with ν(rec ) = 1.As s X ¤ acc X and lim H ¤ acc H, both s X a X and lim H a H M hold.Thus Proc statc (P, R, computable R , formative) = {(∅, R, computable R , formative)}.By the dependency graph processor, the AFSM is terminating.
The computable subterm criterion processor fundamentally relies on the new computable U flag, so it has no counterpart in the literature so far.

Non-termination
While (most of) the processors presented so far are complete, none of them can actually return NO.We have not yet implemented such a processor; however, we can already provide a general specification of a non-termination processor.
Theorem 65 (Non-termination processor).Let M = (P, R, m, f ) be a DP problem.The processor that maps M to NO if it determines that a sufficient criterion for non-termination of ⇒ R or for existence of an infinite conservative (P, R)-chain according to the flags m and f holds is sound and complete.
Proof.Obvious.This is a very general processor, which does not tell us how to determine such a sufficient criterion.However, it allows us to conclude non-termination as part of the framework by identifying a suitable infinite chain.
For example, for a DP problem (P, R, minimal, all) with P = {f F X g (F X), g X f h X}, there is a finite dependency chain: ) is an instance of f h x, the processor maps this DP problem to NO.
To instantiate Thm.65, we can borrow non-termination criteria from firstorder rewriting [21,42,13], with minor adaptions to the typed setting.Of course, it is worthwhile to also investigate dedicated higher-order non-termination criteria.

Conclusions and Future Work
We have built on the static dependency pair approach [6,34,46,33] and formulated it in the language of the DP framework from first-order rewriting [20,22].Our formulation is based on AFSMs, a dedicated formalism designed to make termination proofs transferrable to various higher-order rewriting formalisms.
This framework has two important additions over existing higher-order DP approaches in the literature.First, we consider not only arbitrary and minimally non-terminating dependency chains, but also minimally non-computable chains; this is tracked by the computable U flag.Using the flag, a dedicated processor allows us to efficiently handle rules like Ex. 8.This flag has no counterpart in the first-order setting.Second, we have generalised the idea of formative rules in [31] to a notion of formative chains, tracked by a formative flag.This makes it possible to define a corresponding processor that permanently removes rules.
Implementation and experiments.To provide a strong formal groundwork, we have presented several processors in a general way, using semantic definitions of, e.g., the dependency graph approximation and formative rules rather than syntactic definitions using functions like TCap [21].Even so, most parts of the DP framework for AFSMs have been implemented in the open-source termination prover WANDA [28], alongside a dynamic DP framework [31] and a mechanism to delegate some ordering constraints to a first-order tool [14].For reduction triples, polynomial interpretations [15] and a version of HORPO [29,Ch. 5] are used.To solve the constraints arising in the search for these orderings, and also to determine sort orderings (for the accessibility relation) and projection functions (for the subterm criteria), WANDA employs an external SAT-solver.WANDA has won the higher-order category of the International Termination Competition [50] four times.In the International Confluence Competition [10], the tools ACPH [40] and CSIˆho [38] use WANDA as their "oracle" for termination proofs on HRSs.
We have tested WANDA on the Termination Problems Data Base [49], using AProVE [19] and MiniSat [12] as back-ends.When no additional features are enabled, WANDA proves termination of 124 (out of 198) benchmarks with static DPs, versus 92 with only a search for reduction orderings; a 34% increase.When all features except static DPs are enabled, WANDA succeeds on 153 benchmarks, versus 166 with also static DPs; an 8% increase, or alternatively, a 29% decrease in failure rate.The full evaluation is available in Appendix D.
Future work.While the static and the dynamic DP approaches each have their own strengths, there has thus far been little progress on a unified approach, which could take advantage of the syntactic benefits of both styles.We plan to combine the present work with the ideas of [31] into such a unified DP framework.
In addition, we plan to extend the higher-order DP framework to rewriting with strategies, such as implicit β-normalisation or strategies inspired by functional programming languages like OCaml and Haskell.Other natural directions are dedicated automation to detect non-termination, and reducing the number of term constraints solved by the reduction triple processor via a tighter integration with usable and formative rules with respect to argument filterings.-APPENDIX -This appendix contains detailed proofs for all results in the paper.Proofs in higher-order rewriting are typically intricate and subject to errors in the small details, so we have strived to be very precise.However, aside from Appendix A (which is simply an adaptation of an existing technique to the present setting), the main idea of all proofs is captured by the proof sketches in the paper.
In addition, Appendix D presents an experimental evaluation that considers the power of the techniques in this paper on the termination problem database [49].

A Computability: the set C
In this appendix, we prove Thm. 13: the existence of an RC-set C that provides an accessibility relation ¤ acc that preserves computability, and a base-type accessibility step C that preserves both computability and termination.
As we have said before, V and F contain infinitely many symbols of all types.We will use this to select variables or constructor symbol of any given type without further explanation.
These proofs do not require that computability is considered with respect to a rewrite relation: other relations (such as recursive path orderings) may be used as well.To make this explicit, we will use an alternative relation symbol, a.
The proofs here consider a computability notion over the set T (F, V) of terms without restrictions.However, they could easily be extended to subsets of a different set of terms T , provided T is closed under ⇒ R .This could for instance be used to obtain a computability result for terms that satisfy certain arity restrictions.To make this generality clear, each quantification over terms is explicitly marked with T (F, V).
Note: a more extensive discussion of computability can be found in [7].Our notion of accessibility largely corresponds to membership of the computability closure defined there (although not completely).

A.1 Definitions and main computability result
Definition 67.In Appendix A, a is assumed to be a given relation on terms of the same type, with respect to which we consider computability.We require that: a is monotonic (that is, s a t implies that s u a t u and u s a u t and λx.s a λx.t); for all variables x: headβ u and s a t, then there exists v such that u a * v and t ⇒ * headβ v; here, ⇒ headβ is the relation generated by the step The generality obtained by imposing only the minimal requirements on a is not needed in the current paper (where we only consider computability with respect to a rewrite relation), but could be used to extend the method to other domains.First note: Lemma 68.A rewrite relation ⇒ R satisfies the requirements of a stated in Def.67.
Proof.Clearly ⇒ R is monotonic, applications with a variable at the head cannot be reduced at the head, and moreover ⇒ R includes ⇒ headβ .
The third property we prove by induction on s with ⇒ β , using ⇒ * R instead of ⇒ R for a stronger induction hypothesis.If s = u, then we are done choosing v := t.Otherwise we can write s = (λx.q)w 0 w 1 • • • w n and s ⇒ headβ s := q[x := w 0 ] w 1 • • • w n , and s ⇒ * headβ u.If the reduction s ⇒ * R t does not take any head steps, then and indeed u ⇒ * R v by monotonicity.Otherwise, by the same argument we can safely assume that the head step is done first, so s ⇒ * R t; we complete by the induction hypothesis.
Recall Def. 10 from the text.
Definition 10 (with a rather than ⇒ R ).A set of reducibility candidates, or RC-set, for a relation a as in Def.67 is a set I of base-type terms s ∈ T (F, V) such that: every term in I is terminating under a -I is closed under a (so if s ∈ I and s a t then t ∈ I) if s ∈ T (F, V) is neutral, and for all t with s a t we have t ∈ I, then s ∈ I We define I-computability for an RC-set I by induction on types; for s ∈ T (F, V) we say s is I-computable if: s : ι for some ι ∈ S and s ∈ I (ι ∈ S) s : σ → τ and for all terms t : σ ∈ T (F, V) that are I-computable, s t is

I-computable
For ι a sort and I an RC-set, we will write I(ι) = {s ∈ I | s : ι}.
Let us illustrate Def. 10 with two examples: Lemma 69.The set SN of all terminating base-type terms in T (F, V) is an RC-set.The set MIN of all terminating base-type terms in T (F, V) whose headβnormal form can be written Proof.It is easy to verify that the requirements hold for SN.For MIN, clearly termination holds.If s ∈ MIN, then s ⇒ * headβ x s 1 • • • s m =: s , so for any t with s a * t the assumptions on a provide that t ⇒ * headβ v for some a * -reduct of s , which can only have the form x t 1 • • • t m .Finally, we prove that a neutral term s ∈ T (F, V) is in MIN if all its a + -reducts are, by induction on s with ⇒ β (this suffices because we have already seen that MIN is closed under a).
is terminating, which is the case if all its reducts are terminating, which is certainly the case if they are in MIN.
all its reducts are terminating (which is satisfied if they are in MIN), and (b) the headβ-normal form s of s has the right form, which holds because s a + s (as ⇒ headβ is included in a) and therefore s ∈ MIN by assumption.
In fact, we have that MIN ⊆ I ⊆ SN for all RC-sets I.The latter inclusion is obvious by the termination requirement in the definition of RC-sets.The former inclusion follows easily: Lemma 70.For all RC-sets I, MIN ⊆ I.
Proof.We prove by induction on a that all elements of MIN are also in I.It is easy to see that if s ∈ MIN then s is neutral.Therefore, s ∈ I if t ∈ I whenever s a t.But since MIN is closed by Lemma 69, each such t is in MIN, so also in I by the induction hypothesis.
Aside from minimality of MIN, Lemma 70 actually provides I-computability of all variables, regardless of I. We prove this alongside termination of all Icomputable terms.
Lemma 71.Let I be an RC-set.The following statements hold for all types σ: 1. all variables x : σ are I-computable 2. all I-computable terms s : σ are terminating (w.r.t.a) Proof.By a mutual induction on the form of σ, which we may safely write σ 1 → . . .→ σ m → ι (with m ≥ 0 and ι ∈ S).
(1) By definition of I-computability, x : σ is computable if and only if x s 1 • • • s m ∈ I for all I-computable terms s 1 : σ 1 , . . ., s m : σ m in T (F, V).However, as all σ i are smaller types, we know that such terms s i are terminating, so Lemma 70 gives the required result.
(2) Let x 1 : σ 1 , . . ., x m : σ m be variables; by the induction hypothesis they are computable, and therefore s x 1 • • • x m is in I and therefore terminating.Then the head, s, cannot itself be non-terminating (by monotonicity of a).
While SN is indisputably the easiest RC-set to define and work with, it will be beneficial for the strength of the method to consider a set strictly between MIN and SN.To this end, we assume given an ordering on types, and a function mapping each function symbol f to a set Acc(f) of arguments positions.Here, we deviate from the text by not fixing Acc; again, this generality is not needed for the current paper, but is done with an eye on future extensions.
Definition 72 (Generalisation of Def.11).Assume given a quasi-ordering S on S whose strict part S := S \ S is well-founded.Let ≈ S denote the corresponding equivalence relation ≈ S := S ∩ S .
Remark: This definition of the accessibility relations deviates from, e.g., [9] by using a pair of relations ( S + and S − ) rather than positive and negative positions.This is not an important difference, but simply a matter of personal preference; using a pair of relations avoids the need to discuss type positions in the text, allowing for a shorter presentation.It is also not common to allow a choice in Acc(f), but rather to fix Acc(f) + σ} for some symbols (for instance constructors) and Acc(f) = ∅ for the rest.We elected to leave the choice open for greater generality.
The interplay of the positive and negative relations S + and S − leads to an important result on RC-sets.
First suppose ι S + σ; then ι S κ -so I(κ) ⊆ J(κ) -and each ι S − σ i .Assume that s is I-computable; we must show that it is J-computable, so that for all J-computable t 1 : σ 1 , . . ., t m : σ m we have: s t 1 • • • t m ∈ J.However, by the induction hypothesis each t i is also I-computable, so s t 1 • • • t m ∈ I(κ) ⊆ J(κ) by the assumption.
The RC-set C whose existence is asserted below offers computability with a notion of accessibility.It is worth noting that this is not a standard definition, but is designed to provide an additional relationship I that is terminating on computable terms.This relation will be useful in termination proofs using static DPs.
Theorem 74.Let I be the relation on base-type terms where f s 1 • • • s m I s i t 1 • • • t n whenever i ∈ Acc(f) and s i : σ 1 → . . .→ σ n → ι and each t j is I-computable.
There exists an RC-set C such that C = {s ∈ T (F, V) | s has base type ∧ s is terminating under a ∪ C and if s a * f s 1 • • • s m then s i is C-computable for all i ∈ Acc(f)}.
Proof.We will define, by well-founded induction on ι using S , a set A ι of terms as follows.
Assume A κ has already been defined for all κ with ι S κ, and let X ι be the set of RC-sets I such that I(κ) = A κ whenever ι S κ.We observe that X ι is a complete lattice with respect to ⊆: defining the bottom element ∅ := {A κ | ι S κ} ∪ MIN and the top element ∅ := {A κ | ι S κ} ∪ { SN(κ) | ¬(ι S κ)}, and letting Z := Z, Z := Z for non-empty Z, it is easily checked that and give a greatest lower and least upper bound within X ι respectively.Now for an RC-set I ∈ X ι , we let: Clearly, F ι maps elements of X ι to X ι : terms of type κ ≈ S ι are left alone, and F ι (I) satisfies the properties to be an RC-set.Moreover, F ι is monotone.To see this, let I, J ∈ X ι such that I ⊆ J; we must see that F ι (I) ⊆ F ι (J).To this end, let s ∈ F ι (I); we will see that also s ∈ F ι (J).This is immediate if s : κ ≈ S ι, as membership in X ι guarantees that F ι (I)(κ) = I(κ) ⊆ J(κ) = F ι (J)(κ).So assume s : κ ≈ S ι.We must see two things: s is terminating under a ∪ J .We show that a ∪ J ⊆ a ∪ I ; as s is terminating in the latter, the requirement follows.Clearly a ⊆ a ∪ I , so assume s J s .Then s = f t 1 • • • t m and s = t i u 1 • • • u n for i ∈ Acc(f) and J-computable u 1 , . . ., u n .We can write t i : σ 1 → . . .→ σ n → κ and since i ∈ Acc(f) we have ι S κ and ι S − σ j for each j.By Lemma 73 then each u j is also I-computable, so also s I s 1 .
-If s a * f s 1 • • • s m for some symbol f then for all i ∈ Acc(f): s i is Jcomputable.But this is obvious: as s ∈ F ι (I), we know that such s i are I-computable, and since ι S + σ i for i ∈ Acc(f), Lemma 73 provides Jcomputability.
Thus, F is a monotone function on a complete lattice; by Tarski's fixpoint theorem there is a fixpoint, so an RC-set I such that for all sorts κ: We define A κ := I(κ) for all κ ≈ S ι.Now we let C := ι∈S A ι .Clearly, C satisfies the given requirement.
Thm. 74 easily gives the proof of Thm. 13 in the text: Proof (Proof of Thm.13).Thm. 13 follows by taking ⇒ R for a (which satisfies the requirements by Lemma 68) and taking for each Acc(f) the maximum set {i | 1 ≤ i ≤ m ∧ ι S + σ i }.

A.2 Additional properties of computable terms
For reasoning about computable terms (as we will do when defining static DPs and reasoning about computable chains), there are a number of properties besides those in Lemma 71 that will prove very useful to have.In the following, we fix the RC-set C as obtained from Thm. 74.
Lemma 75.If s is C-computable and s a t, then t is also C-computable.
(This actually holds for any RC-set, but we will only use it for C.) Proof.By induction on the type of s.If s has base type, then C-computability implies that s ∈ C, and because C is an RC-set all reducts of s are also in C.
Otherwise, s : σ → τ and computability of s implies computability of s u for all computable u : σ.By the induction hypothesis, the fact that s u a t u by monotonicity of a implies that t u is computable for all computable u, and therefore by definition t is computable.
Thus, computability is preserved under a; the following result shows that it is also preserved under C .Lemma 76.If s is C-computable and s C t, then t is also C-computable.
Proof.If s C t, then both terms have base type, so C-computability is simply membership in C. We have s = f s 1 • • • s m and t = s i t 1 • • • t n with each t j Ccomputable.Since, by definition of C, also s i is C-computable, C-computability of t immediately follows.
Finally, we will see that C-computability is also preserved under ¤ acc .For this, we first make a more general statement, which will also handle variables below binders (which are freed in subterms).
Let u 1 : τ 1 , . . ., u n : τ n be C-computable terms, and δ a substitution with dom(δ) ⊆ V such that each δ(x) is C-computable, and for t := (t(γ ∪ δ)) u 1 • • • u n there is no overlap between FV (t ) and the variables bound in s.
Then there exist a C-computable substitution ξ with dom(ξ) ⊆ V and Ccomputable terms v 1 : σ 1 , . . ., v m : σ m such that we have (s We prove this by induction on (t 1 , . . ., t m ) ordered by a prod .Clearly, since s does not have the form f s 1 • • • s n with Acc(f) = ∅, nor does u, so u ∈ C if all its reducts are in C.But since s is neutral, all reducts of u either have the form s t 1 • • • t m with s a s -which is in C because all t i are C-computable and s is computable as a reduct of s -or the form s t 1 • • • t i • • • t m with t i a t i -which is in C by the induction hypothesis.
Using the ⇒ headβ -restrictions on a, we obtain the following result: For the other direction, suppose s[x := t] is C-computable for all C-computable t : σ.To obtain C-computability of λx.s, we must see that (λx.s) t is Ccomputable for all C-computable t : σ.As (λx.s) t is neutral, this holds if all its a-reducts u are C-computable by Lemma 79, and certainly if all its a +reducts are C-computable, which we prove by induction on u oriented with a.But by definition of a (and induction on the derivation (λx.s) t a + u) there exists a term v such that s[x := t] a * v and u ⇒ * headβ v.If u = v, we thus obtain the required property, and if u ⇒ + headβ v, then u is neutral and hence is C-computable if all its a-reducts are, which is the case by the induction hypothesis.

B Static dependency pairs
In this appendix, we will first prove the main result from § 4: Thm.37.Then, we will prove the "inverse" result, Thm. 34.Finally, to provide a greater context to the current work, we will discuss how the definitions in [34,46] relate to the definitions here.

B.1 Static dependency pairs: the main result
To start, we prove Thm. 37, which states that a properly applied, accessible function passing AFSM with rules R is terminating if it admits no R-computable formative (SDP (R), R)-dependency chains.Thm.32, which states that an AFSM is terminating if it admits no (SDP (R), R)-dependency chains, follows as a corollary.
In the following, let C = C R be a computability predicate following Def.74 for a the rewrite relation ⇒ R .We will briefly call a term "computable" if it is C-computable.
Henceforth, we will assume without explicitly stating it that (F, R) is properly applied, so we can speak of minar (f) without disclaimers; we let minar (f) = 0 for f / ∈ D. We start with an observation on the consequences of accessible function passingness: Lemma 81.Let be a closed pattern, Z a meta-variable and x 1 , . . ., x k variables such that ¤ acc Z x 1 , . . ., x k .If γ is a computable term, then so is γ(Z).
Thus, computability of the left-hand side of an instantiated DP implies computability of all instantiated meta-variables.To transfer this property to the right-hand side of the instantiated pair, we have a closer look at the relation ¤ A .
In the following, we say that a meta-term s respects minar if s Lemma 82.Let s be a meta-term that respects minar and γ a substitution on a finite domain with FMV (s) ⊆ dom(γ) ⊆ M, such that all γ(Z) are computable.If there exists a computable substitution δ on a variable domain (that is, dom(γ) ⊆ V) such that s(γ ∪ δ) is not computable, then there exists a pair t (A) ∈ cand(s) such that all of the following hold: there is a computable substitution δ on variable domain such that t(γ ∪ δ) is not computable; γ respects A; for all t = t such that t ¤ B t holds for some B respected by γ: t (γ ∪ δ) is computable for all computable substitutions δ on variable domain.
Proof.Let S be the set of all pairs t (A) such that (a) s ¤ A t, (b) there exists a computable substitution δ on variable domain such that t(γ ∪δ) is not computable, and (c) γ respects A. This set is non-empty, as it contains {s (∅)}.As the relations ¤ β and ⊇ are both well-founded quasi-orderings (the latter on finite sets), we can select a pair t (A) that is, in a sense, minimal in S: for all t (A ) ∈ S: if t ¤ β t then t = t and not A A (it is possible that A and A are incomparable).We observe that for all t , B such that t = t and t ¤ B t and γ respects B we cannot have t (A ∪ B) ∈ S by minimality of t (A), so since s ¤ A∪B t ¤ A∪B t and clearly γ respects A ∪ B, it can only follow that requirement (b) is not satisfied for t .Now suppose that t has the form f t 1 • • • t n .Then by the above reasoning, all t i (γ ∪ δ) are computable, and by definition of "s respects minar " we know that n ≥ k := minar (f).Thus, (f Otherwise, note that all many-step reducts of t(γ ∪ δ) are either also a reduct of (u[x := t 0 ] t 1 • • • t n )(γ ∪ δ) -and therefore computable -or have the form (λx.u ) t 0 • • • t n with u(γ ∪ δ) ⇒ * R u and each t i (γ ∪ δ) ⇒ * R t i .Thus, at least one of u(γ ∪ δ) or t i (γ ∪ δ) has to be non-terminating.But if u(γ ∪δ) is non-terminating, then so is u[x := u ](γ ∪δ), contradicting computability of (u[x := t 0 ] t 1 • • • t n )(γ ∪ δ).The same holds if t i (γ ∪ δ) is non-terminating for some i ≥ 1.Thus, t 0 (γ ∪ δ) is non-terminating and therefore non-computable, and we indeed have t ¤ A t 0 .
Next, let us consider formative reductions.We will prove that reductions from a terminating term to some instance of a pattern may be assumed to be formative.
Lemma 83.Let be a pattern and γ a substitution on domain FMV ( ) such that a meta-variable Z with arity(Z) = k is mapped to a term λx 1 . . .x k .t.Let s be a terminating term.If s ⇒ * R γ, then there exists a substitution δ on the same domain as γ such that each δ(Z) ⇒ * R γ(Z) and s ⇒ * R δ by an -formative reduction.
Note that the restriction on γ is very light: every substitution γ on domain FMV ( ) can be altered to map meta-variables with arity k to terms with k abstracted variables: if γ(Z) = λx 1 . . .x k .twith k = arity(Z) then let γ (Z) = γ(Z), and if γ(Z) = λx 1 . . .x i .twith i < arity(Z) and t not an abstraction, then replace this by setting γ (Z Proof.We prove the lemma by induction first on s ordered by ⇒ R ∪ £, second on the length of the reduction s ⇒ * R γ.If is not a fully extended linear pattern, then we are done choosing δ := γ.Otherwise, we consider four cases: 1. is a meta-variable application Z x 1 , . . ., x k ; 2. is not a meta-variable application, and the reduction s ⇒ * R γ does not contain any headmost steps; 3. is not a meta-variable application, and the reduction s ⇒ * R γ contains headmost steps, the first of which is a ⇒ β step; 4. is not a meta-variable application, and the reduction s ⇒ * R γ contains headmost steps, the first of which is not a ⇒ β step.
In the second case, a reduction without any headmost steps, note that s has the same outer shape as : either (a) s = λx.sand = λx., or (b) s = a s 1 • • • s n and = a 1 • • • n for some a ∈ V ∪ F (since is a pattern, a cannot be a metavariable application or abstraction if n > 0).In case (a), we obtain δ such that s ⇒ * R δ by an -formative reduction and δ ⇒ * R γ by the induction hypothesis (as sub-meta-terms of linear patterns are still linear patterns).In case (b), we let γ i be the restriction of γ to FMV ( i ) for 1 ≤ i ≤ n; by linearity of , all γ i have non-overlapping domains and γ = γ 1 ∪• • •∪γ n .The induction hypothesis provides δ 1 , . . ., δ n on the same domains such that each s i ⇒ * R i δ i by an i -formative reduction and δ i ⇒ * R γ i ; we are done choosing δ := δ 1 ∪ • • • ∪ δ n .In the third case, if the first headmost step is a β-step, note that s must have the form (λx.t) u q 1 • • • q n , and moreover s ⇒ * R (λx.t ) u q 1 • • • q n ⇒ β t [x := u ] q 1 • • • q n ⇒ * R γ by steps in the respective subterms.But then also s ⇒ β t[x := u] q 1 • • • q n ⇒ * R t [x := u ] q 1 • • • q n ⇒ * R γ, and we can get δ and an -formative reduction for t[x := u] q 1 • • • q n ⇒ * R δ by the induction hypothesis.In the last case, if the first headmost step is not a β-step, then we can write R γ for some f ∈ D, terms s j ⇒ * R s j for 1 ≤ j ≤ n, rule ⇒ r and substitution η on domain FMV ( ).But then , so by the first induction hypothesis we obtain δ such that (r R δ by anformative reduction, and δ ⇒ * R γ. Essentially, Lemma 83 states that we can postpone reductions that are not needed to obtain an instance of the given pattern.This is not overly surprising, but will help us eliminate some proof obligations later in the termination proof.
From this, we have the main result on static dependency chains.
Theorem 37. Let (F, R) be a properly applied, accessible function passing AFSM.If (F, R) is non-terminating, then there is an infinite R-computable formative (SDP (R), R)-dependency chain.
Proof.In the following, let a minimal non-computable term be a term s := f s 1 • • • s k with k = minar (f), such that f ∈ D, and s is not computable but all s i are C-computable.We say that s is MNC.We first observe that if ⇒ R is non-terminating, then there exists a MNC term.After all, if ⇒ R is non-terminating, then there is a non-terminating term s, which (by Lemma 71(2)) is also non-computable.Let t (A) be the element of cand(s) that is given by Lemma 82 for γ = δ = [].Then A = ∅ and t has the form f t 1 • • • t k with k = minar (f), and there exists a computable substitution δ such that tδ is not computable but all t i δ are.
Thus, assuming ⇒ R is non-terminating, we can select a MNC term t −1 .Now for i ∈ N, let a MNC term t i−1 = f q 1 • • • q k be given.By definition of computability, there are computable q k+1 , . . ., q m such that f q 1 • • • q k has base type and is not computable.Since all q i are computable this implies that f q 1 • • • q k is non-terminating, and since they are terminating, there is eventually a reduction at the head: there exist a rule f 1 • • • k ⇒ r and a substitution γ such that f q 1 • • • q m ⇒ * R,in f q 1 • • • q m (where ⇒ * R,in indicates a reduction in the argument terms q j ) = f ( 1 γ) • • • ( k γ) q k+1 • • • q m ⇒ R (rγ) q k+1 • • • q m , which latter term The definitions of PFP in [34,46] also capture some non-pattern HRSs, but these cannot be represented as AFSMs.Note that the key difference between ¤ [46]   safe and ¤ for patterns is that the former is not allowed to descend into a non-base argument of a function symbol.The same difference applies when comparing ¤ [46]   safe with ¤ acc : ¤ [46]  safe also cannot descend into the accessible higher-order arguments.
Example 88.The rules from Ex. 6 are PFP following both definitions.The rules from Ex. 17 are PFP following [46] but not following [34].The rules from Ex. 8 are not PFP in either definition, since lim F ¤ [46]  safe F does not hold (although they are AFP).
For a PFP AFSM, static dependency pairs are then defined as pairs f p 1 • • • p m .This allows for a very simple notion of chains, even closer to the one in the first-order setting than our Def.30.
Both papers present a counterpart of Theorems 32 and 37 that roughly translates to the following: Theorem 90 ( [34,46]).Let R be plain function passing following either definition in Def.87.
is non-terminating, then there is an infinite minimal static dependency chain with all i p i ∈ P.
Note that the chains are proved minimal, but not computable (which is a new definition in the current paper).
However, there is no counterpart to Thm. 34: this result relies on the presence of meta-variable conditions, which are not present in the static DPs from the literature.
Note that ¤ acc corresponds to ¤ [46]  safe (from Def.87) if S equates all sorts (as then always Acc(f) = { the indices of all base type arguments of f}).Thus, Def.18 includes both notions from Def. 87.

C Dependency pair processors
In this appendix, we prove the soundness -and where applicable completenessof all DP processors defined in the text.
We first observe: Lemma 91.If Proc maps every DP problem to a set of problems such that for all (P , R , m , f ) ∈ Proc(P, R, m, f ) we have that P ⊆ P, R ⊆ R, m m and f = f , then Proc is complete.
Proof.Proc(P, R, m, f ) is never NO.Suppose Proc(P, R, m, f ) contains an infinite element (P , R , m , f ); we must prove that then (P, R, m, f ) is infinite as well.This is certainly the case if ⇒ R is non-terminating, so assume that ⇒ R is terminating.Then certainly ⇒ R ⊆ ⇒ R is terminating as well, so (P , R , m , f ) can be infinite only because there exists an infinite (P , R )-chain that is Ucomputable if m = computable U , minimal if m = minimal and formative if f = formative.By definition, this is also a (P, R)-dependency chain, which is formative if f = f = formative.Since ⇒ R is terminating, this chain is also minimal.If we have m = computable U , then also m = computable U (since computable U is maximal under ) and the chain is indeed U-computable.

C.1 The dependency graph
The dependency graph processor lets us split a DP problem into multiple smaller ones.To prove soundness of its main processor, we first prove a helper result.
Proof.We claim (**): for all i ∈ N, there is an edge from θ(ρ i ) to θ(ρ i+1 ).By definition of approximation, the claim follows if DG has an edge from ρ i to ρ i+1 .But this is obvious: by definition of a chain, if [(ρ 0 , s 0 , t 0 ), (ρ 1 , s 1 , t 1 ), . ..] is a dependency chain, then so is [(ρ i , s i , t i ), (ρ i+1 , s i+1 , t i+1 )].Now, having (**), the chain traces an infinite path in G θ .Let C be the set of nodes that occur infinitely often on this path; then for every node d that is not in C, there is an index n d after which θ(ρ i ) is never d anymore.Since G θ is a finite graph, we can take n := max({n d | d a node in G θ ∧ d / ∈ C}).Now for every pair d, b ∈ C: because they occur infinitely often, there is some i > n with θ(ρ i ) = d and there is j > i with θ(ρ j ) = b.Thus, by (**) there is a path in G θ from d to b.Similarly, there is a path from b to d.Hence, they are on a cycle.
Note that to find a chain with all θ(ρ i ) ∈ C, we do not need to modify the original chain at all: the satisfying chain is a tail of the original chain.Hence, the same flags apply to the resulting chain.This makes it very easy to prove correctness of the main processor: Theorem 45 (Dependency graph processor).The processor Proc G θ that maps a DP problem M = (P, R, m, f ) to {({ρ ∈ P | θ(ρ) ∈ C i }, R, m, f ) | 1 ≤ i ≤ n} if G θ is an approximation of the dependency graph of M and C 1 , . . ., C n are the (nodes of the) non-trivial strongly connected components (SCCs) of G θ , is both sound and complete.
Proof.Completeness follows by Lemma 91.Soundness follows because if (P, R, m, f ) admits an infinite chain, then by Lemma 92 there is a cycle C such that a tail of this chain is mapped into C. Let C be the strongly connected component in which C lies, and P = {ρ ∈ P | θ(ρ) ∈ C }. Then clearly the same tail lies in P , giving an infinite (P , R, m, f )-chain, and (P , R, m, f ) is one of the elements of the set returned by the dependency graph processor.
and no rules have type ι; (3) FR(s, R) = R otherwise.This is a formative rules approximation: if s ⇒ * R Zγ by a Z-formative reduction, then s = Zγ, and if s ⇒ * R f 1 • • • m and no rules have the same output type as s, then s = f s 1 • • • s m and each s i ⇒ * R i γ (by an i -formative reduction).
x k .t]with γ = t.Let δ be [Z := λx 1 . . .x k .s].Then δ has the same domain as γ, and indeed δ , and for η := η ∪ [Z i+1 := s i+1 , . . ., Z n := s n ] we both have s ⇒ * R ( Z i+1 • • • Z n )η without any headmost steps, and (r Z i+1 • • • Z n )η ⇒ * R γ.By the second induction hypothesis, there exists a substitution ξ such thats ⇒ * R ( Z i+1 • • • Z n )ξ by a ( Z i+1 • • • Z n )-formative reduction and ξ ⇒ * R η .This gives s ⇒ . We write s ¤ acc t if either s = t, or s = λx.sands¤acct, or s = a s 1 • • • s n with a ∈ F ∪ V and s i ¤ acc t for some i ∈ Acc(a) with a / ∈ FV (s i ).With this definition, we will be able to define a set C such that, roughly, s is C-computable if and only if (a) s : σ → τ and s t is C-computable for all C-computable t, or (b) s has base type, is terminating, and ifs = f s 1 • • • s m then s i is C-computable for all accessible i (see Thm. 13 below).The reason that Acc(x) for x ∈ V is different is proof-technical: computability of λx.x s 1 • • • s m implies the computability of more arguments s i than computability of f s 1 • • • s m does, sincex can be instantiated by anything.Example 12. Consider a quasi-ordering S such that ord S nat.In Ex. 8, we then have ord S + nat → ord.Thus, 1 ∈ Acc(lim), which gives lim H ¤ acc H. Theorem 13.Let (F, R) be an AFSM.Let f s 1 • • • s m I s i t 1 • • • t n if both sides have base type, i ∈ Acc(f), and all t j are I-computable.There is an RC-set 48. Terese.Term Rewriting Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science.Cambridge University Press, 2003.49.Wiki.Termination Problems DataBase (tpdb).http://termination-portal.org/ wiki/TPDB.50.Wiki.The International Termination Competition (TermComp).http:// termination-portal.org/wiki/Termination_Competition,2018.
and only if s[x := t] is computable for all C-computable t : σ.Proof.If λx.s is C-computable, then by definition so is (λx.s)t for all Ccomputable t; by Lemma 75 and inclusion of ⇒ headβ in a, this implies Ccomputability of the reducts s[x := t].
not computable (since otherwise t(γ ∪ δ) would be computable), and by definition of S as a set of BRSMTs of s (and minimality of A) we have f t 1 • • • t k (A) ∈ cand(s).By minimality of t in S, we see that f t 1 • • • t k (A) satisfies all the requirements for the lemma to hold.Thus, if t has the form f t 1 • • • t n , we are done; towards a contradiction we will show that if t does not have this form, then t (A) is not minimal.Consider the form of t:t = λx.t:byLemma80,non-computability of t(γ ∪ δ) implies non-computability of t (γ ∪ δ)[x := u] for some computable u.Since, by α-conversion, we can assume that x does not occur in domain or range of γ or δ, we have non-computability of t (γ ∪ δ ∪ [x := u]), and δ ∪ [x := u] is a computable substitution on variable domain while t¤ A t .t=xt 1 • • • t n with x ∈ V: whether x ∈ dom(δ) or not, δ(x) is computable(either by the assumption on δ or by Lemma 71(1)).Therefore, the only way for t(γ ∪ δ) to not be computable is if some s i (γ ∪ δ) is not computable, ands ¤ A s i .t= c t 1 • • • t n with c ∈ F \ D: t(γ ∪ δ)is non-computable only if there exist computable terms u n+1 , . . ., u m such that the term c t 1 • • • t n u n+1 • • • u m of base type is not in C.This can only be the case if it is non-terminating or some t i (γ ∪ δ) is not computable.Since head-reductions are impossible, non-termination implies non-termination of some t i (γ ∪ δ) or u j , which by Lemma 71(2) implies non-computability; as all u j are computable by assumption, this means some t i (γ ∪ δ) is non-computable.We are done because t ¤ A t i .t = f t 1 • • • t n with f ∈ D but n < arity(f): same as above, because terms of this form cannot be reduced at the head (or the root).t = (λx.u)t 0 • • • t n : t(γ ∪ δ) is neutral, so by Lemma 79 non-computability implies the non-computability of a reduct.If the reduct u