(0) Obligation:

Clauses:

max(X, Y, X) :- less(Y, X).
max(X, Y, Y) :- less(X, s(Y)).
less(0, s(X1)).
less(s(X), s(Y)) :- less(X, Y).

Queries:

max(a,g,a).

(1) PrologToPrologProblemTransformerProof (SOUND transformation)

Built Prolog problem from termination graph.

(2) Obligation:

Clauses:

less13(0, s(T31)).
less13(s(T36), s(T38)) :- less13(T36, T38).
less32(0, s(T68)).
less32(s(T75), s(T74)) :- less32(T75, T74).
max1(s(T13), 0, s(T13)).
max1(s(T24), s(T22), s(T24)) :- less13(T22, T24).
max1(0, T54, T54).
max1(s(T61), T60, T60) :- less32(T61, T60).
max1(0, T87, T87).
max1(s(T94), T93, T93) :- less32(T94, T93).

Queries:

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

max1_in_aga(s(T13), 0, s(T13)) → max1_out_aga(s(T13), 0, s(T13))
max1_in_aga(s(T24), s(T22), s(T24)) → U3_aga(T24, T22, less13_in_ga(T22, T24))
less13_in_ga(0, s(T31)) → less13_out_ga(0, s(T31))
less13_in_ga(s(T36), s(T38)) → U1_ga(T36, T38, less13_in_ga(T36, T38))
U1_ga(T36, T38, less13_out_ga(T36, T38)) → less13_out_ga(s(T36), s(T38))
U3_aga(T24, T22, less13_out_ga(T22, T24)) → max1_out_aga(s(T24), s(T22), s(T24))
max1_in_aga(0, T54, T54) → max1_out_aga(0, T54, T54)
max1_in_aga(s(T61), T60, T60) → U4_aga(T61, T60, less32_in_ag(T61, T60))
less32_in_ag(0, s(T68)) → less32_out_ag(0, s(T68))
less32_in_ag(s(T75), s(T74)) → U2_ag(T75, T74, less32_in_ag(T75, T74))
U2_ag(T75, T74, less32_out_ag(T75, T74)) → less32_out_ag(s(T75), s(T74))
U4_aga(T61, T60, less32_out_ag(T61, T60)) → max1_out_aga(s(T61), T60, T60)
max1_in_aga(s(T94), T93, T93) → U5_aga(T94, T93, less32_in_ag(T94, T93))
U5_aga(T94, T93, less32_out_ag(T94, T93)) → max1_out_aga(s(T94), T93, T93)

The argument filtering Pi contains the following mapping:
max1_in_aga(x1, x2, x3)  =  max1_in_aga(x2)
0  =  0
max1_out_aga(x1, x2, x3)  =  max1_out_aga
s(x1)  =  s(x1)
U3_aga(x1, x2, x3)  =  U3_aga(x3)
less13_in_ga(x1, x2)  =  less13_in_ga(x1)
less13_out_ga(x1, x2)  =  less13_out_ga
U1_ga(x1, x2, x3)  =  U1_ga(x3)
U4_aga(x1, x2, x3)  =  U4_aga(x3)
less32_in_ag(x1, x2)  =  less32_in_ag(x2)
less32_out_ag(x1, x2)  =  less32_out_ag(x1)
U2_ag(x1, x2, x3)  =  U2_ag(x3)
U5_aga(x1, x2, x3)  =  U5_aga(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:

max1_in_aga(s(T13), 0, s(T13)) → max1_out_aga(s(T13), 0, s(T13))
max1_in_aga(s(T24), s(T22), s(T24)) → U3_aga(T24, T22, less13_in_ga(T22, T24))
less13_in_ga(0, s(T31)) → less13_out_ga(0, s(T31))
less13_in_ga(s(T36), s(T38)) → U1_ga(T36, T38, less13_in_ga(T36, T38))
U1_ga(T36, T38, less13_out_ga(T36, T38)) → less13_out_ga(s(T36), s(T38))
U3_aga(T24, T22, less13_out_ga(T22, T24)) → max1_out_aga(s(T24), s(T22), s(T24))
max1_in_aga(0, T54, T54) → max1_out_aga(0, T54, T54)
max1_in_aga(s(T61), T60, T60) → U4_aga(T61, T60, less32_in_ag(T61, T60))
less32_in_ag(0, s(T68)) → less32_out_ag(0, s(T68))
less32_in_ag(s(T75), s(T74)) → U2_ag(T75, T74, less32_in_ag(T75, T74))
U2_ag(T75, T74, less32_out_ag(T75, T74)) → less32_out_ag(s(T75), s(T74))
U4_aga(T61, T60, less32_out_ag(T61, T60)) → max1_out_aga(s(T61), T60, T60)
max1_in_aga(s(T94), T93, T93) → U5_aga(T94, T93, less32_in_ag(T94, T93))
U5_aga(T94, T93, less32_out_ag(T94, T93)) → max1_out_aga(s(T94), T93, T93)

The argument filtering Pi contains the following mapping:
max1_in_aga(x1, x2, x3)  =  max1_in_aga(x2)
0  =  0
max1_out_aga(x1, x2, x3)  =  max1_out_aga
s(x1)  =  s(x1)
U3_aga(x1, x2, x3)  =  U3_aga(x3)
less13_in_ga(x1, x2)  =  less13_in_ga(x1)
less13_out_ga(x1, x2)  =  less13_out_ga
U1_ga(x1, x2, x3)  =  U1_ga(x3)
U4_aga(x1, x2, x3)  =  U4_aga(x3)
less32_in_ag(x1, x2)  =  less32_in_ag(x2)
less32_out_ag(x1, x2)  =  less32_out_ag(x1)
U2_ag(x1, x2, x3)  =  U2_ag(x3)
U5_aga(x1, x2, x3)  =  U5_aga(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:

MAX1_IN_AGA(s(T24), s(T22), s(T24)) → U3_AGA(T24, T22, less13_in_ga(T22, T24))
MAX1_IN_AGA(s(T24), s(T22), s(T24)) → LESS13_IN_GA(T22, T24)
LESS13_IN_GA(s(T36), s(T38)) → U1_GA(T36, T38, less13_in_ga(T36, T38))
LESS13_IN_GA(s(T36), s(T38)) → LESS13_IN_GA(T36, T38)
MAX1_IN_AGA(s(T61), T60, T60) → U4_AGA(T61, T60, less32_in_ag(T61, T60))
MAX1_IN_AGA(s(T61), T60, T60) → LESS32_IN_AG(T61, T60)
LESS32_IN_AG(s(T75), s(T74)) → U2_AG(T75, T74, less32_in_ag(T75, T74))
LESS32_IN_AG(s(T75), s(T74)) → LESS32_IN_AG(T75, T74)
MAX1_IN_AGA(s(T94), T93, T93) → U5_AGA(T94, T93, less32_in_ag(T94, T93))

The TRS R consists of the following rules:

max1_in_aga(s(T13), 0, s(T13)) → max1_out_aga(s(T13), 0, s(T13))
max1_in_aga(s(T24), s(T22), s(T24)) → U3_aga(T24, T22, less13_in_ga(T22, T24))
less13_in_ga(0, s(T31)) → less13_out_ga(0, s(T31))
less13_in_ga(s(T36), s(T38)) → U1_ga(T36, T38, less13_in_ga(T36, T38))
U1_ga(T36, T38, less13_out_ga(T36, T38)) → less13_out_ga(s(T36), s(T38))
U3_aga(T24, T22, less13_out_ga(T22, T24)) → max1_out_aga(s(T24), s(T22), s(T24))
max1_in_aga(0, T54, T54) → max1_out_aga(0, T54, T54)
max1_in_aga(s(T61), T60, T60) → U4_aga(T61, T60, less32_in_ag(T61, T60))
less32_in_ag(0, s(T68)) → less32_out_ag(0, s(T68))
less32_in_ag(s(T75), s(T74)) → U2_ag(T75, T74, less32_in_ag(T75, T74))
U2_ag(T75, T74, less32_out_ag(T75, T74)) → less32_out_ag(s(T75), s(T74))
U4_aga(T61, T60, less32_out_ag(T61, T60)) → max1_out_aga(s(T61), T60, T60)
max1_in_aga(s(T94), T93, T93) → U5_aga(T94, T93, less32_in_ag(T94, T93))
U5_aga(T94, T93, less32_out_ag(T94, T93)) → max1_out_aga(s(T94), T93, T93)

The argument filtering Pi contains the following mapping:
max1_in_aga(x1, x2, x3)  =  max1_in_aga(x2)
0  =  0
max1_out_aga(x1, x2, x3)  =  max1_out_aga
s(x1)  =  s(x1)
U3_aga(x1, x2, x3)  =  U3_aga(x3)
less13_in_ga(x1, x2)  =  less13_in_ga(x1)
less13_out_ga(x1, x2)  =  less13_out_ga
U1_ga(x1, x2, x3)  =  U1_ga(x3)
U4_aga(x1, x2, x3)  =  U4_aga(x3)
less32_in_ag(x1, x2)  =  less32_in_ag(x2)
less32_out_ag(x1, x2)  =  less32_out_ag(x1)
U2_ag(x1, x2, x3)  =  U2_ag(x3)
U5_aga(x1, x2, x3)  =  U5_aga(x3)
MAX1_IN_AGA(x1, x2, x3)  =  MAX1_IN_AGA(x2)
U3_AGA(x1, x2, x3)  =  U3_AGA(x3)
LESS13_IN_GA(x1, x2)  =  LESS13_IN_GA(x1)
U1_GA(x1, x2, x3)  =  U1_GA(x3)
U4_AGA(x1, x2, x3)  =  U4_AGA(x3)
LESS32_IN_AG(x1, x2)  =  LESS32_IN_AG(x2)
U2_AG(x1, x2, x3)  =  U2_AG(x3)
U5_AGA(x1, x2, x3)  =  U5_AGA(x3)

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

(6) Obligation:

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

MAX1_IN_AGA(s(T24), s(T22), s(T24)) → U3_AGA(T24, T22, less13_in_ga(T22, T24))
MAX1_IN_AGA(s(T24), s(T22), s(T24)) → LESS13_IN_GA(T22, T24)
LESS13_IN_GA(s(T36), s(T38)) → U1_GA(T36, T38, less13_in_ga(T36, T38))
LESS13_IN_GA(s(T36), s(T38)) → LESS13_IN_GA(T36, T38)
MAX1_IN_AGA(s(T61), T60, T60) → U4_AGA(T61, T60, less32_in_ag(T61, T60))
MAX1_IN_AGA(s(T61), T60, T60) → LESS32_IN_AG(T61, T60)
LESS32_IN_AG(s(T75), s(T74)) → U2_AG(T75, T74, less32_in_ag(T75, T74))
LESS32_IN_AG(s(T75), s(T74)) → LESS32_IN_AG(T75, T74)
MAX1_IN_AGA(s(T94), T93, T93) → U5_AGA(T94, T93, less32_in_ag(T94, T93))

The TRS R consists of the following rules:

max1_in_aga(s(T13), 0, s(T13)) → max1_out_aga(s(T13), 0, s(T13))
max1_in_aga(s(T24), s(T22), s(T24)) → U3_aga(T24, T22, less13_in_ga(T22, T24))
less13_in_ga(0, s(T31)) → less13_out_ga(0, s(T31))
less13_in_ga(s(T36), s(T38)) → U1_ga(T36, T38, less13_in_ga(T36, T38))
U1_ga(T36, T38, less13_out_ga(T36, T38)) → less13_out_ga(s(T36), s(T38))
U3_aga(T24, T22, less13_out_ga(T22, T24)) → max1_out_aga(s(T24), s(T22), s(T24))
max1_in_aga(0, T54, T54) → max1_out_aga(0, T54, T54)
max1_in_aga(s(T61), T60, T60) → U4_aga(T61, T60, less32_in_ag(T61, T60))
less32_in_ag(0, s(T68)) → less32_out_ag(0, s(T68))
less32_in_ag(s(T75), s(T74)) → U2_ag(T75, T74, less32_in_ag(T75, T74))
U2_ag(T75, T74, less32_out_ag(T75, T74)) → less32_out_ag(s(T75), s(T74))
U4_aga(T61, T60, less32_out_ag(T61, T60)) → max1_out_aga(s(T61), T60, T60)
max1_in_aga(s(T94), T93, T93) → U5_aga(T94, T93, less32_in_ag(T94, T93))
U5_aga(T94, T93, less32_out_ag(T94, T93)) → max1_out_aga(s(T94), T93, T93)

The argument filtering Pi contains the following mapping:
max1_in_aga(x1, x2, x3)  =  max1_in_aga(x2)
0  =  0
max1_out_aga(x1, x2, x3)  =  max1_out_aga
s(x1)  =  s(x1)
U3_aga(x1, x2, x3)  =  U3_aga(x3)
less13_in_ga(x1, x2)  =  less13_in_ga(x1)
less13_out_ga(x1, x2)  =  less13_out_ga
U1_ga(x1, x2, x3)  =  U1_ga(x3)
U4_aga(x1, x2, x3)  =  U4_aga(x3)
less32_in_ag(x1, x2)  =  less32_in_ag(x2)
less32_out_ag(x1, x2)  =  less32_out_ag(x1)
U2_ag(x1, x2, x3)  =  U2_ag(x3)
U5_aga(x1, x2, x3)  =  U5_aga(x3)
MAX1_IN_AGA(x1, x2, x3)  =  MAX1_IN_AGA(x2)
U3_AGA(x1, x2, x3)  =  U3_AGA(x3)
LESS13_IN_GA(x1, x2)  =  LESS13_IN_GA(x1)
U1_GA(x1, x2, x3)  =  U1_GA(x3)
U4_AGA(x1, x2, x3)  =  U4_AGA(x3)
LESS32_IN_AG(x1, x2)  =  LESS32_IN_AG(x2)
U2_AG(x1, x2, x3)  =  U2_AG(x3)
U5_AGA(x1, x2, x3)  =  U5_AGA(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 7 less nodes.

(8) Complex Obligation (AND)

(9) Obligation:

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

LESS32_IN_AG(s(T75), s(T74)) → LESS32_IN_AG(T75, T74)

The TRS R consists of the following rules:

max1_in_aga(s(T13), 0, s(T13)) → max1_out_aga(s(T13), 0, s(T13))
max1_in_aga(s(T24), s(T22), s(T24)) → U3_aga(T24, T22, less13_in_ga(T22, T24))
less13_in_ga(0, s(T31)) → less13_out_ga(0, s(T31))
less13_in_ga(s(T36), s(T38)) → U1_ga(T36, T38, less13_in_ga(T36, T38))
U1_ga(T36, T38, less13_out_ga(T36, T38)) → less13_out_ga(s(T36), s(T38))
U3_aga(T24, T22, less13_out_ga(T22, T24)) → max1_out_aga(s(T24), s(T22), s(T24))
max1_in_aga(0, T54, T54) → max1_out_aga(0, T54, T54)
max1_in_aga(s(T61), T60, T60) → U4_aga(T61, T60, less32_in_ag(T61, T60))
less32_in_ag(0, s(T68)) → less32_out_ag(0, s(T68))
less32_in_ag(s(T75), s(T74)) → U2_ag(T75, T74, less32_in_ag(T75, T74))
U2_ag(T75, T74, less32_out_ag(T75, T74)) → less32_out_ag(s(T75), s(T74))
U4_aga(T61, T60, less32_out_ag(T61, T60)) → max1_out_aga(s(T61), T60, T60)
max1_in_aga(s(T94), T93, T93) → U5_aga(T94, T93, less32_in_ag(T94, T93))
U5_aga(T94, T93, less32_out_ag(T94, T93)) → max1_out_aga(s(T94), T93, T93)

The argument filtering Pi contains the following mapping:
max1_in_aga(x1, x2, x3)  =  max1_in_aga(x2)
0  =  0
max1_out_aga(x1, x2, x3)  =  max1_out_aga
s(x1)  =  s(x1)
U3_aga(x1, x2, x3)  =  U3_aga(x3)
less13_in_ga(x1, x2)  =  less13_in_ga(x1)
less13_out_ga(x1, x2)  =  less13_out_ga
U1_ga(x1, x2, x3)  =  U1_ga(x3)
U4_aga(x1, x2, x3)  =  U4_aga(x3)
less32_in_ag(x1, x2)  =  less32_in_ag(x2)
less32_out_ag(x1, x2)  =  less32_out_ag(x1)
U2_ag(x1, x2, x3)  =  U2_ag(x3)
U5_aga(x1, x2, x3)  =  U5_aga(x3)
LESS32_IN_AG(x1, x2)  =  LESS32_IN_AG(x2)

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:

LESS32_IN_AG(s(T75), s(T74)) → LESS32_IN_AG(T75, T74)

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

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

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

LESS32_IN_AG(s(T74)) → LESS32_IN_AG(T74)

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

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

  • LESS32_IN_AG(s(T74)) → LESS32_IN_AG(T74)
    The graph contains the following edges 1 > 1

(15) YES

(16) Obligation:

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

LESS13_IN_GA(s(T36), s(T38)) → LESS13_IN_GA(T36, T38)

The TRS R consists of the following rules:

max1_in_aga(s(T13), 0, s(T13)) → max1_out_aga(s(T13), 0, s(T13))
max1_in_aga(s(T24), s(T22), s(T24)) → U3_aga(T24, T22, less13_in_ga(T22, T24))
less13_in_ga(0, s(T31)) → less13_out_ga(0, s(T31))
less13_in_ga(s(T36), s(T38)) → U1_ga(T36, T38, less13_in_ga(T36, T38))
U1_ga(T36, T38, less13_out_ga(T36, T38)) → less13_out_ga(s(T36), s(T38))
U3_aga(T24, T22, less13_out_ga(T22, T24)) → max1_out_aga(s(T24), s(T22), s(T24))
max1_in_aga(0, T54, T54) → max1_out_aga(0, T54, T54)
max1_in_aga(s(T61), T60, T60) → U4_aga(T61, T60, less32_in_ag(T61, T60))
less32_in_ag(0, s(T68)) → less32_out_ag(0, s(T68))
less32_in_ag(s(T75), s(T74)) → U2_ag(T75, T74, less32_in_ag(T75, T74))
U2_ag(T75, T74, less32_out_ag(T75, T74)) → less32_out_ag(s(T75), s(T74))
U4_aga(T61, T60, less32_out_ag(T61, T60)) → max1_out_aga(s(T61), T60, T60)
max1_in_aga(s(T94), T93, T93) → U5_aga(T94, T93, less32_in_ag(T94, T93))
U5_aga(T94, T93, less32_out_ag(T94, T93)) → max1_out_aga(s(T94), T93, T93)

The argument filtering Pi contains the following mapping:
max1_in_aga(x1, x2, x3)  =  max1_in_aga(x2)
0  =  0
max1_out_aga(x1, x2, x3)  =  max1_out_aga
s(x1)  =  s(x1)
U3_aga(x1, x2, x3)  =  U3_aga(x3)
less13_in_ga(x1, x2)  =  less13_in_ga(x1)
less13_out_ga(x1, x2)  =  less13_out_ga
U1_ga(x1, x2, x3)  =  U1_ga(x3)
U4_aga(x1, x2, x3)  =  U4_aga(x3)
less32_in_ag(x1, x2)  =  less32_in_ag(x2)
less32_out_ag(x1, x2)  =  less32_out_ag(x1)
U2_ag(x1, x2, x3)  =  U2_ag(x3)
U5_aga(x1, x2, x3)  =  U5_aga(x3)
LESS13_IN_GA(x1, x2)  =  LESS13_IN_GA(x1)

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

(17) UsableRulesProof (EQUIVALENT transformation)

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

(18) Obligation:

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

LESS13_IN_GA(s(T36), s(T38)) → LESS13_IN_GA(T36, T38)

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

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

(19) PiDPToQDPProof (SOUND transformation)

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

(20) Obligation:

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

LESS13_IN_GA(s(T36)) → LESS13_IN_GA(T36)

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

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

  • LESS13_IN_GA(s(T36)) → LESS13_IN_GA(T36)
    The graph contains the following edges 1 > 1

(22) YES