We consider the system extrec. Alphabet: !plus : [nat * nat] --> nat !times : [nat * nat] --> nat 0 : [] --> nat rec : [nat * nat * nat -> nat -> nat] --> nat s : [nat] --> nat Rules: !plus(x, 0) => x !plus(x, s(y)) => s(!plus(x, y)) rec(0, x, f) => x rec(s(x), y, f) => f x rec(x, y, f) !times(x, y) => rec(y, 0, /\z./\u.!plus(x, u)) 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]): !plus(X, 0) >? X !plus(X, s(Y)) >? s(!plus(X, Y)) rec(0, X, F) >? X rec(s(X), Y, F) >? F X rec(X, Y, F) !times(X, Y) >? rec(Y, 0, /\x./\y.!plus(X, y)) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[0]] = _|_ We choose Lex = {} and Mul = {!plus, !times, @_{o -> o -> o}, @_{o -> o}, rec, s}, and the following precedence: !times > !plus > @_{o -> o -> o} = rec > @_{o -> o} = s Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: !plus(X, _|_) >= X !plus(X, s(Y)) > s(!plus(X, Y)) rec(_|_, X, F) > X rec(s(X), Y, F) >= @_{o -> o}(@_{o -> o -> o}(F, X), rec(X, Y, F)) !times(X, Y) > rec(Y, _|_, /\x./\y.!plus(X, y)) With these choices, we have: 1] !plus(X, _|_) >= X because [2], by (Star) 2] !plus*(X, _|_) >= X because [3], by (Select) 3] X >= X by (Meta) 4] !plus(X, s(Y)) > s(!plus(X, Y)) because [5], by definition 5] !plus*(X, s(Y)) >= s(!plus(X, Y)) because !plus > s and [6], by (Copy) 6] !plus*(X, s(Y)) >= !plus(X, Y) because !plus in Mul, [7] and [8], by (Stat) 7] X >= X by (Meta) 8] s(Y) > Y because [9], by definition 9] s*(Y) >= Y because [10], by (Select) 10] Y >= Y by (Meta) 11] rec(_|_, X, F) > X because [12], by definition 12] rec*(_|_, X, F) >= X because [13], by (Select) 13] X >= X by (Meta) 14] rec(s(X), Y, F) >= @_{o -> o}(@_{o -> o -> o}(F, X), rec(X, Y, F)) because [15], by (Star) 15] rec*(s(X), Y, F) >= @_{o -> o}(@_{o -> o -> o}(F, X), rec(X, Y, F)) because rec > @_{o -> o}, [16] and [21], by (Copy) 16] rec*(s(X), Y, F) >= @_{o -> o -> o}(F, X) because rec = @_{o -> o -> o}, rec in Mul, [17] and [20], by (Stat) 17] s(X) > X because [18], by definition 18] s*(X) >= X because [19], by (Select) 19] X >= X by (Meta) 20] F >= F by (Meta) 21] rec*(s(X), Y, F) >= rec(X, Y, F) because rec in Mul, [17], [22] and [20], by (Stat) 22] Y >= Y by (Meta) 23] !times(X, Y) > rec(Y, _|_, /\x./\y.!plus(X, y)) because [24], by definition 24] !times*(X, Y) >= rec(Y, _|_, /\x./\y.!plus(X, y)) because !times > rec, [25], [27] and [28], by (Copy) 25] !times*(X, Y) >= Y because [26], by (Select) 26] Y >= Y by (Meta) 27] !times*(X, Y) >= _|_ by (Bot) 28] !times*(X, Y) >= /\y./\z.!plus(X, z) because [29], by (F-Abs) 29] !times*(X, Y, x) >= /\z.!plus(X, z) because [30], by (F-Abs) 30] !times*(X, Y, x, y) >= !plus(X, y) because !times > !plus, [31] and [33], by (Copy) 31] !times*(X, Y, x, y) >= X because [32], by (Select) 32] X >= X by (Meta) 33] !times*(X, Y, x, y) >= y because [34], by (Select) 34] y >= y by (Var) We can thus remove the following rules: !plus(X, s(Y)) => s(!plus(X, Y)) rec(0, X, F) => X !times(X, Y) => rec(Y, 0, /\x./\y.!plus(X, 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]): !plus(X, 0) >? X rec(s(X), Y, F) >? F X rec(X, Y, F) We use a recursive path ordering as defined in [Kop12, Chapter 5]. We choose Lex = {} and Mul = {!plus, 0, @_{o -> o -> o}, @_{o -> o}, rec, s}, and the following precedence: rec > s > !plus > 0 > @_{o -> o -> o} > @_{o -> o} With these choices, we have: 1] !plus(X, 0) > X because [2], by definition 2] !plus*(X, 0) >= X because [3], by (Select) 3] X >= X by (Meta) 4] rec(s(X), Y, F) > @_{o -> o}(@_{o -> o -> o}(F, X), rec(X, Y, F)) because [5], by definition 5] rec*(s(X), Y, F) >= @_{o -> o}(@_{o -> o -> o}(F, X), rec(X, Y, F)) because rec > @_{o -> o}, [6] and [13], by (Copy) 6] rec*(s(X), Y, F) >= @_{o -> o -> o}(F, X) because rec > @_{o -> o -> o}, [7] and [9], by (Copy) 7] rec*(s(X), Y, F) >= F because [8], by (Select) 8] F >= F by (Meta) 9] rec*(s(X), Y, F) >= X because [10], by (Select) 10] s(X) >= X because [11], by (Star) 11] s*(X) >= X because [12], by (Select) 12] X >= X by (Meta) 13] rec*(s(X), Y, F) >= rec(X, Y, F) because rec in Mul, [14], [16] and [17], by (Stat) 14] s(X) > X because [15], by definition 15] s*(X) >= X because [12], by (Select) 16] Y >= Y by (Meta) 17] F >= F by (Meta) We can thus remove the following rules: !plus(X, 0) => X rec(s(X), Y, F) => F X rec(X, Y, F) 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.