We consider the system foldl. Alphabet: 0 : [] --> nat cons : [nat * list] --> list foldl : [nat -> nat -> nat * nat * list] --> nat nil : [] --> list plus : [nat * nat] --> nat plusc : [] --> nat -> nat -> nat sum : [list] --> nat Rules: foldl(f, x, nil) => x foldl(f, x, cons(y, z)) => foldl(f, f x y, z) plusc => /\x./\y.plus(x, y) sum(x) => foldl(plusc, 0, x) This AFS is converted to an AFSM simply by replacing all free variables by meta-variables (with arity 0). 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(F, X, nil) >? X foldl(F, X, cons(Y, Z)) >? foldl(F, F X Y, Z) plusc >? /\x./\y.plus(x, y) sum(X) >? foldl(plusc, 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_1, x_3, x_2) We choose Lex = {foldl} and Mul = {@_{o -> o -> o}, @_{o -> o}, cons, nil, plus, plusc, sum}, and the following precedence: plusc = sum > foldl > plus > @_{o -> o} > nil > cons > @_{o -> o -> o} Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(F, X, nil) >= X foldl(F, X, cons(Y, Z)) >= foldl(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) plusc > /\x./\y.plus(x, y) sum(X) > foldl(plusc, _|_, X) With these choices, we have: 1] foldl(F, X, nil) >= X because [2], by (Star) 2] foldl*(F, X, nil) >= X because [3], by (Select) 3] X >= X by (Meta) 4] foldl(F, X, cons(Y, Z)) >= foldl(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) because [5], by (Star) 5] foldl*(F, X, cons(Y, Z)) >= foldl(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) because [6], [7], [10], [11] and [19], by (Stat) 6] F >= F by (Meta) 7] cons(Y, Z) > Z because [8], by definition 8] cons*(Y, Z) >= Z because [9], by (Select) 9] Z >= Z by (Meta) 10] foldl*(F, X, cons(Y, Z)) >= F because [6], by (Select) 11] foldl*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, X), Y) because foldl > @_{o -> o}, [12] and [15], by (Copy) 12] foldl*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, X) because foldl > @_{o -> o -> o}, [10] and [13], by (Copy) 13] foldl*(F, X, cons(Y, Z)) >= X because [14], by (Select) 14] X >= X by (Meta) 15] foldl*(F, X, cons(Y, Z)) >= Y because [16], by (Select) 16] cons(Y, Z) >= Y because [17], by (Star) 17] cons*(Y, Z) >= Y because [18], by (Select) 18] Y >= Y by (Meta) 19] foldl*(F, X, cons(Y, Z)) >= Z because [20], by (Select) 20] cons(Y, Z) >= Z because [8], by (Star) 21] plusc > /\x./\y.plus(x, y) because [22], by definition 22] plusc* >= /\y./\z.plus(y, z) because [23], by (F-Abs) 23] plusc*(x) >= /\z.plus(x, z) because [24], by (F-Abs) 24] plusc*(x, y) >= plus(x, y) because plusc > plus, [25] and [27], by (Copy) 25] plusc*(x, y) >= x because [26], by (Select) 26] x >= x by (Var) 27] plusc*(x, y) >= y because [28], by (Select) 28] y >= y by (Var) 29] sum(X) > foldl(plusc, _|_, X) because [30], by definition 30] sum*(X) >= foldl(plusc, _|_, X) because sum > foldl, [31], [32] and [33], by (Copy) 31] sum*(X) >= plusc because sum = plusc and sum in Mul, by (Stat) 32] sum*(X) >= _|_ by (Bot) 33] sum*(X) >= X because [34], by (Select) 34] X >= X by (Meta) We can thus remove the following rules: plusc => /\x./\y.plus(x, y) sum(X) => foldl(plusc, 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(F, X, nil) >? X foldl(F, X, cons(Y, Z)) >? foldl(F, F X Y, Z) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[@_{o -> o}(x_1, x_2)]] = @_{o -> o}(x_2, x_1) [[foldl(x_1, x_2, x_3)]] = foldl(x_3, x_1, x_2) We choose Lex = {@_{o -> o}, foldl} and Mul = {@_{o -> o -> o}, cons, nil}, and the following precedence: @_{o -> o} = foldl > cons > @_{o -> o -> o} > nil Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: foldl(F, X, nil) > X foldl(F, X, cons(Y, Z)) > foldl(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) With these choices, we have: 1] foldl(F, X, nil) > X because [2], by definition 2] foldl*(F, X, nil) >= X because [3], by (Select) 3] X >= X by (Meta) 4] foldl(F, X, cons(Y, Z)) > foldl(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) because [5], by definition 5] foldl*(F, X, cons(Y, Z)) >= foldl(F, @_{o -> o}(@_{o -> o -> o}(F, X), Y), Z) because [6], [9], [11] and [20], 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*(F, X, cons(Y, Z)) >= F because [10], by (Select) 10] F >= F by (Meta) 11] foldl*(F, X, cons(Y, Z)) >= @_{o -> o}(@_{o -> o -> o}(F, X), Y) because foldl = @_{o -> o}, [12], [15] and [18], by (Stat) 12] cons(Y, Z) > Y because [13], by definition 13] cons*(Y, Z) >= Y because [14], by (Select) 14] Y >= Y by (Meta) 15] foldl*(F, X, cons(Y, Z)) >= @_{o -> o -> o}(F, X) because foldl > @_{o -> o -> o}, [9] and [16], by (Copy) 16] foldl*(F, X, cons(Y, Z)) >= X because [17], by (Select) 17] X >= X by (Meta) 18] foldl*(F, X, cons(Y, Z)) >= Y because [19], by (Select) 19] cons(Y, Z) >= Y because [13], by (Star) 20] foldl*(F, X, cons(Y, Z)) >= Z because [21], by (Select) 21] cons(Y, Z) >= Z because [7], by (Star) We can thus remove the following rules: foldl(F, X, nil) => X foldl(F, X, cons(Y, Z)) => foldl(F, F X Y, Z) 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.