YES We show the termination of the TRS R: lt(|0|(),s(X)) -> true() lt(s(X),|0|()) -> false() lt(s(X),s(Y)) -> lt(X,Y) append(nil(),Y) -> Y append(add(N,X),Y) -> add(N,append(X,Y)) split(N,nil()) -> pair(nil(),nil()) split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) qsort(nil()) -> nil() qsort(add(N,X)) -> f_3(split(N,X),N,X) f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: lt#(s(X),s(Y)) -> lt#(X,Y) p2: append#(add(N,X),Y) -> append#(X,Y) p3: split#(N,add(M,Y)) -> f_1#(split(N,Y),N,M,Y) p4: split#(N,add(M,Y)) -> split#(N,Y) p5: f_1#(pair(X,Z),N,M,Y) -> f_2#(lt(N,M),N,M,Y,X,Z) p6: f_1#(pair(X,Z),N,M,Y) -> lt#(N,M) p7: qsort#(add(N,X)) -> f_3#(split(N,X),N,X) p8: qsort#(add(N,X)) -> split#(N,X) p9: f_3#(pair(Y,Z),N,X) -> append#(qsort(Y),add(X,qsort(Z))) p10: f_3#(pair(Y,Z),N,X) -> qsort#(Y) p11: f_3#(pair(Y,Z),N,X) -> qsort#(Z) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The estimated dependency graph contains the following SCCs: {p7, p10, p11} {p4} {p1} {p2} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: f_3#(pair(Y,Z),N,X) -> qsort#(Z) p2: qsort#(add(N,X)) -> f_3#(split(N,X),N,X) p3: f_3#(pair(Y,Z),N,X) -> qsort#(Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The set of usable rules consists of r1, r2, r3, r6, r7, r8, r9, r10 Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: f_3#_A(x1,x2,x3) = max{x1 + 7, x2 + 21, x3 + 6} pair_A(x1,x2) = max{x1 + 1, x2 + 6} qsort#_A(x1) = x1 + 7 add_A(x1,x2) = max{x1 + 21, x2 + 22} split_A(x1,x2) = x2 + 15 lt_A(x1,x2) = max{30, x1 - 31, x2 + 3} |0|_A = 30 s_A(x1) = x1 + 30 true_A = 33 false_A = 29 f_2_A(x1,x2,x3,x4,x5,x6) = max{x3 + 28, x5 + 23, x6 + 28} f_1_A(x1,x2,x3,x4) = max{x1 + 22, x3 + 28} nil_A = 3 precedence: add > f_3# > pair = qsort# = split = lt = |0| = s = true = false = f_2 = f_1 = nil partial status: pi(f_3#) = [1, 2, 3] pi(pair) = [] pi(qsort#) = [1] pi(add) = [2] pi(split) = [] pi(lt) = [] pi(|0|) = [] pi(s) = [1] pi(true) = [] pi(false) = [] pi(f_2) = [] pi(f_1) = [] pi(nil) = [] The next rules are strictly ordered: p1 We remove them from the problem. -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: qsort#(add(N,X)) -> f_3#(split(N,X),N,X) p2: f_3#(pair(Y,Z),N,X) -> qsort#(Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The estimated dependency graph contains the following SCCs: {p1, p2} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: qsort#(add(N,X)) -> f_3#(split(N,X),N,X) p2: f_3#(pair(Y,Z),N,X) -> qsort#(Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The set of usable rules consists of r1, r2, r3, r6, r7, r8, r9, r10 Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: qsort#_A(x1) = max{5, x1} add_A(x1,x2) = max{x1 + 5, x2 + 10} f_3#_A(x1,x2,x3) = max{x1 - 1, x2 + 5, x3 + 10} split_A(x1,x2) = x2 + 11 pair_A(x1,x2) = max{x1 + 6, x2 + 6} lt_A(x1,x2) = max{3, x2 - 12} |0|_A = 22 s_A(x1) = x1 + 11 true_A = 0 false_A = 10 f_2_A(x1,x2,x3,x4,x5,x6) = max{x1 - 5, x3 + 13, x5 + 16, x6 + 16} f_1_A(x1,x2,x3,x4) = max{x1 + 10, x3 + 13} nil_A = 2 precedence: qsort# = add = f_3# = split = pair = lt = |0| = s = true = false = f_2 = f_1 = nil partial status: pi(qsort#) = [1] pi(add) = [1] pi(f_3#) = [] pi(split) = [] pi(pair) = [] pi(lt) = [] pi(|0|) = [] pi(s) = [1] pi(true) = [] pi(false) = [] pi(f_2) = [] pi(f_1) = [] pi(nil) = [] The next rules are strictly ordered: p1 We remove them from the problem. -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: f_3#(pair(Y,Z),N,X) -> qsort#(Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The estimated dependency graph contains the following SCCs: (no SCCs) -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: split#(N,add(M,Y)) -> split#(N,Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The set of usable rules consists of (no rules) Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: split#_A(x1,x2) = max{0, x2 - 2} add_A(x1,x2) = max{x1 + 3, x2 + 1} precedence: split# = add partial status: pi(split#) = [] pi(add) = [2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: lt#(s(X),s(Y)) -> lt#(X,Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The set of usable rules consists of (no rules) Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: lt#_A(x1,x2) = max{0, x1 - 2, x2 - 2} s_A(x1) = max{3, x1 + 1} precedence: lt# = s partial status: pi(lt#) = [] pi(s) = [] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: append#(add(N,X),Y) -> append#(X,Y) and R consists of: r1: lt(|0|(),s(X)) -> true() r2: lt(s(X),|0|()) -> false() r3: lt(s(X),s(Y)) -> lt(X,Y) r4: append(nil(),Y) -> Y r5: append(add(N,X),Y) -> add(N,append(X,Y)) r6: split(N,nil()) -> pair(nil(),nil()) r7: split(N,add(M,Y)) -> f_1(split(N,Y),N,M,Y) r8: f_1(pair(X,Z),N,M,Y) -> f_2(lt(N,M),N,M,Y,X,Z) r9: f_2(true(),N,M,Y,X,Z) -> pair(X,add(M,Z)) r10: f_2(false(),N,M,Y,X,Z) -> pair(add(M,X),Z) r11: qsort(nil()) -> nil() r12: qsort(add(N,X)) -> f_3(split(N,X),N,X) r13: f_3(pair(Y,Z),N,X) -> append(qsort(Y),add(X,qsort(Z))) The set of usable rules consists of (no rules) Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: append#_A(x1,x2) = max{x1 + 1, x2 + 1} add_A(x1,x2) = x2 precedence: append# = add partial status: pi(append#) = [1] pi(add) = [2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.