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_1, x_3, x_2) [[s(x_1)]] = x_1 We choose Lex = {foldl} and Mul = {@_{o -> o}, cons, nil, plusc, sum, yap}, and the following precedence: sum > nil > cons = plusc > @_{o -> o} = yap > 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 definition 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], [12], [15], [16] and [25], by (Stat) 6] /\x./\z.yap(F(x), z) >= /\x./\z.yap(F(x), z) because [7], by (Abs) 7] /\z.yap(F(y), z) >= /\z.yap(F(y), z) because [8], by (Abs) 8] yap(F(y), x) >= yap(F(y), x) because yap in Mul, [9] and [11], by (Fun) 9] F(y) >= F(y) because [10], by (Meta) 10] y >= y by (Var) 11] x >= x by (Var) 12] cons(Y, Z) > Z because [13], by definition 13] cons*(Y, Z) >= Z because [14], by (Select) 14] Z >= Z by (Meta) 15] foldl*(/\z./\u.yap(F(z), u), X, cons(Y, Z)) >= /\z./\u.yap(F(z), u) because [6], by (Select) 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 [13], by (Star) 27] @_{o -> o}(plusc(X), _|_) > X because [28], by definition 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 definition 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 yap = @_{o -> o}, yap in Mul, [50] and [51], by (Fun) 50] F >= F by (Meta) 51] X >= X by (Meta) We can thus remove the following 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 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]): plusc(X, s(Y)) >? s(plusc(X, Y)) yap(F, X) >? F X We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[s(x_1)]] = x_1 We choose Lex = {} and Mul = {@_{o -> o}, plusc, yap}, and the following precedence: plusc > yap > @_{o -> o} Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: plusc(X, Y) >= plusc(X, Y) yap(F, X) > @_{o -> o}(F, X) With these choices, we have: 1] plusc(X, Y) >= plusc(X, Y) because plusc in Mul, [2] and [3], by (Fun) 2] X >= X by (Meta) 3] Y >= Y by (Meta) 4] yap(F, X) > @_{o -> o}(F, X) because [5], by definition 5] yap*(F, X) >= @_{o -> o}(F, X) because yap > @_{o -> o}, [6] and [8], by (Copy) 6] yap*(F, X) >= F because [7], by (Select) 7] F >= F by (Meta) 8] yap*(F, X) >= X because [9], by (Select) 9] 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]): plusc(X, s(Y)) >? s(plusc(X, Y)) We use a recursive path ordering as defined in [Kop12, Chapter 5]. We choose Lex = {} and Mul = {plusc, s}, and the following precedence: plusc > s With these choices, we have: 1] plusc(X, s(Y)) > s(plusc(X, Y)) because [2], by definition 2] plusc*(X, s(Y)) >= s(plusc(X, Y)) because plusc > s and [3], by (Copy) 3] plusc*(X, s(Y)) >= plusc(X, Y) because plusc in Mul, [4] and [5], by (Stat) 4] X >= X by (Meta) 5] s(Y) > Y because [6], by definition 6] s*(Y) >= Y because [7], by (Select) 7] Y >= Y by (Meta) We can thus remove the following rules: plusc(X, s(Y)) => s(plusc(X, Y)) 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.