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: lexicographic combination of reduction pairs: 1. matrix interpretations: carrier: N^4 order: lexicographic order interpretations: qsort#_A(x1) = ((1,0,0,0),(0,1,0,0),(1,0,1,0),(1,0,0,0)) x1 ._A(x1,x2) = ((1,0,0,0),(1,1,0,0),(0,1,1,0),(0,0,0,0)) x1 + ((1,0,0,0),(1,1,0,0),(0,0,1,0),(0,0,0,1)) x2 + (2,0,1,0) lowers_A(x1,x2) = ((1,0,0,0),(0,0,0,0),(1,1,0,0),(0,0,0,0)) x1 + ((1,0,0,0),(1,0,0,0),(1,1,0,0),(1,1,0,0)) x2 + (1,2,3,1) greaters_A(x1,x2) = ((0,0,0,0),(1,0,0,0),(1,1,0,0),(0,0,1,0)) x1 + ((1,0,0,0),(1,1,0,0),(0,0,1,0),(0,0,1,1)) x2 + (1,1,6,0) nil_A() = (0,1,1,0) if_A(x1,x2,x3) = ((0,0,0,0),(0,0,0,0),(0,0,0,0),(1,0,0,0)) x1 + ((0,0,0,0),(0,0,0,0),(0,0,0,0),(1,0,0,0)) x2 + ((1,0,0,0),(0,1,0,0),(0,0,0,0),(1,1,1,0)) x3 + (0,0,6,0) <=_A(x1,x2) = ((0,0,0,0),(1,0,0,0),(0,0,0,0),(1,1,0,0)) x1 + ((1,0,0,0),(0,1,0,0),(0,0,1,0),(1,1,1,1)) x2 + (1,1,1,1) 2. lexicographic path order with precedence: precedence: . > qsort# > if > <= > greaters > lowers > nil argument filter: pi(qsort#) = [] pi(.) = [] pi(lowers) = [] pi(greaters) = 2 pi(nil) = [] pi(if) = [] pi(<=) = 2 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: 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: lexicographic combination of reduction pairs: 1. matrix interpretations: carrier: N^4 order: lexicographic order interpretations: lowers#_A(x1,x2) = ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,1,1,1)) x1 + ((1,0,0,0),(1,1,0,0),(0,0,0,0),(1,0,0,0)) x2 ._A(x1,x2) = ((1,0,0,0),(0,0,0,0),(0,1,0,0),(1,1,1,0)) x1 + ((1,0,0,0),(0,0,0,0),(0,0,0,0),(1,1,0,0)) x2 + (1,1,1,1) 2. lexicographic path order with precedence: precedence: . > lowers# argument filter: pi(lowers#) = [1] 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: 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: lexicographic combination of reduction pairs: 1. matrix interpretations: carrier: N^4 order: lexicographic order interpretations: greaters#_A(x1,x2) = ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,1,1,1)) x1 + ((1,0,0,0),(1,1,0,0),(0,0,0,0),(1,0,0,0)) x2 ._A(x1,x2) = ((1,0,0,0),(1,0,0,0),(0,1,0,0),(1,1,1,0)) x1 + ((1,0,0,0),(0,0,0,0),(0,0,0,0),(1,1,0,0)) x2 + (1,1,1,1) 2. lexicographic path order with precedence: precedence: . > greaters# argument filter: pi(greaters#) = [1] pi(.) = [] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.