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: weighted path order base order: max/plus interpretations on natural numbers: bsort#_A(x1) = max{12, x1 + 3} ._A(x1,x2) = x2 + 22 butlast_A(x1) = max{13, x1 - 9} bubble_A(x1) = max{27, x1 + 4} nil_A = 1 if_A(x1,x2,x3) = max{48, x1 - 55, x2 - 1, x3 - 1} <=_A(x1,x2) = 49 precedence: bsort# = . = butlast = bubble = nil = if = <= partial status: pi(bsort#) = [1] 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: weighted path order base order: max/plus interpretations on natural numbers: last#_A(x1) = x1 + 6 ._A(x1,x2) = max{x1 - 2, x2 + 1} precedence: last# = . partial status: pi(last#) = [] 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: 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: weighted path order base order: max/plus interpretations on natural numbers: bubble#_A(x1) = x1 + 6 ._A(x1,x2) = max{x1 - 7, x2 + 2} precedence: bubble# = . partial status: pi(bubble#) = [] pi(.) = [2] The next rules are strictly ordered: p2 We remove them from the problem. -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: bubble#(.(x,.(y,z))) -> bubble#(.(x,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: {p1} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: bubble#(.(x,.(y,z))) -> bubble#(.(x,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: weighted path order base order: max/plus interpretations on natural numbers: bubble#_A(x1) = x1 ._A(x1,x2) = max{x1, x2} precedence: . > bubble# partial status: pi(bubble#) = [1] 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: 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: weighted path order base order: max/plus interpretations on natural numbers: butlast#_A(x1) = x1 + 6 ._A(x1,x2) = max{x1 - 2, x2 + 1} precedence: butlast# = . partial status: pi(butlast#) = [] pi(.) = [2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.