We consider the system Applicative_05__Ex6Folding. Alphabet: 0 : [] --> c 1 : [] --> c add : [] --> c -> a -> c cons : [a * b] --> b fold : [c -> a -> c * b * c] --> c mul : [] --> c -> a -> c nil : [] --> b prod : [b] --> c sum : [b] --> c Rules: fold(f, nil, x) => x fold(f, cons(x, y), z) => fold(f, y, f z x) sum(x) => fold(add, x, 0) fold(mul, x, 1) => prod(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]). In order to do so, we start by eta-expanding the system, which gives: fold(F, nil, X) => X fold(F, cons(X, Y), Z) => fold(F, Y, F Z X) sum(X) => fold(/\x./\y.add(x, y), X, 0) fold(/\x./\y.mul(x, y), X, 1) => prod(X) We thus obtain the following dependency pair problem (P_0, R_0, static, formative): Dependency Pairs P_0: 0] fold#(F, cons(X, Y), Z) =#> fold#(F, Y, F Z X) 1] sum#(X) =#> fold#(/\x./\y.add(x, y), X, 0) Rules R_0: fold(F, nil, X) => X fold(F, cons(X, Y), Z) => fold(F, Y, F Z X) sum(X) => fold(/\x./\y.add(x, y), X, 0) fold(/\x./\y.mul(x, y), X, 1) => prod(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: fold#(F, cons(X, Y), Z) =#> fold#(F, Y, F Z 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, 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: fold#(F, cons(X, Y), Z) >? fold#(F, Y, F Z X) fold(F, nil, X) >= X fold(F, cons(X, Y), Z) >= fold(F, Y, F Z X) sum(X) >= fold(/\x./\y.add(x, y), X, 0) fold(/\x./\y.mul(x, y), X, 1) >= prod(X) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( sum(X) ) = #argfun-sum#(fold(/\x./\y.add(x, y), X, 0)) 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]] = _|_ [[add(x_1, x_2)]] = _|_ [[fold(x_1, x_2, x_3)]] = fold(x_2, x_1, x_3) [[fold#(x_1, x_2, x_3)]] = x_2 [[mul(x_1, x_2)]] = mul [[prod(x_1)]] = _|_ [[sum(x_1)]] = x_1 We choose Lex = {fold} and Mul = {#argfun-sum#, 1, @_{o -> o -> o}, @_{o -> o}, cons, mul, nil}, and the following precedence: mul > 1 > nil > #argfun-sum# > fold > @_{o -> o -> o} > cons > @_{o -> o} Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: cons(X, Y) > Y fold(F, nil, X) >= X fold(F, cons(X, Y), Z) >= fold(F, Y, @_{o -> o}(@_{o -> o -> o}(F, Z), X)) #argfun-sum#(fold(/\x./\y._|_, X, _|_)) >= fold(/\x./\y._|_, X, _|_) fold(/\x./\y.mul, X, 1) >= _|_ 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] fold(F, nil, X) >= X because [5], by (Star) 5] fold*(F, nil, X) >= X because [6], by (Select) 6] X >= X by (Meta) 7] fold(F, cons(X, Y), Z) >= fold(F, Y, @_{o -> o}(@_{o -> o -> o}(F, Z), X)) because [8], by (Star) 8] fold*(F, cons(X, Y), Z) >= fold(F, Y, @_{o -> o}(@_{o -> o -> o}(F, Z), X)) because [9], [10], [12] and [14], by (Stat) 9] cons(X, Y) > Y because [2], by definition 10] fold*(F, cons(X, Y), Z) >= F because [11], by (Select) 11] F >= F by (Meta) 12] fold*(F, cons(X, Y), Z) >= Y because [13], by (Select) 13] cons(X, Y) >= Y because [2], by (Star) 14] fold*(F, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because fold > @_{o -> o}, [15] and [18], by (Copy) 15] fold*(F, cons(X, Y), Z) >= @_{o -> o -> o}(F, Z) because fold > @_{o -> o -> o}, [10] and [16], by (Copy) 16] fold*(F, cons(X, Y), Z) >= Z because [17], by (Select) 17] Z >= Z by (Meta) 18] fold*(F, cons(X, Y), Z) >= X because [19], by (Select) 19] cons(X, Y) >= X because [20], by (Star) 20] cons*(X, Y) >= X because [21], by (Select) 21] X >= X by (Meta) 22] #argfun-sum#(fold(/\x./\y._|_, X, _|_)) >= fold(/\x./\y._|_, X, _|_) because [23], by (Star) 23] #argfun-sum#*(fold(/\x./\y._|_, X, _|_)) >= fold(/\x./\y._|_, X, _|_) because #argfun-sum# > fold, [24], [27] and [31], by (Copy) 24] #argfun-sum#*(fold(/\x./\y._|_, X, _|_)) >= /\x./\y._|_ because [25], by (F-Abs) 25] #argfun-sum#*(fold(/\x./\y._|_, X, _|_), z) >= /\x._|_ because [26], by (F-Abs) 26] #argfun-sum#*(fold(/\x./\y._|_, X, _|_), z, u) >= _|_ by (Bot) 27] #argfun-sum#*(fold(/\x./\y._|_, X, _|_)) >= X because [28], by (Select) 28] fold(/\x./\y._|_, X, _|_) >= X because [29], by (Star) 29] fold*(/\x./\y._|_, X, _|_) >= X because [30], by (Select) 30] X >= X by (Meta) 31] #argfun-sum#*(fold(/\x./\y._|_, X, _|_)) >= _|_ by (Bot) 32] fold(/\x./\y.mul, X, 1) >= _|_ by (Bot) 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.