YES We show the termination of the TRS R: le(|0|(),Y) -> true() le(s(X),|0|()) -> false() le(s(X),s(Y)) -> le(X,Y) app(nil(),Y) -> Y app(cons(N,L),Y) -> cons(N,app(L,Y)) low(N,nil()) -> nil() low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) iflow(false(),N,cons(M,L)) -> low(N,L) high(N,nil()) -> nil() high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) ifhigh(true(),N,cons(M,L)) -> high(N,L) ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) quicksort(nil()) -> nil() quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: le#(s(X),s(Y)) -> le#(X,Y) p2: app#(cons(N,L),Y) -> app#(L,Y) p3: low#(N,cons(M,L)) -> iflow#(le(M,N),N,cons(M,L)) p4: low#(N,cons(M,L)) -> le#(M,N) p5: iflow#(true(),N,cons(M,L)) -> low#(N,L) p6: iflow#(false(),N,cons(M,L)) -> low#(N,L) p7: high#(N,cons(M,L)) -> ifhigh#(le(M,N),N,cons(M,L)) p8: high#(N,cons(M,L)) -> le#(M,N) p9: ifhigh#(true(),N,cons(M,L)) -> high#(N,L) p10: ifhigh#(false(),N,cons(M,L)) -> high#(N,L) p11: quicksort#(cons(N,L)) -> app#(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) p12: quicksort#(cons(N,L)) -> quicksort#(low(N,L)) p13: quicksort#(cons(N,L)) -> low#(N,L) p14: quicksort#(cons(N,L)) -> quicksort#(high(N,L)) p15: quicksort#(cons(N,L)) -> high#(N,L) and R consists of: r1: le(|0|(),Y) -> true() r2: le(s(X),|0|()) -> false() r3: le(s(X),s(Y)) -> le(X,Y) r4: app(nil(),Y) -> Y r5: app(cons(N,L),Y) -> cons(N,app(L,Y)) r6: low(N,nil()) -> nil() r7: low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) r8: iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) r9: iflow(false(),N,cons(M,L)) -> low(N,L) r10: high(N,nil()) -> nil() r11: high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) r12: ifhigh(true(),N,cons(M,L)) -> high(N,L) r13: ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) r14: quicksort(nil()) -> nil() r15: quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) The estimated dependency graph contains the following SCCs: {p12, p14} {p7, p9, p10} {p3, p5, p6} {p1} {p2} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: quicksort#(cons(N,L)) -> quicksort#(high(N,L)) p2: quicksort#(cons(N,L)) -> quicksort#(low(N,L)) and R consists of: r1: le(|0|(),Y) -> true() r2: le(s(X),|0|()) -> false() r3: le(s(X),s(Y)) -> le(X,Y) r4: app(nil(),Y) -> Y r5: app(cons(N,L),Y) -> cons(N,app(L,Y)) r6: low(N,nil()) -> nil() r7: low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) r8: iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) r9: iflow(false(),N,cons(M,L)) -> low(N,L) r10: high(N,nil()) -> nil() r11: high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) r12: ifhigh(true(),N,cons(M,L)) -> high(N,L) r13: ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) r14: quicksort(nil()) -> nil() r15: quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) The set of usable rules consists of r1, r2, r3, r6, r7, r8, r9, r10, r11, r12, r13 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: quicksort#_A(x1) = max{7, x1 + 2} cons_A(x1,x2) = max{10, x2 + 7} high_A(x1,x2) = max{3, x2} low_A(x1,x2) = max{8, x2 + 5} le_A(x1,x2) = max{21, x1 + 16, x2 + 19} |0|_A = 31 true_A = 15 s_A(x1) = max{32, x1 + 31} false_A = 30 iflow_A(x1,x2,x3) = max{11, x3 + 5} ifhigh_A(x1,x2,x3) = max{10, x3} nil_A = 0 precedence: high = |0| > true > low = s = iflow = ifhigh = nil > cons > quicksort# > false > le partial status: pi(quicksort#) = [1] pi(cons) = [] pi(high) = [2] pi(low) = [2] pi(le) = [1, 2] pi(|0|) = [] pi(true) = [] pi(s) = [1] pi(false) = [] pi(iflow) = [] pi(ifhigh) = [3] pi(nil) = [] 2. weighted path order base order: max/plus interpretations on natural numbers: quicksort#_A(x1) = x1 + 35 cons_A(x1,x2) = 4 high_A(x1,x2) = 3 low_A(x1,x2) = 5 le_A(x1,x2) = max{x1 - 18, x2 + 17} |0|_A = 15 true_A = 16 s_A(x1) = x1 + 17 false_A = 16 iflow_A(x1,x2,x3) = 5 ifhigh_A(x1,x2,x3) = x3 + 9 nil_A = 8 precedence: quicksort# = high = low = le = |0| = iflow = ifhigh = nil > cons = true = s = false partial status: pi(quicksort#) = [1] pi(cons) = [] pi(high) = [] pi(low) = [] pi(le) = [2] pi(|0|) = [] pi(true) = [] pi(s) = [1] pi(false) = [] pi(iflow) = [] pi(ifhigh) = [3] pi(nil) = [] The next rules are strictly ordered: p1, p2 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: ifhigh#(false(),N,cons(M,L)) -> high#(N,L) p2: high#(N,cons(M,L)) -> ifhigh#(le(M,N),N,cons(M,L)) p3: ifhigh#(true(),N,cons(M,L)) -> high#(N,L) and R consists of: r1: le(|0|(),Y) -> true() r2: le(s(X),|0|()) -> false() r3: le(s(X),s(Y)) -> le(X,Y) r4: app(nil(),Y) -> Y r5: app(cons(N,L),Y) -> cons(N,app(L,Y)) r6: low(N,nil()) -> nil() r7: low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) r8: iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) r9: iflow(false(),N,cons(M,L)) -> low(N,L) r10: high(N,nil()) -> nil() r11: high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) r12: ifhigh(true(),N,cons(M,L)) -> high(N,L) r13: ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) r14: quicksort(nil()) -> nil() r15: quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) The set of usable rules consists of r1, r2, r3 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: ifhigh#_A(x1,x2,x3) = max{x1 - 9, x2 + 6, x3 + 3} false_A = 12 cons_A(x1,x2) = max{7, x1, x2 + 1} high#_A(x1,x2) = max{x1 + 6, x2 + 3} le_A(x1,x2) = x2 + 15 true_A = 14 |0|_A = 13 s_A(x1) = x1 + 13 precedence: ifhigh# = false = cons = high# = le = true = |0| = s partial status: pi(ifhigh#) = [3] pi(false) = [] pi(cons) = [1, 2] pi(high#) = [2] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: ifhigh#_A(x1,x2,x3) = max{2, x3} false_A = 9 cons_A(x1,x2) = max{x1 + 6, x2 + 2} high#_A(x1,x2) = max{5, x2 + 1} le_A(x1,x2) = 8 true_A = 12 |0|_A = 8 s_A(x1) = x1 + 10 precedence: ifhigh# = false = cons = high# = le = true = |0| = s partial status: pi(ifhigh#) = [3] pi(false) = [] pi(cons) = [2] pi(high#) = [] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] The next rules are strictly ordered: p1, p2, p3 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: iflow#(false(),N,cons(M,L)) -> low#(N,L) p2: low#(N,cons(M,L)) -> iflow#(le(M,N),N,cons(M,L)) p3: iflow#(true(),N,cons(M,L)) -> low#(N,L) and R consists of: r1: le(|0|(),Y) -> true() r2: le(s(X),|0|()) -> false() r3: le(s(X),s(Y)) -> le(X,Y) r4: app(nil(),Y) -> Y r5: app(cons(N,L),Y) -> cons(N,app(L,Y)) r6: low(N,nil()) -> nil() r7: low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) r8: iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) r9: iflow(false(),N,cons(M,L)) -> low(N,L) r10: high(N,nil()) -> nil() r11: high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) r12: ifhigh(true(),N,cons(M,L)) -> high(N,L) r13: ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) r14: quicksort(nil()) -> nil() r15: quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) The set of usable rules consists of r1, r2, r3 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: iflow#_A(x1,x2,x3) = max{x1 - 9, x2 + 6, x3 + 3} false_A = 12 cons_A(x1,x2) = max{7, x1, x2 + 1} low#_A(x1,x2) = max{x1 + 6, x2 + 3} le_A(x1,x2) = x2 + 15 true_A = 14 |0|_A = 13 s_A(x1) = x1 + 13 precedence: iflow# = false = cons = low# = le = true = |0| = s partial status: pi(iflow#) = [3] pi(false) = [] pi(cons) = [1, 2] pi(low#) = [2] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: iflow#_A(x1,x2,x3) = max{2, x3} false_A = 9 cons_A(x1,x2) = max{x1 + 6, x2 + 2} low#_A(x1,x2) = max{5, x2 + 1} le_A(x1,x2) = 8 true_A = 12 |0|_A = 8 s_A(x1) = x1 + 10 precedence: iflow# = false = cons = low# = le = true = |0| = s partial status: pi(iflow#) = [3] pi(false) = [] pi(cons) = [2] pi(low#) = [] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] The next rules are strictly ordered: p1, p2, p3 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: le#(s(X),s(Y)) -> le#(X,Y) and R consists of: r1: le(|0|(),Y) -> true() r2: le(s(X),|0|()) -> false() r3: le(s(X),s(Y)) -> le(X,Y) r4: app(nil(),Y) -> Y r5: app(cons(N,L),Y) -> cons(N,app(L,Y)) r6: low(N,nil()) -> nil() r7: low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) r8: iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) r9: iflow(false(),N,cons(M,L)) -> low(N,L) r10: high(N,nil()) -> nil() r11: high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) r12: ifhigh(true(),N,cons(M,L)) -> high(N,L) r13: ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) r14: quicksort(nil()) -> nil() r15: quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: le#_A(x1,x2) = max{2, x1 - 1, x2 + 1} s_A(x1) = max{1, x1} precedence: le# = s partial status: pi(le#) = [2] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: le#_A(x1,x2) = 0 s_A(x1) = max{2, x1} precedence: le# = s partial status: pi(le#) = [] pi(s) = [1] 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: app#(cons(N,L),Y) -> app#(L,Y) and R consists of: r1: le(|0|(),Y) -> true() r2: le(s(X),|0|()) -> false() r3: le(s(X),s(Y)) -> le(X,Y) r4: app(nil(),Y) -> Y r5: app(cons(N,L),Y) -> cons(N,app(L,Y)) r6: low(N,nil()) -> nil() r7: low(N,cons(M,L)) -> iflow(le(M,N),N,cons(M,L)) r8: iflow(true(),N,cons(M,L)) -> cons(M,low(N,L)) r9: iflow(false(),N,cons(M,L)) -> low(N,L) r10: high(N,nil()) -> nil() r11: high(N,cons(M,L)) -> ifhigh(le(M,N),N,cons(M,L)) r12: ifhigh(true(),N,cons(M,L)) -> high(N,L) r13: ifhigh(false(),N,cons(M,L)) -> cons(M,high(N,L)) r14: quicksort(nil()) -> nil() r15: quicksort(cons(N,L)) -> app(quicksort(low(N,L)),cons(N,quicksort(high(N,L)))) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: app#_A(x1,x2) = x1 + 1 cons_A(x1,x2) = max{x1, x2 + 1} precedence: app# = cons partial status: pi(app#) = [1] pi(cons) = [1, 2] 2. weighted path order base order: max/plus interpretations on natural numbers: app#_A(x1,x2) = max{0, x1 - 1} cons_A(x1,x2) = max{x1, x2} precedence: app# = cons partial status: pi(app#) = [] pi(cons) = [1, 2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.