(0) Obligation:

Clauses:

p(0).
p(s(X)) :- ','(q(X), ','(!, r)).
p(X) :- r.
q(0).
q(s(X)) :- ','(p(X), ','(!, r)).
q(X) :- r.
r.

Query: p(g)

(1) CutEliminatorProof (SOUND transformation)

Eliminated all cuts by simply ignoring them[PROLOG].

(2) Obligation:

Clauses:

p(0).
p(s(X)) :- ','(q(X), r).
p(X) :- r.
q(0).
q(s(X)) :- ','(p(X), r).
q(X) :- r.
r.

Query: p(g)

(3) PrologToPiTRSProof (SOUND transformation)

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

p_in_g(0) → p_out_g(0)
p_in_g(s(X)) → U1_g(X, q_in_g(X))
q_in_g(0) → q_out_g(0)
q_in_g(s(X)) → U4_g(X, p_in_g(X))
p_in_g(X) → U3_g(X, r_in_)
r_in_r_out_
U3_g(X, r_out_) → p_out_g(X)
U4_g(X, p_out_g(X)) → U5_g(X, r_in_)
U5_g(X, r_out_) → q_out_g(s(X))
q_in_g(X) → U6_g(X, r_in_)
U6_g(X, r_out_) → q_out_g(X)
U1_g(X, q_out_g(X)) → U2_g(X, r_in_)
U2_g(X, r_out_) → p_out_g(s(X))

The argument filtering Pi contains the following mapping:
p_in_g(x1)  =  p_in_g(x1)
0  =  0
p_out_g(x1)  =  p_out_g
s(x1)  =  s(x1)
U1_g(x1, x2)  =  U1_g(x2)
q_in_g(x1)  =  q_in_g(x1)
q_out_g(x1)  =  q_out_g
U4_g(x1, x2)  =  U4_g(x2)
U3_g(x1, x2)  =  U3_g(x2)
r_in_  =  r_in_
r_out_  =  r_out_
U5_g(x1, x2)  =  U5_g(x2)
U6_g(x1, x2)  =  U6_g(x2)
U2_g(x1, x2)  =  U2_g(x2)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(4) Obligation:

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

p_in_g(0) → p_out_g(0)
p_in_g(s(X)) → U1_g(X, q_in_g(X))
q_in_g(0) → q_out_g(0)
q_in_g(s(X)) → U4_g(X, p_in_g(X))
p_in_g(X) → U3_g(X, r_in_)
r_in_r_out_
U3_g(X, r_out_) → p_out_g(X)
U4_g(X, p_out_g(X)) → U5_g(X, r_in_)
U5_g(X, r_out_) → q_out_g(s(X))
q_in_g(X) → U6_g(X, r_in_)
U6_g(X, r_out_) → q_out_g(X)
U1_g(X, q_out_g(X)) → U2_g(X, r_in_)
U2_g(X, r_out_) → p_out_g(s(X))

The argument filtering Pi contains the following mapping:
p_in_g(x1)  =  p_in_g(x1)
0  =  0
p_out_g(x1)  =  p_out_g
s(x1)  =  s(x1)
U1_g(x1, x2)  =  U1_g(x2)
q_in_g(x1)  =  q_in_g(x1)
q_out_g(x1)  =  q_out_g
U4_g(x1, x2)  =  U4_g(x2)
U3_g(x1, x2)  =  U3_g(x2)
r_in_  =  r_in_
r_out_  =  r_out_
U5_g(x1, x2)  =  U5_g(x2)
U6_g(x1, x2)  =  U6_g(x2)
U2_g(x1, x2)  =  U2_g(x2)

(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:

P_IN_G(s(X)) → U1_G(X, q_in_g(X))
P_IN_G(s(X)) → Q_IN_G(X)
Q_IN_G(s(X)) → U4_G(X, p_in_g(X))
Q_IN_G(s(X)) → P_IN_G(X)
P_IN_G(X) → U3_G(X, r_in_)
P_IN_G(X) → R_IN_
U4_G(X, p_out_g(X)) → U5_G(X, r_in_)
U4_G(X, p_out_g(X)) → R_IN_
Q_IN_G(X) → U6_G(X, r_in_)
Q_IN_G(X) → R_IN_
U1_G(X, q_out_g(X)) → U2_G(X, r_in_)
U1_G(X, q_out_g(X)) → R_IN_

The TRS R consists of the following rules:

p_in_g(0) → p_out_g(0)
p_in_g(s(X)) → U1_g(X, q_in_g(X))
q_in_g(0) → q_out_g(0)
q_in_g(s(X)) → U4_g(X, p_in_g(X))
p_in_g(X) → U3_g(X, r_in_)
r_in_r_out_
U3_g(X, r_out_) → p_out_g(X)
U4_g(X, p_out_g(X)) → U5_g(X, r_in_)
U5_g(X, r_out_) → q_out_g(s(X))
q_in_g(X) → U6_g(X, r_in_)
U6_g(X, r_out_) → q_out_g(X)
U1_g(X, q_out_g(X)) → U2_g(X, r_in_)
U2_g(X, r_out_) → p_out_g(s(X))

The argument filtering Pi contains the following mapping:
p_in_g(x1)  =  p_in_g(x1)
0  =  0
p_out_g(x1)  =  p_out_g
s(x1)  =  s(x1)
U1_g(x1, x2)  =  U1_g(x2)
q_in_g(x1)  =  q_in_g(x1)
q_out_g(x1)  =  q_out_g
U4_g(x1, x2)  =  U4_g(x2)
U3_g(x1, x2)  =  U3_g(x2)
r_in_  =  r_in_
r_out_  =  r_out_
U5_g(x1, x2)  =  U5_g(x2)
U6_g(x1, x2)  =  U6_g(x2)
U2_g(x1, x2)  =  U2_g(x2)
P_IN_G(x1)  =  P_IN_G(x1)
U1_G(x1, x2)  =  U1_G(x2)
Q_IN_G(x1)  =  Q_IN_G(x1)
U4_G(x1, x2)  =  U4_G(x2)
U3_G(x1, x2)  =  U3_G(x2)
R_IN_  =  R_IN_
U5_G(x1, x2)  =  U5_G(x2)
U6_G(x1, x2)  =  U6_G(x2)
U2_G(x1, x2)  =  U2_G(x2)

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

(6) Obligation:

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

P_IN_G(s(X)) → U1_G(X, q_in_g(X))
P_IN_G(s(X)) → Q_IN_G(X)
Q_IN_G(s(X)) → U4_G(X, p_in_g(X))
Q_IN_G(s(X)) → P_IN_G(X)
P_IN_G(X) → U3_G(X, r_in_)
P_IN_G(X) → R_IN_
U4_G(X, p_out_g(X)) → U5_G(X, r_in_)
U4_G(X, p_out_g(X)) → R_IN_
Q_IN_G(X) → U6_G(X, r_in_)
Q_IN_G(X) → R_IN_
U1_G(X, q_out_g(X)) → U2_G(X, r_in_)
U1_G(X, q_out_g(X)) → R_IN_

The TRS R consists of the following rules:

p_in_g(0) → p_out_g(0)
p_in_g(s(X)) → U1_g(X, q_in_g(X))
q_in_g(0) → q_out_g(0)
q_in_g(s(X)) → U4_g(X, p_in_g(X))
p_in_g(X) → U3_g(X, r_in_)
r_in_r_out_
U3_g(X, r_out_) → p_out_g(X)
U4_g(X, p_out_g(X)) → U5_g(X, r_in_)
U5_g(X, r_out_) → q_out_g(s(X))
q_in_g(X) → U6_g(X, r_in_)
U6_g(X, r_out_) → q_out_g(X)
U1_g(X, q_out_g(X)) → U2_g(X, r_in_)
U2_g(X, r_out_) → p_out_g(s(X))

The argument filtering Pi contains the following mapping:
p_in_g(x1)  =  p_in_g(x1)
0  =  0
p_out_g(x1)  =  p_out_g
s(x1)  =  s(x1)
U1_g(x1, x2)  =  U1_g(x2)
q_in_g(x1)  =  q_in_g(x1)
q_out_g(x1)  =  q_out_g
U4_g(x1, x2)  =  U4_g(x2)
U3_g(x1, x2)  =  U3_g(x2)
r_in_  =  r_in_
r_out_  =  r_out_
U5_g(x1, x2)  =  U5_g(x2)
U6_g(x1, x2)  =  U6_g(x2)
U2_g(x1, x2)  =  U2_g(x2)
P_IN_G(x1)  =  P_IN_G(x1)
U1_G(x1, x2)  =  U1_G(x2)
Q_IN_G(x1)  =  Q_IN_G(x1)
U4_G(x1, x2)  =  U4_G(x2)
U3_G(x1, x2)  =  U3_G(x2)
R_IN_  =  R_IN_
U5_G(x1, x2)  =  U5_G(x2)
U6_G(x1, x2)  =  U6_G(x2)
U2_G(x1, x2)  =  U2_G(x2)

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

(7) DependencyGraphProof (EQUIVALENT transformation)

The approximation of the Dependency Graph [LOPSTR] contains 1 SCC with 10 less nodes.

(8) Obligation:

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

P_IN_G(s(X)) → Q_IN_G(X)
Q_IN_G(s(X)) → P_IN_G(X)

The TRS R consists of the following rules:

p_in_g(0) → p_out_g(0)
p_in_g(s(X)) → U1_g(X, q_in_g(X))
q_in_g(0) → q_out_g(0)
q_in_g(s(X)) → U4_g(X, p_in_g(X))
p_in_g(X) → U3_g(X, r_in_)
r_in_r_out_
U3_g(X, r_out_) → p_out_g(X)
U4_g(X, p_out_g(X)) → U5_g(X, r_in_)
U5_g(X, r_out_) → q_out_g(s(X))
q_in_g(X) → U6_g(X, r_in_)
U6_g(X, r_out_) → q_out_g(X)
U1_g(X, q_out_g(X)) → U2_g(X, r_in_)
U2_g(X, r_out_) → p_out_g(s(X))

The argument filtering Pi contains the following mapping:
p_in_g(x1)  =  p_in_g(x1)
0  =  0
p_out_g(x1)  =  p_out_g
s(x1)  =  s(x1)
U1_g(x1, x2)  =  U1_g(x2)
q_in_g(x1)  =  q_in_g(x1)
q_out_g(x1)  =  q_out_g
U4_g(x1, x2)  =  U4_g(x2)
U3_g(x1, x2)  =  U3_g(x2)
r_in_  =  r_in_
r_out_  =  r_out_
U5_g(x1, x2)  =  U5_g(x2)
U6_g(x1, x2)  =  U6_g(x2)
U2_g(x1, x2)  =  U2_g(x2)
P_IN_G(x1)  =  P_IN_G(x1)
Q_IN_G(x1)  =  Q_IN_G(x1)

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

(9) UsableRulesProof (EQUIVALENT transformation)

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

(10) Obligation:

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

P_IN_G(s(X)) → Q_IN_G(X)
Q_IN_G(s(X)) → P_IN_G(X)

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

(11) PiDPToQDPProof (EQUIVALENT transformation)

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

(12) Obligation:

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

P_IN_G(s(X)) → Q_IN_G(X)
Q_IN_G(s(X)) → P_IN_G(X)

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

(13) QDPSizeChangeProof (EQUIVALENT transformation)

By using the subterm criterion [SUBTERM_CRITERION] together with the size-change analysis [AAECC05] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:

  • Q_IN_G(s(X)) → P_IN_G(X)
    The graph contains the following edges 1 > 1

  • P_IN_G(s(X)) → Q_IN_G(X)
    The graph contains the following edges 1 > 1

(14) YES