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 reduction pair:

  lexicographic combination of reduction pairs:
  
    1. lexicographic path order with precedence:
    
      precedence:
      
        g > s# > f
      
      argument filter:
    
        pi(s#) = [1]
        pi(g) = [1, 2]
        pi(f) = [1, 2]
    
    2. lexicographic path order with precedence:
    
      precedence:
      
        f > s# > g
      
      argument filter:
    
        pi(s#) = [1]
        pi(g) = 1
        pi(f) = [1]
    

The next rules are strictly ordered:

  p1, p2, p3, p4

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. lexicographic path order with precedence:
    
      precedence:
      
        g > f#
      
      argument filter:
    
        pi(f#) = 1
        pi(g) = [1, 2]
    
    2. lexicographic path order with precedence:
    
      precedence:
      
        g > f#
      
      argument filter:
    
        pi(f#) = [1]
        pi(g) = []
    

The next rules are strictly ordered:

  p1, p2

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