We consider the system Applicative_05__Ex5Sorting. Alphabet: 0 : [] --> a ascending!fac6220sort : [b] --> b cons : [a * b] --> b descending!fac6220sort : [b] --> b insert : [a -> a -> a * a -> a -> a * b * a] --> b max : [] --> a -> a -> a min : [] --> a -> a -> a nil : [] --> b s : [a] --> a sort : [a -> a -> a * a -> a -> a * b] --> b Rules: max 0 x => x max x 0 => x max s(x) s(y) => max x y min 0 x => 0 min x 0 => 0 min s(x) s(y) => min x y insert(f, g, nil, x) => cons(x, nil) insert(f, g, cons(x, y), z) => cons(f z x, insert(f, g, y, g z x)) sort(f, g, nil) => nil sort(f, g, cons(x, y)) => insert(f, g, sort(f, g, y), x) ascending!fac6220sort(x) => sort(min, max, x) descending!fac6220sort(x) => sort(max, min, 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] max s(X) s(Y) =#> max X Y 1] max s(X) s(Y) =#> max X 2] max s(X) s(Y) =#> max# 3] min s(X) s(Y) =#> min X Y 4] min s(X) s(Y) =#> min X 5] min s(X) s(Y) =#> min# 6] insert#(F, G, cons(X, Y), Z) =#> F(Z, X) 7] insert#(F, G, cons(X, Y), Z) =#> insert#(F, G, Y, G Z X) 8] insert#(F, G, cons(X, Y), Z) =#> G(Z, X) 9] sort#(F, G, cons(X, Y)) =#> insert#(F, G, sort(F, G, Y), X) 10] sort#(F, G, cons(X, Y)) =#> sort#(F, G, Y) 11] ascending!fac6220sort#(X) =#> sort#(min, max, X) 12] ascending!fac6220sort#(X) =#> min# 13] ascending!fac6220sort#(X) =#> max# 14] descending!fac6220sort#(X) =#> sort#(max, min, X) 15] descending!fac6220sort#(X) =#> max# 16] descending!fac6220sort#(X) =#> min# Rules R_0: max 0 X => X max X 0 => X max s(X) s(Y) => max X Y min 0 X => 0 min X 0 => 0 min s(X) s(Y) => min X Y insert(F, G, nil, X) => cons(X, nil) insert(F, G, cons(X, Y), Z) => cons(F Z X, insert(F, G, Y, G Z X)) sort(F, G, nil) => nil sort(F, G, cons(X, Y)) => insert(F, G, sort(F, G, Y), X) ascending!fac6220sort(X) => sort(min, max, X) descending!fac6220sort(X) => sort(max, min, 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). 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 * 1 : * 2 : * 3 : 3, 4, 5 * 4 : * 5 : * 6 : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 * 7 : 6, 7, 8 * 8 : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 * 9 : 6, 7, 8 * 10 : 9, 10 * 11 : 9, 10 * 12 : * 13 : * 14 : 9, 10 * 15 : * 16 : This graph has the following strongly connected components: P_1: max s(X) s(Y) =#> max X Y P_2: min s(X) s(Y) =#> min X Y P_3: insert#(F, G, cons(X, Y), Z) =#> F(Z, X) insert#(F, G, cons(X, Y), Z) =#> insert#(F, G, Y, G Z X) insert#(F, G, cons(X, Y), Z) =#> G(Z, X) sort#(F, G, cons(X, Y)) =#> insert#(F, G, sort(F, G, Y), X) sort#(F, G, cons(X, Y)) =#> sort#(F, G, Y) ascending!fac6220sort#(X) =#> sort#(min, max, X) descending!fac6220sort#(X) =#> sort#(max, min, 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), (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). The formative rules of (P_3, R_0) are R_1 ::= insert(F, G, nil, X) => cons(X, nil) insert(F, G, cons(X, Y), Z) => cons(F Z X, insert(F, G, Y, G Z X)) sort(F, G, nil) => nil sort(F, G, cons(X, Y)) => insert(F, G, sort(F, G, Y), X) ascending!fac6220sort(X) => sort(min, max, X) descending!fac6220sort(X) => sort(max, min, X) By [Kop12, Thm. 7.17], we may replace the dependency pair problem (P_3, R_0, minimal, formative) by (P_3, R_1, minimal, formative). 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_1, minimal, formative) is finite. We consider the dependency pair problem (P_3, 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: insert#(F, G, cons(X, Y), Z) >? F(Z, X) insert#(F, G, cons(X, Y), Z) >? insert#(F, G, Y, G Z X) insert#(F, G, cons(X, Y), Z) >? G(Z, X) sort#(F, G, cons(X, Y)) >? insert#(F, G, sort(F, G, Y), X) sort#(F, G, cons(X, Y)) >? sort#(F, G, Y) ascending!fac6220sort#(X) >? sort#(min, max, X) descending!fac6220sort#(X) >? sort#(max, min, X) insert(F, G, nil, X) >= cons(X, nil) insert(F, G, cons(X, Y), Z) >= cons(F Z X, insert(F, G, Y, G Z X)) sort(F, G, nil) >= nil sort(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) ascending!fac6220sort(X) >= sort(min, max, X) descending!fac6220sort(X) >= sort(max, min, X) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( ascending!fac6220sort(X) ) = #argfun-ascending!fac6220sort#(sort(min, max, X)) pi( ascending!fac6220sort#(X) ) = #argfun-ascending!fac6220sort##(sort#(min, max, X)) pi( descending!fac6220sort(X) ) = #argfun-descending!fac6220sort#(sort(max, min, X)) pi( descending!fac6220sort#(X) ) = #argfun-descending!fac6220sort##(sort#(max, min, 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: [[ascending!fac6220sort(x_1)]] = x_1 [[ascending!fac6220sort#(x_1)]] = x_1 [[descending!fac6220sort(x_1)]] = x_1 [[descending!fac6220sort#(x_1)]] = x_1 [[insert(x_1, x_2, x_3, x_4)]] = insert(x_3, x_2, x_1, x_4) [[insert#(x_1, x_2, x_3, x_4)]] = insert#(x_3, x_1, x_2, x_4) [[nil]] = _|_ We choose Lex = {insert, insert#} and Mul = {#argfun-ascending!fac6220sort#, #argfun-ascending!fac6220sort##, #argfun-descending!fac6220sort#, #argfun-descending!fac6220sort##, @_{o -> o -> o}, @_{o -> o}, cons, max, min, sort, sort#}, and the following precedence: #argfun-ascending!fac6220sort## > #argfun-descending!fac6220sort# > #argfun-descending!fac6220sort## > #argfun-ascending!fac6220sort# = max > min > sort = sort# > insert > insert# > @_{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: insert#(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) insert#(F, G, cons(X, Y), Z) > insert#(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X)) insert#(F, G, cons(X, Y), Z) > @_{o -> o}(@_{o -> o -> o}(G, Z), X) sort#(F, G, cons(X, Y)) >= insert#(F, G, sort(F, G, Y), X) sort#(F, G, cons(X, Y)) >= sort#(F, G, Y) #argfun-ascending!fac6220sort##(sort#(min, max, X)) >= sort#(min, max, X) #argfun-descending!fac6220sort##(sort#(max, min, X)) >= sort#(max, min, X) insert(F, G, _|_, X) >= cons(X, _|_) insert(F, G, cons(X, Y), Z) >= cons(@_{o -> o}(@_{o -> o -> o}(F, Z), X), insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X))) sort(F, G, _|_) >= _|_ sort(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) #argfun-ascending!fac6220sort#(sort(min, max, X)) >= sort(min, max, X) #argfun-descending!fac6220sort#(sort(max, min, X)) >= sort(max, min, X) With these choices, we have: 1] insert#(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because [2], by (Star) 2] insert#*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because insert# > @_{o -> o}, [3] and [8], by (Copy) 3] insert#*(F, G, cons(X, Y), Z) >= @_{o -> o -> o}(F, Z) because insert# > @_{o -> o -> o}, [4] and [6], by (Copy) 4] insert#*(F, G, cons(X, Y), Z) >= F because [5], by (Select) 5] F >= F by (Meta) 6] insert#*(F, G, cons(X, Y), Z) >= Z because [7], by (Select) 7] Z >= Z by (Meta) 8] insert#*(F, G, cons(X, Y), Z) >= X because [9], by (Select) 9] cons(X, Y) >= X because [10], by (Star) 10] cons*(X, Y) >= X because [11], by (Select) 11] X >= X by (Meta) 12] insert#(F, G, cons(X, Y), Z) > insert#(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X)) because [13], by definition 13] insert#*(F, G, cons(X, Y), Z) >= insert#(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X)) because [14], [4], [17], [19] and [21], by (Stat) 14] cons(X, Y) > Y because [15], by definition 15] cons*(X, Y) >= Y because [16], by (Select) 16] Y >= Y by (Meta) 17] insert#*(F, G, cons(X, Y), Z) >= G because [18], by (Select) 18] G >= G by (Meta) 19] insert#*(F, G, cons(X, Y), Z) >= Y because [20], by (Select) 20] cons(X, Y) >= Y because [15], by (Star) 21] insert#*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(G, Z), X) because insert# > @_{o -> o}, [22] and [8], by (Copy) 22] insert#*(F, G, cons(X, Y), Z) >= @_{o -> o -> o}(G, Z) because insert# > @_{o -> o -> o}, [17] and [6], by (Copy) 23] insert#(F, G, cons(X, Y), Z) > @_{o -> o}(@_{o -> o -> o}(G, Z), X) because [24], by definition 24] insert#*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(G, Z), X) because insert# > @_{o -> o}, [22] and [8], by (Copy) 25] sort#(F, G, cons(X, Y)) >= insert#(F, G, sort(F, G, Y), X) because [26], by (Star) 26] sort#*(F, G, cons(X, Y)) >= insert#(F, G, sort(F, G, Y), X) because sort# > insert#, [27], [29], [31] and [37], by (Copy) 27] sort#*(F, G, cons(X, Y)) >= F because [28], by (Select) 28] F >= F by (Meta) 29] sort#*(F, G, cons(X, Y)) >= G because [30], by (Select) 30] G >= G by (Meta) 31] sort#*(F, G, cons(X, Y)) >= sort(F, G, Y) because sort# = sort, sort# in Mul, [32], [33] and [34], by (Stat) 32] F >= F by (Meta) 33] G >= G by (Meta) 34] cons(X, Y) > Y because [35], by definition 35] cons*(X, Y) >= Y because [36], by (Select) 36] Y >= Y by (Meta) 37] sort#*(F, G, cons(X, Y)) >= X because [38], by (Select) 38] cons(X, Y) >= X because [39], by (Star) 39] cons*(X, Y) >= X because [40], by (Select) 40] X >= X by (Meta) 41] sort#(F, G, cons(X, Y)) >= sort#(F, G, Y) because sort# in Mul, [32], [33] and [42], by (Fun) 42] cons(X, Y) >= Y because [35], by (Star) 43] #argfun-ascending!fac6220sort##(sort#(min, max, X)) >= sort#(min, max, X) because [44], by (Star) 44] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= sort#(min, max, X) because #argfun-ascending!fac6220sort## > sort#, [45], [46] and [47], by (Copy) 45] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= min because #argfun-ascending!fac6220sort## > min, by (Copy) 46] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= max because #argfun-ascending!fac6220sort## > max, by (Copy) 47] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= X because [48], by (Select) 48] sort#(min, max, X) >= X because [49], by (Star) 49] sort#*(min, max, X) >= X because [50], by (Select) 50] X >= X by (Meta) 51] #argfun-descending!fac6220sort##(sort#(max, min, X)) >= sort#(max, min, X) because [52], by (Star) 52] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= sort#(max, min, X) because #argfun-descending!fac6220sort## > sort#, [53], [54] and [55], by (Copy) 53] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= max because #argfun-descending!fac6220sort## > max, by (Copy) 54] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= min because #argfun-descending!fac6220sort## > min, by (Copy) 55] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= X because [56], by (Select) 56] sort#(max, min, X) >= X because [57], by (Star) 57] sort#*(max, min, X) >= X because [58], by (Select) 58] X >= X by (Meta) 59] insert(F, G, _|_, X) >= cons(X, _|_) because [60], by (Star) 60] insert*(F, G, _|_, X) >= cons(X, _|_) because insert > cons, [61] and [63], by (Copy) 61] insert*(F, G, _|_, X) >= X because [62], by (Select) 62] X >= X by (Meta) 63] insert*(F, G, _|_, X) >= _|_ by (Bot) 64] insert(F, G, cons(X, Y), Z) >= cons(@_{o -> o}(@_{o -> o -> o}(F, Z), X), insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X))) because [65], by (Star) 65] insert*(F, G, cons(X, Y), Z) >= cons(@_{o -> o}(@_{o -> o -> o}(F, Z), X), insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X))) because insert > cons, [66] and [71], by (Copy) 66] insert*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because insert > @_{o -> o}, [67] and [70], by (Copy) 67] insert*(F, G, cons(X, Y), Z) >= @_{o -> o -> o}(F, Z) because insert > @_{o -> o -> o}, [68] and [69], by (Copy) 68] insert*(F, G, cons(X, Y), Z) >= F because [5], by (Select) 69] insert*(F, G, cons(X, Y), Z) >= Z because [7], by (Select) 70] insert*(F, G, cons(X, Y), Z) >= X because [9], by (Select) 71] insert*(F, G, cons(X, Y), Z) >= insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X)) because [14], [68], [72], [73] and [74], by (Stat) 72] insert*(F, G, cons(X, Y), Z) >= G because [18], by (Select) 73] insert*(F, G, cons(X, Y), Z) >= Y because [20], by (Select) 74] insert*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(G, Z), X) because insert > @_{o -> o}, [75] and [70], by (Copy) 75] insert*(F, G, cons(X, Y), Z) >= @_{o -> o -> o}(G, Z) because insert > @_{o -> o -> o}, [72] and [69], by (Copy) 76] sort(F, G, _|_) >= _|_ by (Bot) 77] sort(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) because [78], by (Star) 78] sort*(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) because sort > insert, [79], [80], [81] and [82], by (Copy) 79] sort*(F, G, cons(X, Y)) >= F because [32], by (Select) 80] sort*(F, G, cons(X, Y)) >= G because [33], by (Select) 81] sort*(F, G, cons(X, Y)) >= sort(F, G, Y) because sort in Mul, [32], [33] and [34], by (Stat) 82] sort*(F, G, cons(X, Y)) >= X because [38], by (Select) 83] #argfun-ascending!fac6220sort#(sort(min, max, X)) >= sort(min, max, X) because [84], by (Star) 84] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= sort(min, max, X) because #argfun-ascending!fac6220sort# > sort, [85], [86] and [87], by (Copy) 85] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= min because #argfun-ascending!fac6220sort# > min, by (Copy) 86] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= max because #argfun-ascending!fac6220sort# = max and #argfun-ascending!fac6220sort# in Mul, by (Stat) 87] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= X because [88], by (Select) 88] sort(min, max, X) >= X because [89], by (Star) 89] sort*(min, max, X) >= X because [50], by (Select) 90] #argfun-descending!fac6220sort#(sort(max, min, X)) >= sort(max, min, X) because [91], by (Star) 91] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= sort(max, min, X) because #argfun-descending!fac6220sort# > sort, [92], [93] and [94], by (Copy) 92] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= max because #argfun-descending!fac6220sort# > max, by (Copy) 93] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= min because #argfun-descending!fac6220sort# > min, by (Copy) 94] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= X because [95], by (Select) 95] sort(max, min, X) >= X because [96], by (Star) 96] sort*(max, min, X) >= X because [58], by (Select) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_3, R_1, minimal, formative) by (P_4, R_1, minimal, formative), where P_4 consists of: insert#(F, G, cons(X, Y), Z) =#> F(Z, X) sort#(F, G, cons(X, Y)) =#> insert#(F, G, sort(F, G, Y), X) sort#(F, G, cons(X, Y)) =#> sort#(F, G, Y) ascending!fac6220sort#(X) =#> sort#(min, max, X) descending!fac6220sort#(X) =#> sort#(max, min, X) Thus, the original system is terminating if each of (P_1, R_0, minimal, formative), (P_2, R_0, minimal, formative) and (P_4, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_4, 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: insert#(F, G, cons(X, Y), Z) >? F(Z, X) sort#(F, G, cons(X, Y)) >? insert#(F, G, sort(F, G, Y), X) sort#(F, G, cons(X, Y)) >? sort#(F, G, Y) ascending!fac6220sort#(X) >? sort#(min, max, X) descending!fac6220sort#(X) >? sort#(max, min, X) insert(F, G, nil, X) >= cons(X, nil) insert(F, G, cons(X, Y), Z) >= cons(F Z X, insert(F, G, Y, G Z X)) sort(F, G, nil) >= nil sort(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) ascending!fac6220sort(X) >= sort(min, max, X) descending!fac6220sort(X) >= sort(max, min, X) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( ascending!fac6220sort(X) ) = #argfun-ascending!fac6220sort#(sort(min, max, X)) pi( ascending!fac6220sort#(X) ) = #argfun-ascending!fac6220sort##(sort#(min, max, X)) pi( descending!fac6220sort(X) ) = #argfun-descending!fac6220sort#(sort(max, min, X)) pi( descending!fac6220sort#(X) ) = #argfun-descending!fac6220sort##(sort#(max, min, 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: [[ascending!fac6220sort(x_1)]] = x_1 [[ascending!fac6220sort#(x_1)]] = x_1 [[descending!fac6220sort(x_1)]] = x_1 [[descending!fac6220sort#(x_1)]] = x_1 [[insert(x_1, x_2, x_3, x_4)]] = insert(x_3, x_1, x_2, x_4) [[insert#(x_1, x_2, x_3, x_4)]] = insert#(x_1, x_3, x_4) [[nil]] = _|_ We choose Lex = {insert} and Mul = {#argfun-ascending!fac6220sort#, #argfun-ascending!fac6220sort##, #argfun-descending!fac6220sort#, #argfun-descending!fac6220sort##, @_{o -> o -> o}, @_{o -> o}, cons, insert#, max, min, sort, sort#}, and the following precedence: #argfun-ascending!fac6220sort# > #argfun-ascending!fac6220sort## > #argfun-descending!fac6220sort# > #argfun-descending!fac6220sort## > max > min > sort = sort# > insert > cons > insert# > @_{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: insert#(F, cons(X, Y), Z) > @_{o -> o}(@_{o -> o -> o}(F, Z), X) sort#(F, G, cons(X, Y)) > insert#(F, sort(F, G, Y), X) sort#(F, G, cons(X, Y)) >= sort#(F, G, Y) #argfun-ascending!fac6220sort##(sort#(min, max, X)) >= sort#(min, max, X) #argfun-descending!fac6220sort##(sort#(max, min, X)) >= sort#(max, min, X) insert(F, G, _|_, X) >= cons(X, _|_) insert(F, G, cons(X, Y), Z) >= cons(@_{o -> o}(@_{o -> o -> o}(F, Z), X), insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X))) sort(F, G, _|_) >= _|_ sort(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) #argfun-ascending!fac6220sort#(sort(min, max, X)) >= sort(min, max, X) #argfun-descending!fac6220sort#(sort(max, min, X)) >= sort(max, min, X) With these choices, we have: 1] insert#(F, cons(X, Y), Z) > @_{o -> o}(@_{o -> o -> o}(F, Z), X) because [2], by definition 2] insert#*(F, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because insert# > @_{o -> o}, [3] and [8], by (Copy) 3] insert#*(F, cons(X, Y), Z) >= @_{o -> o -> o}(F, Z) because insert# > @_{o -> o -> o}, [4] and [6], by (Copy) 4] insert#*(F, cons(X, Y), Z) >= F because [5], by (Select) 5] F >= F by (Meta) 6] insert#*(F, cons(X, Y), Z) >= Z because [7], by (Select) 7] Z >= Z by (Meta) 8] insert#*(F, cons(X, Y), Z) >= X because [9], by (Select) 9] cons(X, Y) >= X because [10], by (Star) 10] cons*(X, Y) >= X because [11], by (Select) 11] X >= X by (Meta) 12] sort#(F, G, cons(X, Y)) > insert#(F, sort(F, G, Y), X) because [13], by definition 13] sort#*(F, G, cons(X, Y)) >= insert#(F, sort(F, G, Y), X) because sort# > insert#, [14], [16] and [22], by (Copy) 14] sort#*(F, G, cons(X, Y)) >= F because [15], by (Select) 15] F >= F by (Meta) 16] sort#*(F, G, cons(X, Y)) >= sort(F, G, Y) because sort# = sort, sort# in Mul, [17], [18] and [19], by (Stat) 17] F >= F by (Meta) 18] G >= G by (Meta) 19] cons(X, Y) > Y because [20], by definition 20] cons*(X, Y) >= Y because [21], by (Select) 21] Y >= Y by (Meta) 22] sort#*(F, G, cons(X, Y)) >= X because [23], by (Select) 23] cons(X, Y) >= X because [24], by (Star) 24] cons*(X, Y) >= X because [25], by (Select) 25] X >= X by (Meta) 26] sort#(F, G, cons(X, Y)) >= sort#(F, G, Y) because [27], by (Star) 27] sort#*(F, G, cons(X, Y)) >= sort#(F, G, Y) because sort# in Mul, [17], [18] and [19], by (Stat) 28] #argfun-ascending!fac6220sort##(sort#(min, max, X)) >= sort#(min, max, X) because [29], by (Star) 29] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= sort#(min, max, X) because #argfun-ascending!fac6220sort## > sort#, [30], [31] and [32], by (Copy) 30] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= min because #argfun-ascending!fac6220sort## > min, by (Copy) 31] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= max because #argfun-ascending!fac6220sort## > max, by (Copy) 32] #argfun-ascending!fac6220sort##*(sort#(min, max, X)) >= X because [33], by (Select) 33] sort#(min, max, X) >= X because [34], by (Star) 34] sort#*(min, max, X) >= X because [35], by (Select) 35] X >= X by (Meta) 36] #argfun-descending!fac6220sort##(sort#(max, min, X)) >= sort#(max, min, X) because [37], by (Star) 37] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= sort#(max, min, X) because #argfun-descending!fac6220sort## > sort#, [38], [39] and [40], by (Copy) 38] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= max because #argfun-descending!fac6220sort## > max, by (Copy) 39] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= min because #argfun-descending!fac6220sort## > min, by (Copy) 40] #argfun-descending!fac6220sort##*(sort#(max, min, X)) >= X because [41], by (Select) 41] sort#(max, min, X) >= X because [42], by (Star) 42] sort#*(max, min, X) >= X because [43], by (Select) 43] X >= X by (Meta) 44] insert(F, G, _|_, X) >= cons(X, _|_) because [45], by (Star) 45] insert*(F, G, _|_, X) >= cons(X, _|_) because insert > cons, [46] and [48], by (Copy) 46] insert*(F, G, _|_, X) >= X because [47], by (Select) 47] X >= X by (Meta) 48] insert*(F, G, _|_, X) >= _|_ by (Bot) 49] insert(F, G, cons(X, Y), Z) >= cons(@_{o -> o}(@_{o -> o -> o}(F, Z), X), insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X))) because [50], by (Star) 50] insert*(F, G, cons(X, Y), Z) >= cons(@_{o -> o}(@_{o -> o -> o}(F, Z), X), insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X))) because insert > cons, [51] and [56], by (Copy) 51] insert*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(F, Z), X) because insert > @_{o -> o}, [52] and [55], by (Copy) 52] insert*(F, G, cons(X, Y), Z) >= @_{o -> o -> o}(F, Z) because insert > @_{o -> o -> o}, [53] and [54], by (Copy) 53] insert*(F, G, cons(X, Y), Z) >= F because [5], by (Select) 54] insert*(F, G, cons(X, Y), Z) >= Z because [7], by (Select) 55] insert*(F, G, cons(X, Y), Z) >= X because [9], by (Select) 56] insert*(F, G, cons(X, Y), Z) >= insert(F, G, Y, @_{o -> o}(@_{o -> o -> o}(G, Z), X)) because [57], [53], [60], [62] and [64], by (Stat) 57] cons(X, Y) > Y because [58], by definition 58] cons*(X, Y) >= Y because [59], by (Select) 59] Y >= Y by (Meta) 60] insert*(F, G, cons(X, Y), Z) >= G because [61], by (Select) 61] G >= G by (Meta) 62] insert*(F, G, cons(X, Y), Z) >= Y because [63], by (Select) 63] cons(X, Y) >= Y because [58], by (Star) 64] insert*(F, G, cons(X, Y), Z) >= @_{o -> o}(@_{o -> o -> o}(G, Z), X) because insert > @_{o -> o}, [65] and [55], by (Copy) 65] insert*(F, G, cons(X, Y), Z) >= @_{o -> o -> o}(G, Z) because insert > @_{o -> o -> o}, [60] and [54], by (Copy) 66] sort(F, G, _|_) >= _|_ by (Bot) 67] sort(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) because [68], by (Star) 68] sort*(F, G, cons(X, Y)) >= insert(F, G, sort(F, G, Y), X) because sort > insert, [69], [70], [71] and [72], by (Copy) 69] sort*(F, G, cons(X, Y)) >= F because [17], by (Select) 70] sort*(F, G, cons(X, Y)) >= G because [18], by (Select) 71] sort*(F, G, cons(X, Y)) >= sort(F, G, Y) because sort in Mul, [17], [18] and [19], by (Stat) 72] sort*(F, G, cons(X, Y)) >= X because [23], by (Select) 73] #argfun-ascending!fac6220sort#(sort(min, max, X)) >= sort(min, max, X) because [74], by (Star) 74] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= sort(min, max, X) because #argfun-ascending!fac6220sort# > sort, [75], [76] and [77], by (Copy) 75] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= min because #argfun-ascending!fac6220sort# > min, by (Copy) 76] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= max because #argfun-ascending!fac6220sort# > max, by (Copy) 77] #argfun-ascending!fac6220sort#*(sort(min, max, X)) >= X because [78], by (Select) 78] sort(min, max, X) >= X because [79], by (Star) 79] sort*(min, max, X) >= X because [35], by (Select) 80] #argfun-descending!fac6220sort#(sort(max, min, X)) >= sort(max, min, X) because [81], by (Star) 81] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= sort(max, min, X) because #argfun-descending!fac6220sort# > sort, [82], [83] and [84], by (Copy) 82] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= max because #argfun-descending!fac6220sort# > max, by (Copy) 83] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= min because #argfun-descending!fac6220sort# > min, by (Copy) 84] #argfun-descending!fac6220sort#*(sort(max, min, X)) >= X because [85], by (Select) 85] sort(max, min, X) >= X because [86], by (Star) 86] sort*(max, min, X) >= X because [43], by (Select) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_4, R_1, minimal, formative) by (P_5, R_1, minimal, formative), where P_5 consists of: sort#(F, G, cons(X, Y)) =#> sort#(F, G, Y) ascending!fac6220sort#(X) =#> sort#(min, max, X) descending!fac6220sort#(X) =#> sort#(max, min, X) Thus, the original system is terminating if each of (P_1, R_0, minimal, formative), (P_2, R_0, minimal, formative) and (P_5, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_5, 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_6: sort#(F, G, cons(X, Y)) =#> sort#(F, G, Y) By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_5, R_1, m, f) by (P_6, R_1, 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_6, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_6, R_1, minimal, formative). We apply the subterm criterion with the following projection function: nu(sort#) = 3 Thus, we can orient the dependency pairs as follows: nu(sort#(F, G, cons(X, Y))) = cons(X, Y) |> Y = nu(sort#(F, G, Y)) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_6, R_1, minimal, f) by ({}, R_1, 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(min) = 1 Thus, we can orient the dependency pairs as follows: nu(min s(X) s(Y)) = s(X) |> X = nu(min 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). We apply the subterm criterion with the following projection function: nu(max) = 1 Thus, we can orient the dependency pairs as follows: nu(max s(X) s(Y)) = s(X) |> X = nu(max X Y) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_1, R_0, minimal, f) by ({}, R_0, 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.