We consider the system Applicative_05__TreeFlatten. Alphabet: append : [a * a] --> a concat : [a] --> a cons : [a * a] --> a flatten : [] --> a -> a map : [a -> a * a] --> a nil : [] --> a node : [a * a] --> a Rules: map(f, nil) => nil map(f, cons(x, y)) => cons(f x, map(f, y)) flatten node(x, y) => cons(x, concat(map(flatten, y))) concat(nil) => nil concat(cons(x, y)) => append(x, concat(y)) append(nil, x) => x append(cons(x, y), z) => cons(x, append(y, z)) 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]): map(F, nil) >? nil map(F, cons(X, Y)) >? cons(F X, map(F, Y)) flatten node(X, Y) >? cons(X, concat(map(flatten, Y))) concat(nil) >? nil concat(cons(X, Y)) >? append(X, concat(Y)) append(nil, X) >? X append(cons(X, Y), Z) >? cons(X, append(Y, Z)) We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: append = Lam[y0;y1].2 + y1 + 2*y0 concat = Lam[y0].y0 cons = Lam[y0;y1].3 + y1 + 2*y0 flatten = Lam[y0].0 map = Lam[G0;y1].2*y1 + G0(y1) + 3*y1*G0(y1) nil = 0 node = Lam[y0;y1].3 + 3*y0 + 3*y1 Using this interpretation, the requirements translate to: [[map(_F0, nil)]] = F0(0) >= 0 = [[nil]] [[map(_F0, cons(_x1, _x2))]] = 6 + 2*x2 + 4*x1 + 3*x2*F0(3 + x2 + 2*x1) + 6*x1*F0(3 + x2 + 2*x1) + 10*F0(3 + x2 + 2*x1) > 3 + 2*x1 + 2*x2 + F0(x2) + 2*F0(x1) + 3*x2*F0(x2) = [[cons(_F0 _x1, map(_F0, _x2))]] [[flatten node(_x0, _x1)]] = 3 + 3*x0 + 3*x1 >= 3 + 2*x0 + 2*x1 = [[cons(_x0, concat(map(flatten, _x1)))]] [[concat(nil)]] = 0 >= 0 = [[nil]] [[concat(cons(_x0, _x1))]] = 3 + x1 + 2*x0 > 2 + x1 + 2*x0 = [[append(_x0, concat(_x1))]] [[append(nil, _x0)]] = 2 + x0 > x0 = [[_x0]] [[append(cons(_x0, _x1), _x2)]] = 8 + x2 + 2*x1 + 4*x0 > 5 + x2 + 2*x0 + 2*x1 = [[cons(_x0, append(_x1, _x2))]] We can thus remove the following rules: map(F, cons(X, Y)) => cons(F X, map(F, Y)) concat(cons(X, Y)) => append(X, concat(Y)) append(nil, X) => X append(cons(X, Y), Z) => cons(X, append(Y, Z)) We use rule removal, following [Kop12, Theorem 2.23]. This gives the following requirements (possibly using Theorems 2.25 and 2.26 in [Kop12]): map(F, nil) >? nil flatten node(X, Y) >? cons(X, concat(map(flatten, Y))) concat(nil) >? nil We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: concat = Lam[y0].y0 cons = Lam[y0;y1].y0 + y1 flatten = Lam[y0].2 + 2*y0 map = Lam[G0;y1].y1 + G0(0) nil = 0 node = Lam[y0;y1].3 + 3*y0 + 3*y1 Using this interpretation, the requirements translate to: [[map(_F0, nil)]] = F0(0) >= 0 = [[nil]] [[flatten node(_x0, _x1)]] = 11 + 9*x0 + 9*x1 > 2 + x0 + x1 = [[cons(_x0, concat(map(flatten, _x1)))]] [[concat(nil)]] = 0 >= 0 = [[nil]] We can thus remove the following rules: flatten node(X, Y) => cons(X, concat(map(flatten, 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]): map(F, nil) >? nil concat(nil) >? nil We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: concat = Lam[y0].3 + 3*y0 map = Lam[G0;y1].3 + 3*y1 + G0(y1) nil = 2 Using this interpretation, the requirements translate to: [[map(_F0, nil)]] = 9 + F0(2) > 2 = [[nil]] [[concat(nil)]] = 9 > 2 = [[nil]] We can thus remove the following rules: map(F, nil) => nil concat(nil) => nil 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.