(0) Obligation:

Clauses:

goal(X) :- ','(s2t(X, T), tree(T)).
tree(nil).
tree(X) :- ','(no(empty(X)), ','(left(T, L), ','(right(T, R), ','(tree(L), tree(R))))).
s2t(0, nil).
s2t(X, node(T, X1, T)) :- ','(no(zero(X)), ','(p(X, P), s2t(P, T))).
s2t(X, node(nil, X2, T)) :- ','(no(zero(X)), ','(p(X, P), s2t(P, T))).
s2t(X, node(T, X3, nil)) :- ','(no(zero(X)), ','(p(X, P), s2t(P, T))).
s2t(X, node(nil, X4, nil)) :- no(zero(X)).
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).
empty(nil).
zero(0).
no(X) :- ','(X, ','(!, failure(a))).
no(X9).
failure(b).

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:

f1_in(T4) → U1(f9_in(T4), T4)
U1(f9_out1, T4) → f1_out1
f28_in(0) → f28_out1
f28_in(s(T19)) → U2(f28_in(T19), s(T19))
U2(f28_out1, s(T19)) → f28_out1
f28_in(s(T33)) → U3(f28_in(T33), s(T33))
U3(f28_out1, s(T33)) → f28_out1
f28_in(s(T47)) → U4(f28_in(T47), s(T47))
U4(f28_out1, s(T47)) → f28_out1
f28_in(T56) → f28_out1
f398_inf398_out1
f446_inf446_out1
f29_inf29_out1
f29_inU5(f391_in)
U5(f391_out1) → f29_out1
f29_inU6(f438_in)
U6(f438_out1) → f29_out1
f9_in(T4) → U7(f28_in(T4), T4)
U7(f28_out1, T4) → U8(f29_in, T4)
U8(f29_out1, T4) → f9_out1
f391_inU9(f398_in)
U9(f398_out1) → U10(f398_in)
U10(f398_out1) → f391_out1
f438_inU11(f446_in)
U11(f446_out1) → U12(f446_in)
U12(f446_out1) → f438_out1

Q is empty.

(3) QTRSRRRProof (EQUIVALENT transformation)

Used ordering:
Combined order from the following AFS and order.
f1_in(x1)  =  f1_in(x1)
U1(x1, x2)  =  U1(x1, x2)
f9_in(x1)  =  f9_in(x1)
f9_out1  =  f9_out1
f1_out1  =  f1_out1
f28_in(x1)  =  f28_in(x1)
0  =  0
f28_out1  =  f28_out1
s(x1)  =  s(x1)
U2(x1, x2)  =  U2(x1, x2)
U3(x1, x2)  =  U3(x1, x2)
U4(x1, x2)  =  U4(x1, x2)
f398_in  =  f398_in
f398_out1  =  f398_out1
f446_in  =  f446_in
f446_out1  =  f446_out1
f29_in  =  f29_in
f29_out1  =  f29_out1
U5(x1)  =  U5(x1)
f391_in  =  f391_in
f391_out1  =  f391_out1
U6(x1)  =  x1
f438_in  =  f438_in
f438_out1  =  f438_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:
f1in1 > U12 > f1out1
f1in1 > f9in1 > [f28in1, s1] > U22 > f28out1
f1in1 > f9in1 > [f28in1, s1] > U32
f1in1 > f9in1 > [f28in1, s1] > U42 > f28out1
f1in1 > f9in1 > [f29in, U72] > U51 > [f29out1, f391out1, f438out1]
f1in1 > f9in1 > [f29in, U72] > f391in > [f398in, U91] > f398out1 > [f29out1, f391out1, f438out1]
f1in1 > f9in1 > [f29in, U72] > f438in > U111 > f446in > f446out1 > [f29out1, f391out1, f438out1]
f1in1 > f9in1 > [f29in, U72] > U82 > f9out1 > f1out1
0 > f28out1

Status:
f1in1: multiset
U12: [2,1]
f9in1: [1]
f9out1: multiset
f1out1: multiset
f28in1: multiset
0: multiset
f28out1: multiset
s1: multiset
U22: multiset
U32: multiset
U42: multiset
f398in: multiset
f398out1: multiset
f446in: multiset
f446out1: multiset
f29in: multiset
f29out1: multiset
U51: multiset
f391in: multiset
f391out1: multiset
f438in: multiset
f438out1: 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:

f1_in(T4) → U1(f9_in(T4), T4)
U1(f9_out1, T4) → f1_out1
f28_in(0) → f28_out1
f28_in(s(T19)) → U2(f28_in(T19), s(T19))
U2(f28_out1, s(T19)) → f28_out1
f28_in(s(T33)) → U3(f28_in(T33), s(T33))
U3(f28_out1, s(T33)) → f28_out1
f28_in(s(T47)) → U4(f28_in(T47), s(T47))
U4(f28_out1, s(T47)) → f28_out1
f28_in(T56) → f28_out1
f398_inf398_out1
f446_inf446_out1
f29_inf29_out1
f29_inU5(f391_in)
U5(f391_out1) → f29_out1
f29_inU6(f438_in)
f9_in(T4) → U7(f28_in(T4), T4)
U7(f28_out1, T4) → U8(f29_in, T4)
U8(f29_out1, T4) → f9_out1
f391_inU9(f398_in)
U9(f398_out1) → U10(f398_in)
U10(f398_out1) → f391_out1
f438_inU11(f446_in)
U11(f446_out1) → U12(f446_in)
U12(f446_out1) → f438_out1


(4) Obligation:

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

U6(f438_out1) → f29_out1

Q is empty.

(5) QTRSRRRProof (EQUIVALENT transformation)

Used ordering:
Combined order from the following AFS and order.
U6(x1)  =  x1
f438_out1  =  f438_out1
f29_out1  =  f29_out1

Recursive path order with status [RPO].
Quasi-Precedence:
f438out1 > f29out1

Status:
f438out1: multiset
f29out1: multiset

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

U6(f438_out1) → f29_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