We consider the system monad. Alphabet: bind : [] --> Ta -> (a -> Ta) -> Ta return : [] --> a -> Ta Rules: bind (return x) (/\y.f y) => f x bind x (/\y.return y) => x bind (bind x (/\y.f y)) (/\z.g z) => bind x (/\u.bind (f u) (/\v.g v)) Using the transformations described in [Kop11], this system can be brought in a form without leading free variables in the left-hand side, and where the left-hand side of a variable is always a functional term or application headed by a functional term. We now transform the resulting AFS into an AFSM by replacing all free variables by meta-variables (with arity 0). This leads to the following AFSM: Alphabet: bind : [Ta * a -> Ta] --> Ta return : [a] --> Ta ~AP1 : [a -> Ta * a] --> Ta Rules: bind(return(X), /\x.~AP1(F, x)) => ~AP1(F, X) bind(X, /\x.return(x)) => X bind(bind(X, /\x.~AP1(F, x)), /\y.~AP1(G, y)) => bind(X, /\z.bind(~AP1(F, z), /\u.~AP1(G, u))) bind(return(X), /\x.return(x)) => return(X) bind(bind(X, /\x.return(x)), /\y.~AP1(F, y)) => bind(X, /\z.bind(return(z), /\u.~AP1(F, u))) bind(bind(X, /\x.~AP1(F, x)), /\y.return(y)) => bind(X, /\z.bind(~AP1(F, z), /\u.return(u))) bind(bind(X, /\x.return(x)), /\y.return(y)) => bind(X, /\z.bind(return(z), /\u.return(u))) ~AP1(F, X) => F X Symbol ~AP1 is an encoding for application that is only used in innocuous ways. We can simplify the program (without losing non-termination) by removing it. Additionally, we can remove some (now-)redundant rules. This gives: Alphabet: bind : [Ta * a -> Ta] --> Ta return : [a] --> Ta Rules: bind(return(X), /\x.Y(x)) => Y(X) bind(X, /\x.return(x)) => X bind(bind(X, /\x.Y(x)), /\y.Z(y)) => bind(X, /\z.bind(Y(z), /\u.Z(u))) We use the dependency pair framework as described in [Kop12, Ch. 6/7], with dynamic dependency pairs. We thus obtain the following dependency pair problem (P_0, R_0, minimal, formative): Dependency Pairs P_0: 0] bind#(return(X), /\x.Y(x)) =#> Y(X) 1] bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> bind#(X, /\z.bind(Y(z), /\u.Z(u))) 2] bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> bind#(Y(z), /\u.Z(u)) 3] bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> Y(z) 4] bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> Z(z) Rules R_0: bind(return(X), /\x.Y(x)) => Y(X) bind(X, /\x.return(x)) => X bind(bind(X, /\x.Y(x)), /\y.Z(y)) => bind(X, /\z.bind(Y(z), /\u.Z(u))) Thus, the original system is terminating if (P_0, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_0, R_0, minimal, formative). We will use the reduction pair processor [Kop12, Thm. 7.16]. As the system is abstraction-simple and the formative flag is set, it suffices to find a tagged reduction pair [Kop12, Def. 6.70]. Thus, we must orient: bind#(return(X), /\x.Y(x)) >? Y(X) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? bind#(X, /\z.bind-(Y(z), /\u.Z(u))) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? bind#(Y(~c0), /\z.Z(z)) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? Y(~c1) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? Z(~c2) bind(return(X), /\x.Y(x)) >= Y(X) bind(X, /\x.return(x)) >= X bind(bind(X, /\x.Y(x)), /\y.Z(y)) >= bind(X, /\z.bind-(Y(z), /\u.Z(u))) bind-(X, F) >= bind(X, F) bind-(X, F) >= bind#(X, F) We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: bind = \y0G1.y0 + G1(y0) bind- = \y0G1.y0 + G1(y0) bind# = \y0G1.y0 + G1(y0) return = \y0.3 + 2y0 ~c0 = 0 ~c1 = 0 ~c2 = 0 Using this interpretation, the requirements translate to: [[bind#(return(_x0), /\x._x1(x))]] = 3 + 2x0 + F1(3 + 2x0) > F1(x0) = [[_x1(_x0)]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = x0 + F1(x0) + F2(x0 + F1(x0)) >= x0 + F1(x0) + F2(F1(x0)) = [[bind#(_x0, /\x.bind-(_x1(x), /\y._x2(y)))]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = x0 + F1(x0) + F2(x0 + F1(x0)) >= F1(0) + F2(F1(0)) = [[bind#(_x1(~c0), /\x._x2(x))]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = x0 + F1(x0) + F2(x0 + F1(x0)) >= F1(0) = [[_x1(~c1)]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = x0 + F1(x0) + F2(x0 + F1(x0)) >= F2(0) = [[_x2(~c2)]] [[bind(return(_x0), /\x._x1(x))]] = 3 + 2x0 + F1(3 + 2x0) >= F1(x0) = [[_x1(_x0)]] [[bind(_x0, /\x.return(x))]] = 3 + 3x0 >= x0 = [[_x0]] [[bind(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = x0 + F1(x0) + F2(x0 + F1(x0)) >= x0 + F1(x0) + F2(F1(x0)) = [[bind(_x0, /\x.bind-(_x1(x), /\y._x2(y)))]] [[bind-(_x0, _F1)]] = x0 + F1(x0) >= x0 + F1(x0) = [[bind(_x0, _F1)]] [[bind-(_x0, _F1)]] = x0 + F1(x0) >= x0 + F1(x0) = [[bind#(_x0, _F1)]] By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_0, R_0, minimal, formative) by (P_1, R_0, minimal, formative), where P_1 consists of: bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> bind#(X, /\z.bind(Y(z), /\u.Z(u))) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> bind#(Y(z), /\u.Z(u)) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> Y(z) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) =#> Z(z) Thus, the original system is terminating if (P_1, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_1, R_0, minimal, formative). We will use the reduction pair processor [Kop12, Thm. 7.16]. As the system is abstraction-simple and the formative flag is set, it suffices to find a tagged reduction pair [Kop12, Def. 6.70]. Thus, we must orient: bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? bind#(X, /\z.bind-(Y(z), /\u.Z(u))) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? bind#(Y(~c0), /\z.Z(z)) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? Y(~c1) bind#(bind(X, /\x.Y(x)), /\y.Z(y)) >? Z(~c2) bind(return(X), /\x.Y(x)) >= Y(X) bind(X, /\x.return(x)) >= X bind(bind(X, /\x.Y(x)), /\y.Z(y)) >= bind(X, /\z.bind-(Y(z), /\u.Z(u))) bind-(X, F) >= bind(X, F) bind-(X, F) >= bind#(X, F) We orient these requirements with a polynomial interpretation in the natural numbers. The following interpretation satisfies the requirements: bind = \y0G1.1 + 3y0 + G1(y0) + 3y0G1(y0) bind- = \y0G1.2 + 3y0 + 2G1(y0) + 3y0G1(y0) bind# = \y0G1.2y0 + 2y0G1(y0) return = \y0.3 + y0 ~c0 = 0 ~c1 = 0 ~c2 = 0 Using this interpretation, the requirements translate to: [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = 2 + 6x0 + 2F1(x0) + 2F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 2F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F1(x0) + 6x0F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) > 6x0 + 4x0F2(F1(x0)) + 6x0F1(x0) + 6x0F1(x0)F2(F1(x0)) = [[bind#(_x0, /\x.bind-(_x1(x), /\y._x2(y)))]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = 2 + 6x0 + 2F1(x0) + 2F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 2F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F1(x0) + 6x0F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) > 2F1(0) + 2F1(0)F2(F1(0)) = [[bind#(_x1(~c0), /\x._x2(x))]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = 2 + 6x0 + 2F1(x0) + 2F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 2F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F1(x0) + 6x0F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) > F1(0) = [[_x1(~c1)]] [[bind#(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = 2 + 6x0 + 2F1(x0) + 2F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 2F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F1(x0) + 6x0F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 6x0F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) > F2(0) = [[_x2(~c2)]] [[bind(return(_x0), /\x._x1(x))]] = 10 + 3x0 + 3x0F1(3 + x0) + 10F1(3 + x0) >= F1(x0) = [[_x1(_x0)]] [[bind(_x0, /\x.return(x))]] = 4 + 3x0x0 + 13x0 >= x0 = [[_x0]] [[bind(bind(_x0, /\x._x1(x)), /\y._x2(y))]] = 4 + 9x0 + 3F1(x0) + 3F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 4F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 9x0F1(x0) + 9x0F1(x0)F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) + 9x0F2(1 + 3x0 + F1(x0) + 3x0F1(x0)) >= 3 + 9x0 + 2F2(F1(x0)) + 3F1(x0) + 3F1(x0)F2(F1(x0)) + 6x0F2(F1(x0)) + 9x0F1(x0) + 9x0F1(x0)F2(F1(x0)) = [[bind(_x0, /\x.bind-(_x1(x), /\y._x2(y)))]] [[bind-(_x0, _F1)]] = 2 + 3x0 + 2F1(x0) + 3x0F1(x0) >= 1 + 3x0 + F1(x0) + 3x0F1(x0) = [[bind(_x0, _F1)]] [[bind-(_x0, _F1)]] = 2 + 3x0 + 2F1(x0) + 3x0F1(x0) >= 2x0 + 2x0F1(x0) = [[bind#(_x0, _F1)]] By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace a dependency pair problem (P_1, R_0) by ({}, R_0). By the empty set processor [Kop12, Thm. 7.15] this problem may be immediately removed. As all dependency pair problems were succesfully simplified with sound (and complete) processors until nothing remained, we conclude termination. +++ Citations +++ [Kop11] C. Kop. Simplifying Algebraic Functional Systems. In Proceedings of CAI 2011, volume 6742 of LNCS. 201--215, Springer, 2011. [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012.