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: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: if_qs#_A(x1,x2,x3,x4) = max{12, x1, x2 + 8, x3 + 11, x4 + 6} false_A = 13 quicksort#_A(x1) = max{12, x1 + 5} isempty_A(x1) = max{12, x1 + 4} low_A(x1,x2) = x2 head_A(x1) = max{1, x1 - 6} tail_A(x1) = max{4, x1 - 3} high_A(x1,x2) = max{4, x2 + 2} le_A(x1,x2) = max{22, x1 + 19} |0|_A = 36 true_A = 35 s_A(x1) = max{23, x1 + 22} if_low_A(x1,x2,x3) = max{1, x1 - 14, x3} add_A(x1,x2) = max{20, x1 + 17, x2 + 14} if_high_A(x1,x2,x3) = max{3, x1 - 7, x3 + 2} nil_A = 36 precedence: quicksort# > isempty = low = head = tail = high = true = s = if_high = nil > if_qs# > false = le = |0| = if_low = add partial status: pi(if_qs#) = [1, 4] pi(false) = [] pi(quicksort#) = [] pi(isempty) = [1] pi(low) = [2] pi(head) = [] pi(tail) = [] pi(high) = [2] pi(le) = [1] pi(|0|) = [] pi(true) = [] pi(s) = [1] pi(if_low) = [3] pi(add) = [1, 2] pi(if_high) = [3] pi(nil) = [] 2. weighted path order base order: max/plus interpretations on natural numbers: if_qs#_A(x1,x2,x3,x4) = max{x1 + 13, x4 + 11} false_A = 20 quicksort#_A(x1) = 25 isempty_A(x1) = 11 low_A(x1,x2) = max{17, x2 + 15} head_A(x1) = 1 tail_A(x1) = 11 high_A(x1,x2) = max{13, x2} le_A(x1,x2) = max{37, x1 + 36} |0|_A = 3 true_A = 38 s_A(x1) = x1 + 21 if_low_A(x1,x2,x3) = max{32, x3} add_A(x1,x2) = max{x1 + 21, x2 + 22} if_high_A(x1,x2,x3) = 0 nil_A = 18 precedence: if_qs# = false = quicksort# = isempty = low = head = tail = high = le = |0| = true = s = if_low = add = if_high = nil partial status: pi(if_qs#) = [4] 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(if_low) = [] pi(add) = [2] pi(if_high) = [] pi(nil) = [] The next rules are strictly ordered: p1, p3 We remove them from the problem. -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: quicksort#(x) -> if_qs#(isempty(x),low(head(x),tail(x)),head(x),high(head(x),tail(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 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 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: if_high#_A(x1,x2,x3) = max{4, x1 + 1, x3 + 1} false_A = 1 add_A(x1,x2) = max{x1 + 1, x2 + 6} high#_A(x1,x2) = x2 + 7 le_A(x1,x2) = max{6, x1 - 3} true_A = 3 |0|_A = 2 s_A(x1) = max{10, x1 + 2} precedence: add = true > le = |0| > false = s > if_high# = high# partial status: pi(if_high#) = [1, 3] pi(false) = [] pi(add) = [] pi(high#) = [] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: if_high#_A(x1,x2,x3) = x3 + 1 false_A = 5 add_A(x1,x2) = 0 high#_A(x1,x2) = 1 le_A(x1,x2) = 4 true_A = 5 |0|_A = 4 s_A(x1) = x1 + 6 precedence: if_high# = false = high# = le > add = true > |0| = s partial status: pi(if_high#) = [3] pi(false) = [] pi(add) = [] 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: 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: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: if_low#_A(x1,x2,x3) = max{11, x1 + 2, x3 - 8} false_A = 6 add_A(x1,x2) = max{13, x1 + 11, x2 + 9} low#_A(x1,x2) = max{6, x2 + 1} le_A(x1,x2) = x1 + 9 true_A = 9 |0|_A = 8 s_A(x1) = max{9, x1} precedence: true = |0| = s > add > if_low# = false > low# = le partial status: pi(if_low#) = [1] pi(false) = [] pi(add) = [] pi(low#) = [] pi(le) = [1] pi(true) = [] pi(|0|) = [] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: if_low#_A(x1,x2,x3) = max{0, x1 - 2} false_A = 4 add_A(x1,x2) = 1 low#_A(x1,x2) = 1 le_A(x1,x2) = 2 true_A = 4 |0|_A = 3 s_A(x1) = x1 + 5 precedence: if_low# = le > low# > false > add = true > |0| = s partial status: pi(if_low#) = [] pi(false) = [] pi(add) = [] pi(low#) = [] pi(le) = [] pi(true) = [] pi(|0|) = [] pi(s) = [1] The next rules are strictly ordered: p1, p3 We remove them from the problem. -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: low#(n,add(m,x)) -> if_low#(le(m,n),n,add(m,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 estimated dependency graph contains the following SCCs: (no SCCs) -- 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: 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#(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: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: app#_A(x1,x2) = max{x1 + 1, x2} add_A(x1,x2) = max{x1 - 1, x2} precedence: app# = add partial status: pi(app#) = [1, 2] pi(add) = [2] 2. weighted path order base order: max/plus interpretations on natural numbers: app#_A(x1,x2) = max{x1 - 1, x2 + 1} add_A(x1,x2) = x2 precedence: app# = add partial status: pi(app#) = [] pi(add) = [2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.