We consider the system Applicative_05__Ex5Folding. Alphabet: 0 : [] --> c add : [] --> a -> c -> c cons : [a * b] --> b fold : [a -> c -> c * c] --> b -> c mul : [] --> a -> c -> c nil : [] --> b plus : [c * c] --> c prod : [] --> b -> c s : [c] --> c sum : [] --> b -> c times : [c * c] --> c Rules: fold(f, x) nil => x fold(f, x) cons(y, z) => f y (fold(f, x) z) plus(0, x) => x plus(s(x), y) => s(plus(x, y)) times(0, x) => 0 times(s(x), y) => plus(times(x, y), y) sum => fold(add, 0) prod => fold(mul, s(0)) 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, X) cons(Y, Z) =#> F(Y, fold(F, X) Z) 1] fold(F, X) cons(Y, Z) =#> fold(F, X) Z 2] fold(F, X) cons(Y, Z) =#> fold#(F, X) 3] plus#(s(X), Y) =#> plus#(X, Y) 4] times#(s(X), Y) =#> plus#(times(X, Y), Y) 5] times#(s(X), Y) =#> times#(X, Y) 6] sum X =#> fold(add, 0) X 7] sum# =#> fold#(add, 0) 8] prod X =#> fold(mul, s(0)) X 9] prod# =#> fold#(mul, s(0)) Rules R_0: fold(F, X) nil => X fold(F, X) cons(Y, Z) => F Y (fold(F, X) Z) plus(0, X) => X plus(s(X), Y) => s(plus(X, Y)) times(0, X) => 0 times(s(X), Y) => plus(times(X, Y), Y) sum => fold(add, 0) prod => fold(mul, s(0)) 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, 2, 3, 4, 5, 6, 7, 8, 9 * 1 : 0, 1, 2 * 2 : * 3 : 3 * 4 : 3 * 5 : 4, 5 * 6 : 0, 1, 2 * 7 : * 8 : 0, 1, 2 * 9 : This graph has the following strongly connected components: P_1: fold(F, X) cons(Y, Z) =#> F(Y, fold(F, X) Z) fold(F, X) cons(Y, Z) =#> fold(F, X) Z sum X =#> fold(add, 0) X prod X =#> fold(mul, s(0)) X P_2: plus#(s(X), Y) =#> plus#(X, Y) P_3: times#(s(X), Y) =#> times#(X, Y) 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), (P_2, R_0, m, f) and (P_3, R_0, m, f). Thus, the original system is terminating if each of (P_1, R_0, minimal, formative), (P_2, R_0, minimal, formative) and (P_3, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_3, R_0, minimal, formative). We apply the subterm criterion with the following projection function: nu(times#) = 1 Thus, we can orient the dependency pairs as follows: nu(times#(s(X), Y)) = s(X) |> X = nu(times#(X, Y)) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_3, R_0, minimal, f) by ({}, R_0, minimal, f). By the empty set processor [Kop12, Thm. 7.15] this problem may be immediately removed. Thus, the original system is terminating if each of (P_1, R_0, minimal, formative) and (P_2, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_2, R_0, minimal, formative). We apply the subterm criterion with the following projection function: nu(plus#) = 1 Thus, we can orient the dependency pairs as follows: nu(plus#(s(X), Y)) = s(X) |> X = nu(plus#(X, Y)) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_2, R_0, minimal, f) by ({}, R_0, minimal, f). By the empty set processor [Kop12, Thm. 7.15] this problem may be immediately removed. 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: fold(F, X, cons(Y, Z)) >? F(Y, fold(F, X, Z)) fold(F, X, cons(Y, Z)) >? fold(F, X, Z) sum(X) >? fold(add, 0, X) prod(X) >? fold(mul, s(0), X) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( prod(X) ) = #argfun-prod#(fold(mul, s(0), X)) pi( sum(X) ) = #argfun-sum#(fold(add, 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]] = _|_ [[add]] = _|_ [[mul]] = _|_ [[prod(x_1)]] = x_1 [[sum(x_1)]] = x_1 We choose Lex = {} and Mul = {#argfun-prod#, #argfun-sum#, @_{o -> o -> o}, @_{o -> o}, cons, fold, s}, and the following precedence: #argfun-prod# > #argfun-sum# > fold > s > @_{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: fold(F, X, cons(Y, Z)) > @_{o -> o}(@_{o -> o -> o}(F, Y), fold(F, X, Z)) fold(F, X, cons(Y, Z)) >= fold(F, X, Z) #argfun-sum#(fold(_|_, _|_, X)) >= fold(_|_, _|_, X) #argfun-prod#(fold(_|_, s(_|_), X)) >= fold(_|_, s(_|_), X) With these choices, we have: 1] fold(F, X, cons(Y, Z)) > @_{o -> o}(@_{o -> o -> o}(F, Y), fold(F, X, Z)) because [2], by definition 2] fold*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, Y), fold(F, X, Z)) because fold > @_{o -> o}, [3] and [10], by (Copy) 3] fold*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, Y) because fold > @_{o -> o -> o}, [4] and [6], by (Copy) 4] fold*(F, X, cons(Y, Z)) >= F because [5], by (Select) 5] F >= F by (Meta) 6] fold*(F, X, cons(Y, Z)) >= Y because [7], by (Select) 7] cons(Y, Z) >= Y because [8], by (Star) 8] cons*(Y, Z) >= Y because [9], by (Select) 9] Y >= Y by (Meta) 10] fold*(F, X, cons(Y, Z)) >= fold(F, X, Z) because fold in Mul, [11], [12] and [13], by (Stat) 11] F >= F by (Meta) 12] X >= X by (Meta) 13] cons(Y, Z) > Z because [14], by definition 14] cons*(Y, Z) >= Z because [15], by (Select) 15] Z >= Z by (Meta) 16] fold(F, X, cons(Y, Z)) >= fold(F, X, Z) because [10], by (Star) 17] #argfun-sum#(fold(_|_, _|_, X)) >= fold(_|_, _|_, X) because [18], by (Star) 18] #argfun-sum#*(fold(_|_, _|_, X)) >= fold(_|_, _|_, X) because #argfun-sum# > fold, [19], [20] and [21], by (Copy) 19] #argfun-sum#*(fold(_|_, _|_, X)) >= _|_ by (Bot) 20] #argfun-sum#*(fold(_|_, _|_, X)) >= _|_ by (Bot) 21] #argfun-sum#*(fold(_|_, _|_, X)) >= X because [22], by (Select) 22] fold(_|_, _|_, X) >= X because [23], by (Star) 23] fold*(_|_, _|_, X) >= X because [24], by (Select) 24] X >= X by (Meta) 25] #argfun-prod#(fold(_|_, s(_|_), X)) >= fold(_|_, s(_|_), X) because [26], by (Star) 26] #argfun-prod#*(fold(_|_, s(_|_), X)) >= fold(_|_, s(_|_), X) because #argfun-prod# > fold, [27], [28] and [32], by (Copy) 27] #argfun-prod#*(fold(_|_, s(_|_), X)) >= _|_ by (Bot) 28] #argfun-prod#*(fold(_|_, s(_|_), X)) >= s(_|_) because [29], by (Select) 29] fold(_|_, s(_|_), X) >= s(_|_) because [30], by (Star) 30] fold*(_|_, s(_|_), X) >= s(_|_) because fold > s and [31], by (Copy) 31] fold*(_|_, s(_|_), X) >= _|_ by (Bot) 32] #argfun-prod#*(fold(_|_, s(_|_), X)) >= X because [33], by (Select) 33] fold(_|_, s(_|_), X) >= X because [34], by (Star) 34] fold*(_|_, s(_|_), X) >= X because [35], by (Select) 35] 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_4, R_1, minimal, formative), where P_4 consists of: fold(F, X) cons(Y, Z) =#> fold(F, X) Z sum X =#> fold(add, 0) X prod X =#> fold(mul, s(0)) X Thus, the original system is terminating if (P_4, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_4, 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 * 2 : 0 This graph has the following strongly connected components: P_5: fold(F, X) cons(Y, Z) =#> fold(F, X) Z By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_4, R_1, m, f) by (P_5, R_1, m, f). Thus, the original system is terminating if (P_5, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_5, R_1, minimal, formative). We apply the subterm criterion with the following projection function: nu(fold) = 3 Thus, we can orient the dependency pairs as follows: nu(fold(F, X) cons(Y, Z)) = cons(Y, Z) |> Z = nu(fold(F, X) Z) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_5, 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 +++ [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012.