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. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        sum#_A(x1) = ((0,1),(0,0)) x1
        ++_A(x1,x2) = ((1,1),(1,1)) x1 + x2 + (1,1)
        |:|_A(x1,x2) = x2 + (1,2)
        sum_A(x1) = ((0,1),(0,0)) x1 + (0,3)
        +_A(x1,x2) = ((0,0),(1,1)) x1 + x2 + (2,1)
        |0|_A() = (1,1)
        s_A(x1) = (1,1)
        nil_A() = (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        sum#_A(x1) = (0,0)
        ++_A(x1,x2) = x1 + (3,1)
        |:|_A(x1,x2) = ((0,1),(0,0)) x2 + (1,2)
        sum_A(x1) = (3,1)
        +_A(x1,x2) = (1,1)
        |0|_A() = (1,1)
        s_A(x1) = (2,2)
        nil_A() = (1,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: 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. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        sum#_A(x1) = x1
        |:|_A(x1,x2) = ((1,0),(1,1)) x1 + x2 + (2,1)
        +_A(x1,x2) = x1 + ((1,0),(1,1)) x2 + (1,1)
        |0|_A() = (1,0)
        s_A(x1) = ((1,0),(1,0)) x1 + (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        sum#_A(x1) = ((1,0),(1,0)) x1
        |:|_A(x1,x2) = ((1,1),(0,0)) x1 + x2 + (0,1)
        +_A(x1,x2) = ((0,1),(1,0)) x1 + (1,0)
        |0|_A() = (1,1)
        s_A(x1) = ((0,1),(1,0)) x1 + (2,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 monotone reduction pair:

  lexicographic combination of reduction pairs:
  
    1. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        +#_A(x1,x2) = ((1,0),(1,1)) x1 + x2
        s_A(x1) = ((1,1),(1,1)) x1 + (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        +#_A(x1,x2) = ((1,1),(1,1)) x1 + x2
        s_A(x1) = ((1,1),(1,1)) x1 + (1,1)
    

The next rules are strictly ordered:

  p1
  r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16

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. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        ++#_A(x1,x2) = ((1,1),(1,1)) x1 + x2
        |:|_A(x1,x2) = ((1,1),(1,1)) x1 + ((1,1),(1,1)) x2 + (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        ++#_A(x1,x2) = ((0,1),(1,0)) x1 + x2
        |:|_A(x1,x2) = ((0,1),(0,1)) x1 + ((0,0),(1,0)) x2 + (1,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: 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. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        quot#_A(x1,x2) = x1 + x2
        s_A(x1) = x1 + (2,1)
        -_A(x1,x2) = ((1,0),(1,1)) x1 + (1,1)
        |0|_A() = (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        quot#_A(x1,x2) = x1 + x2
        s_A(x1) = x1 + (2,1)
        -_A(x1,x2) = ((0,0),(1,0)) x1 + (1,2)
        |0|_A() = (2,5)
    

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. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        -#_A(x1,x2) = ((1,1),(1,0)) x1 + ((1,1),(1,1)) x2
        s_A(x1) = ((1,1),(1,1)) x1 + (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        -#_A(x1,x2) = ((0,0),(1,0)) x1 + ((1,1),(0,1)) x2
        s_A(x1) = ((0,1),(1,1)) x1 + (1,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. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        length#_A(x1) = ((1,1),(1,0)) x1
        |:|_A(x1,x2) = ((1,1),(1,1)) x1 + ((1,1),(1,1)) x2 + (1,1)
    
    2. matrix interpretations:
    
      carrier: N^2
      order: standard order
      interpretations:
        length#_A(x1) = ((0,1),(1,0)) x1
        |:|_A(x1,x2) = ((1,1),(0,1)) x1 + ((1,1),(1,1)) x2 + (1,1)
    

The next rules are strictly ordered:

  p1

We remove them from the problem.  Then no dependency pair remains.