Term Rewriting System R: [x, y, z] 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))) Termination of R to be shown. This program has no overlaps, so it is sufficient to show innermost termination. R contains the following Dependency Pairs: BUBBLE(.(x, .(y, z))) -> BUBBLE(.(x, z)) BUBBLE(.(x, .(y, z))) -> BUBBLE(.(y, z)) BSORT(.(x, y)) -> LAST(.(bubble(.(x, y)), bsort(butlast(bubble(.(x, y)))))) BSORT(.(x, y)) -> BUBBLE(.(x, y)) BSORT(.(x, y)) -> BSORT(butlast(bubble(.(x, y)))) BSORT(.(x, y)) -> BUTLAST(bubble(.(x, y))) BUTLAST(.(x, .(y, z))) -> BUTLAST(.(y, z)) LAST(.(x, .(y, z))) -> LAST(.(y, z)) Furthermore, R contains four SCCs. SCC1: BUBBLE(.(x, .(y, z))) -> BUBBLE(.(y, z)) BUBBLE(.(x, .(y, z))) -> BUBBLE(.(x, z)) Removing rules from R by ordering and analyzing Dependency Pairs, Usable Rules, and Usable Equations. This is possible by using the following (C_E-compatible) Polynomial ordering. Polynomial interpretation: POL(BUBBLE(x_1)) = 1 + x_1 POL(.(x_1, x_2)) = 1 + x_1 + x_2 The following Dependency Pairs can be deleted: BUBBLE(.(x, .(y, z))) -> BUBBLE(.(y, z)) BUBBLE(.(x, .(y, z))) -> BUBBLE(.(x, z)) This transformation is resulting in no new subcycles. SCC2: LAST(.(x, .(y, z))) -> LAST(.(y, z)) Removing rules from R by ordering and analyzing Dependency Pairs, Usable Rules, and Usable Equations. This is possible by using the following (C_E-compatible) Polynomial ordering. Polynomial interpretation: POL(LAST(x_1)) = 1 + x_1 POL(.(x_1, x_2)) = 1 + x_1 + x_2 The following Dependency Pairs can be deleted: LAST(.(x, .(y, z))) -> LAST(.(y, z)) This transformation is resulting in no new subcycles. SCC3: BUTLAST(.(x, .(y, z))) -> BUTLAST(.(y, z)) Removing rules from R by ordering and analyzing Dependency Pairs, Usable Rules, and Usable Equations. This is possible by using the following (C_E-compatible) Polynomial ordering. Polynomial interpretation: POL(BUTLAST(x_1)) = 1 + x_1 POL(.(x_1, x_2)) = 1 + x_1 + x_2 The following Dependency Pairs can be deleted: BUTLAST(.(x, .(y, z))) -> BUTLAST(.(y, z)) This transformation is resulting in no new subcycles. SCC4: BSORT(.(x, y)) -> BSORT(butlast(bubble(.(x, y)))) On this Scc, a Narrowing SCC transformation can be performed. As a result of transforming the rule BSORT(.(x, y)) -> BSORT(butlast(bubble(.(x, y)))) two new Dependency Pairs are created: BSORT(.(x'', .(y'', z'))) -> BSORT(butlast(if(<=(x'', y''), .(y'', bubble(.(x'', z'))), .(x'', bubble(.(y'', z')))))) BSORT(.(x'', nil)) -> BSORT(butlast(.(x'', nil))) The transformation is resulting in one subcycle: SCC4.Nar1: BSORT(.(x'', nil)) -> BSORT(butlast(.(x'', nil))) BSORT(.(x'', .(y'', z'))) -> BSORT(butlast(if(<=(x'', y''), .(y'', bubble(.(x'', z'))), .(x'', bubble(.(y'', z')))))) On this Scc, a Rewriting SCC transformation can be performed. As a result of transforming the rule BSORT(.(x'', nil)) -> BSORT(butlast(.(x'', nil))) one new Dependency Pair is created: BSORT(.(x'', nil)) -> BSORT(nil) The transformation is resulting in one subcycle: SCC4.Nar1.Rewr1: BSORT(.(x'', .(y'', z'))) -> BSORT(butlast(if(<=(x'', y''), .(y'', bubble(.(x'', z'))), .(x'', bubble(.(y'', z')))))) By using a polynomial ordering, at least one Dependency Pair of this SCC can be strictly oriented. Additionally, the following rules can be oriented: butlast(.(x, .(y, z))) -> .(x, butlast(.(y, z))) butlast(nil) -> nil butlast(.(x, nil)) -> nil Used ordering: Polynomial ordering with Polynomial interpretation: POL(bubble(x_1)) = 0 POL(nil) = 0 POL(<=(x_1, x_2)) = 0 POL(BSORT(x_1)) = 1 + x_1 POL(butlast(x_1)) = x_1 POL(if(x_1, x_2, x_3)) = 0 POL(.(x_1, x_2)) = 1 resulting in no subcycles. Termination of R successfully shown. Duration: 11.201 seconds.