YES

We show the termination of the TRS R:

  s(a()) -> a()
  s(s(x)) -> x
  s(f(x,y)) -> f(s(y),s(x))
  s(g(x,y)) -> g(s(x),s(y))
  f(x,a()) -> x
  f(a(),y) -> y
  f(g(x,y),g(u,v)) -> g(f(x,u),f(y,v))
  g(a(),a()) -> a()

-- SCC decomposition.

Consider the dependency pair problem (P, R), where P consists of

p1: s#(f(x,y)) -> f#(s(y),s(x))
p2: s#(f(x,y)) -> s#(y)
p3: s#(f(x,y)) -> s#(x)
p4: s#(g(x,y)) -> g#(s(x),s(y))
p5: s#(g(x,y)) -> s#(x)
p6: s#(g(x,y)) -> s#(y)
p7: f#(g(x,y),g(u,v)) -> g#(f(x,u),f(y,v))
p8: f#(g(x,y),g(u,v)) -> f#(x,u)
p9: f#(g(x,y),g(u,v)) -> f#(y,v)

and R consists of:

r1: s(a()) -> a()
r2: s(s(x)) -> x
r3: s(f(x,y)) -> f(s(y),s(x))
r4: s(g(x,y)) -> g(s(x),s(y))
r5: f(x,a()) -> x
r6: f(a(),y) -> y
r7: f(g(x,y),g(u,v)) -> g(f(x,u),f(y,v))
r8: g(a(),a()) -> a()

The estimated dependency graph contains the following SCCs:

  {p2, p3, p5, p6}
  {p8, p9}


-- Reduction pair.

Consider the dependency pair problem (P, R), where P consists of

p1: s#(g(x,y)) -> s#(y)
p2: s#(g(x,y)) -> s#(x)
p3: s#(f(x,y)) -> s#(x)
p4: s#(f(x,y)) -> s#(y)

and R consists of:

r1: s(a()) -> a()
r2: s(s(x)) -> x
r3: s(f(x,y)) -> f(s(y),s(x))
r4: s(g(x,y)) -> g(s(x),s(y))
r5: f(x,a()) -> x
r6: f(a(),y) -> y
r7: f(g(x,y),g(u,v)) -> g(f(x,u),f(y,v))
r8: g(a(),a()) -> a()

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:
        s#_A(x1) = ((1,1),(1,1)) x1
        g_A(x1,x2) = ((1,1),(1,1)) x1 + ((1,1),(1,1)) x2 + (1,1)
        f_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:
        s#_A(x1) = ((1,0),(1,1)) x1
        g_A(x1,x2) = ((1,1),(1,1)) x1 + ((1,1),(1,1)) x2 + (1,1)
        f_A(x1,x2) = ((1,1),(1,1)) x1 + ((1,1),(1,1)) x2 + (1,1)
    

The next rules are strictly ordered:

  p1, p2, p3, p4
  r1, r2, r3, r4, r5, r6, r7, r8

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: f#(g(x,y),g(u,v)) -> f#(y,v)
p2: f#(g(x,y),g(u,v)) -> f#(x,u)

and R consists of:

r1: s(a()) -> a()
r2: s(s(x)) -> x
r3: s(f(x,y)) -> f(s(y),s(x))
r4: s(g(x,y)) -> g(s(x),s(y))
r5: f(x,a()) -> x
r6: f(a(),y) -> y
r7: f(g(x,y),g(u,v)) -> g(f(x,u),f(y,v))
r8: g(a(),a()) -> a()

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

The next rules are strictly ordered:

  p1, p2

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