YES We show the termination of the TRS R: +(|0|(),y) -> y +(s(x),y) -> s(+(x,y)) ++(nil(),ys) -> ys ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) sum(|:|(x,nil())) -> |:|(x,nil()) sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) -(x,|0|()) -> x -(|0|(),s(y)) -> |0|() -(s(x),s(y)) -> -(x,y) quot(|0|(),s(y)) -> |0|() quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) length(nil()) -> |0|() length(|:|(x,xs)) -> s(length(xs)) hd(|:|(x,xs)) -> x avg(xs) -> quot(hd(sum(xs)),length(xs)) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: +#(s(x),y) -> +#(x,y) p2: ++#(|:|(x,xs),ys) -> ++#(xs,ys) p3: sum#(|:|(x,|:|(y,xs))) -> sum#(|:|(+(x,y),xs)) p4: sum#(|:|(x,|:|(y,xs))) -> +#(x,y) p5: sum#(++(xs,|:|(x,|:|(y,ys)))) -> sum#(++(xs,sum(|:|(x,|:|(y,ys))))) p6: sum#(++(xs,|:|(x,|:|(y,ys)))) -> ++#(xs,sum(|:|(x,|:|(y,ys)))) p7: sum#(++(xs,|:|(x,|:|(y,ys)))) -> sum#(|:|(x,|:|(y,ys))) p8: -#(s(x),s(y)) -> -#(x,y) p9: quot#(s(x),s(y)) -> quot#(-(x,y),s(y)) p10: quot#(s(x),s(y)) -> -#(x,y) p11: length#(|:|(x,xs)) -> length#(xs) p12: avg#(xs) -> quot#(hd(sum(xs)),length(xs)) p13: avg#(xs) -> hd#(sum(xs)) p14: avg#(xs) -> sum#(xs) p15: avg#(xs) -> length#(xs) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The estimated dependency graph contains the following SCCs: {p5} {p3} {p1} {p2} {p9} {p8} {p11} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: sum#(++(xs,|:|(x,|:|(y,ys)))) -> sum#(++(xs,sum(|:|(x,|:|(y,ys))))) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of r1, r2, r3, r4, r5, r6 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: matrix interpretations: carrier: N^2 order: standard order interpretations: sum#_A(x1) = ((1,0),(0,0)) x1 + (1,8) ++_A(x1,x2) = x1 + ((1,1),(1,1)) x2 + (1,4) |:|_A(x1,x2) = ((0,0),(1,0)) x2 + (4,3) sum_A(x1) = ((1,0),(1,0)) x1 + (1,0) +_A(x1,x2) = x2 |0|_A() = (1,1) s_A(x1) = (0,0) nil_A() = (1,1) precedence: sum# = ++ = |:| = sum = + = |0| = s = nil partial status: pi(sum#) = [] pi(++) = [] pi(|:|) = [] pi(sum) = [] pi(+) = [] pi(|0|) = [] pi(s) = [] pi(nil) = [] 2. weighted path order base order: matrix interpretations: carrier: N^2 order: standard order interpretations: sum#_A(x1) = ((0,1),(0,0)) x1 + (3,3) ++_A(x1,x2) = x1 + ((1,0),(0,0)) x2 + (3,1) |:|_A(x1,x2) = (2,2) sum_A(x1) = ((0,0),(1,0)) x1 + (3,2) +_A(x1,x2) = x2 + (4,0) |0|_A() = (1,1) s_A(x1) = (1,0) nil_A() = (1,1) precedence: + > sum = s = nil > |0| > ++ = |:| > sum# partial status: pi(sum#) = [] pi(++) = [1] pi(|:|) = [] pi(sum) = [] pi(+) = [2] pi(|0|) = [] pi(s) = [] pi(nil) = [] 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: sum#(|:|(x,|:|(y,xs))) -> sum#(|:|(+(x,y),xs)) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of r1, r2 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: sum#_A(x1) = x1 + 9 |:|_A(x1,x2) = x2 + 2 +_A(x1,x2) = max{x1 + 8, x2 + 8} |0|_A = 0 s_A(x1) = max{7, x1} precedence: sum# = |:| = + > |0| = s partial status: pi(sum#) = [] pi(|:|) = [2] pi(+) = [1, 2] pi(|0|) = [] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: sum#_A(x1) = 19 |:|_A(x1,x2) = max{11, x2 + 7} +_A(x1,x2) = max{12, x1 - 2, x2 + 1} |0|_A = 0 s_A(x1) = max{13, x1 + 1} precedence: sum# = |:| = + = |0| = s partial status: pi(sum#) = [] pi(|:|) = [2] pi(+) = [] pi(|0|) = [] pi(s) = [1] 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: +#(s(x),y) -> +#(x,y) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: +#_A(x1,x2) = max{2, x1 + 1, x2} s_A(x1) = max{1, x1} precedence: +# = s partial status: pi(+#) = [1, 2] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: +#_A(x1,x2) = max{x1 - 1, x2 + 1} s_A(x1) = x1 precedence: +# = s partial status: pi(+#) = [] pi(s) = [1] 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: ++#(|:|(x,xs),ys) -> ++#(xs,ys) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: ++#_A(x1,x2) = max{x1 + 1, x2} |:|_A(x1,x2) = max{x1 - 1, x2} precedence: ++# = |:| partial status: pi(++#) = [1, 2] pi(|:|) = [2] 2. weighted path order base order: max/plus interpretations on natural numbers: ++#_A(x1,x2) = max{x1 - 1, x2 + 1} |:|_A(x1,x2) = x2 precedence: ++# = |:| partial status: pi(++#) = [] 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: quot#(s(x),s(y)) -> quot#(-(x,y),s(y)) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of r8, r9, r10 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: quot#_A(x1,x2) = max{8, x1 + 7} s_A(x1) = x1 + 5 -_A(x1,x2) = x1 + 4 |0|_A = 4 precedence: quot# = s = |0| > - partial status: pi(quot#) = [] pi(s) = [] pi(-) = [1] pi(|0|) = [] 2. weighted path order base order: max/plus interpretations on natural numbers: quot#_A(x1,x2) = 1 s_A(x1) = 0 -_A(x1,x2) = max{4, x1} |0|_A = 5 precedence: quot# = - = |0| > s partial status: pi(quot#) = [] pi(s) = [] pi(-) = [1] pi(|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: -#(s(x),s(y)) -> -#(x,y) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: -#_A(x1,x2) = max{2, x1 - 1, x2 + 1} s_A(x1) = max{1, x1} precedence: -# = s partial status: pi(-#) = [2] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: -#_A(x1,x2) = 0 s_A(x1) = max{2, x1} precedence: -# = s partial status: pi(-#) = [] pi(s) = [1] 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: length#(|:|(x,xs)) -> length#(xs) and R consists of: r1: +(|0|(),y) -> y r2: +(s(x),y) -> s(+(x,y)) r3: ++(nil(),ys) -> ys r4: ++(|:|(x,xs),ys) -> |:|(x,++(xs,ys)) r5: sum(|:|(x,nil())) -> |:|(x,nil()) r6: sum(|:|(x,|:|(y,xs))) -> sum(|:|(+(x,y),xs)) r7: sum(++(xs,|:|(x,|:|(y,ys)))) -> sum(++(xs,sum(|:|(x,|:|(y,ys))))) r8: -(x,|0|()) -> x r9: -(|0|(),s(y)) -> |0|() r10: -(s(x),s(y)) -> -(x,y) r11: quot(|0|(),s(y)) -> |0|() r12: quot(s(x),s(y)) -> s(quot(-(x,y),s(y))) r13: length(nil()) -> |0|() r14: length(|:|(x,xs)) -> s(length(xs)) r15: hd(|:|(x,xs)) -> x r16: avg(xs) -> quot(hd(sum(xs)),length(xs)) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: length#_A(x1) = x1 + 2 |:|_A(x1,x2) = max{x1 + 2, x2 + 2} precedence: |:| > length# partial status: pi(length#) = [1] pi(|:|) = [1, 2] 2. weighted path order base order: max/plus interpretations on natural numbers: length#_A(x1) = x1 + 3 |:|_A(x1,x2) = max{x1 - 1, x2} precedence: length# = |:| partial status: pi(length#) = [] pi(|:|) = [2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.