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(add(n,x),y) -> add(n,app(x,y)) low(n,nil()) -> nil() low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) if_low(true(),n,add(m,x)) -> add(m,low(n,x)) if_low(false(),n,add(m,x)) -> low(n,x) high(n,nil()) -> nil() high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) if_high(true(),n,add(m,x)) -> high(n,x) if_high(false(),n,add(m,x)) -> add(m,high(n,x)) head(add(n,x)) -> n tail(add(n,x)) -> x isempty(nil()) -> true() isempty(add(n,x)) -> false() quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) if_qs(true(),x,n,y) -> nil() if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: le#(s(x),s(y)) -> le#(x,y) p2: app#(add(n,x),y) -> app#(x,y) p3: low#(n,add(m,x)) -> if_low#(le(m,n),n,add(m,x)) p4: low#(n,add(m,x)) -> le#(m,n) p5: if_low#(true(),n,add(m,x)) -> low#(n,x) p6: if_low#(false(),n,add(m,x)) -> low#(n,x) p7: high#(n,add(m,x)) -> if_high#(le(m,n),n,add(m,x)) p8: high#(n,add(m,x)) -> le#(m,n) p9: if_high#(true(),n,add(m,x)) -> high#(n,x) p10: if_high#(false(),n,add(m,x)) -> high#(n,x) p11: quicksort#(x) -> if_qs#(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) p12: quicksort#(x) -> isempty#(x) p13: quicksort#(x) -> low#(head(x),tail(x)) p14: quicksort#(x) -> head#(x) p15: quicksort#(x) -> tail#(x) p16: quicksort#(x) -> high#(head(x),tail(x)) p17: if_qs#(false(),x,n,y) -> app#(quicksort(x),add(n,quicksort(y))) p18: if_qs#(false(),x,n,y) -> quicksort#(x) p19: if_qs#(false(),x,n,y) -> quicksort#(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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The estimated dependency graph contains the following SCCs: {p11, p18, p19} {p7, p9, p10} {p3, p5, p6} {p1} {p2} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: if_qs#(false(),x,n,y) -> quicksort#(y) p2: quicksort#(x) -> if_qs#(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) p3: if_qs#(false(),x,n,y) -> quicksort#(x) 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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The set of usable rules consists of r1, r2, r3, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: if_qs#_A(x1,x2,x3,x4) = 3 false_A() = 4 quicksort#_A(x1) = 3 isempty_A(x1) = x1 + 2 low_A(x1,x2) = x2 head_A(x1) = x1 + 4 tail_A(x1) = x1 + 4 high_A(x1,x2) = x2 + 5 le_A(x1,x2) = x1 + x2 + 1 |0|_A() = 5 true_A() = 1 s_A(x1) = x1 + 5 nil_A() = 0 add_A(x1,x2) = x1 + x2 + 6 if_low_A(x1,x2,x3) = x3 if_high_A(x1,x2,x3) = x3 + 5 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_qs#_A(x1,x2,x3,x4) = max{83, x1 - 48, x2 + 21, x3 - 1, x4 + 21} false_A = 137 quicksort#_A(x1) = max{83, x1 + 21} isempty_A(x1) = max{69, x1 + 66} low_A(x1,x2) = x2 + 21 head_A(x1) = max{0, x1 - 67} tail_A(x1) = max{38, x1 - 25} high_A(x1,x2) = max{62, x2 + 23} le_A(x1,x2) = max{62, x1 - 1} |0|_A = 0 true_A = 1 s_A(x1) = max{138, x1 + 69} nil_A = 21 add_A(x1,x2) = max{x1 + 70, x2 + 74} if_low_A(x1,x2,x3) = max{94, x1 - 138, x3 + 21} if_high_A(x1,x2,x3) = max{94, x1 - 1, x3 + 23} if_qs#!_A(x1,x2,x3,x4) = max{x1 - 70, x2 + 3, x3 + 1, x4 + 2} false!_A = 65 quicksort#!_A(x1) = max{66, x1 + 2} isempty!_A(x1) = max{1, x1 - 20} low!_A(x1,x2) = max{137, x1 - 2, x2 - 36} head!_A(x1) = max{67, x1 - 2} tail!_A(x1) = max{66, x1 - 2} high!_A(x1,x2) = max{137, x2 - 56} le!_A(x1,x2) = max{0, x1 - 5} |0|!_A = 66 true!_A = 0 s!_A(x1) = max{66, x1 - 6} nil!_A = 69 add!_A(x1,x2) = max{0, x1 - 4} if_low!_A(x1,x2,x3) = max{0, x1 - 2, x3 - 37} if_high!_A(x1,x2,x3) = max{0, x3 - 56} partial status: pi(if_qs#) = [] pi(false) = [] pi(quicksort#) = [] pi(isempty) = [] pi(low) = [2] pi(head) = [] pi(tail) = [] pi(high) = [2] pi(le) = [1] pi(|0|) = [] pi(true) = [] pi(s) = [1] pi(nil) = [] pi(add) = [1] pi(if_low) = [3] pi(if_high) = [3] The following rules are removed: p2, p3 -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: if_qs#(false(),x,n,y) -> quicksort#(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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The estimated dependency graph contains the following SCCs: (no SCCs) -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: if_high#(false(),n,add(m,x)) -> high#(n,x) p2: high#(n,add(m,x)) -> if_high#(le(m,n),n,add(m,x)) p3: if_high#(true(),n,add(m,x)) -> high#(n,x) 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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The set of usable rules consists of r1, r2, r3, r10 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: if_high#_A(x1,x2,x3) = x2 + x3 + 6 false_A() = 12 add_A(x1,x2) = x2 + 6 high#_A(x1,x2) = x1 + x2 + 11 le_A(x1,x2) = x2 + 16 true_A() = 10 |0|_A() = 13 s_A(x1) = x1 + 17 high_A(x1,x2) = 15 nil_A() = 2 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_high#_A(x1,x2,x3) = max{0, x1 - 12, x2 - 5, x3 - 14} false_A = 5 add_A(x1,x2) = max{x1 - 28, x2 + 12} high#_A(x1,x2) = max{0, x1 - 5, x2 - 14} le_A(x1,x2) = max{11, x1 - 41, x2 - 3} true_A = 11 |0|_A = 2 s_A(x1) = max{40, x1 + 1} high_A(x1,x2) = max{49, x1 - 26, x2 - 26} nil_A = 25 if_high#!_A(x1,x2,x3) = max{6, x1 - 4, x2 - 1, x3 - 13} false!_A = 6 add!_A(x1,x2) = 0 high#!_A(x1,x2) = max{6, x2 - 16} le!_A(x1,x2) = max{6, x1 - 45} true!_A = 5 |0|!_A = 7 s!_A(x1) = max{6, x1 - 45} high!_A(x1,x2) = max{4, x1 - 76, x2 - 88} nil!_A = 3 partial status: pi(if_high#) = [2] pi(false) = [] pi(add) = [] pi(high#) = [1, 2] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] pi(high) = [] pi(nil) = [] The following rules are removed: p1, p2, p3 Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: if_low#(false(),n,add(m,x)) -> low#(n,x) p2: low#(n,add(m,x)) -> if_low#(le(m,n),n,add(m,x)) p3: if_low#(true(),n,add(m,x)) -> low#(n,x) 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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The set of usable rules consists of r1, r2, r3 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: if_low#_A(x1,x2,x3) = x2 + x3 + 1 false_A() = 7 add_A(x1,x2) = x2 + 8 low#_A(x1,x2) = x1 + x2 + 6 le_A(x1,x2) = x2 + 13 true_A() = 12 |0|_A() = 13 s_A(x1) = x1 + 14 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_low#_A(x1,x2,x3) = max{0, x1 - 2, x2 - 67, x3 - 72} false_A = 1 add_A(x1,x2) = max{x1 - 58, x2 + 14} low#_A(x1,x2) = max{0, x1 - 67, x2 - 72} le_A(x1,x2) = max{1, x1 - 128, x2 - 128} true_A = 1 |0|_A = 127 s_A(x1) = max{127, x1 + 126} if_low#!_A(x1,x2,x3) = max{8, x1 - 67, x2 - 1, x3 - 20} false!_A = 5 add!_A(x1,x2) = 0 low#!_A(x1,x2) = max{4, x2 - 7} le!_A(x1,x2) = max{6, x1 - 128} true!_A = 3 |0|!_A = 6 s!_A(x1) = max{6, x1 - 128} partial status: pi(if_low#) = [2] pi(false) = [] pi(add) = [] pi(low#) = [1, 2] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] The following rules are removed: p1, p2, p3 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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The set of usable rules consists of (no rules) Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: le#_A(x1,x2) = x1 + x2 s_A(x1) = x1 + 7 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: le#_A(x1,x2) = 0 s_A(x1) = max{0, x1 - 1} le#!_A(x1,x2) = max{59, x1 - 1, x2 - 1} s!_A(x1) = max{58, x1 - 2} partial status: pi(le#) = [2] pi(s) = [1] The following rules are removed: p1 Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: app#(add(n,x),y) -> app#(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(add(n,x),y) -> add(n,app(x,y)) r6: low(n,nil()) -> nil() r7: low(n,add(m,x)) -> if_low(le(m,n),n,add(m,x)) r8: if_low(true(),n,add(m,x)) -> add(m,low(n,x)) r9: if_low(false(),n,add(m,x)) -> low(n,x) r10: high(n,nil()) -> nil() r11: high(n,add(m,x)) -> if_high(le(m,n),n,add(m,x)) r12: if_high(true(),n,add(m,x)) -> high(n,x) r13: if_high(false(),n,add(m,x)) -> add(m,high(n,x)) r14: head(add(n,x)) -> n r15: tail(add(n,x)) -> x r16: isempty(nil()) -> true() r17: isempty(add(n,x)) -> false() r18: quicksort(x) -> if_qs(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(x))) r19: if_qs(true(),x,n,y) -> nil() r20: if_qs(false(),x,n,y) -> app(quicksort(x),add(n,quicksort(y))) The set of usable rules consists of (no rules) Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: app#_A(x1,x2) = 1 add_A(x1,x2) = x1 + 4 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: app#_A(x1,x2) = x1 add_A(x1,x2) = max{39, x1 + 34, x2 + 3} app#!_A(x1,x2) = max{1, x1 - 1} add!_A(x1,x2) = max{0, x1 - 20, x2 - 23} partial status: pi(app#) = [] pi(add) = [1] The following rules are removed: p1 Then no dependency pair remains.