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 dynamic dependency pairs. 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] fold#(F, cons(X, Y), Z) =#> fold#(F, Y, F Z X) 1] fold#(F, cons(X, Y), Z) =#> F(Z, X) 2] sum#(X) =#> fold#(add, 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(add, X, 0) fold(mul, X, 1) => prod(X) 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). This combination (P_0, 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_0, R_0, minimal, formative) by (P_0, R_1, minimal, formative). Thus, the original system is terminating if (P_0, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_0, 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: fold#(F, cons(X, Y), Z) >? fold#(F, Y, F Z X) fold#(F, cons(X, Y), Z) >? F(Z, X) sum#(X) >? fold#(add, X, 0) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( sum#(X) ) = #argfun-sum##(fold#(add, 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]] = _|_ [[fold#(x_1, x_2, x_3)]] = fold#(x_2, x_1, x_3) [[sum#(x_1)]] = x_1 We choose Lex = {fold#} and Mul = {#argfun-sum##, @_{o -> o -> o}, @_{o -> o}, add, cons}, and the following precedence: #argfun-sum## = add > cons > fold# > @_{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: fold#(F, cons(X, Y), Z) > fold#(F, Y, @_{o -> o}(@_{o -> o -> o}(F, Z), X)) fold#(F, cons(X, Y), Z) > @_{o -> o}(@_{o -> o -> o}(F, Z), X) #argfun-sum##(fold#(add, X, _|_)) >= fold#(add, X, _|_) With these choices, we have: 1] fold#(F, cons(X, Y), Z) > fold#(F, Y, @_{o -> o}(@_{o -> o -> o}(F, Z), X)) because [2], by definition 2] fold#*(F, cons(X, Y), Z) >= fold#(F, Y, @_{o -> o}(@_{o -> o -> o}(F, Z), X)) because [3], [6], [8] and [10], by (Stat) 3] cons(X, Y) > Y because [4], by definition 4] cons*(X, Y) >= Y because [5], by (Select) 5] Y >= Y by (Meta) 6] fold#*(F, cons(X, Y), Z) >= F because [7], by (Select) 7] F >= F by (Meta) 8] fold#*(F, cons(X, Y), Z) >= Y because [9], by (Select) 9] cons(X, Y) >= Y because [4], by (Star) 10] fold#*(F, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because fold# > @_{o -> o}, [11] and [14], by (Copy) 11] fold#*(F, cons(X, Y), Z) >= @_{o -> o -> o}(F, Z) because fold# > @_{o -> o -> o}, [6] and [12], by (Copy) 12] fold#*(F, cons(X, Y), Z) >= Z because [13], by (Select) 13] Z >= Z by (Meta) 14] fold#*(F, cons(X, Y), Z) >= X because [15], by (Select) 15] cons(X, Y) >= X because [16], by (Star) 16] cons*(X, Y) >= X because [17], by (Select) 17] X >= X by (Meta) 18] fold#(F, cons(X, Y), Z) > @_{o -> o}(@_{o -> o -> o}(F, Z), X) because [10], by definition 19] #argfun-sum##(fold#(add, X, _|_)) >= fold#(add, X, _|_) because [20], by (Star) 20] #argfun-sum##*(fold#(add, X, _|_)) >= fold#(add, X, _|_) because #argfun-sum## > fold#, [21], [22] and [26], by (Copy) 21] #argfun-sum##*(fold#(add, X, _|_)) >= add because #argfun-sum## = add and #argfun-sum## in Mul, by (Stat) 22] #argfun-sum##*(fold#(add, X, _|_)) >= X because [23], by (Select) 23] fold#(add, X, _|_) >= X because [24], by (Star) 24] fold#*(add, X, _|_) >= X because [25], by (Select) 25] X >= X by (Meta) 26] #argfun-sum##*(fold#(add, X, _|_)) >= _|_ by (Bot) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_0, R_1, minimal, formative) by (P_1, R_1, minimal, formative), where P_1 consists of: sum#(X) =#> fold#(add, X, 0) 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 place the elements of P in a dependency graph approximation G (see e.g. [Kop12, Thm. 7.27, 7.29], as follows: * 0 : This graph has no strongly connected components. By [Kop12, Thm. 7.31], this implies finiteness of the dependency pair problem. 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.