We consider the system h02. Alphabet: 0 : [] --> c 1 : [] --> c add : [] --> c -> a -> c cons : [] --> a -> b -> b fold : [] --> (c -> a -> c) -> b -> c -> c mul : [] --> c -> a -> c nil : [] --> b prod : [] --> b -> c sum : [] --> b -> c Rules: fold (/\x./\y.f x y) nil z => z fold (/\x./\y.f x y) (cons z u) v => fold (/\w./\x'.f w x') u (f v z) sum x => fold (/\y./\z.add y z) x 0 fold (/\x./\y.mul x y) z 1 => prod z 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: 0 : [] --> c 1 : [] --> c add : [] --> c -> a -> c cons : [a * b] --> b fold : [c -> a -> c * b * c] --> c mul : [c * a] --> c nil : [] --> b prod : [b] --> c sum : [b] --> c ~AP1 : [c -> a -> c * c] --> a -> c Rules: fold(/\x./\y.~AP1(F, x) y, nil, X) => X fold(/\x./\y.~AP1(F, x) y, cons(X, Y), Z) => fold(/\z./\u.~AP1(F, z) u, Y, ~AP1(F, Z) X) sum(X) => fold(/\x./\y.~AP1(add, x) y, X, 0) fold(/\x./\y.mul(x, y), X, 1) => prod(X) fold(/\x./\y.mul(x, y), nil, X) => X fold(/\x./\y.mul(x, y), cons(X, Y), Z) => fold(/\z./\u.mul(z, u), Y, mul(Z, X)) ~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: 0 : [] --> c 1 : [] --> c add : [c * a] --> c cons : [a * b] --> b fold : [c -> a -> c * b * c] --> c mul : [c * a] --> c nil : [] --> b prod : [b] --> c sum : [b] --> c Rules: fold(/\x./\y.X(x, y), nil, Y) => Y fold(/\x./\y.X(x, y), cons(Y, Z), U) => fold(/\z./\u.X(z, u), Z, X(U, Y)) sum(X) => fold(/\x./\y.add(x, y), X, 0) fold(/\x./\y.mul(x, y), X, 1) => prod(X) 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] fold#(/\x./\y.X(x, y), cons(Y, Z), U) =#> fold#(/\z./\u.X(z, u), Z, X(U, Y)) 1] fold#(/\x./\y.X(x, y), cons(Y, Z), U) =#> X(z, u) 2] fold#(/\x./\y.X(x, y), cons(Y, Z), U) =#> X(U, Y) 3] sum#(X) =#> fold#(/\x./\y.add(x, y), X, 0) Rules R_0: fold(/\x./\y.X(x, y), nil, Y) => Y fold(/\x./\y.X(x, y), cons(Y, Z), U) => fold(/\z./\u.X(z, u), Z, X(U, Y)) sum(X) => fold(/\x./\y.add(x, y), X, 0) fold(/\x./\y.mul(x, y), X, 1) => prod(X) 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). This combination (P_0, R_0) has no formative rules! We will name the empty set of rules:R_1. By [Kop12, Thm. 7.17], we may replace the dependency pair problem (P_0, R_0, minimal, formative) by (P_0, R_1, minimal, formative). Thus, the original system is terminating if (P_0, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_0, R_1, 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: fold#(/\x./\y.X(x, y), cons(Y, Z), U) >? fold#(/\z./\u.X(z, u), Z, X(U, Y)) fold#(/\x./\y.X(x, y), cons(Y, Z), U) >? X(~c0, ~c1) fold#(/\x./\y.X(x, y), cons(Y, Z), U) >? X(U, Y) sum#(X) >? fold#(/\x./\y.add-(x, y), X, 0) add-(X, Y) >= add(X, Y) We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( sum#(X) ) = #argfun-sum##(fold#(/\x./\y.add-(x, y), X, 0)) Since this representation is not advantageous for the higher-order recursive path ordering, we present the strict requirements in their unextended form, which is not problematic since for any F, s and substituion gamma: (F s)gamma beta-reduces to F(s)gamma.) We use a recursive path ordering as defined in [Kop12, Chapter 5]. Argument functions: [[0]] = _|_ [[add(x_1, x_2)]] = _|_ [[fold#(x_1, x_2, x_3)]] = fold#(x_2, x_3, x_1) [[sum#(x_1)]] = x_1 [[~c0]] = _|_ [[~c1]] = _|_ We choose Lex = {fold#} and Mul = {#argfun-sum##, add-, cons}, and the following precedence: cons > #argfun-sum## > fold# > add- Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: fold#(/\x./\y.X(x, y), cons(Y, Z), U) > fold#(/\x./\y.X(x, y), Z, X(U, Y)) fold#(/\x./\y.X(x, y), cons(Y, Z), U) > X(_|_, _|_) fold#(/\x./\y.X(x, y), cons(Y, Z), U) > X(U, Y) #argfun-sum##(fold#(/\x./\y.add-(x, y), X, _|_)) >= fold#(/\x./\y.add-(x, y), X, _|_) add-(X, Y) >= _|_ With these choices, we have: 1] fold#(/\x./\y.X(x, y), cons(Y, Z), U) > fold#(/\x./\y.X(x, y), Z, X(U, Y)) because [2], by definition 2] fold#*(/\x./\y.X(x, y), cons(Y, Z), U) >= fold#(/\x./\y.X(x, y), Z, X(U, Y)) because [3], [6], [12] and [14], by (Stat) 3] cons(Y, Z) > Z because [4], by definition 4] cons*(Y, Z) >= Z because [5], by (Select) 5] Z >= Z by (Meta) 6] fold#*(/\x./\y.X(x, y), cons(Y, Z), U) >= /\x./\y.X(x, y) because [7], by (Select) 7] /\x./\z.X(x, z) >= /\x./\z.X(x, z) because [8], by (Abs) 8] /\z.X(y, z) >= /\z.X(y, z) because [9], by (Abs) 9] X(y, x) >= X(y, x) because [10] and [11], by (Meta) 10] y >= y by (Var) 11] x >= x by (Var) 12] fold#*(/\z./\u.X(z, u), cons(Y, Z), U) >= Z because [13], by (Select) 13] cons(Y, Z) >= Z because [4], by (Star) 14] fold#*(/\z./\u.X(z, u), cons(Y, Z), U) >= X(U, Y) because [15], by (Select) 15] X(fold#*(/\z./\u.X(z, u), cons(Y, Z), U), fold#*(/\v./\w.X(v, w), cons(Y, Z), U)) >= X(U, Y) because [16] and [18], by (Meta) 16] fold#*(/\z./\u.X(z, u), cons(Y, Z), U) >= U because [17], by (Select) 17] U >= U by (Meta) 18] fold#*(/\z./\u.X(z, u), cons(Y, Z), U) >= Y because [19], by (Select) 19] cons(Y, Z) >= Y because [20], by (Star) 20] cons*(Y, Z) >= Y because [21], by (Select) 21] Y >= Y by (Meta) 22] fold#(/\x./\y.X(x, y), cons(Y, Z), U) > X(_|_, _|_) because [23], by definition 23] fold#*(/\x./\y.X(x, y), cons(Y, Z), U) >= X(_|_, _|_) because [24], by (Select) 24] X(fold#*(/\x./\y.X(x, y), cons(Y, Z), U), fold#*(/\z./\u.X(z, u), cons(Y, Z), U)) >= X(_|_, _|_) because [25] and [26], by (Meta) 25] fold#*(/\x./\y.X(x, y), cons(Y, Z), U) >= _|_ by (Bot) 26] fold#*(/\x./\y.X(x, y), cons(Y, Z), U) >= _|_ by (Bot) 27] fold#(/\x./\y.X(x, y), cons(Y, Z), U) > X(U, Y) because [14], by definition 28] #argfun-sum##(fold#(/\x./\y.add-(x, y), X, _|_)) >= fold#(/\x./\y.add-(x, y), X, _|_) because [29], by (Star) 29] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_)) >= fold#(/\x./\y.add-(x, y), X, _|_) because #argfun-sum## > fold#, [30], [37] and [44], by (Copy) 30] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_)) >= /\x./\y.add-(x, y) because [31], by (F-Abs) 31] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_), z) >= /\x.add-(z, x) because [32], by (F-Abs) 32] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_), z, u) >= add-(z, u) because #argfun-sum## > add-, [33] and [35], by (Copy) 33] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_), z, u) >= z because [34], by (Select) 34] z >= z by (Var) 35] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_), z, u) >= u because [36], by (Select) 36] u >= u by (Var) 37] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_)) >= X because [38], by (Select) 38] fold#(/\x./\y.add-(x, y), X, _|_) >= X because [39], by (Star) 39] fold#*(/\x./\y.add-(x, y), X, _|_) >= X because [40], by (Select) 40] add-(fold#*(/\x./\y.add-(x, y), X, _|_), fold#*(/\v./\w.add-(v, w), X, _|_)) >= X because [41], by (Star) 41] add-*(fold#*(/\x./\y.add-(x, y), X, _|_), fold#*(/\v./\w.add-(v, w), X, _|_)) >= X because [42], by (Select) 42] fold#*(/\x./\y.add-(x, y), X, _|_) >= X because [43], by (Select) 43] X >= X by (Meta) 44] #argfun-sum##*(fold#(/\x./\y.add-(x, y), X, _|_)) >= _|_ by (Bot) 45] add-(X, Y) >= _|_ by (Bot) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_0, R_1, minimal, formative) by (P_1, R_1, minimal, formative), where P_1 consists of: sum#(X) =#> fold#(/\x./\y.add(x, y), X, 0) Thus, the original system is terminating if (P_1, R_1, minimal, formative) is finite. We consider the dependency pair problem (P_1, R_1, minimal, formative). We place the elements of P in a dependency graph approximation G (see e.g. [Kop12, Thm. 7.27, 7.29], as follows: * 0 : This graph has no strongly connected components. By [Kop12, Thm. 7.31], this implies finiteness of the dependency pair problem. 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.