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, r15, r16, r17, r19 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_qs#_A(x1,x2,x3,x4) = 1 false_A = 47 quicksort#_A(x1) = 1 isempty_A(x1) = x1 low_A(x1,x2) = x2 + 6 head_A(x1) = x1 + 11 tail_A(x1) = max{0, x1 - 14} high_A(x1,x2) = max{17, x2 + 5} le_A(x1,x2) = 47 |0|_A = 34 true_A = 25 s_A(x1) = max{34, x1 + 33} nil_A = 42 add_A(x1,x2) = max{96, x1 + 46, x2 + 44} if_low_A(x1,x2,x3) = max{96, x1 - 24, x3 + 6} if_high_A(x1,x2,x3) = max{96, x1 - 48, x3 + 5} if_qs_A(x1,x2,x3,x4) = max{42, x1 - 53, x2 + 3, x3 - 8, x4 - 18} if_qs#!_A(x1,x2,x3,x4) = max{x1 - 8, x2 - 7, x4 + 1} false!_A = 31 quicksort#!_A(x1) = max{29, x1 - 7} isempty!_A(x1) = max{30, x1 - 7} low!_A(x1,x2) = 26 head!_A(x1) = max{32, x1 - 8} tail!_A(x1) = max{32, x1 - 8} high!_A(x1,x2) = max{28, x2 - 43} le!_A(x1,x2) = max{21, x1 - 1, x2 + 1} |0|!_A = 35 true!_A = 34 s!_A(x1) = max{32, x1 - 2} nil!_A = 27 add!_A(x1,x2) = 22 if_low!_A(x1,x2,x3) = max{26, x1 - 22} if_high!_A(x1,x2,x3) = max{29, x1 - 24, x3 - 69} if_qs!_A(x1,x2,x3,x4) = max{32, x1 + 1, x3 + 28} 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_qs#_A(x1,x2,x3,x4) = 1 false_A = 27 quicksort#_A(x1) = 1 isempty_A(x1) = max{27, x1 + 7} low_A(x1,x2) = 24 head_A(x1) = x1 + 7 tail_A(x1) = max{72, x1 + 11} high_A(x1,x2) = 0 le_A(x1,x2) = max{4, x1 - 26, x2 - 1} |0|_A = 27 true_A = 2 s_A(x1) = max{53, x1 + 27} nil_A = 0 add_A(x1,x2) = max{0, x2 - 11} if_low_A(x1,x2,x3) = 24 if_high_A(x1,x2,x3) = 0 if_qs_A(x1,x2,x3,x4) = max{0, x1 - 64, x2 - 84, x3 - 10, x4 - 37} if_qs#!_A(x1,x2,x3,x4) = max{0, x1 - 26, x2 - 24, x4 - 1} false!_A = 9 quicksort#!_A(x1) = max{0, x1 - 25} isempty!_A(x1) = max{21, x1 - 27} low!_A(x1,x2) = 8 head!_A(x1) = max{1, x1 - 24} tail!_A(x1) = max{23, x1 - 25} high!_A(x1,x2) = max{48, x2 + 46} le!_A(x1,x2) = max{x1 - 8, x2 + 19} |0|!_A = 21 true!_A = 20 s!_A(x1) = max{10, x1 - 9} nil!_A = 7 add!_A(x1,x2) = 0 if_low!_A(x1,x2,x3) = 8 if_high!_A(x1,x2,x3) = max{47, x1 - 28, x2 - 1} if_qs!_A(x1,x2,x3,x4) = max{x1 - 6, x2 + 23, x3 + 1, x4 + 6} partial status: pi(if_qs#) = [4] pi(false) = [] pi(quicksort#) = [] pi(isempty) = [1] pi(low) = [2] pi(head) = [] pi(tail) = [1] pi(high) = [] pi(le) = [1, 2] pi(|0|) = [] pi(true) = [] pi(s) = [1] pi(nil) = [] pi(add) = [2] pi(if_low) = [3] pi(if_high) = [] pi(if_qs) = [1, 2, 3, 4] 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_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: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_high#_A(x1,x2,x3) = max{0, x1 - 24, x2 - 3, x3 - 57} false_A = 1 add_A(x1,x2) = max{55, x1 + 20, x2 + 20} high#_A(x1,x2) = max{0, x1 - 3, x2 - 57} le_A(x1,x2) = max{23, x1 - 13} true_A = 23 |0|_A = 2 s_A(x1) = x1 + 12 if_high#!_A(x1,x2,x3) = max{6, x1 - 47, x3 - 52} false!_A = 3 add!_A(x1,x2) = max{4, x1 - 432, x2 - 25} high#!_A(x1,x2) = max{5, x2 - 46} le!_A(x1,x2) = max{8, x1 - 3, x2 - 13} true!_A = 1 |0|!_A = 4 s!_A(x1) = max{4, x1 - 14} 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_high#_A(x1,x2,x3) = max{0, x1 - 2, x2 - 16, x3 - 37} false_A = 1 add_A(x1,x2) = max{x1 + 35, x2 + 10} high#_A(x1,x2) = max{0, x1 - 16, x2 - 37} le_A(x1,x2) = max{1, x1 - 1, x2 - 26} true_A = 0 |0|_A = 0 s_A(x1) = x1 if_high#!_A(x1,x2,x3) = max{5, x1 - 39, x3 - 83} false!_A = 1 add!_A(x1,x2) = max{4, x1 - 47, x2 - 39} high#!_A(x1,x2) = max{x1 + 8, x2 - 74} le!_A(x1,x2) = max{7, x1 - 1, x2 - 3} true!_A = 6 |0|!_A = 7 s!_A(x1) = max{2, x1 - 2} partial status: pi(if_high#) = [2] pi(false) = [] pi(add) = [1] pi(high#) = [1] pi(le) = [1] 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: 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, r17 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_low#_A(x1,x2,x3) = max{0, x1 - 18, x2 - 19, x3 - 23} false_A = 17 add_A(x1,x2) = max{x1 + 4, x2 + 14} low#_A(x1,x2) = max{0, x1 - 19, x2 - 16} le_A(x1,x2) = max{17, x1 - 3} true_A = 11 |0|_A = 2 s_A(x1) = x1 isempty_A(x1) = x1 + 12 if_low#!_A(x1,x2,x3) = max{0, x1 - 16, x3 - 15} false!_A = 28 add!_A(x1,x2) = max{36, x1 + 2, x2 + 26} low#!_A(x1,x2) = max{0, x2 - 2} le!_A(x1,x2) = max{37, x1 - 3, x2 - 128} true!_A = 1 |0|!_A = 29 s!_A(x1) = max{29, x1 - 127} isempty!_A(x1) = max{30, x1 - 26} 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: if_low#_A(x1,x2,x3) = max{0, x1 - 62, x2 - 67, x3 - 13} false_A = 2 add_A(x1,x2) = max{12, x1 - 54, x2 + 5} low#_A(x1,x2) = max{0, x1 - 67, x2 - 13} le_A(x1,x2) = max{11, x1 - 5, x2 - 5} true_A = 0 |0|_A = 4 s_A(x1) = x1 isempty_A(x1) = max{38, x1 - 17} if_low#!_A(x1,x2,x3) = max{x1 - 1, x2, x3 - 14} false!_A = 6 add!_A(x1,x2) = max{9, x1 - 69, x2 - 69} low#!_A(x1,x2) = max{0, x2 - 74} le!_A(x1,x2) = max{10, x1 - 1, x2 - 5} true!_A = 2 |0|!_A = 7 s!_A(x1) = max{7, x1 - 6} isempty!_A(x1) = max{7, x1 - 17} partial status: pi(if_low#) = [] pi(false) = [] pi(add) = [] pi(low#) = [] pi(le) = [1] pi(true) = [] pi(|0|) = [] pi(s) = [1] pi(isempty) = [1] The following rules are removed: p1, p2 -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: 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 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: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: le#_A(x1,x2) = max{x1, x2} s_A(x1) = x1 + 29 le#!_A(x1,x2) = max{6, x1 - 30, x2 - 206} s!_A(x1) = max{5, x1 - 206} 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: le#_A(x1,x2) = max{x1, x2} s_A(x1) = x1 + 23 le#!_A(x1,x2) = max{6, x1 - 64, x2 - 66} s!_A(x1) = max{5, x1 - 65} 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 r17 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: app#_A(x1,x2) = 0 add_A(x1,x2) = max{x1 + 6, x2 - 4} isempty_A(x1) = max{23, x1 - 16} false_A = 1 app#!_A(x1,x2) = 0 add!_A(x1,x2) = max{3, x1 - 57} isempty!_A(x1) = max{8, x1 - 26} false!_A = 4 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: app#_A(x1,x2) = 0 add_A(x1,x2) = max{6, x1 + 4, x2 - 9} isempty_A(x1) = max{19, x1 - 10} false_A = 1 app#!_A(x1,x2) = max{1, x1 - 81, x2 - 1} add!_A(x1,x2) = max{4, x1 - 77, x2 - 81} isempty!_A(x1) = max{6, x1 - 10} false!_A = 5 partial status: pi(app#) = [1] pi(add) = [1, 2] pi(isempty) = [1] pi(false) = [] The following rules are removed: p1 Then no dependency pair remains.