We consider the system length. Alphabet: 0 : [] --> nat cons : [nat * list] --> list foldr : [nat -> nat -> nat * nat * list] --> nat length : [list] --> nat nil : [] --> list s : [nat] --> nat Rules: foldr(f, x, nil) => x foldr(f, x, cons(y, z)) => f y foldr(f, x, z) length(x) => foldr(/\y./\z.s(z), 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 static dependency pairs (see [KusIsoSakBla09] and the adaptation for AFSMs and accessible arguments in [Kop13]). We thus obtain the following dependency pair problem (P_0, R_0, static, formative): Dependency Pairs P_0: 0] foldr#(F, X, cons(Y, Z)) =#> foldr#(F, X, Z) 1] length#(X) =#> foldr#(/\x./\y.s(y), 0, X) Rules R_0: foldr(F, X, nil) => X foldr(F, X, cons(Y, Z)) => F Y foldr(F, X, Z) length(X) => foldr(/\x./\y.s(y), 0, X) Thus, the original system is terminating if (P_0, R_0, static, formative) is finite. We consider the dependency pair problem (P_0, R_0, static, 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_1: foldr#(F, X, cons(Y, Z)) =#> foldr#(F, X, Z) 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, static, formative) is finite. We consider the dependency pair problem (P_1, R_0, static, formative). We will use the reduction pair processor [Kop12, Thm. 7.16]. It suffices to find a standard reduction pair [Kop12, Def. 6.69]. Thus, we must orient: foldr#(F, X, cons(Y, Z)) >? foldr#(F, X, Z) foldr(F, X, nil) >= X foldr(F, X, cons(Y, Z)) >= F Y foldr(F, X, Z) length(X) >= foldr(/\x./\y.s(y), 0, X) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( length(X) ) = #argfun-length#(foldr(/\x./\y.s(y), 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]] = _|_ [[foldr#(x_1, x_2, x_3)]] = x_3 We choose Lex = {} and Mul = {#argfun-length#, @_{o -> o -> o}, @_{o -> o}, cons, foldr, length, nil, s}, and the following precedence: cons > #argfun-length# > foldr > @_{o -> o -> o} > @_{o -> o} > length > nil > s Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: cons(X, Y) > Y foldr(F, X, nil) >= X foldr(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) #argfun-length#(foldr(/\x./\y.s(y), _|_, X)) >= foldr(/\x./\y.s(y), _|_, X) With these choices, we have: 1] cons(X, Y) > Y because [2], by definition 2] cons*(X, Y) >= Y because [3], by (Select) 3] Y >= Y by (Meta) 4] foldr(F, X, nil) >= X because [5], by (Star) 5] foldr*(F, X, nil) >= X because [6], by (Select) 6] X >= X by (Meta) 7] foldr(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) because [8], by (Star) 8] foldr*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) because foldr > @_{o -> o}, [9] and [16], by (Copy) 9] foldr*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, Y) because foldr > @_{o -> o -> o}, [10] and [12], by (Copy) 10] foldr*(F, X, cons(Y, Z)) >= F because [11], by (Select) 11] F >= F by (Meta) 12] foldr*(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] foldr*(F, X, cons(Y, Z)) >= foldr(F, X, Z) because foldr in Mul, [17], [18] and [19], by (Stat) 17] F >= F by (Meta) 18] X >= X by (Meta) 19] cons(Y, Z) > Z because [2], by definition 20] #argfun-length#(foldr(/\x./\y.s(y), _|_, X)) >= foldr(/\x./\y.s(y), _|_, X) because [21], by (Star) 21] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X)) >= foldr(/\x./\y.s(y), _|_, X) because #argfun-length# > foldr, [22], [27] and [28], by (Copy) 22] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X)) >= /\x./\y.s(y) because [23], by (F-Abs) 23] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X), z) >= /\x.s(x) because [24], by (F-Abs) 24] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X), z, u) >= s(u) because #argfun-length# > s and [25], by (Copy) 25] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X), z, u) >= u because [26], by (Select) 26] u >= u by (Var) 27] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X)) >= _|_ by (Bot) 28] #argfun-length#*(foldr(/\x./\y.s(y), _|_, X)) >= X because [29], by (Select) 29] foldr(/\x./\y.s(y), _|_, X) >= X because [30], by (Star) 30] foldr*(/\x./\y.s(y), _|_, X) >= X because [31], by (Select) 31] X >= X by (Meta) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace a dependency pair problem (P_1, R_0) by ({}, R_0). 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 +++ [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012. [Kop13] C. Kop. Static Dependency Pairs with Accessibility. Unpublished manuscript, http://cl-informatik.uibk.ac.at/users/kop/static.pdf, 2013. [KusIsoSakBla09] K. Kusakari, Y. Isogai, M. Sakai, and F. Blanqui. Static Dependency Pair Method Based On Strong Computability for Higher-Order Rewrite Systems. In volume 92(10) of IEICE Transactions on Information and Systems. 2007--2015, 2009.