We consider the system foldl. Alphabet: 0 : [] --> nat cons : [nat * list] --> list foldl : [nat -> nat -> nat * nat * list] --> nat nil : [] --> list plus : [nat * nat] --> nat plusc : [] --> nat -> nat -> nat sum : [list] --> nat Rules: foldl(f, x, nil) => x foldl(f, x, cons(y, z)) => foldl(f, f x y, z) plusc => /\x./\y.plus(x, y) sum(x) => foldl(plusc, 0, x) This AFS is converted to an AFSM simply by replacing all free variables by meta-variables (with arity 0). We use the dependency pair framework as described in [Kop12, Ch. 6/7], with dynamic dependency pairs. To start, the system is beta-saturated by adding the following rules: plusc X => /\x.plus(X, x) plusc X Y => plus(X, Y) After applying [Kop12, Thm. 7.22] to denote collapsing dependency pairs in an extended form, we thus obtain the following dependency pair problem (P_0, R_0, minimal, formative): Dependency Pairs P_0: 0] foldl#(F, X, cons(Y, Z)) =#> foldl#(F, F X Y, Z) 1] foldl#(F, X, cons(Y, Z)) =#> F(X, Y) 2] sum#(X) =#> foldl#(plusc, 0, X) 3] sum#(X) =#> plusc# Rules R_0: foldl(F, X, nil) => X foldl(F, X, cons(Y, Z)) => foldl(F, F X Y, Z) plusc => /\x./\y.plus(x, y) sum(X) => foldl(plusc, 0, X) plusc X => /\x.plus(X, x) plusc X Y => plus(X, Y) Thus, the original system is terminating if (P_0, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_0, R_0, minimal, formative). We place the elements of P in a dependency graph approximation G (see e.g. [Kop12, Thm. 7.27, 7.29], as follows: * 0 : 0, 1 * 1 : 0, 1, 2, 3 * 2 : 0, 1 * 3 : This graph has the following strongly connected components: P_1: foldl#(F, X, cons(Y, Z)) =#> foldl#(F, F X Y, Z) foldl#(F, X, cons(Y, Z)) =#> F(X, Y) sum#(X) =#> foldl#(plusc, 0, X) By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_0, R_0, m, f) by (P_1, R_0, m, f). Thus, the original system is terminating if (P_1, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_1, R_0, minimal, formative). This combination (P_1, R_0) has no formative rules! We will name the empty set of rules:R_1. By [Kop12, Thm. 7.17], we may replace the dependency pair problem (P_1, R_0, minimal, formative) by (P_1, R_1, minimal, formative). Thus, the original system is terminating if (P_1, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_1, R_1, minimal, formative). We will use the reduction pair processor [Kop12, Thm. 7.16]. As the system is abstraction-simple and the formative flag is set, it suffices to find a tagged reduction pair [Kop12, Def. 6.70]. Thus, we must orient: foldl#(F, X, cons(Y, Z)) >? foldl#(F, F X Y, Z) foldl#(F, X, cons(Y, Z)) >? F(X, Y) sum#(X) >? foldl#(plusc, 0, X) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( sum#(X) ) = #argfun-sum##(foldl#(plusc, 0, X)) Since this representation is not advantageous for the higher-order recursive path ordering, we present the strict requirements in their unextended form, which is not problematic since for any F, s and substituion gamma: (F s)gamma beta-reduces to F(s)gamma.) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[0]] = _|_ [[foldl#(x_1, x_2, x_3)]] = foldl#(x_3, x_1, x_2) [[plusc]] = _|_ [[sum#(x_1)]] = x_1 We choose Lex = {foldl#} and Mul = {#argfun-sum##, @_{o -> o -> o}, @_{o -> o}, cons}, and the following precedence: #argfun-sum## > cons > foldl# > @_{o -> o -> o} > @_{o -> o} Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl#(F, X, cons(Y, Z)) >= foldl#(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) foldl#(F, X, cons(Y, Z)) > @_{o -> o}(@_{o -> o -> o}(F, X), Y) #argfun-sum##(foldl#(_|_, _|_, X)) >= foldl#(_|_, _|_, X) With these choices, we have: 1] foldl#(F, X, cons(Y, Z)) >= foldl#(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) because [2], by (Star) 2] foldl#*(F, X, cons(Y, Z)) >= foldl#(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) because [3], [6], [8] and [16], by (Stat) 3] cons(Y, Z) > Z because [4], by definition 4] cons*(Y, Z) >= Z because [5], by (Select) 5] Z >= Z by (Meta) 6] foldl#*(F, X, cons(Y, Z)) >= F because [7], by (Select) 7] F >= F by (Meta) 8] foldl#*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, X), Y) because foldl# > @_{o -> o}, [9] and [12], by (Copy) 9] foldl#*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, X) because foldl# > @_{o -> o -> o}, [6] and [10], by (Copy) 10] foldl#*(F, X, cons(Y, Z)) >= X because [11], by (Select) 11] X >= X by (Meta) 12] foldl#*(F, X, cons(Y, Z)) >= Y because [13], by (Select) 13] cons(Y, Z) >= Y because [14], by (Star) 14] cons*(Y, Z) >= Y because [15], by (Select) 15] Y >= Y by (Meta) 16] foldl#*(F, X, cons(Y, Z)) >= Z because [17], by (Select) 17] cons(Y, Z) >= Z because [4], by (Star) 18] foldl#(F, X, cons(Y, Z)) > @_{o -> o}(@_{o -> o -> o}(F, X), Y) because [8], by definition 19] #argfun-sum##(foldl#(_|_, _|_, X)) >= foldl#(_|_, _|_, X) because [20], by (Star) 20] #argfun-sum##*(foldl#(_|_, _|_, X)) >= foldl#(_|_, _|_, X) because #argfun-sum## > foldl#, [21], [22] and [23], by (Copy) 21] #argfun-sum##*(foldl#(_|_, _|_, X)) >= _|_ by (Bot) 22] #argfun-sum##*(foldl#(_|_, _|_, X)) >= _|_ by (Bot) 23] #argfun-sum##*(foldl#(_|_, _|_, X)) >= X because [24], by (Select) 24] foldl#(_|_, _|_, X) >= X because [25], by (Star) 25] foldl#*(_|_, _|_, X) >= X because [26], by (Select) 26] X >= X by (Meta) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_1, R_1, minimal, formative) by (P_2, R_1, minimal, formative), where P_2 consists of: foldl#(F, X, cons(Y, Z)) =#> foldl#(F, F X Y, Z) sum#(X) =#> foldl#(plusc, 0, X) Thus, the original system is terminating if (P_2, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_2, R_1, minimal, formative). We place the elements of P in a dependency graph approximation G (see e.g. [Kop12, Thm. 7.27, 7.29], as follows: * 0 : 0 * 1 : 0 This graph has the following strongly connected components: P_3: foldl#(F, X, cons(Y, Z)) =#> foldl#(F, F X Y, Z) By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_2, R_1, m, f) by (P_3, R_1, m, f). Thus, the original system is terminating if (P_3, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_3, R_1, minimal, formative). We apply the subterm criterion with the following projection function: nu(foldl#) = 3 Thus, we can orient the dependency pairs as follows: nu(foldl#(F, X, cons(Y, Z))) = cons(Y, Z) |> Z = nu(foldl#(F, F X Y, Z)) By [FuhKop19, Thm. 61], we may replace a dependency pair problem (P_3, R_1, minimal, f) by ({}, R_1, minimal, f). By the empty set processor [Kop12, Thm. 7.15] this problem may be immediately removed. As all dependency pair problems were succesfully simplified with sound (and complete) processors until nothing remained, we conclude termination. +++ Citations +++ [FuhKop19] C. Fuhs, and C. Kop. A static higher-order dependency pair framework. In Proceedings of ESOP 2019, 2019. [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012.