We consider the system h52. Alphabet: 0 : [] --> nat cons : [] --> nat -> list -> list foldl : [] --> (nat -> nat -> nat) -> nat -> list -> nat nil : [] --> list plusc : [] --> nat -> nat -> nat s : [] --> nat -> nat sum : [] --> list -> nat Rules: foldl (/\x./\y.f x y) z nil => z foldl (/\x./\y.f x y) z (cons u v) => foldl (/\w./\x'.f w x') (f z u) v plusc x 0 => x plusc x (s y) => s (plusc x y) sum x => foldl (/\y./\z.plusc y z) 0 x Using the transformations described in [Kop11], this system can be brought in a form without leading free variables in the left-hand side, and where the left-hand side of a variable is always a functional term or application headed by a functional term. We now transform the resulting AFS into an AFSM by replacing all free variables by meta-variables (with arity 0). This leads to the following AFSM: Alphabet: 0 : [] --> nat cons : [nat * list] --> list foldl : [nat -> nat -> nat * nat * list] --> nat nil : [] --> list plusc : [nat * nat] --> nat s : [nat] --> nat sum : [list] --> nat ~AP1 : [nat -> nat -> nat * nat] --> nat -> nat Rules: foldl(/\x./\y.~AP1(F, x) y, X, nil) => X foldl(/\x./\y.~AP1(F, x) y, X, cons(Y, Z)) => foldl(/\z./\u.~AP1(F, z) u, ~AP1(F, X) Y, Z) plusc(X, 0) => X plusc(X, s(Y)) => s(plusc(X, Y)) sum(X) => foldl(/\x./\y.plusc(x, y), 0, X) foldl(/\x./\y.plusc(x, y), X, nil) => X foldl(/\x./\y.plusc(x, y), X, cons(Y, Z)) => foldl(/\z./\u.plusc(z, u), plusc(X, Y), Z) ~AP1(F, X) => F X Symbol ~AP1 is an encoding for application that is only used in innocuous ways. We can simplify the program (without losing non-termination) by removing it. Additionally, we can remove some (now-)redundant rules. This gives: Alphabet: 0 : [] --> nat cons : [nat * list] --> list foldl : [nat -> nat -> nat * nat * list] --> nat nil : [] --> list plusc : [nat * nat] --> nat s : [nat] --> nat sum : [list] --> nat Rules: foldl(/\x./\y.X(x, y), Y, nil) => Y foldl(/\x./\y.X(x, y), Y, cons(Z, U)) => foldl(/\z./\u.X(z, u), X(Y, Z), U) plusc(X, 0) => X plusc(X, s(Y)) => s(plusc(X, Y)) sum(X) => foldl(/\x./\y.plusc(x, y), 0, X) We use rule removal, following [Kop12, Theorem 2.23]. This gives the following requirements (possibly using Theorems 2.25 and 2.26 in [Kop12]): foldl(/\x./\y.X(x, y), Y, nil) >? Y foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >? foldl(/\z./\u.X(z, u), X(Y, Z), U) plusc(X, 0) >? X plusc(X, s(Y)) >? s(plusc(X, Y)) sum(X) >? foldl(/\x./\y.plusc(x, y), 0, X) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[0]] = _|_ [[foldl(x_1, x_2, x_3)]] = foldl(x_3, x_1, x_2) We choose Lex = {foldl} and Mul = {cons, nil, plusc, s, sum}, and the following precedence: cons > nil > sum > foldl > plusc > s Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(/\x./\y.X(x, y), Y, nil) >= Y foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) plusc(X, _|_) > X plusc(X, s(Y)) >= s(plusc(X, Y)) sum(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) With these choices, we have: 1] foldl(/\x./\y.X(x, y), Y, nil) >= Y because [2], by (Star) 2] foldl*(/\x./\y.X(x, y), Y, nil) >= Y because [3], by (Select) 3] Y >= Y by (Meta) 4] foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) because [5], by (Star) 5] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) because [6], [9], [15] and [23], by (Stat) 6] cons(Z, U) > U because [7], by definition 7] cons*(Z, U) >= U because [8], by (Select) 8] U >= U by (Meta) 9] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= /\x./\y.X(x, y) because [10], by (Select) 10] /\x./\z.X(x, z) >= /\x./\z.X(x, z) because [11], by (Abs) 11] /\z.X(y, z) >= /\z.X(y, z) because [12], by (Abs) 12] X(y, x) >= X(y, x) because [13] and [14], by (Meta) 13] y >= y by (Var) 14] x >= x by (Var) 15] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= X(Y, Z) because [16], by (Select) 16] X(foldl*(/\z./\u.X(z, u), Y, cons(Z, U)), foldl*(/\v./\w.X(v, w), Y, cons(Z, U))) >= X(Y, Z) because [17] and [19], by (Meta) 17] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= Y because [18], by (Select) 18] Y >= Y by (Meta) 19] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= Z because [20], by (Select) 20] cons(Z, U) >= Z because [21], by (Star) 21] cons*(Z, U) >= Z because [22], by (Select) 22] Z >= Z by (Meta) 23] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= U because [24], by (Select) 24] cons(Z, U) >= U because [7], by (Star) 25] plusc(X, _|_) > X because [26], by definition 26] plusc*(X, _|_) >= X because [27], by (Select) 27] X >= X by (Meta) 28] plusc(X, s(Y)) >= s(plusc(X, Y)) because [29], by (Star) 29] plusc*(X, s(Y)) >= s(plusc(X, Y)) because plusc > s and [30], by (Copy) 30] plusc*(X, s(Y)) >= plusc(X, Y) because plusc in Mul, [31] and [32], by (Stat) 31] X >= X by (Meta) 32] s(Y) > Y because [33], by definition 33] s*(Y) >= Y because [34], by (Select) 34] Y >= Y by (Meta) 35] sum(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) because [36], by (Star) 36] sum*(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) because sum > foldl, [37], [44] and [45], by (Copy) 37] sum*(X) >= /\y./\z.plusc(y, z) because [38], by (F-Abs) 38] sum*(X, x) >= /\z.plusc(x, z) because [39], by (F-Abs) 39] sum*(X, x, y) >= plusc(x, y) because sum > plusc, [40] and [42], by (Copy) 40] sum*(X, x, y) >= x because [41], by (Select) 41] x >= x by (Var) 42] sum*(X, x, y) >= y because [43], by (Select) 43] y >= y by (Var) 44] sum*(X) >= _|_ by (Bot) 45] sum*(X) >= X because [46], by (Select) 46] X >= X by (Meta) We can thus remove the following rules: plusc(X, 0) => X We use rule removal, following [Kop12, Theorem 2.23]. This gives the following requirements (possibly using Theorems 2.25 and 2.26 in [Kop12]): foldl(/\x./\y.X(x, y), Y, nil) >? Y foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >? foldl(/\z./\u.X(z, u), X(Y, Z), U) plusc(X, s(Y)) >? s(plusc(X, Y)) sum(X) >? foldl(/\x./\y.plusc(x, y), 0, X) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[0]] = _|_ [[foldl(x_1, x_2, x_3)]] = foldl(x_3, x_2, x_1) We choose Lex = {foldl} and Mul = {cons, nil, plusc, s, sum}, and the following precedence: cons > nil > sum > foldl > plusc > s Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(/\x./\y.X(x, y), Y, nil) > Y foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) plusc(X, s(Y)) >= s(plusc(X, Y)) sum(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) With these choices, we have: 1] foldl(/\x./\y.X(x, y), Y, nil) > Y because [2], by definition 2] foldl*(/\x./\y.X(x, y), Y, nil) >= Y because [3], by (Select) 3] Y >= Y by (Meta) 4] foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) because [5], by (Star) 5] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) because [6], [9], [16] and [24], by (Stat) 6] cons(Z, U) > U because [7], by definition 7] cons*(Z, U) >= U because [8], by (Select) 8] U >= U by (Meta) 9] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= /\x./\y.X(x, y) because [10], by (F-Abs) 10] foldl*(/\x./\y.X(x, y), Y, cons(Z, U), z) >= /\x.X(z, x) because [11], by (Select) 11] /\x.X(foldl*(/\y./\v.X(y, v), Y, cons(Z, U), z), x) >= /\x.X(z, x) because [12], by (Abs) 12] X(foldl*(/\x./\y.X(x, y), Y, cons(Z, U), z), u) >= X(z, u) because [13] and [15], by (Meta) 13] foldl*(/\x./\y.X(x, y), Y, cons(Z, U), z) >= z because [14], by (Select) 14] z >= z by (Var) 15] u >= u by (Var) 16] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= X(Y, Z) because [17], by (Select) 17] X(foldl*(/\x./\y.X(x, y), Y, cons(Z, U)), foldl*(/\v./\w.X(v, w), Y, cons(Z, U))) >= X(Y, Z) because [18] and [20], by (Meta) 18] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= Y because [19], by (Select) 19] Y >= Y by (Meta) 20] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= Z because [21], by (Select) 21] cons(Z, U) >= Z because [22], by (Star) 22] cons*(Z, U) >= Z because [23], by (Select) 23] Z >= Z by (Meta) 24] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= U because [25], by (Select) 25] cons(Z, U) >= U because [7], by (Star) 26] plusc(X, s(Y)) >= s(plusc(X, Y)) because [27], by (Star) 27] plusc*(X, s(Y)) >= s(plusc(X, Y)) because plusc > s and [28], by (Copy) 28] plusc*(X, s(Y)) >= plusc(X, Y) because plusc in Mul, [29] and [30], by (Stat) 29] X >= X by (Meta) 30] s(Y) > Y because [31], by definition 31] s*(Y) >= Y because [32], by (Select) 32] Y >= Y by (Meta) 33] sum(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) because [34], by (Star) 34] sum*(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) because sum > foldl, [35], [42] and [43], by (Copy) 35] sum*(X) >= /\y./\z.plusc(y, z) because [36], by (F-Abs) 36] sum*(X, x) >= /\z.plusc(x, z) because [37], by (F-Abs) 37] sum*(X, x, y) >= plusc(x, y) because sum > plusc, [38] and [40], by (Copy) 38] sum*(X, x, y) >= x because [39], by (Select) 39] x >= x by (Var) 40] sum*(X, x, y) >= y because [41], by (Select) 41] y >= y by (Var) 42] sum*(X) >= _|_ by (Bot) 43] sum*(X) >= X because [44], by (Select) 44] X >= X by (Meta) We can thus remove the following rules: foldl(/\x./\y.X(x, y), Y, nil) => Y We use rule removal, following [Kop12, Theorem 2.23]. This gives the following requirements (possibly using Theorems 2.25 and 2.26 in [Kop12]): foldl(/\x./\y.X(x, y), Y, cons(Z, U)) >? foldl(/\z./\u.X(z, u), X(Y, Z), U) plusc(X, s(Y)) >? s(plusc(X, Y)) sum(X) >? foldl(/\x./\y.plusc(x, y), 0, X) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[0]] = _|_ [[foldl(x_1, x_2, x_3)]] = foldl(x_3, x_2, x_1) [[s(x_1)]] = x_1 We choose Lex = {foldl} and Mul = {cons, plusc, sum}, and the following precedence: cons > sum > foldl > plusc Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(/\x./\y.X(x, y), Y, cons(Z, U)) > foldl(/\x./\y.X(x, y), X(Y, Z), U) plusc(X, Y) >= plusc(X, Y) sum(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) With these choices, we have: 1] foldl(/\x./\y.X(x, y), Y, cons(Z, U)) > foldl(/\x./\y.X(x, y), X(Y, Z), U) because [2], by definition 2] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= foldl(/\x./\y.X(x, y), X(Y, Z), U) because [3], [6], [12] and [20], by (Stat) 3] cons(Z, U) > U because [4], by definition 4] cons*(Z, U) >= U because [5], by (Select) 5] U >= U by (Meta) 6] foldl*(/\x./\y.X(x, y), Y, cons(Z, U)) >= /\x./\y.X(x, y) because [7], by (Select) 7] /\x./\z.X(x, z) >= /\x./\z.X(x, z) because [8], by (Abs) 8] /\z.X(y, z) >= /\z.X(y, z) because [9], by (Abs) 9] X(y, x) >= X(y, x) because [10] and [11], by (Meta) 10] y >= y by (Var) 11] x >= x by (Var) 12] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= X(Y, Z) because [13], by (Select) 13] X(foldl*(/\z./\u.X(z, u), Y, cons(Z, U)), foldl*(/\v./\w.X(v, w), Y, cons(Z, U))) >= X(Y, Z) because [14] and [16], by (Meta) 14] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= Y because [15], by (Select) 15] Y >= Y by (Meta) 16] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= Z because [17], by (Select) 17] cons(Z, U) >= Z because [18], by (Star) 18] cons*(Z, U) >= Z because [19], by (Select) 19] Z >= Z by (Meta) 20] foldl*(/\z./\u.X(z, u), Y, cons(Z, U)) >= U because [21], by (Select) 21] cons(Z, U) >= U because [4], by (Star) 22] plusc(X, Y) >= plusc(X, Y) because plusc in Mul, [23] and [24], by (Fun) 23] X >= X by (Meta) 24] Y >= Y by (Meta) 25] sum(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) because [26], by (Star) 26] sum*(X) >= foldl(/\x./\y.plusc(x, y), _|_, X) because sum > foldl, [27], [34] and [35], by (Copy) 27] sum*(X) >= /\y./\z.plusc(y, z) because [28], by (F-Abs) 28] sum*(X, x) >= /\z.plusc(x, z) because [29], by (F-Abs) 29] sum*(X, x, y) >= plusc(x, y) because sum > plusc, [30] and [32], by (Copy) 30] sum*(X, x, y) >= x because [31], by (Select) 31] x >= x by (Var) 32] sum*(X, x, y) >= y because [33], by (Select) 33] y >= y by (Var) 34] sum*(X) >= _|_ by (Bot) 35] sum*(X) >= X because [36], by (Select) 36] X >= X by (Meta) We can thus remove the following rules: foldl(/\x./\y.X(x, y), Y, cons(Z, U)) => foldl(/\z./\u.X(z, u), X(Y, Z), U) We use rule removal, following [Kop12, Theorem 2.23]. This gives the following requirements (possibly using Theorems 2.25 and 2.26 in [Kop12]): plusc(X, s(Y)) >? s(plusc(X, Y)) sum(X) >? foldl(/\x./\y.plusc(x, y), 0, X) We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: 0 = 0 foldl = \G0y1y2.y1 + y2 + G0(0,0) plusc = \y0y1.y0 + 2y1 s = \y0.1 + y0 sum = \y0.3 + 3y0 Using this interpretation, the requirements translate to: [[plusc(_x0, s(_x1))]] = 2 + x0 + 2x1 > 1 + x0 + 2x1 = [[s(plusc(_x0, _x1))]] [[sum(_x0)]] = 3 + 3x0 > x0 = [[foldl(/\x./\y.plusc(x, y), 0, _x0)]] We can thus remove the following rules: plusc(X, s(Y)) => s(plusc(X, Y)) sum(X) => foldl(/\x./\y.plusc(x, y), 0, X) All rules were succesfully removed. Thus, termination of the original system has been reduced to termination of the beta-rule, which is well-known to hold. +++ Citations +++ [Kop11] C. Kop. Simplifying Algebraic Functional Systems. In Proceedings of CAI 2011, volume 6742 of LNCS. 201--215, Springer, 2011. [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012.