(0) Obligation:

Clauses:

m(X, 0, Z) :- ','(!, =(Z, X)).
m(0, Y, Z) :- ','(!, =(Z, 0)).
m(X, Y, Z) :- ','(p(X, A), ','(p(Y, B), m(A, B, Z))).
p(0, 0).
p(s(X), X).
q(X, Y, Z) :- m(X, Y, Z).
q(X, Y, Z).
=(X, X).

Queries:

q(g,g,a).

(1) PrologToPrologProblemTransformerProof (SOUND transformation)

Built Prolog problem from termination graph.

(2) Obligation:

Clauses:

m5(T11, 0, T11).
m5(0, T12, 0).
m5(s(T20), s(T21), T19) :- m5(T20, T21, T19).
q1(T11, 0, T11).
q1(0, T12, 0).
q1(s(T20), s(T21), T19) :- m5(T20, T21, T19).
q1(T22, T23, T24).

Queries:

q1(g,g,a).

(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:
q1_in: (b,b,f)
m5_in: (b,b,f)
Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

q1_in_gga(T11, 0, T11) → q1_out_gga(T11, 0, T11)
q1_in_gga(0, T12, 0) → q1_out_gga(0, T12, 0)
q1_in_gga(s(T20), s(T21), T19) → U2_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
m5_in_gga(T11, 0, T11) → m5_out_gga(T11, 0, T11)
m5_in_gga(0, T12, 0) → m5_out_gga(0, T12, 0)
m5_in_gga(s(T20), s(T21), T19) → U1_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
U1_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → m5_out_gga(s(T20), s(T21), T19)
U2_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → q1_out_gga(s(T20), s(T21), T19)
q1_in_gga(T22, T23, T24) → q1_out_gga(T22, T23, T24)

The argument filtering Pi contains the following mapping:
q1_in_gga(x1, x2, x3)  =  q1_in_gga(x1, x2)
0  =  0
q1_out_gga(x1, x2, x3)  =  q1_out_gga
s(x1)  =  s(x1)
U2_gga(x1, x2, x3, x4)  =  U2_gga(x4)
m5_in_gga(x1, x2, x3)  =  m5_in_gga(x1, x2)
m5_out_gga(x1, x2, x3)  =  m5_out_gga(x3)
U1_gga(x1, x2, x3, x4)  =  U1_gga(x4)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(4) Obligation:

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

q1_in_gga(T11, 0, T11) → q1_out_gga(T11, 0, T11)
q1_in_gga(0, T12, 0) → q1_out_gga(0, T12, 0)
q1_in_gga(s(T20), s(T21), T19) → U2_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
m5_in_gga(T11, 0, T11) → m5_out_gga(T11, 0, T11)
m5_in_gga(0, T12, 0) → m5_out_gga(0, T12, 0)
m5_in_gga(s(T20), s(T21), T19) → U1_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
U1_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → m5_out_gga(s(T20), s(T21), T19)
U2_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → q1_out_gga(s(T20), s(T21), T19)
q1_in_gga(T22, T23, T24) → q1_out_gga(T22, T23, T24)

The argument filtering Pi contains the following mapping:
q1_in_gga(x1, x2, x3)  =  q1_in_gga(x1, x2)
0  =  0
q1_out_gga(x1, x2, x3)  =  q1_out_gga
s(x1)  =  s(x1)
U2_gga(x1, x2, x3, x4)  =  U2_gga(x4)
m5_in_gga(x1, x2, x3)  =  m5_in_gga(x1, x2)
m5_out_gga(x1, x2, x3)  =  m5_out_gga(x3)
U1_gga(x1, x2, x3, x4)  =  U1_gga(x4)

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

Q1_IN_GGA(s(T20), s(T21), T19) → U2_GGA(T20, T21, T19, m5_in_gga(T20, T21, T19))
Q1_IN_GGA(s(T20), s(T21), T19) → M5_IN_GGA(T20, T21, T19)
M5_IN_GGA(s(T20), s(T21), T19) → U1_GGA(T20, T21, T19, m5_in_gga(T20, T21, T19))
M5_IN_GGA(s(T20), s(T21), T19) → M5_IN_GGA(T20, T21, T19)

The TRS R consists of the following rules:

q1_in_gga(T11, 0, T11) → q1_out_gga(T11, 0, T11)
q1_in_gga(0, T12, 0) → q1_out_gga(0, T12, 0)
q1_in_gga(s(T20), s(T21), T19) → U2_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
m5_in_gga(T11, 0, T11) → m5_out_gga(T11, 0, T11)
m5_in_gga(0, T12, 0) → m5_out_gga(0, T12, 0)
m5_in_gga(s(T20), s(T21), T19) → U1_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
U1_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → m5_out_gga(s(T20), s(T21), T19)
U2_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → q1_out_gga(s(T20), s(T21), T19)
q1_in_gga(T22, T23, T24) → q1_out_gga(T22, T23, T24)

The argument filtering Pi contains the following mapping:
q1_in_gga(x1, x2, x3)  =  q1_in_gga(x1, x2)
0  =  0
q1_out_gga(x1, x2, x3)  =  q1_out_gga
s(x1)  =  s(x1)
U2_gga(x1, x2, x3, x4)  =  U2_gga(x4)
m5_in_gga(x1, x2, x3)  =  m5_in_gga(x1, x2)
m5_out_gga(x1, x2, x3)  =  m5_out_gga(x3)
U1_gga(x1, x2, x3, x4)  =  U1_gga(x4)
Q1_IN_GGA(x1, x2, x3)  =  Q1_IN_GGA(x1, x2)
U2_GGA(x1, x2, x3, x4)  =  U2_GGA(x4)
M5_IN_GGA(x1, x2, x3)  =  M5_IN_GGA(x1, x2)
U1_GGA(x1, x2, x3, x4)  =  U1_GGA(x4)

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

(6) Obligation:

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

Q1_IN_GGA(s(T20), s(T21), T19) → U2_GGA(T20, T21, T19, m5_in_gga(T20, T21, T19))
Q1_IN_GGA(s(T20), s(T21), T19) → M5_IN_GGA(T20, T21, T19)
M5_IN_GGA(s(T20), s(T21), T19) → U1_GGA(T20, T21, T19, m5_in_gga(T20, T21, T19))
M5_IN_GGA(s(T20), s(T21), T19) → M5_IN_GGA(T20, T21, T19)

The TRS R consists of the following rules:

q1_in_gga(T11, 0, T11) → q1_out_gga(T11, 0, T11)
q1_in_gga(0, T12, 0) → q1_out_gga(0, T12, 0)
q1_in_gga(s(T20), s(T21), T19) → U2_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
m5_in_gga(T11, 0, T11) → m5_out_gga(T11, 0, T11)
m5_in_gga(0, T12, 0) → m5_out_gga(0, T12, 0)
m5_in_gga(s(T20), s(T21), T19) → U1_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
U1_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → m5_out_gga(s(T20), s(T21), T19)
U2_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → q1_out_gga(s(T20), s(T21), T19)
q1_in_gga(T22, T23, T24) → q1_out_gga(T22, T23, T24)

The argument filtering Pi contains the following mapping:
q1_in_gga(x1, x2, x3)  =  q1_in_gga(x1, x2)
0  =  0
q1_out_gga(x1, x2, x3)  =  q1_out_gga
s(x1)  =  s(x1)
U2_gga(x1, x2, x3, x4)  =  U2_gga(x4)
m5_in_gga(x1, x2, x3)  =  m5_in_gga(x1, x2)
m5_out_gga(x1, x2, x3)  =  m5_out_gga(x3)
U1_gga(x1, x2, x3, x4)  =  U1_gga(x4)
Q1_IN_GGA(x1, x2, x3)  =  Q1_IN_GGA(x1, x2)
U2_GGA(x1, x2, x3, x4)  =  U2_GGA(x4)
M5_IN_GGA(x1, x2, x3)  =  M5_IN_GGA(x1, x2)
U1_GGA(x1, x2, x3, x4)  =  U1_GGA(x4)

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

(7) DependencyGraphProof (EQUIVALENT transformation)

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

(8) Obligation:

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

M5_IN_GGA(s(T20), s(T21), T19) → M5_IN_GGA(T20, T21, T19)

The TRS R consists of the following rules:

q1_in_gga(T11, 0, T11) → q1_out_gga(T11, 0, T11)
q1_in_gga(0, T12, 0) → q1_out_gga(0, T12, 0)
q1_in_gga(s(T20), s(T21), T19) → U2_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
m5_in_gga(T11, 0, T11) → m5_out_gga(T11, 0, T11)
m5_in_gga(0, T12, 0) → m5_out_gga(0, T12, 0)
m5_in_gga(s(T20), s(T21), T19) → U1_gga(T20, T21, T19, m5_in_gga(T20, T21, T19))
U1_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → m5_out_gga(s(T20), s(T21), T19)
U2_gga(T20, T21, T19, m5_out_gga(T20, T21, T19)) → q1_out_gga(s(T20), s(T21), T19)
q1_in_gga(T22, T23, T24) → q1_out_gga(T22, T23, T24)

The argument filtering Pi contains the following mapping:
q1_in_gga(x1, x2, x3)  =  q1_in_gga(x1, x2)
0  =  0
q1_out_gga(x1, x2, x3)  =  q1_out_gga
s(x1)  =  s(x1)
U2_gga(x1, x2, x3, x4)  =  U2_gga(x4)
m5_in_gga(x1, x2, x3)  =  m5_in_gga(x1, x2)
m5_out_gga(x1, x2, x3)  =  m5_out_gga(x3)
U1_gga(x1, x2, x3, x4)  =  U1_gga(x4)
M5_IN_GGA(x1, x2, x3)  =  M5_IN_GGA(x1, x2)

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:

M5_IN_GGA(s(T20), s(T21), T19) → M5_IN_GGA(T20, T21, T19)

R is empty.
The argument filtering Pi contains the following mapping:
s(x1)  =  s(x1)
M5_IN_GGA(x1, x2, x3)  =  M5_IN_GGA(x1, x2)

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

(11) PiDPToQDPProof (SOUND 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:

M5_IN_GGA(s(T20), s(T21)) → M5_IN_GGA(T20, T21)

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:

  • M5_IN_GGA(s(T20), s(T21)) → M5_IN_GGA(T20, T21)
    The graph contains the following edges 1 > 1, 2 > 2

(14) TRUE