YES

We show the termination of the TRS R:

  f(a,empty()) -> g(a,empty())
  f(a,cons(x,k)) -> f(cons(x,a),k)
  g(empty(),d) -> d
  g(cons(x,k),d) -> g(k,cons(x,d))

-- SCC decomposition.

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

p1: f#(a,empty()) -> g#(a,empty())
p2: f#(a,cons(x,k)) -> f#(cons(x,a),k)
p3: g#(cons(x,k),d) -> g#(k,cons(x,d))

and R consists of:

r1: f(a,empty()) -> g(a,empty())
r2: f(a,cons(x,k)) -> f(cons(x,a),k)
r3: g(empty(),d) -> d
r4: g(cons(x,k),d) -> g(k,cons(x,d))

The estimated dependency graph contains the following SCCs:

  {p2}
  {p3}


-- Reduction pair.

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

p1: f#(a,cons(x,k)) -> f#(cons(x,a),k)

and R consists of:

r1: f(a,empty()) -> g(a,empty())
r2: f(a,cons(x,k)) -> f(cons(x,a),k)
r3: g(empty(),d) -> d
r4: g(cons(x,k),d) -> g(k,cons(x,d))

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

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: g#(cons(x,k),d) -> g#(k,cons(x,d))

and R consists of:

r1: f(a,empty()) -> g(a,empty())
r2: f(a,cons(x,k)) -> f(cons(x,a),k)
r3: g(empty(),d) -> d
r4: g(cons(x,k),d) -> g(k,cons(x,d))

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

The next rules are strictly ordered:

  p1

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