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 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) length#(X) >? foldr#(/\x./\y.s(y), 0, X) 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)) 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: [[#argfun-length#(x_1)]] = x_1 [[0]] = _|_ [[foldr#(x_1, x_2, x_3)]] = foldr#(x_1) [[length(x_1)]] = x_1 [[length#(x_1)]] = length# We choose Lex = {} and Mul = {#argfun-length##, @_{o -> o -> o}, @_{o -> o}, cons, foldr, foldr#, length#, nil, s}, and the following precedence: foldr# > cons > s > foldr > @_{o -> o -> o} > nil > @_{o -> o} > length# > #argfun-length## Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldr#(F) >= foldr#(F) #argfun-length##(foldr#(/\x./\y.s(y))) > foldr#(/\x./\y.s(y)) foldr(F, X, nil) >= X foldr(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) foldr(/\x./\y.s(y), _|_, X) >= foldr(/\x./\y.s(y), _|_, X) With these choices, we have: 1] foldr#(F) >= foldr#(F) because foldr# in Mul and [2], by (Fun) 2] F >= F by (Meta) 3] #argfun-length##(foldr#(/\x./\y.s(y))) > foldr#(/\x./\y.s(y)) because [4], by definition 4] #argfun-length##*(foldr#(/\x./\y.s(y))) >= foldr#(/\x./\y.s(y)) because [5], by (Select) 5] foldr#(/\x./\y.s(y)) >= foldr#(/\x./\y.s(y)) because foldr# in Mul and [6], by (Fun) 6] /\x./\y.s(y) >= /\x./\y.s(y) because [7], by (Abs) 7] /\y.s(y) >= /\y.s(y) because [8], by (Abs) 8] s(x) >= s(x) because s in Mul and [9], by (Fun) 9] x >= x by (Var) 10] foldr(F, X, nil) >= X because [11], by (Star) 11] foldr*(F, X, nil) >= X because [12], by (Select) 12] X >= X by (Meta) 13] foldr(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) because [14], by (Star) 14] foldr*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) because foldr > @_{o -> o}, [15] and [21], by (Copy) 15] foldr*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, Y) because foldr > @_{o -> o -> o}, [16] and [17], by (Copy) 16] foldr*(F, X, cons(Y, Z)) >= F because [2], by (Select) 17] foldr*(F, X, cons(Y, Z)) >= Y because [18], by (Select) 18] cons(Y, Z) >= Y because [19], by (Star) 19] cons*(Y, Z) >= Y because [20], by (Select) 20] Y >= Y by (Meta) 21] foldr*(F, X, cons(Y, Z)) >= foldr(F, X, Z) because foldr in Mul, [2], [22] and [23], by (Stat) 22] X >= X by (Meta) 23] cons(Y, Z) > Z because [24], by definition 24] cons*(Y, Z) >= Z because [25], by (Select) 25] Z >= Z by (Meta) 26] foldr(/\x./\y.s(y), _|_, X) >= foldr(/\x./\y.s(y), _|_, X) because foldr in Mul, [6], [27] and [28], by (Fun) 27] _|_ >= _|_ by (Bot) 28] 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_0, R_0, static, formative) by (P_1, R_0, static, formative), where P_1 consists of: foldr#(F, X, cons(Y, Z)) =#> foldr#(F, X, Z) 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: [[length(x_1)]] = x_1 We choose Lex = {} and Mul = {#argfun-length#, 0, @_{o -> o -> o}, @_{o -> o}, cons, foldr, foldr#, nil, s}, and the following precedence: #argfun-length# > 0 > cons > foldr# > nil > foldr > s > @_{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: foldr#(F, X, cons(Y, Z)) > foldr#(F, X, Z) 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), 0, X)) >= foldr(/\x./\y.s(y), 0, X) With these choices, we have: 1] foldr#(F, X, cons(Y, Z)) > foldr#(F, X, Z) because [2], by definition 2] foldr#*(F, X, cons(Y, Z)) >= foldr#(F, X, Z) because foldr# in Mul, [3], [4] and [5], by (Stat) 3] F >= F by (Meta) 4] X >= X by (Meta) 5] cons(Y, Z) > Z because [6], by definition 6] cons*(Y, Z) >= Z because [7], by (Select) 7] Z >= Z by (Meta) 8] foldr(F, X, nil) >= X because [9], by (Star) 9] foldr*(F, X, nil) >= X because [10], by (Select) 10] X >= X by (Meta) 11] foldr(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) because [12], by (Star) 12] foldr*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), foldr(F, X, Z)) because foldr > @_{o -> o}, [13] and [19], by (Copy) 13] foldr*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, Y) because foldr > @_{o -> o -> o}, [14] and [15], by (Copy) 14] foldr*(F, X, cons(Y, Z)) >= F because [3], by (Select) 15] foldr*(F, X, cons(Y, Z)) >= Y because [16], by (Select) 16] cons(Y, Z) >= Y because [17], by (Star) 17] cons*(Y, Z) >= Y because [18], by (Select) 18] Y >= Y by (Meta) 19] foldr*(F, X, cons(Y, Z)) >= foldr(F, X, Z) because foldr in Mul, [3], [4] and [5], by (Stat) 20] #argfun-length#(foldr(/\x./\y.s(y), 0, X)) >= foldr(/\x./\y.s(y), 0, X) because [21], by (Star) 21] #argfun-length#*(foldr(/\x./\y.s(y), 0, X)) >= foldr(/\x./\y.s(y), 0, X) because #argfun-length# > foldr, [22], [27] and [28], by (Copy) 22] #argfun-length#*(foldr(/\x./\y.s(y), 0, X)) >= /\x./\y.s(y) because [23], by (F-Abs) 23] #argfun-length#*(foldr(/\x./\y.s(y), 0, X), z) >= /\x.s(x) because [24], by (F-Abs) 24] #argfun-length#*(foldr(/\x./\y.s(y), 0, X), z, u) >= s(u) because #argfun-length# > s and [25], by (Copy) 25] #argfun-length#*(foldr(/\x./\y.s(y), 0, X), z, u) >= u because [26], by (Select) 26] u >= u by (Var) 27] #argfun-length#*(foldr(/\x./\y.s(y), 0, X)) >= 0 because #argfun-length# > 0, by (Copy) 28] #argfun-length#*(foldr(/\x./\y.s(y), 0, X)) >= X because [29], by (Select) 29] foldr(/\x./\y.s(y), 0, X) >= X because [30], by (Star) 30] foldr*(/\x./\y.s(y), 0, 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.