We consider the system findzero. Alphabet: 0 : [] --> nat find0 : [nat -> nat * nat * nat] --> nat if : [nat * nat * nat] --> nat min : [nat * nat] --> nat nul : [nat -> nat * nat] --> nat s : [nat] --> nat Rules: min(s(x), s(y)) => min(x, y) min(x, 0) => 0 min(0, x) => 0 min(nul(f, x), y) => nul(f, min(x, y)) nul(f, x) => find0(f, 0, x) find0(f, x, 0) => x find0(f, x, s(y)) => if(f x, find0(f, s(x), y), x) if(s(x), y, z) => y if(0, x, y) => y This AFS is converted to an AFSM simply by replacing all free variables by meta-variables (with arity 0). We use the dependency pair framework as described in [Kop12, Ch. 6/7], with dynamic dependency pairs. After applying [Kop12, Thm. 7.22] to denote collapsing dependency pairs in an extended form, we thus obtain the following dependency pair problem (P_0, R_0, minimal, formative): Dependency Pairs P_0: 0] min#(s(X), s(Y)) =#> min#(X, Y) 1] min#(nul(F, X), Y) =#> nul#(F, min(X, Y)) 2] min#(nul(F, X), Y) =#> min#(X, Y) 3] nul#(F, X) =#> find0#(F, 0, X) 4] find0#(F, X, s(Y)) =#> if#(F X, find0(F, s(X), Y), X) 5] find0#(F, X, s(Y)) =#> F(X) 6] find0#(F, X, s(Y)) =#> find0#(F, s(X), Y) Rules R_0: min(s(X), s(Y)) => min(X, Y) min(X, 0) => 0 min(0, X) => 0 min(nul(F, X), Y) => nul(F, min(X, Y)) nul(F, X) => find0(F, 0, X) find0(F, X, 0) => X find0(F, X, s(Y)) => if(F X, find0(F, s(X), Y), X) if(s(X), Y, Z) => Y if(0, X, Y) => Y 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 place the elements of P in a dependency graph approximation G (see e.g. [Kop12, Thm. 7.27, 7.29], as follows: * 0 : 0, 1, 2 * 1 : 3 * 2 : 0, 1, 2 * 3 : 4, 5, 6 * 4 : * 5 : 0, 1, 2, 3, 4, 5, 6 * 6 : 4, 5, 6 This graph has the following strongly connected components: P_1: min#(s(X), s(Y)) =#> min#(X, Y) min#(nul(F, X), Y) =#> nul#(F, min(X, Y)) min#(nul(F, X), Y) =#> min#(X, Y) nul#(F, X) =#> find0#(F, 0, X) find0#(F, X, s(Y)) =#> F(X) find0#(F, X, s(Y)) =#> find0#(F, s(X), Y) By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_0, R_0, m, f) by (P_1, R_0, m, f). 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: min#(s(X), s(Y)) >? min#(X, Y) min#(nul(F, X), Y) >? nul#(F, min(X, Y)) min#(nul(F, X), Y) >? min#(X, Y) nul#(F, X) >? find0#(F, 0, X) find0#(F, X, s(Y)) >? F(X) find0#(F, X, s(Y)) >? find0#(F, s(X), Y) min(s(X), s(Y)) >= min(X, Y) min(X, 0) >= 0 min(0, X) >= 0 min(nul(F, X), Y) >= nul(F, min(X, Y)) nul(F, X) >= find0(F, 0, X) find0(F, X, 0) >= X find0(F, X, s(Y)) >= if(F X, find0(F, s(X), Y), X) if(s(X), Y, Z) >= Y if(0, X, Y) >= Y We apply [Kop12, Thm. 6.75] and use the following argument functions: pi( nul#(F, X) ) = #argfun-nul##(find0#(F, 0, X)) 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: [[#argfun-nul##(x_1)]] = x_1 [[0]] = _|_ [[@_{o -> o}(x_1, x_2)]] = @_{o -> o}(x_2, x_1) [[find0(x_1, x_2, x_3)]] = find0(x_1, x_3, x_2) [[find0#(x_1, x_2, x_3)]] = find0#(x_3, x_1, x_2) [[if(x_1, x_2, x_3)]] = if(x_3, x_2) [[min(x_1, x_2)]] = x_1 [[min#(x_1, x_2)]] = min#(x_2, x_1) [[nul(x_1, x_2)]] = nul(x_2, x_1) We choose Lex = {@_{o -> o}, find0, find0#, if, min#, nul, s} and Mul = {nul#}, and the following precedence: min# > nul > find0# > find0 > nul# > @_{o -> o} > s > if Taking the argument function into account, and fixing the greater / greater equal choices, the constraints can be denoted as follows: min#(s(X), s(Y)) >= min#(X, Y) min#(nul(F, X), Y) >= find0#(F, _|_, X) min#(nul(F, X), Y) >= min#(X, Y) find0#(F, _|_, X) >= find0#(F, _|_, X) find0#(F, X, s(Y)) > @_{o -> o}(F, X) find0#(F, X, s(Y)) >= find0#(F, s(X), Y) s(X) >= X X >= _|_ _|_ >= _|_ nul(F, X) >= nul(F, X) nul(F, X) >= find0(F, _|_, X) find0(F, X, _|_) >= X find0(F, X, s(Y)) >= if(@_{o -> o}(F, X), find0(F, s(X), Y), X) if(s(X), Y, Z) >= Y if(_|_, X, Y) >= Y With these choices, we have: 1] min#(s(X), s(Y)) >= min#(X, Y) because [2] and [5], by (Fun) 2] s(X) >= X because [3], by (Star) 3] s*(X) >= X because [4], by (Select) 4] X >= X by (Meta) 5] s(Y) >= Y because [6], by (Star) 6] s*(Y) >= Y because [7], by (Select) 7] Y >= Y by (Meta) 8] min#(nul(F, X), Y) >= find0#(F, _|_, X) because [9], by (Star) 9] min#*(nul(F, X), Y) >= find0#(F, _|_, X) because [10], by (Select) 10] nul(F, X) >= find0#(F, _|_, X) because [11], by (Star) 11] nul*(F, X) >= find0#(F, _|_, X) because nul > find0#, [12], [14] and [15], by (Copy) 12] nul*(F, X) >= F because [13], by (Select) 13] F >= F by (Meta) 14] nul*(F, X) >= _|_ by (Bot) 15] nul*(F, X) >= X because [16], by (Select) 16] X >= X by (Meta) 17] min#(nul(F, X), Y) >= min#(X, Y) because [18] and [19], by (Fun) 18] nul(F, X) >= X because [15], by (Star) 19] Y >= Y by (Meta) 20] find0#(F, _|_, X) >= find0#(F, _|_, X) because [21], [22] and [23], by (Fun) 21] F >= F by (Meta) 22] _|_ >= _|_ by (Bot) 23] X >= X by (Meta) 24] find0#(F, X, s(Y)) > @_{o -> o}(F, X) because [25], by definition 25] find0#*(F, X, s(Y)) >= @_{o -> o}(F, X) because find0# > @_{o -> o}, [26] and [28], by (Copy) 26] find0#*(F, X, s(Y)) >= F because [27], by (Select) 27] F >= F by (Meta) 28] find0#*(F, X, s(Y)) >= X because [29], by (Select) 29] X >= X by (Meta) 30] find0#(F, X, s(Y)) >= find0#(F, s(X), Y) because [31], by (Star) 31] find0#*(F, X, s(Y)) >= find0#(F, s(X), Y) because [32], [26], [35] and [36], by (Stat) 32] s(Y) > Y because [33], by definition 33] s*(Y) >= Y because [34], by (Select) 34] Y >= Y by (Meta) 35] find0#*(F, X, s(Y)) >= s(X) because find0# > s and [28], by (Copy) 36] find0#*(F, X, s(Y)) >= Y because [37], by (Select) 37] s(Y) >= Y because [33], by (Star) 38] s(X) >= X because [3], by (Star) 39] X >= _|_ by (Bot) 40] _|_ >= _|_ by (Bot) 41] nul(F, X) >= nul(F, X) because [42] and [43], by (Fun) 42] F >= F by (Meta) 43] X >= X by (Meta) 44] nul(F, X) >= find0(F, _|_, X) because [45], by (Star) 45] nul*(F, X) >= find0(F, _|_, X) because nul > find0, [46], [47] and [48], by (Copy) 46] nul*(F, X) >= F because [21], by (Select) 47] nul*(F, X) >= _|_ by (Bot) 48] nul*(F, X) >= X because [23], by (Select) 49] find0(F, X, _|_) >= X because [50], by (Star) 50] find0*(F, X, _|_) >= X because [51], by (Select) 51] X >= X by (Meta) 52] find0(F, X, s(Y)) >= if(@_{o -> o}(F, X), find0(F, s(X), Y), X) because [53], by (Star) 53] find0*(F, X, s(Y)) >= if(@_{o -> o}(F, X), find0(F, s(X), Y), X) because find0 > if, [54] and [58], by (Copy) 54] find0*(F, X, s(Y)) >= find0(F, s(X), Y) because [55], [32], [56], [57] and [59], by (Stat) 55] F >= F by (Meta) 56] find0*(F, X, s(Y)) >= F because [55], by (Select) 57] find0*(F, X, s(Y)) >= s(X) because find0 > s and [58], by (Copy) 58] find0*(F, X, s(Y)) >= X because [29], by (Select) 59] find0*(F, X, s(Y)) >= Y because [37], by (Select) 60] if(s(X), Y, Z) >= Y because [61], by (Star) 61] if*(s(X), Y, Z) >= Y because [62], by (Select) 62] Y >= Y by (Meta) 63] if(_|_, X, Y) >= Y because [64], by (Star) 64] if*(_|_, X, Y) >= Y because [65], by (Select) 65] Y >= Y by (Meta) By the observations in [Kop12, Sec. 6.6], this reduction pair suffices; we may thus replace the dependency pair problem (P_1, R_0, minimal, formative) by (P_2, R_0, minimal, formative), where P_2 consists of: min#(s(X), s(Y)) =#> min#(X, Y) min#(nul(F, X), Y) =#> nul#(F, min(X, Y)) min#(nul(F, X), Y) =#> min#(X, Y) nul#(F, X) =#> find0#(F, 0, X) find0#(F, X, s(Y)) =#> find0#(F, s(X), Y) Thus, the original system is terminating if (P_2, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_2, R_0, 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 : 0, 1, 2 * 1 : 3 * 2 : 0, 1, 2 * 3 : 4 * 4 : 4 This graph has the following strongly connected components: P_3: min#(s(X), s(Y)) =#> min#(X, Y) min#(nul(F, X), Y) =#> min#(X, Y) P_4: find0#(F, X, s(Y)) =#> find0#(F, s(X), Y) By [Kop12, Thm. 7.31], we may replace any dependency pair problem (P_2, R_0, m, f) by (P_3, R_0, m, f) and (P_4, R_0, m, f). Thus, the original system is terminating if each of (P_3, R_0, minimal, formative) and (P_4, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_4, R_0, minimal, formative). We apply the subterm criterion with the following projection function: nu(find0#) = 3 Thus, we can orient the dependency pairs as follows: nu(find0#(F, X, s(Y))) = s(Y) |> Y = nu(find0#(F, s(X), Y)) By [FuhKop19, Thm. 61], we may replace a dependency pair problem (P_4, R_0, minimal, f) by ({}, R_0, minimal, f). By the empty set processor [Kop12, Thm. 7.15] this problem may be immediately removed. Thus, the original system is terminating if (P_3, R_0, minimal, formative) is finite. We consider the dependency pair problem (P_3, R_0, minimal, formative). We apply the subterm criterion with the following projection function: nu(min#) = 1 Thus, we can orient the dependency pairs as follows: nu(min#(s(X), s(Y))) = s(X) |> X = nu(min#(X, Y)) nu(min#(nul(F, X), Y)) = nul(F, X) |> X = nu(min#(X, Y)) By [FuhKop19, Thm. 61], we may replace a dependency pair problem (P_3, R_0, minimal, f) by ({}, R_0, minimal, f). 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 +++ [FuhKop19] C. Fuhs, and C. Kop. A static higher-order dependency pair framework. In Proceedings of ESOP 2019, 2019. [Kop12] C. Kop. Higher Order Termination. PhD Thesis, 2012.