YES

We show the termination of the TRS R:

  a(f(),a(f(),x)) -> a(x,x)
  a(h(),x) -> a(f(),a(g(),a(f(),x)))

-- SCC decomposition.

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

p1: a#(f(),a(f(),x)) -> a#(x,x)
p2: a#(h(),x) -> a#(f(),a(g(),a(f(),x)))
p3: a#(h(),x) -> a#(g(),a(f(),x))
p4: a#(h(),x) -> a#(f(),x)

and R consists of:

r1: a(f(),a(f(),x)) -> a(x,x)
r2: a(h(),x) -> a(f(),a(g(),a(f(),x)))

The estimated dependency graph contains the following SCCs:

  {p1, p4}


-- Reduction pair.

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

p1: a#(f(),a(f(),x)) -> a#(x,x)
p2: a#(h(),x) -> a#(f(),x)

and R consists of:

r1: a(f(),a(f(),x)) -> a(x,x)
r2: a(h(),x) -> a(f(),a(g(),a(f(),x)))

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

The next rules are strictly ordered:

  p1

We remove them from the problem.

-- SCC decomposition.

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

p1: a#(h(),x) -> a#(f(),x)

and R consists of:

r1: a(f(),a(f(),x)) -> a(x,x)
r2: a(h(),x) -> a(f(),a(g(),a(f(),x)))

The estimated dependency graph contains the following SCCs:

  (no SCCs)