(0) Obligation:

Clauses:

f(0, Y, 0).
f(s(X), Y, Z) :- ','(f(X, Y, U), f(U, Y, Z)).

Query: f(g,a,a)

(1) PrologToTRSTransformerProof (SOUND transformation)

Transformed Prolog program to TRS.

(2) Obligation:

Q restricted rewrite system:
The TRS R consists of the following rules:

f1_in(0) → f1_out1(0)
f1_in(s(T15)) → U1(f16_in(T15), s(T15))
U1(f16_out1(X16, T19), s(T15)) → f1_out1(T19)
f35_in(0) → f35_out1(0)
f35_in(s(T36)) → U2(f59_in(T36), s(T36))
U2(f59_out1(X38, X39), s(T36)) → f35_out1(X39)
f16_in(T15) → U3(f35_in(T15), T15)
U3(f35_out1(T22), T15) → U4(f1_in(T22), T15, T22)
U4(f1_out1(T24), T15, T22) → f16_out1(T22, T24)
f59_in(T36) → U5(f35_in(T36), T36)
U5(f35_out1(T41), T36) → U6(f35_in(T41), T36, T41)
U6(f35_out1(X39), T36, T41) → f59_out1(T41, X39)

Q is empty.

(3) QTRSRRRProof (EQUIVALENT transformation)

Used ordering:
Combined order from the following AFS and order.
f1_in(x1)  =  f1_in(x1)
0  =  0
f1_out1(x1)  =  f1_out1(x1)
s(x1)  =  s(x1)
U1(x1, x2)  =  U1(x1, x2)
f16_in(x1)  =  f16_in(x1)
f16_out1(x1, x2)  =  f16_out1(x1, x2)
f35_in(x1)  =  f35_in(x1)
f35_out1(x1)  =  x1
U2(x1, x2)  =  U2(x1, x2)
f59_in(x1)  =  f59_in(x1)
f59_out1(x1, x2)  =  f59_out1(x1, x2)
U3(x1, x2)  =  U3(x1, x2)
U4(x1, x2, x3)  =  U4(x1, x2, x3)
U5(x1, x2)  =  U5(x1, x2)
U6(x1, x2, x3)  =  U6(x1, x2, x3)

Recursive path order with status [RPO].
Quasi-Precedence:
[s1, f16in1] > [f1in1, U32] > 0 > f59out12
[s1, f16in1] > [f1in1, U32] > [f1out11, U12] > f16out12 > f59out12
[s1, f16in1] > [f1in1, U32] > U43 > f16out12 > f59out12
[s1, f16in1] > f59in1 > U52 > [f35in1, U22] > f59out12
[s1, f16in1] > f59in1 > U52 > U63 > f59out12

Status:
f1in1: multiset
0: multiset
f1out11: multiset
s1: [1]
U12: multiset
f16in1: [1]
f16out12: multiset
f35in1: [1]
U22: [1,2]
f59in1: multiset
f59out12: [1,2]
U32: multiset
U43: multiset
U52: [1,2]
U63: [1,2,3]

With this ordering the following rules can be removed by the rule removal processor [LPAR04] because they are oriented strictly:

f1_in(0) → f1_out1(0)
f1_in(s(T15)) → U1(f16_in(T15), s(T15))
U1(f16_out1(X16, T19), s(T15)) → f1_out1(T19)
f35_in(0) → f35_out1(0)
f35_in(s(T36)) → U2(f59_in(T36), s(T36))
U2(f59_out1(X38, X39), s(T36)) → f35_out1(X39)
f16_in(T15) → U3(f35_in(T15), T15)
U3(f35_out1(T22), T15) → U4(f1_in(T22), T15, T22)
U4(f1_out1(T24), T15, T22) → f16_out1(T22, T24)
f59_in(T36) → U5(f35_in(T36), T36)
U5(f35_out1(T41), T36) → U6(f35_in(T41), T36, T41)
U6(f35_out1(X39), T36, T41) → f59_out1(T41, X39)


(4) Obligation:

Q restricted rewrite system:
R is empty.
Q is empty.

(5) RisEmptyProof (EQUIVALENT transformation)

The TRS R is empty. Hence, termination is trivially proven.

(6) YES