(0) Obligation:

Clauses:

goal(X) :- ','(s2t(X, T), tree(T)).
tree(nil) :- !.
tree(X) :- ','(left(T, L), ','(right(T, R), ','(tree(L), tree(R)))).
s2t(0, L) :- ','(!, eq(L, nil)).
s2t(X, node(T, X1, T)) :- ','(p(X, P), s2t(P, T)).
s2t(X, node(nil, X2, T)) :- ','(p(X, P), s2t(P, T)).
s2t(X, node(T, X3, nil)) :- ','(p(X, P), s2t(P, T)).
s2t(X, node(nil, X4, nil)).
left(nil, nil).
left(node(L, X5, X6), L).
right(nil, nil).
right(node(X7, X8, R), R).
p(0, 0).
p(s(X), X).
eq(X, X).

Query: goal(g)

(1) PrologToTRSTransformerProof (SOUND transformation)

Transformed Prolog program to TRS.

(2) Obligation:

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

f3_in(T4) → U1(f9_in(T4), T4)
U1(f9_out1, T4) → f3_out1
f18_in(0) → f18_out1
f18_in(s(T13)) → U2(f18_in(T13), s(T13))
U2(f18_out1, s(T13)) → f18_out1
f18_in(s(T21)) → U3(f18_in(T21), s(T21))
U3(f18_out1, s(T21)) → f18_out1
f18_in(s(T29)) → U4(f18_in(T29), s(T29))
U4(f18_out1, s(T29)) → f18_out1
f18_in(T32) → f18_out1
f137_inf137_out1
f165_inf165_out1
f20_inf20_out1
f20_inU5(f133_in)
U5(f133_out1) → f20_out1
f20_inU6(f160_in)
U6(f160_out1) → f20_out1
f9_in(T4) → U7(f18_in(T4), T4)
U7(f18_out1, T4) → U8(f20_in, T4)
U8(f20_out1, T4) → f9_out1
f133_inU9(f137_in)
U9(f137_out1) → U10(f137_in)
U10(f137_out1) → f133_out1
f160_inU11(f165_in)
U11(f165_out1) → U12(f165_in)
U12(f165_out1) → f160_out1

Q is empty.

(3) QTRSRRRProof (EQUIVALENT transformation)

Used ordering:
Combined order from the following AFS and order.
f3_in(x1)  =  f3_in(x1)
U1(x1, x2)  =  U1(x1, x2)
f9_in(x1)  =  f9_in(x1)
f9_out1  =  f9_out1
f3_out1  =  f3_out1
f18_in(x1)  =  f18_in(x1)
0  =  0
f18_out1  =  f18_out1
s(x1)  =  s(x1)
U2(x1, x2)  =  U2(x1, x2)
U3(x1, x2)  =  U3(x1, x2)
U4(x1, x2)  =  U4(x1, x2)
f137_in  =  f137_in
f137_out1  =  f137_out1
f165_in  =  f165_in
f165_out1  =  f165_out1
f20_in  =  f20_in
f20_out1  =  f20_out1
U5(x1)  =  U5(x1)
f133_in  =  f133_in
f133_out1  =  f133_out1
U6(x1)  =  x1
f160_in  =  f160_in
f160_out1  =  f160_out1
U7(x1, x2)  =  U7(x1, x2)
U8(x1, x2)  =  U8(x1, x2)
U9(x1)  =  U9(x1)
U10(x1)  =  x1
U11(x1)  =  U11(x1)
U12(x1)  =  x1

Recursive path order with status [RPO].
Quasi-Precedence:
f3in1 > U12 > f3out1
f3in1 > f9in1 > [f18in1, s1] > U22 > f18out1
f3in1 > f9in1 > [f18in1, s1] > U32
f3in1 > f9in1 > [f18in1, s1] > U42 > f18out1
f3in1 > f9in1 > [f20in, U72] > U51 > [f20out1, f133out1, f160out1]
f3in1 > f9in1 > [f20in, U72] > f133in > [f137in, U91] > f137out1 > [f20out1, f133out1, f160out1]
f3in1 > f9in1 > [f20in, U72] > f160in > U111 > f165in > f165out1 > [f20out1, f133out1, f160out1]
f3in1 > f9in1 > [f20in, U72] > U82 > f9out1 > f3out1
0 > f18out1

Status:
f3in1: multiset
U12: [2,1]
f9in1: [1]
f9out1: multiset
f3out1: multiset
f18in1: multiset
0: multiset
f18out1: multiset
s1: multiset
U22: multiset
U32: multiset
U42: multiset
f137in: multiset
f137out1: multiset
f165in: multiset
f165out1: multiset
f20in: multiset
f20out1: multiset
U51: multiset
f133in: multiset
f133out1: multiset
f160in: multiset
f160out1: multiset
U72: [1,2]
U82: multiset
U91: multiset
U111: multiset

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

f3_in(T4) → U1(f9_in(T4), T4)
U1(f9_out1, T4) → f3_out1
f18_in(0) → f18_out1
f18_in(s(T13)) → U2(f18_in(T13), s(T13))
U2(f18_out1, s(T13)) → f18_out1
f18_in(s(T21)) → U3(f18_in(T21), s(T21))
U3(f18_out1, s(T21)) → f18_out1
f18_in(s(T29)) → U4(f18_in(T29), s(T29))
U4(f18_out1, s(T29)) → f18_out1
f18_in(T32) → f18_out1
f137_inf137_out1
f165_inf165_out1
f20_inf20_out1
f20_inU5(f133_in)
U5(f133_out1) → f20_out1
f20_inU6(f160_in)
f9_in(T4) → U7(f18_in(T4), T4)
U7(f18_out1, T4) → U8(f20_in, T4)
U8(f20_out1, T4) → f9_out1
f133_inU9(f137_in)
U9(f137_out1) → U10(f137_in)
U10(f137_out1) → f133_out1
f160_inU11(f165_in)
U11(f165_out1) → U12(f165_in)
U12(f165_out1) → f160_out1


(4) Obligation:

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

U6(f160_out1) → f20_out1

Q is empty.

(5) QTRSRRRProof (EQUIVALENT transformation)

Used ordering:
Polynomial interpretation [POLO]:

POL(U6(x1)) = 2·x1   
POL(f160_out1) = 2   
POL(f20_out1) = 2   
With this ordering the following rules can be removed by the rule removal processor [LPAR04] because they are oriented strictly:

U6(f160_out1) → f20_out1


(6) Obligation:

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

(7) RisEmptyProof (EQUIVALENT transformation)

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

(8) YES