YES We show the termination of the TRS R: empty(nil()) -> true() empty(cons(x,l)) -> false() head(cons(x,l)) -> x tail(nil()) -> nil() tail(cons(x,l)) -> l rev(nil()) -> nil() rev(cons(x,l)) -> cons(rev1(x,l),rev2(x,l)) last(x,l) -> if(empty(l),x,l) if(true(),x,l) -> x if(false(),x,l) -> last(head(l),tail(l)) rev2(x,nil()) -> nil() rev2(x,cons(y,l)) -> rev(cons(x,rev2(y,l))) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: rev#(cons(x,l)) -> rev2#(x,l) p2: last#(x,l) -> if#(empty(l),x,l) p3: last#(x,l) -> empty#(l) p4: if#(false(),x,l) -> last#(head(l),tail(l)) p5: if#(false(),x,l) -> head#(l) p6: if#(false(),x,l) -> tail#(l) p7: rev2#(x,cons(y,l)) -> rev#(cons(x,rev2(y,l))) p8: rev2#(x,cons(y,l)) -> rev2#(y,l) and R consists of: r1: empty(nil()) -> true() r2: empty(cons(x,l)) -> false() r3: head(cons(x,l)) -> x r4: tail(nil()) -> nil() r5: tail(cons(x,l)) -> l r6: rev(nil()) -> nil() r7: rev(cons(x,l)) -> cons(rev1(x,l),rev2(x,l)) r8: last(x,l) -> if(empty(l),x,l) r9: if(true(),x,l) -> x r10: if(false(),x,l) -> last(head(l),tail(l)) r11: rev2(x,nil()) -> nil() r12: rev2(x,cons(y,l)) -> rev(cons(x,rev2(y,l))) The estimated dependency graph contains the following SCCs: {p1, p7, p8} {p2, p4} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: rev#(cons(x,l)) -> rev2#(x,l) p2: rev2#(x,cons(y,l)) -> rev2#(y,l) p3: rev2#(x,cons(y,l)) -> rev#(cons(x,rev2(y,l))) and R consists of: r1: empty(nil()) -> true() r2: empty(cons(x,l)) -> false() r3: head(cons(x,l)) -> x r4: tail(nil()) -> nil() r5: tail(cons(x,l)) -> l r6: rev(nil()) -> nil() r7: rev(cons(x,l)) -> cons(rev1(x,l),rev2(x,l)) r8: last(x,l) -> if(empty(l),x,l) r9: if(true(),x,l) -> x r10: if(false(),x,l) -> last(head(l),tail(l)) r11: rev2(x,nil()) -> nil() r12: rev2(x,cons(y,l)) -> rev(cons(x,rev2(y,l))) The set of usable rules consists of r4, r6, r7, r11, r12 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: rev#_A(x1) = max{15, x1 + 3} cons_A(x1,x2) = max{21, x2 + 13} rev2#_A(x1,x2) = max{14, x2 + 12} rev2_A(x1,x2) = max{2, x2} tail_A(x1) = max{17, x1 - 14} nil_A = 1 rev_A(x1) = max{16, x1} rev1_A(x1,x2) = max{13, x1 - 1, x2 + 1} base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: rev#_A(x1) = 1 cons_A(x1,x2) = x1 + 9 rev2#_A(x1,x2) = 1 rev2_A(x1,x2) = x1 + 12 tail_A(x1) = max{16, x1 - 10} nil_A = 9 rev_A(x1) = max{8, x1 + 3} rev1_A(x1,x2) = max{3, x1} rev#!_A(x1) = max{10, x1 + 4} cons!_A(x1,x2) = max{11, x2 + 9} rev2#!_A(x1,x2) = max{14, x1 + 11, x2 + 9} rev2!_A(x1,x2) = max{x1 + 23, x2 - 10} tail!_A(x1) = max{25, x1 - 10} nil!_A = 24 rev!_A(x1) = x1 + 13 rev1!_A(x1,x2) = max{23, x1 - 1} partial status: pi(rev#) = [1] pi(cons) = [] pi(rev2#) = [] pi(rev2) = [] pi(tail) = [] pi(nil) = [] pi(rev) = [] pi(rev1) = [2] The following rules are removed: p1, p2, p3 Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: last#(x,l) -> if#(empty(l),x,l) p2: if#(false(),x,l) -> last#(head(l),tail(l)) and R consists of: r1: empty(nil()) -> true() r2: empty(cons(x,l)) -> false() r3: head(cons(x,l)) -> x r4: tail(nil()) -> nil() r5: tail(cons(x,l)) -> l r6: rev(nil()) -> nil() r7: rev(cons(x,l)) -> cons(rev1(x,l),rev2(x,l)) r8: last(x,l) -> if(empty(l),x,l) r9: if(true(),x,l) -> x r10: if(false(),x,l) -> last(head(l),tail(l)) r11: rev2(x,nil()) -> nil() r12: rev2(x,cons(y,l)) -> rev(cons(x,rev2(y,l))) The set of usable rules consists of r1, r2, r3, r4, r5 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: last#_A(x1,x2) = x2 + 5 if#_A(x1,x2,x3) = max{x1 + 2, x3 + 4} empty_A(x1) = max{2, x1 - 10} false_A = 12 head_A(x1) = max{26, x1 + 24} tail_A(x1) = max{8, x1 - 6} nil_A = 7 true_A = 0 cons_A(x1,x2) = max{x1 - 23, x2 + 22} base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: last#_A(x1,x2) = max{0, x1 - 14, x2 - 12} if#_A(x1,x2,x3) = max{0, x1 - 12, x2 - 14, x3 - 12} empty_A(x1) = max{1, x1 - 9} false_A = 0 head_A(x1) = max{3, x1 + 2} tail_A(x1) = max{11, x1 - 4} nil_A = 3 true_A = 0 cons_A(x1,x2) = max{x1 - 2, x2 + 8} last#!_A(x1,x2) = max{7, x1 - 4, x2 - 17} if#!_A(x1,x2,x3) = max{6, x1 - 9, x2 - 5} empty!_A(x1) = max{2, x1 - 18} false!_A = 1 head!_A(x1) = max{5, x1 - 3} tail!_A(x1) = max{4, x1 - 4} nil!_A = 1 true!_A = 0 cons!_A(x1,x2) = max{3, x1 - 23, x2 - 6} partial status: pi(last#) = [] pi(if#) = [3] pi(empty) = [] pi(false) = [] pi(head) = [] pi(tail) = [] pi(nil) = [] pi(true) = [] pi(cons) = [] The following rules are removed: p1, p2 Then no dependency pair remains.