(0) Obligation:

Clauses:

h(X) :- ','(f(X), g(X)).
f(c(0, X1)) :- !.
f(c(X, Y)) :- ','(p(X, P), f(c(P, s(Y)))).
g(c(X2, 0)) :- !.
g(c(X, Y)) :- ','(p(Y, P), g(c(s(X), P))).
p(0, 0).
p(s(X), X).

Queries:

h(g).

(1) PrologToPrologProblemTransformerProof (SOUND transformation)

Built Prolog problem from termination graph.

(2) Obligation:

Clauses:

f4(c(0, T3)).
f4(c(s(T6), T5)) :- f4(c(T6, s(T5))).
g5(c(T7, 0)).
g5(c(T8, s(T10))) :- g5(c(s(T8), T10)).
h1(T2) :- f4(T2).
h1(c(T7, 0)) :- f4(c(T7, 0)).
h1(c(T8, s(T10))) :- ','(f4(c(T8, s(T10))), g5(c(s(T8), T10))).

Queries:

h1(g).

(3) PrologToPiTRSProof (SOUND transformation)

We use the technique of [LOPSTR]. With regard to the inferred argument filtering the predicates were used in the following modes:
h1_in: (b)
f4_in: (b)
g5_in: (b)
Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

h1_in_g(T2) → U3_g(T2, f4_in_g(T2))
f4_in_g(c(0, T3)) → f4_out_g(c(0, T3))
f4_in_g(c(s(T6), T5)) → U1_g(T6, T5, f4_in_g(c(T6, s(T5))))
U1_g(T6, T5, f4_out_g(c(T6, s(T5)))) → f4_out_g(c(s(T6), T5))
U3_g(T2, f4_out_g(T2)) → h1_out_g(T2)
h1_in_g(c(T7, 0)) → U4_g(T7, f4_in_g(c(T7, 0)))
U4_g(T7, f4_out_g(c(T7, 0))) → h1_out_g(c(T7, 0))
h1_in_g(c(T8, s(T10))) → U5_g(T8, T10, f4_in_g(c(T8, s(T10))))
U5_g(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_g(T8, T10, g5_in_g(c(s(T8), T10)))
g5_in_g(c(T7, 0)) → g5_out_g(c(T7, 0))
g5_in_g(c(T8, s(T10))) → U2_g(T8, T10, g5_in_g(c(s(T8), T10)))
U2_g(T8, T10, g5_out_g(c(s(T8), T10))) → g5_out_g(c(T8, s(T10)))
U6_g(T8, T10, g5_out_g(c(s(T8), T10))) → h1_out_g(c(T8, s(T10)))

The argument filtering Pi contains the following mapping:
h1_in_g(x1)  =  h1_in_g(x1)
U3_g(x1, x2)  =  U3_g(x2)
f4_in_g(x1)  =  f4_in_g(x1)
c(x1, x2)  =  c(x1, x2)
0  =  0
f4_out_g(x1)  =  f4_out_g
s(x1)  =  s(x1)
U1_g(x1, x2, x3)  =  U1_g(x3)
h1_out_g(x1)  =  h1_out_g
U4_g(x1, x2)  =  U4_g(x2)
U5_g(x1, x2, x3)  =  U5_g(x1, x2, x3)
U6_g(x1, x2, x3)  =  U6_g(x3)
g5_in_g(x1)  =  g5_in_g(x1)
g5_out_g(x1)  =  g5_out_g
U2_g(x1, x2, x3)  =  U2_g(x3)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(4) Obligation:

Pi-finite rewrite system:
The TRS R consists of the following rules:

h1_in_g(T2) → U3_g(T2, f4_in_g(T2))
f4_in_g(c(0, T3)) → f4_out_g(c(0, T3))
f4_in_g(c(s(T6), T5)) → U1_g(T6, T5, f4_in_g(c(T6, s(T5))))
U1_g(T6, T5, f4_out_g(c(T6, s(T5)))) → f4_out_g(c(s(T6), T5))
U3_g(T2, f4_out_g(T2)) → h1_out_g(T2)
h1_in_g(c(T7, 0)) → U4_g(T7, f4_in_g(c(T7, 0)))
U4_g(T7, f4_out_g(c(T7, 0))) → h1_out_g(c(T7, 0))
h1_in_g(c(T8, s(T10))) → U5_g(T8, T10, f4_in_g(c(T8, s(T10))))
U5_g(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_g(T8, T10, g5_in_g(c(s(T8), T10)))
g5_in_g(c(T7, 0)) → g5_out_g(c(T7, 0))
g5_in_g(c(T8, s(T10))) → U2_g(T8, T10, g5_in_g(c(s(T8), T10)))
U2_g(T8, T10, g5_out_g(c(s(T8), T10))) → g5_out_g(c(T8, s(T10)))
U6_g(T8, T10, g5_out_g(c(s(T8), T10))) → h1_out_g(c(T8, s(T10)))

The argument filtering Pi contains the following mapping:
h1_in_g(x1)  =  h1_in_g(x1)
U3_g(x1, x2)  =  U3_g(x2)
f4_in_g(x1)  =  f4_in_g(x1)
c(x1, x2)  =  c(x1, x2)
0  =  0
f4_out_g(x1)  =  f4_out_g
s(x1)  =  s(x1)
U1_g(x1, x2, x3)  =  U1_g(x3)
h1_out_g(x1)  =  h1_out_g
U4_g(x1, x2)  =  U4_g(x2)
U5_g(x1, x2, x3)  =  U5_g(x1, x2, x3)
U6_g(x1, x2, x3)  =  U6_g(x3)
g5_in_g(x1)  =  g5_in_g(x1)
g5_out_g(x1)  =  g5_out_g
U2_g(x1, x2, x3)  =  U2_g(x3)

(5) DependencyPairsProof (EQUIVALENT transformation)

Using Dependency Pairs [AG00,LOPSTR] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

H1_IN_G(T2) → U3_G(T2, f4_in_g(T2))
H1_IN_G(T2) → F4_IN_G(T2)
F4_IN_G(c(s(T6), T5)) → U1_G(T6, T5, f4_in_g(c(T6, s(T5))))
F4_IN_G(c(s(T6), T5)) → F4_IN_G(c(T6, s(T5)))
H1_IN_G(c(T7, 0)) → U4_G(T7, f4_in_g(c(T7, 0)))
H1_IN_G(c(T7, 0)) → F4_IN_G(c(T7, 0))
H1_IN_G(c(T8, s(T10))) → U5_G(T8, T10, f4_in_g(c(T8, s(T10))))
H1_IN_G(c(T8, s(T10))) → F4_IN_G(c(T8, s(T10)))
U5_G(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_G(T8, T10, g5_in_g(c(s(T8), T10)))
U5_G(T8, T10, f4_out_g(c(T8, s(T10)))) → G5_IN_G(c(s(T8), T10))
G5_IN_G(c(T8, s(T10))) → U2_G(T8, T10, g5_in_g(c(s(T8), T10)))
G5_IN_G(c(T8, s(T10))) → G5_IN_G(c(s(T8), T10))

The TRS R consists of the following rules:

h1_in_g(T2) → U3_g(T2, f4_in_g(T2))
f4_in_g(c(0, T3)) → f4_out_g(c(0, T3))
f4_in_g(c(s(T6), T5)) → U1_g(T6, T5, f4_in_g(c(T6, s(T5))))
U1_g(T6, T5, f4_out_g(c(T6, s(T5)))) → f4_out_g(c(s(T6), T5))
U3_g(T2, f4_out_g(T2)) → h1_out_g(T2)
h1_in_g(c(T7, 0)) → U4_g(T7, f4_in_g(c(T7, 0)))
U4_g(T7, f4_out_g(c(T7, 0))) → h1_out_g(c(T7, 0))
h1_in_g(c(T8, s(T10))) → U5_g(T8, T10, f4_in_g(c(T8, s(T10))))
U5_g(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_g(T8, T10, g5_in_g(c(s(T8), T10)))
g5_in_g(c(T7, 0)) → g5_out_g(c(T7, 0))
g5_in_g(c(T8, s(T10))) → U2_g(T8, T10, g5_in_g(c(s(T8), T10)))
U2_g(T8, T10, g5_out_g(c(s(T8), T10))) → g5_out_g(c(T8, s(T10)))
U6_g(T8, T10, g5_out_g(c(s(T8), T10))) → h1_out_g(c(T8, s(T10)))

The argument filtering Pi contains the following mapping:
h1_in_g(x1)  =  h1_in_g(x1)
U3_g(x1, x2)  =  U3_g(x2)
f4_in_g(x1)  =  f4_in_g(x1)
c(x1, x2)  =  c(x1, x2)
0  =  0
f4_out_g(x1)  =  f4_out_g
s(x1)  =  s(x1)
U1_g(x1, x2, x3)  =  U1_g(x3)
h1_out_g(x1)  =  h1_out_g
U4_g(x1, x2)  =  U4_g(x2)
U5_g(x1, x2, x3)  =  U5_g(x1, x2, x3)
U6_g(x1, x2, x3)  =  U6_g(x3)
g5_in_g(x1)  =  g5_in_g(x1)
g5_out_g(x1)  =  g5_out_g
U2_g(x1, x2, x3)  =  U2_g(x3)
H1_IN_G(x1)  =  H1_IN_G(x1)
U3_G(x1, x2)  =  U3_G(x2)
F4_IN_G(x1)  =  F4_IN_G(x1)
U1_G(x1, x2, x3)  =  U1_G(x3)
U4_G(x1, x2)  =  U4_G(x2)
U5_G(x1, x2, x3)  =  U5_G(x1, x2, x3)
U6_G(x1, x2, x3)  =  U6_G(x3)
G5_IN_G(x1)  =  G5_IN_G(x1)
U2_G(x1, x2, x3)  =  U2_G(x3)

We have to consider all (P,R,Pi)-chains

(6) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

H1_IN_G(T2) → U3_G(T2, f4_in_g(T2))
H1_IN_G(T2) → F4_IN_G(T2)
F4_IN_G(c(s(T6), T5)) → U1_G(T6, T5, f4_in_g(c(T6, s(T5))))
F4_IN_G(c(s(T6), T5)) → F4_IN_G(c(T6, s(T5)))
H1_IN_G(c(T7, 0)) → U4_G(T7, f4_in_g(c(T7, 0)))
H1_IN_G(c(T7, 0)) → F4_IN_G(c(T7, 0))
H1_IN_G(c(T8, s(T10))) → U5_G(T8, T10, f4_in_g(c(T8, s(T10))))
H1_IN_G(c(T8, s(T10))) → F4_IN_G(c(T8, s(T10)))
U5_G(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_G(T8, T10, g5_in_g(c(s(T8), T10)))
U5_G(T8, T10, f4_out_g(c(T8, s(T10)))) → G5_IN_G(c(s(T8), T10))
G5_IN_G(c(T8, s(T10))) → U2_G(T8, T10, g5_in_g(c(s(T8), T10)))
G5_IN_G(c(T8, s(T10))) → G5_IN_G(c(s(T8), T10))

The TRS R consists of the following rules:

h1_in_g(T2) → U3_g(T2, f4_in_g(T2))
f4_in_g(c(0, T3)) → f4_out_g(c(0, T3))
f4_in_g(c(s(T6), T5)) → U1_g(T6, T5, f4_in_g(c(T6, s(T5))))
U1_g(T6, T5, f4_out_g(c(T6, s(T5)))) → f4_out_g(c(s(T6), T5))
U3_g(T2, f4_out_g(T2)) → h1_out_g(T2)
h1_in_g(c(T7, 0)) → U4_g(T7, f4_in_g(c(T7, 0)))
U4_g(T7, f4_out_g(c(T7, 0))) → h1_out_g(c(T7, 0))
h1_in_g(c(T8, s(T10))) → U5_g(T8, T10, f4_in_g(c(T8, s(T10))))
U5_g(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_g(T8, T10, g5_in_g(c(s(T8), T10)))
g5_in_g(c(T7, 0)) → g5_out_g(c(T7, 0))
g5_in_g(c(T8, s(T10))) → U2_g(T8, T10, g5_in_g(c(s(T8), T10)))
U2_g(T8, T10, g5_out_g(c(s(T8), T10))) → g5_out_g(c(T8, s(T10)))
U6_g(T8, T10, g5_out_g(c(s(T8), T10))) → h1_out_g(c(T8, s(T10)))

The argument filtering Pi contains the following mapping:
h1_in_g(x1)  =  h1_in_g(x1)
U3_g(x1, x2)  =  U3_g(x2)
f4_in_g(x1)  =  f4_in_g(x1)
c(x1, x2)  =  c(x1, x2)
0  =  0
f4_out_g(x1)  =  f4_out_g
s(x1)  =  s(x1)
U1_g(x1, x2, x3)  =  U1_g(x3)
h1_out_g(x1)  =  h1_out_g
U4_g(x1, x2)  =  U4_g(x2)
U5_g(x1, x2, x3)  =  U5_g(x1, x2, x3)
U6_g(x1, x2, x3)  =  U6_g(x3)
g5_in_g(x1)  =  g5_in_g(x1)
g5_out_g(x1)  =  g5_out_g
U2_g(x1, x2, x3)  =  U2_g(x3)
H1_IN_G(x1)  =  H1_IN_G(x1)
U3_G(x1, x2)  =  U3_G(x2)
F4_IN_G(x1)  =  F4_IN_G(x1)
U1_G(x1, x2, x3)  =  U1_G(x3)
U4_G(x1, x2)  =  U4_G(x2)
U5_G(x1, x2, x3)  =  U5_G(x1, x2, x3)
U6_G(x1, x2, x3)  =  U6_G(x3)
G5_IN_G(x1)  =  G5_IN_G(x1)
U2_G(x1, x2, x3)  =  U2_G(x3)

We have to consider all (P,R,Pi)-chains

(7) DependencyGraphProof (EQUIVALENT transformation)

The approximation of the Dependency Graph [LOPSTR] contains 2 SCCs with 10 less nodes.

(8) Complex Obligation (AND)

(9) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

G5_IN_G(c(T8, s(T10))) → G5_IN_G(c(s(T8), T10))

The TRS R consists of the following rules:

h1_in_g(T2) → U3_g(T2, f4_in_g(T2))
f4_in_g(c(0, T3)) → f4_out_g(c(0, T3))
f4_in_g(c(s(T6), T5)) → U1_g(T6, T5, f4_in_g(c(T6, s(T5))))
U1_g(T6, T5, f4_out_g(c(T6, s(T5)))) → f4_out_g(c(s(T6), T5))
U3_g(T2, f4_out_g(T2)) → h1_out_g(T2)
h1_in_g(c(T7, 0)) → U4_g(T7, f4_in_g(c(T7, 0)))
U4_g(T7, f4_out_g(c(T7, 0))) → h1_out_g(c(T7, 0))
h1_in_g(c(T8, s(T10))) → U5_g(T8, T10, f4_in_g(c(T8, s(T10))))
U5_g(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_g(T8, T10, g5_in_g(c(s(T8), T10)))
g5_in_g(c(T7, 0)) → g5_out_g(c(T7, 0))
g5_in_g(c(T8, s(T10))) → U2_g(T8, T10, g5_in_g(c(s(T8), T10)))
U2_g(T8, T10, g5_out_g(c(s(T8), T10))) → g5_out_g(c(T8, s(T10)))
U6_g(T8, T10, g5_out_g(c(s(T8), T10))) → h1_out_g(c(T8, s(T10)))

The argument filtering Pi contains the following mapping:
h1_in_g(x1)  =  h1_in_g(x1)
U3_g(x1, x2)  =  U3_g(x2)
f4_in_g(x1)  =  f4_in_g(x1)
c(x1, x2)  =  c(x1, x2)
0  =  0
f4_out_g(x1)  =  f4_out_g
s(x1)  =  s(x1)
U1_g(x1, x2, x3)  =  U1_g(x3)
h1_out_g(x1)  =  h1_out_g
U4_g(x1, x2)  =  U4_g(x2)
U5_g(x1, x2, x3)  =  U5_g(x1, x2, x3)
U6_g(x1, x2, x3)  =  U6_g(x3)
g5_in_g(x1)  =  g5_in_g(x1)
g5_out_g(x1)  =  g5_out_g
U2_g(x1, x2, x3)  =  U2_g(x3)
G5_IN_G(x1)  =  G5_IN_G(x1)

We have to consider all (P,R,Pi)-chains

(10) UsableRulesProof (EQUIVALENT transformation)

For (infinitary) constructor rewriting [LOPSTR] we can delete all non-usable rules from R.

(11) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

G5_IN_G(c(T8, s(T10))) → G5_IN_G(c(s(T8), T10))

R is empty.
Pi is empty.
We have to consider all (P,R,Pi)-chains

(12) PiDPToQDPProof (EQUIVALENT transformation)

Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.

(13) Obligation:

Q DP problem:
The TRS P consists of the following rules:

G5_IN_G(c(T8, s(T10))) → G5_IN_G(c(s(T8), T10))

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(14) MRRProof (EQUIVALENT transformation)

By using the rule removal processor [LPAR04] with the following ordering, at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

G5_IN_G(c(T8, s(T10))) → G5_IN_G(c(s(T8), T10))


Used ordering: Polynomial interpretation [POLO]:

POL(G5_IN_G(x1)) = 2·x1   
POL(c(x1, x2)) = x1 + 2·x2   
POL(s(x1)) = 1 + x1   

(15) Obligation:

Q DP problem:
P is empty.
R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(16) PisEmptyProof (EQUIVALENT transformation)

The TRS P is empty. Hence, there is no (P,Q,R) chain.

(17) TRUE

(18) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

F4_IN_G(c(s(T6), T5)) → F4_IN_G(c(T6, s(T5)))

The TRS R consists of the following rules:

h1_in_g(T2) → U3_g(T2, f4_in_g(T2))
f4_in_g(c(0, T3)) → f4_out_g(c(0, T3))
f4_in_g(c(s(T6), T5)) → U1_g(T6, T5, f4_in_g(c(T6, s(T5))))
U1_g(T6, T5, f4_out_g(c(T6, s(T5)))) → f4_out_g(c(s(T6), T5))
U3_g(T2, f4_out_g(T2)) → h1_out_g(T2)
h1_in_g(c(T7, 0)) → U4_g(T7, f4_in_g(c(T7, 0)))
U4_g(T7, f4_out_g(c(T7, 0))) → h1_out_g(c(T7, 0))
h1_in_g(c(T8, s(T10))) → U5_g(T8, T10, f4_in_g(c(T8, s(T10))))
U5_g(T8, T10, f4_out_g(c(T8, s(T10)))) → U6_g(T8, T10, g5_in_g(c(s(T8), T10)))
g5_in_g(c(T7, 0)) → g5_out_g(c(T7, 0))
g5_in_g(c(T8, s(T10))) → U2_g(T8, T10, g5_in_g(c(s(T8), T10)))
U2_g(T8, T10, g5_out_g(c(s(T8), T10))) → g5_out_g(c(T8, s(T10)))
U6_g(T8, T10, g5_out_g(c(s(T8), T10))) → h1_out_g(c(T8, s(T10)))

The argument filtering Pi contains the following mapping:
h1_in_g(x1)  =  h1_in_g(x1)
U3_g(x1, x2)  =  U3_g(x2)
f4_in_g(x1)  =  f4_in_g(x1)
c(x1, x2)  =  c(x1, x2)
0  =  0
f4_out_g(x1)  =  f4_out_g
s(x1)  =  s(x1)
U1_g(x1, x2, x3)  =  U1_g(x3)
h1_out_g(x1)  =  h1_out_g
U4_g(x1, x2)  =  U4_g(x2)
U5_g(x1, x2, x3)  =  U5_g(x1, x2, x3)
U6_g(x1, x2, x3)  =  U6_g(x3)
g5_in_g(x1)  =  g5_in_g(x1)
g5_out_g(x1)  =  g5_out_g
U2_g(x1, x2, x3)  =  U2_g(x3)
F4_IN_G(x1)  =  F4_IN_G(x1)

We have to consider all (P,R,Pi)-chains

(19) UsableRulesProof (EQUIVALENT transformation)

For (infinitary) constructor rewriting [LOPSTR] we can delete all non-usable rules from R.

(20) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

F4_IN_G(c(s(T6), T5)) → F4_IN_G(c(T6, s(T5)))

R is empty.
Pi is empty.
We have to consider all (P,R,Pi)-chains

(21) PiDPToQDPProof (EQUIVALENT transformation)

Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.

(22) Obligation:

Q DP problem:
The TRS P consists of the following rules:

F4_IN_G(c(s(T6), T5)) → F4_IN_G(c(T6, s(T5)))

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(23) MRRProof (EQUIVALENT transformation)

By using the rule removal processor [LPAR04] with the following ordering, at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

F4_IN_G(c(s(T6), T5)) → F4_IN_G(c(T6, s(T5)))


Used ordering: Polynomial interpretation [POLO]:

POL(F4_IN_G(x1)) = 2·x1   
POL(c(x1, x2)) = 2·x1 + x2   
POL(s(x1)) = 1 + x1   

(24) Obligation:

Q DP problem:
P is empty.
R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(25) PisEmptyProof (EQUIVALENT transformation)

The TRS P is empty. Hence, there is no (P,Q,R) chain.

(26) TRUE