YES

We show the termination of the relative TRS R/S:

  R:
  t(f(x),g(y),f(z)) -> t(z,g(x),g(y))
  t(g(x),g(y),f(z)) -> t(f(y),f(z),x)

  S:
  f(g(x)) -> g(f(x))
  g(f(x)) -> f(g(x))
  f(f(x)) -> g(g(x))
  g(g(x)) -> f(f(x))

-- SCC decomposition.

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

p1: t#(f(x),g(y),f(z)) -> t#(z,g(x),g(y))
p2: t#(g(x),g(y),f(z)) -> t#(f(y),f(z),x)

and R consists of:

r1: t(f(x),g(y),f(z)) -> t(z,g(x),g(y))
r2: t(g(x),g(y),f(z)) -> t(f(y),f(z),x)
r3: f(g(x)) -> g(f(x))
r4: g(f(x)) -> f(g(x))
r5: f(f(x)) -> g(g(x))
r6: g(g(x)) -> f(f(x))

The estimated dependency graph contains the following SCCs:

  {p1, p2}


-- Reduction pair.

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

p1: t#(f(x),g(y),f(z)) -> t#(z,g(x),g(y))
p2: t#(g(x),g(y),f(z)) -> t#(f(y),f(z),x)

and R consists of:

r1: t(f(x),g(y),f(z)) -> t(z,g(x),g(y))
r2: t(g(x),g(y),f(z)) -> t(f(y),f(z),x)
r3: f(g(x)) -> g(f(x))
r4: g(f(x)) -> f(g(x))
r5: f(f(x)) -> g(g(x))
r6: g(g(x)) -> f(f(x))

The set of usable rules consists of

  r1, r2, r3, r4, r5, r6

Take the monotone reduction pair:

  matrix interpretations:
  
    carrier: N^1
    order: standard order
    interpretations:
      t#_A(x1,x2,x3) = x1 + x2 + x3
      f_A(x1) = x1 + 1
      g_A(x1) = x1 + 1
      t_A(x1,x2,x3) = x1 + x2 + x3

The next rules are strictly ordered:

  p1, p2
  r1, r2

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