YES We show the termination of the TRS R: qsort(nil()) -> nil() qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) lowers(x,nil()) -> nil() lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) greaters(x,nil()) -> nil() greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,z))) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: qsort#(.(x,y)) -> qsort#(lowers(x,y)) p2: qsort#(.(x,y)) -> lowers#(x,y) p3: qsort#(.(x,y)) -> qsort#(greaters(x,y)) p4: qsort#(.(x,y)) -> greaters#(x,y) p5: lowers#(x,.(y,z)) -> lowers#(x,z) p6: greaters#(x,.(y,z)) -> greaters#(x,z) and R consists of: r1: qsort(nil()) -> nil() r2: qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) r3: lowers(x,nil()) -> nil() r4: lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) r5: greaters(x,nil()) -> nil() r6: greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,z))) The estimated dependency graph contains the following SCCs: {p1, p3} {p5} {p6} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: qsort#(.(x,y)) -> qsort#(lowers(x,y)) p2: qsort#(.(x,y)) -> qsort#(greaters(x,y)) and R consists of: r1: qsort(nil()) -> nil() r2: qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) r3: lowers(x,nil()) -> nil() r4: lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) r5: greaters(x,nil()) -> nil() r6: greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,z))) The set of usable rules consists of r3, r4, r5, r6 Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: qsort#_A(x1) = x1 + 14 ._A(x1,x2) = max{13, x1 + 5, x2 + 6} lowers_A(x1,x2) = max{3, x1 - 10, x2 - 9} greaters_A(x1,x2) = max{x1 + 5, x2 - 7} nil_A = 2 if_A(x1,x2,x3) = max{4, x1 - 5, x2 - 24, x3 - 16} <=_A(x1,x2) = max{9, x1 + 1, x2 - 6} precedence: qsort# = . = lowers = greaters = nil = if = <= partial status: pi(qsort#) = [] pi(.) = [2] pi(lowers) = [] pi(greaters) = [] pi(nil) = [] pi(if) = [] pi(<=) = [] 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#(.(x,y)) -> qsort#(greaters(x,y)) and R consists of: r1: qsort(nil()) -> nil() r2: qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) r3: lowers(x,nil()) -> nil() r4: lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) r5: greaters(x,nil()) -> nil() r6: greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,z))) The estimated dependency graph contains the following SCCs: {p1} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: qsort#(.(x,y)) -> qsort#(greaters(x,y)) and R consists of: r1: qsort(nil()) -> nil() r2: qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) r3: lowers(x,nil()) -> nil() r4: lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) r5: greaters(x,nil()) -> nil() r6: greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,z))) The set of usable rules consists of r5, r6 Take the reduction pair: weighted path order base order: max/plus interpretations on natural numbers: qsort#_A(x1) = x1 + 5 ._A(x1,x2) = max{x1 + 3, x2} greaters_A(x1,x2) = max{x1 + 2, x2 - 1} nil_A = 1 if_A(x1,x2,x3) = max{2, x1 - 4, x2, x3 - 5} <=_A(x1,x2) = max{x1 + 2, x2 + 6} precedence: qsort# = . = greaters = nil = if = <= partial status: pi(qsort#) = [] pi(.) = [2] pi(greaters) = [] pi(nil) = [] pi(if) = [] pi(<=) = [] 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: lowers#(x,.(y,z)) -> lowers#(x,z) and R consists of: r1: qsort(nil()) -> nil() r2: qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) r3: lowers(x,nil()) -> nil() r4: lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) r5: greaters(x,nil()) -> nil() r6: greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,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: lowers#_A(x1,x2) = max{0, x2 - 2} ._A(x1,x2) = max{x1 + 3, x2 + 1} precedence: lowers# = . partial status: pi(lowers#) = [] pi(.) = [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: greaters#(x,.(y,z)) -> greaters#(x,z) and R consists of: r1: qsort(nil()) -> nil() r2: qsort(.(x,y)) -> ++(qsort(lowers(x,y)),.(x,qsort(greaters(x,y)))) r3: lowers(x,nil()) -> nil() r4: lowers(x,.(y,z)) -> if(<=(y,x),.(y,lowers(x,z)),lowers(x,z)) r5: greaters(x,nil()) -> nil() r6: greaters(x,.(y,z)) -> if(<=(y,x),greaters(x,z),.(y,greaters(x,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: greaters#_A(x1,x2) = max{0, x2 - 2} ._A(x1,x2) = max{x1 + 3, x2 + 1} precedence: greaters# = . partial status: pi(greaters#) = [] pi(.) = [2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.