YES We show the termination of the TRS R: bsort(nil()) -> nil() bsort(.(x,y)) -> last(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) bubble(nil()) -> nil() bubble(.(x,nil())) -> .(x,nil()) bubble(.(x,.(y,z))) -> if(<=(x,y),.(y,bubble(.(x,z))),.(x,bubble(.(y,z)))) last(nil()) -> |0|() last(.(x,nil())) -> x last(.(x,.(y,z))) -> last(.(y,z)) butlast(nil()) -> nil() butlast(.(x,nil())) -> nil() butlast(.(x,.(y,z))) -> .(x,butlast(.(y,z))) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: bsort#(.(x,y)) -> last#(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) p2: bsort#(.(x,y)) -> bubble#(.(x,y)) p3: bsort#(.(x,y)) -> bsort#(butlast(bubble(.(x,y)))) p4: bsort#(.(x,y)) -> butlast#(bubble(.(x,y))) p5: bubble#(.(x,.(y,z))) -> bubble#(.(x,z)) p6: bubble#(.(x,.(y,z))) -> bubble#(.(y,z)) p7: last#(.(x,.(y,z))) -> last#(.(y,z)) p8: butlast#(.(x,.(y,z))) -> butlast#(.(y,z)) and R consists of: r1: bsort(nil()) -> nil() r2: bsort(.(x,y)) -> last(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) r3: bubble(nil()) -> nil() r4: bubble(.(x,nil())) -> .(x,nil()) r5: bubble(.(x,.(y,z))) -> if(<=(x,y),.(y,bubble(.(x,z))),.(x,bubble(.(y,z)))) r6: last(nil()) -> |0|() r7: last(.(x,nil())) -> x r8: last(.(x,.(y,z))) -> last(.(y,z)) r9: butlast(nil()) -> nil() r10: butlast(.(x,nil())) -> nil() r11: butlast(.(x,.(y,z))) -> .(x,butlast(.(y,z))) The estimated dependency graph contains the following SCCs: {p3} {p7} {p5, p6} {p8} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: bsort#(.(x,y)) -> bsort#(butlast(bubble(.(x,y)))) and R consists of: r1: bsort(nil()) -> nil() r2: bsort(.(x,y)) -> last(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) r3: bubble(nil()) -> nil() r4: bubble(.(x,nil())) -> .(x,nil()) r5: bubble(.(x,.(y,z))) -> if(<=(x,y),.(y,bubble(.(x,z))),.(x,bubble(.(y,z)))) r6: last(nil()) -> |0|() r7: last(.(x,nil())) -> x r8: last(.(x,.(y,z))) -> last(.(y,z)) r9: butlast(nil()) -> nil() r10: butlast(.(x,nil())) -> nil() r11: butlast(.(x,.(y,z))) -> .(x,butlast(.(y,z))) The set of usable rules consists of r4, r5, r9, r10, r11 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: bsort#_A(x1) = x1 + (0,4) ._A(x1,x2) = ((1,0),(0,0)) x2 + (6,13) butlast_A(x1) = ((1,0),(1,0)) x1 + (0,2) bubble_A(x1) = (6,16) nil_A() = (0,1) if_A(x1,x2,x3) = x1 + (1,1) <=_A(x1,x2) = (4,14) precedence: bsort# = butlast = if > bubble = <= > . = nil partial status: pi(bsort#) = [1] pi(.) = [] pi(butlast) = [] pi(bubble) = [] pi(nil) = [] pi(if) = [1] pi(<=) = [] 2. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: bsort#_A(x1) = x1 + (2,1) ._A(x1,x2) = (2,4) butlast_A(x1) = (2,2) bubble_A(x1) = (3,0) nil_A() = (1,1) if_A(x1,x2,x3) = (0,0) <=_A(x1,x2) = (1,3) precedence: bubble = if > bsort# = . = butlast = nil = <= partial status: pi(bsort#) = [] pi(.) = [] pi(butlast) = [] pi(bubble) = [] 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: last#(.(x,.(y,z))) -> last#(.(y,z)) and R consists of: r1: bsort(nil()) -> nil() r2: bsort(.(x,y)) -> last(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) r3: bubble(nil()) -> nil() r4: bubble(.(x,nil())) -> .(x,nil()) r5: bubble(.(x,.(y,z))) -> if(<=(x,y),.(y,bubble(.(x,z))),.(x,bubble(.(y,z)))) r6: last(nil()) -> |0|() r7: last(.(x,nil())) -> x r8: last(.(x,.(y,z))) -> last(.(y,z)) r9: butlast(nil()) -> nil() r10: butlast(.(x,nil())) -> nil() r11: butlast(.(x,.(y,z))) -> .(x,butlast(.(y,z))) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: last#_A(x1) = ((0,0),(1,0)) x1 + (0,1) ._A(x1,x2) = x1 + x2 + (1,4) precedence: last# = . partial status: pi(last#) = [] pi(.) = [] 2. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: last#_A(x1) = (0,0) ._A(x1,x2) = x1 + x2 + (1,1) precedence: . > last# partial status: pi(last#) = [] pi(.) = [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: bubble#(.(x,.(y,z))) -> bubble#(.(x,z)) p2: bubble#(.(x,.(y,z))) -> bubble#(.(y,z)) and R consists of: r1: bsort(nil()) -> nil() r2: bsort(.(x,y)) -> last(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) r3: bubble(nil()) -> nil() r4: bubble(.(x,nil())) -> .(x,nil()) r5: bubble(.(x,.(y,z))) -> if(<=(x,y),.(y,bubble(.(x,z))),.(x,bubble(.(y,z)))) r6: last(nil()) -> |0|() r7: last(.(x,nil())) -> x r8: last(.(x,.(y,z))) -> last(.(y,z)) r9: butlast(nil()) -> nil() r10: butlast(.(x,nil())) -> nil() r11: butlast(.(x,.(y,z))) -> .(x,butlast(.(y,z))) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: bubble#_A(x1) = x1 ._A(x1,x2) = ((1,0),(1,1)) x1 + ((1,0),(0,0)) x2 + (1,1) precedence: bubble# = . partial status: pi(bubble#) = [1] pi(.) = [] 2. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: bubble#_A(x1) = (0,0) ._A(x1,x2) = (1,1) precedence: bubble# = . partial status: pi(bubble#) = [] pi(.) = [] 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: butlast#(.(x,.(y,z))) -> butlast#(.(y,z)) and R consists of: r1: bsort(nil()) -> nil() r2: bsort(.(x,y)) -> last(.(bubble(.(x,y)),bsort(butlast(bubble(.(x,y)))))) r3: bubble(nil()) -> nil() r4: bubble(.(x,nil())) -> .(x,nil()) r5: bubble(.(x,.(y,z))) -> if(<=(x,y),.(y,bubble(.(x,z))),.(x,bubble(.(y,z)))) r6: last(nil()) -> |0|() r7: last(.(x,nil())) -> x r8: last(.(x,.(y,z))) -> last(.(y,z)) r9: butlast(nil()) -> nil() r10: butlast(.(x,nil())) -> nil() r11: butlast(.(x,.(y,z))) -> .(x,butlast(.(y,z))) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: butlast#_A(x1) = ((0,0),(1,0)) x1 + (0,1) ._A(x1,x2) = x1 + x2 + (1,4) precedence: butlast# = . partial status: pi(butlast#) = [] pi(.) = [] 2. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: butlast#_A(x1) = (0,0) ._A(x1,x2) = x1 + x2 + (1,1) precedence: . > butlast# partial status: pi(butlast#) = [] pi(.) = [1] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.