We consider the system filter. Alphabet: 0 : [] --> nat bool : [nat] --> boolean cons : [nat * list] --> list consif : [boolean * nat * list] --> list false : [] --> boolean filter : [nat -> boolean * list] --> list nil : [] --> list rand : [nat] --> nat s : [nat] --> nat true : [] --> boolean Rules: rand(x) => x rand(s(x)) => rand(x) bool(0) => false bool(s(0)) => true filter(f, nil) => nil filter(f, cons(x, y)) => consif(f x, x, filter(f, y)) consif(true, x, y) => cons(x, y) consif(false, x, y) => y 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]): rand(X) >? X rand(s(X)) >? rand(X) bool(0) >? false bool(s(0)) >? true filter(F, nil) >? nil filter(F, cons(X, Y)) >? consif(F X, X, filter(F, Y)) consif(true, X, Y) >? cons(X, Y) consif(false, X, Y) >? Y We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: 0 = 3 bool = Lam[y0].3 + 3*y0 cons = Lam[y0;y1].2 + 2*y0 + 2*y1 consif = Lam[y0;y1;y2].y0 + 2*y1 + 2*y2 false = 0 filter = Lam[G0;y1].3*y1 + G0(y1) + y1*G0(y1) nil = 0 rand = Lam[y0].3 + y0 s = Lam[y0].3 + 3*y0 true = 3 Using this interpretation, the requirements translate to: [[rand(_x0)]] = 3 + x0 > x0 = [[_x0]] [[rand(s(_x0))]] = 6 + 3*x0 > 3 + x0 = [[rand(_x0)]] [[bool(0)]] = 12 > 0 = [[false]] [[bool(s(0))]] = 39 > 3 = [[true]] [[filter(_F0, nil)]] = F0(0) >= 0 = [[nil]] [[filter(_F0, cons(_x1, _x2))]] = 6 + 6*x1 + 6*x2 + 2*x1*F0(2 + 2*x1 + 2*x2) + 2*x2*F0(2 + 2*x1 + 2*x2) + 3*F0(2 + 2*x1 + 2*x2) > 3*x1 + 6*x2 + F0(x1) + 2*x2*F0(x2) + 2*F0(x2) = [[consif(_F0 _x1, _x1, filter(_F0, _x2))]] [[consif(true, _x0, _x1)]] = 3 + 2*x0 + 2*x1 > 2 + 2*x0 + 2*x1 = [[cons(_x0, _x1)]] [[consif(false, _x0, _x1)]] = 2*x0 + 2*x1 >= x1 = [[_x1]] We can thus remove the following rules: rand(X) => X rand(s(X)) => rand(X) bool(0) => false bool(s(0)) => true filter(F, cons(X, Y)) => consif(F X, X, filter(F, Y)) consif(true, X, Y) => cons(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]): filter(F, nil) >? nil consif(false, X, Y) >? Y We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: consif = Lam[y0;y1;y2].3 + y0 + y1 + y2 false = 3 filter = Lam[G0;y1].3 + 3*y1 + G0(0) nil = 2 Using this interpretation, the requirements translate to: [[filter(_F0, nil)]] = 9 + F0(0) > 2 = [[nil]] [[consif(false, _x0, _x1)]] = 6 + x0 + x1 > x1 = [[_x1]] We can thus remove the following rules: filter(F, nil) => nil consif(false, X, Y) => 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.