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. max/plus interpretations on natural numbers: bsort#_A(x1) = max{0, x1 - 4} ._A(x1,x2) = x2 + 9 butlast_A(x1) = max{1, x1 - 7} bubble_A(x1) = max{15, x1 + 1} nil_A = 0 if_A(x1,x2,x3) = max{x1 + 16, x2 - 5, x3 - 15} <=_A(x1,x2) = 0 2. max/plus interpretations on natural numbers: bsort#_A(x1) = 0 ._A(x1,x2) = 4 butlast_A(x1) = 5 bubble_A(x1) = 1 nil_A = 0 if_A(x1,x2,x3) = 0 <=_A(x1,x2) = 0 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. max/plus interpretations on natural numbers: last#_A(x1) = x1 ._A(x1,x2) = max{x1 + 2, x2 + 1} 2. max/plus interpretations on natural numbers: last#_A(x1) = max{1, x1} ._A(x1,x2) = 0 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. max/plus interpretations on natural numbers: bubble#_A(x1) = max{1, x1} ._A(x1,x2) = x2 + 2 2. max/plus interpretations on natural numbers: bubble#_A(x1) = 0 ._A(x1,x2) = 0 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. max/plus interpretations on natural numbers: butlast#_A(x1) = max{2, x1} ._A(x1,x2) = max{x1 + 5, x2 + 3} 2. max/plus interpretations on natural numbers: butlast#_A(x1) = 1 ._A(x1,x2) = 0 The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.