YES We show the termination of the TRS R: half(|0|()) -> |0|() half(s(|0|())) -> |0|() half(s(s(x))) -> s(half(x)) inc(|0|()) -> |0|() inc(s(x)) -> s(inc(x)) zero(|0|()) -> true() zero(s(x)) -> false() p(|0|()) -> |0|() p(s(x)) -> x bits(x) -> bitIter(x,|0|()) bitIter(x,y) -> if(zero(x),x,inc(y)) if(true(),x,y) -> p(y) if(false(),x,y) -> bitIter(half(x),y) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: half#(s(s(x))) -> half#(x) p2: inc#(s(x)) -> inc#(x) p3: bits#(x) -> bitIter#(x,|0|()) p4: bitIter#(x,y) -> if#(zero(x),x,inc(y)) p5: bitIter#(x,y) -> zero#(x) p6: bitIter#(x,y) -> inc#(y) p7: if#(true(),x,y) -> p#(y) p8: if#(false(),x,y) -> bitIter#(half(x),y) p9: if#(false(),x,y) -> half#(x) and R consists of: r1: half(|0|()) -> |0|() r2: half(s(|0|())) -> |0|() r3: half(s(s(x))) -> s(half(x)) r4: inc(|0|()) -> |0|() r5: inc(s(x)) -> s(inc(x)) r6: zero(|0|()) -> true() r7: zero(s(x)) -> false() r8: p(|0|()) -> |0|() r9: p(s(x)) -> x r10: bits(x) -> bitIter(x,|0|()) r11: bitIter(x,y) -> if(zero(x),x,inc(y)) r12: if(true(),x,y) -> p(y) r13: if(false(),x,y) -> bitIter(half(x),y) The estimated dependency graph contains the following SCCs: {p4, p8} {p1} {p2} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: bitIter#(x,y) -> if#(zero(x),x,inc(y)) p2: if#(false(),x,y) -> bitIter#(half(x),y) and R consists of: r1: half(|0|()) -> |0|() r2: half(s(|0|())) -> |0|() r3: half(s(s(x))) -> s(half(x)) r4: inc(|0|()) -> |0|() r5: inc(s(x)) -> s(inc(x)) r6: zero(|0|()) -> true() r7: zero(s(x)) -> false() r8: p(|0|()) -> |0|() r9: p(s(x)) -> x r10: bits(x) -> bitIter(x,|0|()) r11: bitIter(x,y) -> if(zero(x),x,inc(y)) r12: if(true(),x,y) -> p(y) r13: if(false(),x,y) -> bitIter(half(x),y) The set of usable rules consists of r1, r2, r3, r4, r6, r7 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: bitIter#_A(x1,x2) = max{1, x1 - 7} if#_A(x1,x2,x3) = max{1, x1 - 22, x2 - 7} zero_A(x1) = max{13, x1 + 5} inc_A(x1) = max{6, x1} false_A = 20 half_A(x1) = max{6, x1} |0|_A = 7 s_A(x1) = 15 true_A = 13 bitIter#!_A(x1,x2) = x1 + 4 if#!_A(x1,x2,x3) = max{x1 - 9, x2 + 4} zero!_A(x1) = x1 + 5 inc!_A(x1) = 0 false!_A = 1 half!_A(x1) = max{11, x1 - 10} |0|!_A = 0 s!_A(x1) = 0 true!_A = 3 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: bitIter#_A(x1,x2) = max{2, x1 - 1} if#_A(x1,x2,x3) = max{2, x1 - 18, x2 - 13} zero_A(x1) = max{0, x1 - 29} inc_A(x1) = x1 + 5 false_A = 17 half_A(x1) = max{3, x1 - 12} |0|_A = 3 s_A(x1) = max{46, x1 + 29} true_A = 0 bitIter#!_A(x1,x2) = x1 + 12 if#!_A(x1,x2,x3) = max{x1 - 1, x2 + 11} zero!_A(x1) = 9 inc!_A(x1) = max{15, x1 - 4} false!_A = 13 half!_A(x1) = max{88, x1 + 13} |0|!_A = 6 s!_A(x1) = max{72, x1 + 12} true!_A = 8 partial status: pi(bitIter#) = [] pi(if#) = [] pi(zero) = [] pi(inc) = [] pi(false) = [] pi(half) = [1] pi(|0|) = [] pi(s) = [] pi(true) = [] The following rules are removed: p1, p2 Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: half#(s(s(x))) -> half#(x) and R consists of: r1: half(|0|()) -> |0|() r2: half(s(|0|())) -> |0|() r3: half(s(s(x))) -> s(half(x)) r4: inc(|0|()) -> |0|() r5: inc(s(x)) -> s(inc(x)) r6: zero(|0|()) -> true() r7: zero(s(x)) -> false() r8: p(|0|()) -> |0|() r9: p(s(x)) -> x r10: bits(x) -> bitIter(x,|0|()) r11: bitIter(x,y) -> if(zero(x),x,inc(y)) r12: if(true(),x,y) -> p(y) r13: if(false(),x,y) -> bitIter(half(x),y) The set of usable rules consists of r1, r2, r4 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: half#_A(x1) = 0 s_A(x1) = max{2, x1 - 7} half_A(x1) = max{6, x1 - 7} |0|_A = 2 inc_A(x1) = max{5, x1 - 5} half#!_A(x1) = max{1, x1 - 11} s!_A(x1) = max{4, x1 - 10} half!_A(x1) = max{3, x1 - 16} |0|!_A = 2 inc!_A(x1) = max{5, x1 - 9} 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: half#_A(x1) = 0 s_A(x1) = max{4, x1 - 9} half_A(x1) = max{8, x1 - 9} |0|_A = 2 inc_A(x1) = max{2, x1 - 9} half#!_A(x1) = max{1, x1 - 5} s!_A(x1) = 6 half!_A(x1) = max{11, x1 + 6} |0|!_A = 7 inc!_A(x1) = max{8, x1 - 13} partial status: pi(half#) = [1] pi(s) = [1] pi(half) = [1] pi(|0|) = [] pi(inc) = [1] The following rules are removed: p1 Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: inc#(s(x)) -> inc#(x) and R consists of: r1: half(|0|()) -> |0|() r2: half(s(|0|())) -> |0|() r3: half(s(s(x))) -> s(half(x)) r4: inc(|0|()) -> |0|() r5: inc(s(x)) -> s(inc(x)) r6: zero(|0|()) -> true() r7: zero(s(x)) -> false() r8: p(|0|()) -> |0|() r9: p(s(x)) -> x r10: bits(x) -> bitIter(x,|0|()) r11: bitIter(x,y) -> if(zero(x),x,inc(y)) r12: if(true(),x,y) -> p(y) r13: if(false(),x,y) -> bitIter(half(x),y) The set of usable rules consists of r1, r2 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: trivial reduction triple (T x T, T x T, Φ) base order 2: lexicographic combination of reduction triples: 1. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: inc#_A(x1) = 0 s_A(x1) = max{3, x1 - 8} half_A(x1) = max{7, x1 - 25} |0|_A = 3 inc#!_A(x1) = max{4, x1 - 9} s!_A(x1) = max{4, x1 - 8} half!_A(x1) = max{4, x1 - 16} |0|!_A = 2 2. marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: inc#_A(x1) = 0 s_A(x1) = max{3, x1 - 17} half_A(x1) = max{16, x1 - 5} |0|_A = 3 inc#!_A(x1) = max{1, x1 - 17} s!_A(x1) = max{7, x1 - 17} half!_A(x1) = max{7, x1 - 34} |0|!_A = 3 partial status: pi(inc#) = [1] pi(s) = [1] pi(half) = [] pi(|0|) = [] The following rules are removed: p1 Then no dependency pair remains.