We consider the system h54. 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 xap : [nat -> nat -> nat * nat] --> nat -> nat yap : [nat -> nat * nat] --> nat Rules: foldl(/\x./\y.yap(xap(f, x), y), z, nil) => z foldl(/\x./\y.yap(xap(f, x), y), z, cons(u, v)) => foldl(/\w./\x'.yap(xap(f, w), x'), yap(xap(f, z), u), v) plusc x 0 => x plusc x s(y) => s(plusc x y) sum(x) => foldl(/\y./\z.yap(xap(plusc, y), z), 0, x) xap(f, x) => f x yap(f, x) => f x This AFS is converted to an AFSM simply by replacing all free variables by meta-variables (with arity 0). Symbol xap is an encoding for application that is only used in innocuous ways. We can simplify the program (without losing non-termination) by removing it. 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 yap : [nat -> nat * nat] --> nat Rules: foldl(/\x./\y.yap(F(x), y), X, nil) => X foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) => foldl(/\z./\u.yap(F(z), u), yap(F(X), Y), Z) plusc(X) 0 => X plusc(X) s(Y) => s(plusc(X) Y) sum(X) => foldl(/\x./\y.yap(plusc(x), y), 0, X) yap(F, X) => F 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.yap(F(x), y), X, nil) >? X foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >? foldl(/\z./\u.yap(F(z), u), yap(F(X), Y), Z) plusc(X) 0 >? X plusc(X) s(Y) >? s(plusc(X) Y) sum(X) >? foldl(/\x./\y.yap(plusc(x), y), 0, X) yap(F, X) >? F 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) [[s(x_1)]] = x_1 We choose Lex = {foldl} and Mul = {@_{o -> o}, cons, nil, plusc, sum, yap}, and the following precedence: nil > sum > plusc > cons > yap > @_{o -> o} > foldl Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(/\x./\y.yap(F(x), y), X, nil) >= X foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= foldl(/\x./\y.yap(F(x), y), yap(F(X), Y), Z) @_{o -> o}(plusc(X), _|_) >= X @_{o -> o}(plusc(X), Y) >= @_{o -> o}(plusc(X), Y) sum(X) >= foldl(/\x./\y.yap(plusc(x), y), _|_, X) yap(F, X) > @_{o -> o}(F, X) With these choices, we have: 1] foldl(/\x./\y.yap(F(x), y), X, nil) >= X because [2], by (Star) 2] foldl*(/\x./\y.yap(F(x), y), X, nil) >= X because [3], by (Select) 3] X >= X by (Meta) 4] foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= foldl(/\x./\y.yap(F(x), y), yap(F(X), Y), Z) because [5], by (Star) 5] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= foldl(/\x./\y.yap(F(x), y), yap(F(X), Y), Z) because [6], [9], [16] and [25], by (Stat) 6] cons(Y, Z) > Z because [7], by definition 7] cons*(Y, Z) >= Z because [8], by (Select) 8] Z >= Z by (Meta) 9] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= /\x./\y.yap(F(x), y) because [10], by (Select) 10] /\x./\z.yap(F(x), z) >= /\x./\z.yap(F(x), z) because [11], by (Abs) 11] /\z.yap(F(y), z) >= /\z.yap(F(y), z) because [12], by (Abs) 12] yap(F(y), x) >= yap(F(y), x) because yap in Mul, [13] and [15], by (Fun) 13] F(y) >= F(y) because [14], by (Meta) 14] y >= y by (Var) 15] x >= x by (Var) 16] foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z)) >= yap(F(X), Y) because [17], by (Select) 17] yap(F(foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z))), foldl*(/\v./\w.yap(F(v), w), X, cons(Y, Z))) >= yap(F(X), Y) because yap in Mul, [18] and [21], by (Fun) 18] F(foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z))) >= F(X) because [19], by (Meta) 19] foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z)) >= X because [20], by (Select) 20] X >= X by (Meta) 21] foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z)) >= Y because [22], by (Select) 22] cons(Y, Z) >= Y because [23], by (Star) 23] cons*(Y, Z) >= Y because [24], by (Select) 24] Y >= Y by (Meta) 25] foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z)) >= Z because [26], by (Select) 26] cons(Y, Z) >= Z because [7], by (Star) 27] @_{o -> o}(plusc(X), _|_) >= X because [28], by (Star) 28] @_{o -> o}*(plusc(X), _|_) >= X because [29], by (Select) 29] plusc(X) @_{o -> o}*(plusc(X), _|_) >= X because [30] 30] plusc*(X, @_{o -> o}*(plusc(X), _|_)) >= X because [31], by (Select) 31] X >= X by (Meta) 32] @_{o -> o}(plusc(X), Y) >= @_{o -> o}(plusc(X), Y) because @_{o -> o} in Mul, [33] and [35], by (Fun) 33] plusc(X) >= plusc(X) because plusc in Mul and [34], by (Fun) 34] X >= X by (Meta) 35] Y >= Y by (Meta) 36] sum(X) >= foldl(/\x./\y.yap(plusc(x), y), _|_, X) because [37], by (Star) 37] sum*(X) >= foldl(/\x./\y.yap(plusc(x), y), _|_, X) because sum > foldl, [38], [46] and [47], by (Copy) 38] sum*(X) >= /\y./\z.yap(plusc(y), z) because [39], by (F-Abs) 39] sum*(X, x) >= /\z.yap(plusc(x), z) because [40], by (F-Abs) 40] sum*(X, x, y) >= yap(plusc(x), y) because sum > yap, [41] and [44], by (Copy) 41] sum*(X, x, y) >= plusc(x) because sum > plusc and [42], by (Copy) 42] sum*(X, x, y) >= x because [43], by (Select) 43] x >= x by (Var) 44] sum*(X, x, y) >= y because [45], by (Select) 45] y >= y by (Var) 46] sum*(X) >= _|_ by (Bot) 47] sum*(X) >= X because [48], by (Select) 48] X >= X by (Meta) 49] yap(F, X) > @_{o -> o}(F, X) because [50], by definition 50] yap*(F, X) >= @_{o -> o}(F, X) because yap > @_{o -> o}, [51] and [53], by (Copy) 51] yap*(F, X) >= F because [52], by (Select) 52] F >= F by (Meta) 53] yap*(F, X) >= X because [54], by (Select) 54] X >= X by (Meta) We can thus remove the following rules: yap(F, X) => F 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.yap(F(x), y), X, nil) >? X foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >? foldl(/\z./\u.yap(F(z), u), yap(F(X), Y), Z) plusc(X) 0 >? X plusc(X) s(Y) >? s(plusc(X) Y) sum(X) >? foldl(/\x./\y.yap(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 = {@_{o -> o}, cons, nil, plusc, s, sum, yap}, and the following precedence: nil > sum > plusc > @_{o -> o} > s > foldl > cons > yap Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(/\x./\y.yap(F(x), y), X, nil) >= X foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) > foldl(/\x./\y.yap(F(x), y), yap(F(X), Y), Z) @_{o -> o}(plusc(X), _|_) > X @_{o -> o}(plusc(X), s(Y)) > s(@_{o -> o}(plusc(X), Y)) sum(X) > foldl(/\x./\y.yap(plusc(x), y), _|_, X) With these choices, we have: 1] foldl(/\x./\y.yap(F(x), y), X, nil) >= X because [2], by (Star) 2] foldl*(/\x./\y.yap(F(x), y), X, nil) >= X because [3], by (Select) 3] X >= X by (Meta) 4] foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) > foldl(/\x./\y.yap(F(x), y), yap(F(X), Y), Z) because [5], by definition 5] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= foldl(/\x./\y.yap(F(x), y), yap(F(X), Y), Z) because [6], [9], [19] and [29], by (Stat) 6] cons(Y, Z) > Z because [7], by definition 7] cons*(Y, Z) >= Z because [8], by (Select) 8] Z >= Z by (Meta) 9] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= /\x./\y.yap(F(x), y) because [10], by (F-Abs) 10] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z), z) >= /\x.yap(F(z), x) because [11], by (F-Abs) 11] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z), z, u) >= yap(F(z), u) because foldl > yap, [12] and [17], by (Copy) 12] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z), z, u) >= F(z) because [13], by (Select) 13] /\x.yap(F(foldl*(/\y./\v.yap(F(y), v), X, cons(Y, Z), z, u)), x) >= F(z) because [14], by (Eta)[Kop13:2] 14] F(foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z), z, u)) >= F(z) because [15], by (Meta) 15] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z), z, u) >= z because [16], by (Select) 16] z >= z by (Var) 17] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z), z, u) >= u because [18], by (Select) 18] u >= u by (Var) 19] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= yap(F(X), Y) because foldl > yap, [20] and [25], by (Copy) 20] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= F(X) because [21], by (Select) 21] /\x.yap(F(foldl*(/\y./\v.yap(F(y), v), X, cons(Y, Z))), x) >= F(X) because [22], by (Eta)[Kop13:2] 22] F(foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z))) >= F(X) because [23], by (Meta) 23] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= X because [24], by (Select) 24] X >= X by (Meta) 25] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= Y because [26], by (Select) 26] cons(Y, Z) >= Y because [27], by (Star) 27] cons*(Y, Z) >= Y because [28], by (Select) 28] Y >= Y by (Meta) 29] foldl*(/\x./\y.yap(F(x), y), X, cons(Y, Z)) >= Z because [30], by (Select) 30] cons(Y, Z) >= Z because [7], by (Star) 31] @_{o -> o}(plusc(X), _|_) > X because [32], by definition 32] @_{o -> o}*(plusc(X), _|_) >= X because [33], by (Select) 33] plusc(X) @_{o -> o}*(plusc(X), _|_) >= X because [34] 34] plusc*(X, @_{o -> o}*(plusc(X), _|_)) >= X because [35], by (Select) 35] X >= X by (Meta) 36] @_{o -> o}(plusc(X), s(Y)) > s(@_{o -> o}(plusc(X), Y)) because [37], by definition 37] @_{o -> o}*(plusc(X), s(Y)) >= s(@_{o -> o}(plusc(X), Y)) because [38], by (Select) 38] plusc(X) @_{o -> o}*(plusc(X), s(Y)) >= s(@_{o -> o}(plusc(X), Y)) because [39] 39] plusc*(X, @_{o -> o}*(plusc(X), s(Y))) >= s(@_{o -> o}(plusc(X), Y)) because plusc > s and [40], by (Copy) 40] plusc*(X, @_{o -> o}*(plusc(X), s(Y))) >= @_{o -> o}(plusc(X), Y) because [41], by (Select) 41] @_{o -> o}*(plusc(X), s(Y)) >= @_{o -> o}(plusc(X), Y) because @_{o -> o} in Mul, [42] and [44], by (Stat) 42] plusc(X) >= plusc(X) because plusc in Mul and [43], by (Fun) 43] X >= X by (Meta) 44] s(Y) > Y because [45], by definition 45] s*(Y) >= Y because [46], by (Select) 46] Y >= Y by (Meta) 47] sum(X) > foldl(/\x./\y.yap(plusc(x), y), _|_, X) because [48], by definition 48] sum*(X) >= foldl(/\x./\y.yap(plusc(x), y), _|_, X) because sum > foldl, [49], [57] and [58], by (Copy) 49] sum*(X) >= /\y./\z.yap(plusc(y), z) because [50], by (F-Abs) 50] sum*(X, x) >= /\z.yap(plusc(x), z) because [51], by (F-Abs) 51] sum*(X, x, y) >= yap(plusc(x), y) because sum > yap, [52] and [55], by (Copy) 52] sum*(X, x, y) >= plusc(x) because sum > plusc and [53], by (Copy) 53] sum*(X, x, y) >= x because [54], by (Select) 54] x >= x by (Var) 55] sum*(X, x, y) >= y because [56], by (Select) 56] y >= y by (Var) 57] sum*(X) >= _|_ by (Bot) 58] sum*(X) >= X because [59], by (Select) 59] X >= X by (Meta) We can thus remove the following rules: foldl(/\x./\y.yap(F(x), y), X, cons(Y, Z)) => foldl(/\z./\u.yap(F(z), u), yap(F(X), Y), Z) plusc(X) 0 => X plusc(X) s(Y) => s(plusc(X) Y) sum(X) => foldl(/\x./\y.yap(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.yap(F(x), y), X, nil) >? X We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: foldl = \G0y1y2.3 + y1 + y2 + G0(0,0) nil = 3 yap = \G0y1.3 + y1 + G0(0) Using this interpretation, the requirements translate to: [[foldl(/\x./\y.yap(_F0(x), y), _x1, nil)]] = 9 + x1 + F0(0,0) > x1 = [[_x1]] We can thus remove the following rules: foldl(/\x./\y.yap(F(x), y), X, nil) => 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 +++ [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012. [Kop13:2] C. Kop. StarHorpo with an Eta-Rule. Unpublished manuscript, http://cl-informatik.uibk.ac.at/users/kop/etahorpo.pdf, 2013.