We consider the system sort. Alphabet: 0 : [] --> nat ascending!6220sort : [list] --> list cons : [nat * list] --> list descending!6220sort : [list] --> list insert : [nat * list * nat -> nat -> nat * nat -> nat -> nat] --> list max : [nat * nat] --> nat min : [nat * nat] --> nat nil : [] --> list s : [nat] --> nat sort : [list * nat -> nat -> nat * nat -> nat -> nat] --> list Rules: max(0, x) => x max(x, 0) => x max(s(x), s(y)) => s(max(x, y)) min(0, x) => 0 min(x, 0) => 0 min(s(x), s(y)) => s(min(x, y)) insert(x, nil, f, g) => cons(x, nil) insert(x, cons(y, z), f, g) => cons(f x y, insert(g x y, z, f, g)) sort(nil, f, g) => nil sort(cons(x, y), f, g) => insert(x, sort(y, f, g), f, g) ascending!6220sort(x) => sort(x, /\y./\z.min(y, z), /\u./\v.max(u, v)) descending!6220sort(x) => sort(x, /\y./\z.max(y, z), /\u./\v.min(u, v)) This AFS is converted to an AFSM simply by replacing all free variables by meta-variables (with arity 0). We observe that the rules contain a first-order subset: max(0, X) => X max(X, 0) => X max(s(X), s(Y)) => s(max(X, Y)) min(0, X) => 0 min(X, 0) => 0 min(s(X), s(Y)) => s(min(X, Y)) Moreover, the system is finitely branching. Thus, by [Kop12, Thm. 7.55], we may omit all first-order dependency pairs from the dependency pair problem (DP(R), R) if this first-order part is Ce-terminating when seen as a many-sorted first-order TRS. According to the external first-order termination prover, this system is indeed Ce-terminating: || proof of resources/system.trs || # AProVE Commit ID: d84c10301d352dfd14de2104819581f4682260f5 fuhs 20130616 || || || Termination w.r.t. Q of the given QTRS could be proven: || || (0) QTRS || (1) QTRSRRRProof [EQUIVALENT] || (2) QTRS || (3) RisEmptyProof [EQUIVALENT] || (4) YES || || || ---------------------------------------- || || (0) || Obligation: || Q restricted rewrite system: || The TRS R consists of the following rules: || || max(0, %X) -> %X || max(%X, 0) -> %X || max(s(%X), s(%Y)) -> s(max(%X, %Y)) || min(0, %X) -> 0 || min(%X, 0) -> 0 || min(s(%X), s(%Y)) -> s(min(%X, %Y)) || ~PAIR(%X, %Y) -> %X || ~PAIR(%X, %Y) -> %Y || || Q is empty. || || ---------------------------------------- || || (1) QTRSRRRProof (EQUIVALENT) || Used ordering: || Knuth-Bendix order [KBO] with precedence:~PAIR_2 > 0 > min_2 > max_2 > s_1 || || and weight map: || || 0=1 || s_1=1 || max_2=0 || min_2=0 || ~PAIR_2=0 || || The variable weight is 1With this ordering the following rules can be removed by the rule removal processor [LPAR04] because they are oriented strictly: || || max(0, %X) -> %X || max(%X, 0) -> %X || max(s(%X), s(%Y)) -> s(max(%X, %Y)) || min(0, %X) -> 0 || min(%X, 0) -> 0 || min(s(%X), s(%Y)) -> s(min(%X, %Y)) || ~PAIR(%X, %Y) -> %X || ~PAIR(%X, %Y) -> %Y || || || || || ---------------------------------------- || || (2) || Obligation: || Q restricted rewrite system: || R is empty. || Q is empty. || || ---------------------------------------- || || (3) RisEmptyProof (EQUIVALENT) || The TRS R is empty. Hence, termination is trivially proven. || ---------------------------------------- || || (4) || YES || 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] insert#(X, cons(Y, Z), F, G) =#> F(X, Y) 1] insert#(X, cons(Y, Z), F, G) =#> insert#(G X Y, Z, F, G) 2] insert#(X, cons(Y, Z), F, G) =#> G(X, Y) 3] sort#(cons(X, Y), F, G) =#> insert#(X, sort(Y, F, G), F, G) 4] sort#(cons(X, Y), F, G) =#> sort#(Y, F, G) 5] ascending!6220sort#(X) =#> sort#(X, /\x./\y.min(x, y), /\z./\u.max(z, u)) 6] ascending!6220sort#(X) =#> min#(x, y) 7] ascending!6220sort#(X) =#> max#(x, y) 8] descending!6220sort#(X) =#> sort#(X, /\x./\y.max(x, y), /\z./\u.min(z, u)) 9] descending!6220sort#(X) =#> max#(x, y) 10] descending!6220sort#(X) =#> min#(x, y) Rules R_0: max(0, X) => X max(X, 0) => X max(s(X), s(Y)) => s(max(X, Y)) min(0, X) => 0 min(X, 0) => 0 min(s(X), s(Y)) => s(min(X, Y)) insert(X, nil, F, G) => cons(X, nil) insert(X, cons(Y, Z), F, G) => cons(F X Y, insert(G X Y, Z, F, G)) sort(nil, F, G) => nil sort(cons(X, Y), F, G) => insert(X, sort(Y, F, G), F, G) ascending!6220sort(X) => sort(X, /\x./\y.min(x, y), /\z./\u.max(z, u)) descending!6220sort(X) => sort(X, /\x./\y.max(x, y), /\z./\u.min(z, u)) 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, 10 * 1 : 0, 1, 2 * 2 : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 * 3 : 0, 1, 2 * 4 : 3, 4 * 5 : 3, 4 * 6 : * 7 : * 8 : 3, 4 * 9 : * 10 : This graph has the following strongly connected components: P_1: insert#(X, cons(Y, Z), F, G) =#> F(X, Y) insert#(X, cons(Y, Z), F, G) =#> insert#(G X Y, Z, F, G) insert#(X, cons(Y, Z), F, G) =#> G(X, Y) sort#(cons(X, Y), F, G) =#> insert#(X, sort(Y, F, G), F, G) sort#(cons(X, Y), F, G) =#> sort#(Y, F, G) ascending!6220sort#(X) =#> sort#(X, /\x./\y.min(x, y), /\z./\u.max(z, u)) descending!6220sort#(X) =#> sort#(X, /\x./\y.max(x, y), /\z./\u.min(z, u)) 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, minimal, formative) is finite. We consider the dependency pair problem (P_1, R_0, minimal, formative). The formative rules of (P_1, R_0) are R_1 ::= insert(X, nil, F, G) => cons(X, nil) insert(X, cons(Y, Z), F, G) => cons(F X Y, insert(G X Y, Z, F, G)) sort(nil, F, G) => nil sort(cons(X, Y), F, G) => insert(X, sort(Y, F, G), F, G) ascending!6220sort(X) => sort(X, /\x./\y.min(x, y), /\z./\u.max(z, u)) descending!6220sort(X) => sort(X, /\x./\y.max(x, y), /\z./\u.min(z, u)) 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: insert#(X, cons(Y, Z), F, G) >? F(X, Y) insert#(X, cons(Y, Z), F, G) >? insert#(G X Y, Z, F, G) insert#(X, cons(Y, Z), F, G) >? G(X, Y) sort#(cons(X, Y), F, G) >? insert#(X, sort(Y, F, G), F, G) sort#(cons(X, Y), F, G) >? sort#(Y, F, G) ascending!6220sort#(X) >? sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) descending!6220sort#(X) >? sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) insert(X, nil, F, G) >= cons(X, nil) insert(X, cons(Y, Z), F, G) >= cons(F X Y, insert(G X Y, Z, F, G)) sort(nil, F, G) >= nil sort(cons(X, Y), F, G) >= insert(X, sort(Y, F, G), F, G) ascending!6220sort(X) >= sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) descending!6220sort(X) >= sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) max-(X, Y) >= max(X, Y) min-(X, Y) >= min(X, Y) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( ascending!6220sort(X) ) = #argfun-ascending!6220sort#(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) pi( ascending!6220sort#(X) ) = #argfun-ascending!6220sort##(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) pi( descending!6220sort(X) ) = #argfun-descending!6220sort#(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) pi( descending!6220sort#(X) ) = #argfun-descending!6220sort##(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) 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!6220sort(x_1)]] = x_1 [[ascending!6220sort#(x_1)]] = x_1 [[descending!6220sort(x_1)]] = x_1 [[descending!6220sort#(x_1)]] = x_1 [[insert(x_1, x_2, x_3, x_4)]] = insert(x_2, x_4, x_1, x_3) [[insert#(x_1, x_2, x_3, x_4)]] = insert#(x_4, x_3, x_2, x_1) [[min(x_1, x_2)]] = x_1 [[nil]] = _|_ We choose Lex = {insert, insert#} and Mul = {#argfun-ascending!6220sort#, #argfun-ascending!6220sort##, #argfun-descending!6220sort#, #argfun-descending!6220sort##, @_{o -> o -> o}, @_{o -> o}, cons, max, max-, min-, sort, sort#}, and the following precedence: #argfun-ascending!6220sort# > #argfun-ascending!6220sort## > #argfun-descending!6220sort# > #argfun-descending!6220sort## > max = max- > min- > sort# > insert# > sort > 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#(X, cons(Y, Z), F, G) > @_{o -> o}(@_{o -> o -> o}(F, X), Y) insert#(X, cons(Y, Z), F, G) >= insert#(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G) insert#(X, cons(Y, Z), F, G) > @_{o -> o}(@_{o -> o -> o}(G, X), Y) sort#(cons(X, Y), F, G) >= insert#(X, sort(Y, F, G), F, G) sort#(cons(X, Y), F, G) >= sort#(Y, F, G) #argfun-ascending!6220sort##(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) > sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) #argfun-descending!6220sort##(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) insert(X, _|_, F, G) >= cons(X, _|_) insert(X, cons(Y, Z), F, G) >= cons(@_{o -> o}(@_{o -> o -> o}(F, X), Y), insert(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G)) sort(_|_, F, G) >= _|_ sort(cons(X, Y), F, G) >= insert(X, sort(Y, F, G), F, G) #argfun-ascending!6220sort#(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) #argfun-descending!6220sort#(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) max-(X, Y) >= max(X, Y) min-(X, Y) >= X With these choices, we have: 1] insert#(X, cons(Y, Z), F, G) > @_{o -> o}(@_{o -> o -> o}(F, X), Y) because [2], by definition 2] insert#*(X, cons(Y, Z), F, G) >= @_{o -> o}(@_{o -> o -> o}(F, X), Y) because insert# > @_{o -> o}, [3] and [8], by (Copy) 3] insert#*(X, cons(Y, Z), F, G) >= @_{o -> o -> o}(F, X) because insert# > @_{o -> o -> o}, [4] and [6], by (Copy) 4] insert#*(X, cons(Y, Z), F, G) >= F because [5], by (Select) 5] F >= F by (Meta) 6] insert#*(X, cons(Y, Z), F, G) >= X because [7], by (Select) 7] X >= X by (Meta) 8] insert#*(X, cons(Y, Z), F, G) >= Y because [9], by (Select) 9] cons(Y, Z) >= Y because [10], by (Star) 10] cons*(Y, Z) >= Y because [11], by (Select) 11] Y >= Y by (Meta) 12] insert#(X, cons(Y, Z), F, G) >= insert#(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G) because [13], by (Star) 13] insert#*(X, cons(Y, Z), F, G) >= insert#(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G) because [14], [17], [18], [19], [22], [4] and [21], by (Stat) 14] cons(Y, Z) > Z because [15], by definition 15] cons*(Y, Z) >= Z because [16], by (Select) 16] Z >= Z by (Meta) 17] F >= F by (Meta) 18] G >= G by (Meta) 19] insert#*(X, cons(Y, Z), F, G) >= @_{o -> o}(@_{o -> o -> o}(G, X), Y) because insert# > @_{o -> o}, [20] and [8], by (Copy) 20] insert#*(X, cons(Y, Z), F, G) >= @_{o -> o -> o}(G, X) because insert# > @_{o -> o -> o}, [21] and [6], by (Copy) 21] insert#*(X, cons(Y, Z), F, G) >= G because [18], by (Select) 22] insert#*(X, cons(Y, Z), F, G) >= Z because [23], by (Select) 23] cons(Y, Z) >= Z because [15], by (Star) 24] insert#(X, cons(Y, Z), F, G) > @_{o -> o}(@_{o -> o -> o}(G, X), Y) because [25], by definition 25] insert#*(X, cons(Y, Z), F, G) >= @_{o -> o}(@_{o -> o -> o}(G, X), Y) because insert# > @_{o -> o}, [20] and [8], by (Copy) 26] sort#(cons(X, Y), F, G) >= insert#(X, sort(Y, F, G), F, G) because [27], by (Star) 27] sort#*(cons(X, Y), F, G) >= insert#(X, sort(Y, F, G), F, G) because sort# > insert#, [28], [32], [37] and [39], by (Copy) 28] sort#*(cons(X, Y), F, G) >= X because [29], by (Select) 29] cons(X, Y) >= X because [30], by (Star) 30] cons*(X, Y) >= X because [31], by (Select) 31] X >= X by (Meta) 32] sort#*(cons(X, Y), F, G) >= sort(Y, F, G) because sort# > sort, [33], [37] and [39], by (Copy) 33] sort#*(cons(X, Y), F, G) >= Y because [34], by (Select) 34] cons(X, Y) >= Y because [35], by (Star) 35] cons*(X, Y) >= Y because [36], by (Select) 36] Y >= Y by (Meta) 37] sort#*(cons(X, Y), F, G) >= F because [38], by (Select) 38] F >= F by (Meta) 39] sort#*(cons(X, Y), F, G) >= G because [40], by (Select) 40] G >= G by (Meta) 41] sort#(cons(X, Y), F, G) >= sort#(Y, F, G) because sort# in Mul, [42], [43] and [44], by (Fun) 42] cons(X, Y) >= Y because [35], by (Star) 43] F >= F by (Meta) 44] G >= G by (Meta) 45] #argfun-ascending!6220sort##(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) > sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) because [46], by definition 46] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) because #argfun-ascending!6220sort## > sort#, [47], [51] and [58], by (Copy) 47] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= X because [48], by (Select) 48] sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) >= X because [49], by (Star) 49] sort#*(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) >= X because [50], by (Select) 50] X >= X by (Meta) 51] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= /\x./\y.min-(x, y) because [52], by (F-Abs) 52] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v) >= /\x.min-(v, x) because [53], by (F-Abs) 53] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v, w) >= min-(v, w) because #argfun-ascending!6220sort## > min-, [54] and [56], by (Copy) 54] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v, w) >= v because [55], by (Select) 55] v >= v by (Var) 56] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v, w) >= w because [57], by (Select) 57] w >= w by (Var) 58] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= /\x./\y.max-(x, y) because [59], by (F-Abs) 59] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x') >= /\x.max-(x', x) because [60], by (F-Abs) 60] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x', y') >= max-(x', y') because #argfun-ascending!6220sort## > max-, [61] and [63], by (Copy) 61] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x', y') >= x' because [62], by (Select) 62] x' >= x' by (Var) 63] #argfun-ascending!6220sort##*(sort#(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x', y') >= y' because [64], by (Select) 64] y' >= y' by (Var) 65] #argfun-descending!6220sort##(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) because [66], by (Star) 66] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) because #argfun-descending!6220sort## > sort#, [67], [71] and [78], by (Copy) 67] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= X because [68], by (Select) 68] sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) >= X because [69], by (Star) 69] sort#*(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) >= X because [70], by (Select) 70] X >= X by (Meta) 71] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= /\x./\y.max-(x, y) because [72], by (F-Abs) 72] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v) >= /\x.max-(v, x) because [73], by (F-Abs) 73] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v, w) >= max-(v, w) because #argfun-descending!6220sort## > max-, [74] and [76], by (Copy) 74] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v, w) >= v because [75], by (Select) 75] v >= v by (Var) 76] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v, w) >= w because [77], by (Select) 77] w >= w by (Var) 78] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= /\x./\y.min-(x, y) because [79], by (F-Abs) 79] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x') >= /\x.min-(x', x) because [80], by (F-Abs) 80] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x', y') >= min-(x', y') because #argfun-descending!6220sort## > min-, [81] and [83], by (Copy) 81] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x', y') >= x' because [82], by (Select) 82] x' >= x' by (Var) 83] #argfun-descending!6220sort##*(sort#(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x', y') >= y' because [84], by (Select) 84] y' >= y' by (Var) 85] insert(X, _|_, F, G) >= cons(X, _|_) because [86], by (Star) 86] insert*(X, _|_, F, G) >= cons(X, _|_) because insert > cons, [87] and [89], by (Copy) 87] insert*(X, _|_, F, G) >= X because [88], by (Select) 88] X >= X by (Meta) 89] insert*(X, _|_, F, G) >= _|_ by (Bot) 90] insert(X, cons(Y, Z), F, G) >= cons(@_{o -> o}(@_{o -> o -> o}(F, X), Y), insert(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G)) because [91], by (Star) 91] insert*(X, cons(Y, Z), F, G) >= cons(@_{o -> o}(@_{o -> o -> o}(F, X), Y), insert(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G)) because insert > cons, [92] and [97], by (Copy) 92] insert*(X, cons(Y, Z), F, G) >= @_{o -> o}(@_{o -> o -> o}(F, X), Y) because insert > @_{o -> o}, [93] and [96], by (Copy) 93] insert*(X, cons(Y, Z), F, G) >= @_{o -> o -> o}(F, X) because insert > @_{o -> o -> o}, [94] and [95], by (Copy) 94] insert*(X, cons(Y, Z), F, G) >= F because [17], by (Select) 95] insert*(X, cons(Y, Z), F, G) >= X because [7], by (Select) 96] insert*(X, cons(Y, Z), F, G) >= Y because [9], by (Select) 97] insert*(X, cons(Y, Z), F, G) >= insert(@_{o -> o}(@_{o -> o -> o}(G, X), Y), Z, F, G) because [14], [98], [101], [94] and [100], by (Stat) 98] insert*(X, cons(Y, Z), F, G) >= @_{o -> o}(@_{o -> o -> o}(G, X), Y) because insert > @_{o -> o}, [99] and [96], by (Copy) 99] insert*(X, cons(Y, Z), F, G) >= @_{o -> o -> o}(G, X) because insert > @_{o -> o -> o}, [100] and [95], by (Copy) 100] insert*(X, cons(Y, Z), F, G) >= G because [18], by (Select) 101] insert*(X, cons(Y, Z), F, G) >= Z because [23], by (Select) 102] sort(_|_, F, G) >= _|_ by (Bot) 103] sort(cons(X, Y), F, G) >= insert(X, sort(Y, F, G), F, G) because [104], by (Star) 104] sort*(cons(X, Y), F, G) >= insert(X, sort(Y, F, G), F, G) because sort > insert, [105], [106], [109] and [110], by (Copy) 105] sort*(cons(X, Y), F, G) >= X because [29], by (Select) 106] sort*(cons(X, Y), F, G) >= sort(Y, F, G) because sort in Mul, [107], [43] and [44], by (Stat) 107] cons(X, Y) > Y because [108], by definition 108] cons*(X, Y) >= Y because [36], by (Select) 109] sort*(cons(X, Y), F, G) >= F because [43], by (Select) 110] sort*(cons(X, Y), F, G) >= G because [44], by (Select) 111] #argfun-ascending!6220sort#(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) because [112], by (Star) 112] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) because #argfun-ascending!6220sort# > sort, [113], [116] and [123], by (Copy) 113] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= X because [114], by (Select) 114] sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) >= X because [115], by (Star) 115] sort*(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)) >= X because [50], by (Select) 116] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= /\x./\y.min-(x, y) because [117], by (F-Abs) 117] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v) >= /\x.min-(v, x) because [118], by (F-Abs) 118] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v, w) >= min-(v, w) because #argfun-ascending!6220sort# > min-, [119] and [121], by (Copy) 119] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v, w) >= v because [120], by (Select) 120] v >= v by (Var) 121] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), v, w) >= w because [122], by (Select) 122] w >= w by (Var) 123] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u))) >= /\x./\y.max-(x, y) because [124], by (F-Abs) 124] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x') >= /\x.max-(x', x) because [125], by (F-Abs) 125] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x', y') >= max-(x', y') because #argfun-ascending!6220sort# > max-, [126] and [128], by (Copy) 126] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x', y') >= x' because [127], by (Select) 127] x' >= x' by (Var) 128] #argfun-ascending!6220sort#*(sort(X, /\x./\y.min-(x, y), /\z./\u.max-(z, u)), x', y') >= y' because [129], by (Select) 129] y' >= y' by (Var) 130] #argfun-descending!6220sort#(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) because [131], by (Star) 131] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) because #argfun-descending!6220sort# > sort, [132], [135] and [142], by (Copy) 132] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= X because [133], by (Select) 133] sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) >= X because [134], by (Star) 134] sort*(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)) >= X because [70], by (Select) 135] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= /\x./\y.max-(x, y) because [136], by (F-Abs) 136] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v) >= /\x.max-(v, x) because [137], by (F-Abs) 137] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v, w) >= max-(v, w) because #argfun-descending!6220sort# > max-, [138] and [140], by (Copy) 138] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v, w) >= v because [139], by (Select) 139] v >= v by (Var) 140] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), v, w) >= w because [141], by (Select) 141] w >= w by (Var) 142] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u))) >= /\x./\y.min-(x, y) because [143], by (F-Abs) 143] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x') >= /\x.min-(x', x) because [144], by (F-Abs) 144] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x', y') >= min-(x', y') because #argfun-descending!6220sort# > min-, [145] and [147], by (Copy) 145] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x', y') >= x' because [146], by (Select) 146] x' >= x' by (Var) 147] #argfun-descending!6220sort#*(sort(X, /\x./\y.max-(x, y), /\z./\u.min-(z, u)), x', y') >= y' because [148], by (Select) 148] y' >= y' by (Var) 149] max-(X, Y) >= max(X, Y) because max- = max, max- in Mul, [150] and [151], by (Fun) 150] X >= X by (Meta) 151] Y >= Y by (Meta) 152] min-(X, Y) >= X because [153], by (Star) 153] min-*(X, Y) >= X because [154], by (Select) 154] 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_2, R_1, minimal, formative), where P_2 consists of: insert#(X, cons(Y, Z), F, G) =#> insert#(G X Y, Z, F, G) sort#(cons(X, Y), F, G) =#> insert#(X, sort(Y, F, G), F, G) sort#(cons(X, Y), F, G) =#> sort#(Y, F, G) descending!6220sort#(X) =#> sort#(X, /\x./\y.max(x, y), /\z./\u.min(z, u)) Thus, the original system is terminating if (P_2, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_2, 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 : 1, 2 * 3 : 1, 2 This graph has the following strongly connected components: P_3: insert#(X, cons(Y, Z), F, G) =#> insert#(G X Y, Z, F, G) P_4: sort#(cons(X, Y), F, G) =#> sort#(Y, F, G) By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_2, R_1, m, f) by (P_3, R_1, m, f) and (P_4, R_1, m, f). Thus, the original system is terminating if each of (P_3, R_1, minimal, formative) and (P_4, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_4, R_1, minimal, formative). We apply the subterm criterion with the following projection function: nu(sort#) = 1 Thus, we can orient the dependency pairs as follows: nu(sort#(cons(X, Y), F, G)) = cons(X, Y) |> Y = nu(sort#(Y, F, G)) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_4, 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 (P_3, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_3, R_1, minimal, formative). We apply the subterm criterion with the following projection function: nu(insert#) = 2 Thus, we can orient the dependency pairs as follows: nu(insert#(X, cons(Y, Z), F, G)) = cons(Y, Z) |> Z = nu(insert#(G X Y, Z, F, G)) By [Kop12, Thm. 7.35], we may replace a dependency pair problem (P_3, 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.