(0) Obligation:

Clauses:

insert(X, void, tree(X, void, void)).
insert(X, tree(X, Left, Right), tree(X, Left, Right)).
insert(X, tree(Y, Left, Right), tree(Y, Left1, Right)) :- ','(less(X, Y), insert(X, Left, Left1)).
insert(X, tree(Y, Left, Right), tree(Y, Left, Right1)) :- ','(less(Y, X), insert(X, Right, Right1)).
less(0, s(X1)).
less(s(X), s(Y)) :- less(X, Y).

Query: insert(g,a,g)

(1) PrologToTRSTransformerProof (SOUND transformation)

Transformed Prolog program to TRS.

(2) Obligation:

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

f2_in(T8, tree(T8, void, void)) → f2_out1(void)
f2_in(T21, tree(T21, T22, T23)) → f2_out1(tree(T21, T22, T23))
f2_in(T44, tree(T45, T48, T47)) → U1(f51_in(T44, T45, T48), T44, tree(T45, T48, T47))
U1(f51_out1(T49), T44, tree(T45, T48, T47)) → f2_out1(tree(T45, T49, T47))
f2_in(T79, tree(T80, T81, T83)) → U2(f86_in(T80, T79, T83), T79, tree(T80, T81, T83))
U2(f86_out1(T84), T79, tree(T80, T81, T83)) → f2_out1(tree(T80, T81, T84))
f55_in(0, s(T58)) → f55_out1
f55_in(s(T63), s(T64)) → U3(f55_in(T63, T64), s(T63), s(T64))
U3(f55_out1, s(T63), s(T64)) → f55_out1
f51_in(T44, T45, T48) → U4(f55_in(T44, T45), T44, T45, T48)
U4(f55_out1, T44, T45, T48) → U5(f2_in(T44, T48), T44, T45, T48)
U5(f2_out1(T49), T44, T45, T48) → f51_out1(T49)
f86_in(T80, T79, T83) → U6(f55_in(T80, T79), T80, T79, T83)
U6(f55_out1, T80, T79, T83) → U7(f2_in(T79, T83), T80, T79, T83)
U7(f2_out1(T84), T80, T79, T83) → f86_out1(T84)

Q is empty.

(3) DependencyPairsProof (EQUIVALENT transformation)

Using Dependency Pairs [AG00,LPAR04] we result in the following initial DP problem.

(4) Obligation:

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

F2_IN(T44, tree(T45, T48, T47)) → U11(f51_in(T44, T45, T48), T44, tree(T45, T48, T47))
F2_IN(T44, tree(T45, T48, T47)) → F51_IN(T44, T45, T48)
F2_IN(T79, tree(T80, T81, T83)) → U21(f86_in(T80, T79, T83), T79, tree(T80, T81, T83))
F2_IN(T79, tree(T80, T81, T83)) → F86_IN(T80, T79, T83)
F55_IN(s(T63), s(T64)) → U31(f55_in(T63, T64), s(T63), s(T64))
F55_IN(s(T63), s(T64)) → F55_IN(T63, T64)
F51_IN(T44, T45, T48) → U41(f55_in(T44, T45), T44, T45, T48)
F51_IN(T44, T45, T48) → F55_IN(T44, T45)
U41(f55_out1, T44, T45, T48) → U51(f2_in(T44, T48), T44, T45, T48)
U41(f55_out1, T44, T45, T48) → F2_IN(T44, T48)
F86_IN(T80, T79, T83) → U61(f55_in(T80, T79), T80, T79, T83)
F86_IN(T80, T79, T83) → F55_IN(T80, T79)
U61(f55_out1, T80, T79, T83) → U71(f2_in(T79, T83), T80, T79, T83)
U61(f55_out1, T80, T79, T83) → F2_IN(T79, T83)

The TRS R consists of the following rules:

f2_in(T8, tree(T8, void, void)) → f2_out1(void)
f2_in(T21, tree(T21, T22, T23)) → f2_out1(tree(T21, T22, T23))
f2_in(T44, tree(T45, T48, T47)) → U1(f51_in(T44, T45, T48), T44, tree(T45, T48, T47))
U1(f51_out1(T49), T44, tree(T45, T48, T47)) → f2_out1(tree(T45, T49, T47))
f2_in(T79, tree(T80, T81, T83)) → U2(f86_in(T80, T79, T83), T79, tree(T80, T81, T83))
U2(f86_out1(T84), T79, tree(T80, T81, T83)) → f2_out1(tree(T80, T81, T84))
f55_in(0, s(T58)) → f55_out1
f55_in(s(T63), s(T64)) → U3(f55_in(T63, T64), s(T63), s(T64))
U3(f55_out1, s(T63), s(T64)) → f55_out1
f51_in(T44, T45, T48) → U4(f55_in(T44, T45), T44, T45, T48)
U4(f55_out1, T44, T45, T48) → U5(f2_in(T44, T48), T44, T45, T48)
U5(f2_out1(T49), T44, T45, T48) → f51_out1(T49)
f86_in(T80, T79, T83) → U6(f55_in(T80, T79), T80, T79, T83)
U6(f55_out1, T80, T79, T83) → U7(f2_in(T79, T83), T80, T79, T83)
U7(f2_out1(T84), T80, T79, T83) → f86_out1(T84)

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

(5) DependencyGraphProof (EQUIVALENT transformation)

The approximation of the Dependency Graph [LPAR04,FROCOS05,EDGSTAR] contains 2 SCCs with 7 less nodes.

(6) Complex Obligation (AND)

(7) Obligation:

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

F55_IN(s(T63), s(T64)) → F55_IN(T63, T64)

The TRS R consists of the following rules:

f2_in(T8, tree(T8, void, void)) → f2_out1(void)
f2_in(T21, tree(T21, T22, T23)) → f2_out1(tree(T21, T22, T23))
f2_in(T44, tree(T45, T48, T47)) → U1(f51_in(T44, T45, T48), T44, tree(T45, T48, T47))
U1(f51_out1(T49), T44, tree(T45, T48, T47)) → f2_out1(tree(T45, T49, T47))
f2_in(T79, tree(T80, T81, T83)) → U2(f86_in(T80, T79, T83), T79, tree(T80, T81, T83))
U2(f86_out1(T84), T79, tree(T80, T81, T83)) → f2_out1(tree(T80, T81, T84))
f55_in(0, s(T58)) → f55_out1
f55_in(s(T63), s(T64)) → U3(f55_in(T63, T64), s(T63), s(T64))
U3(f55_out1, s(T63), s(T64)) → f55_out1
f51_in(T44, T45, T48) → U4(f55_in(T44, T45), T44, T45, T48)
U4(f55_out1, T44, T45, T48) → U5(f2_in(T44, T48), T44, T45, T48)
U5(f2_out1(T49), T44, T45, T48) → f51_out1(T49)
f86_in(T80, T79, T83) → U6(f55_in(T80, T79), T80, T79, T83)
U6(f55_out1, T80, T79, T83) → U7(f2_in(T79, T83), T80, T79, T83)
U7(f2_out1(T84), T80, T79, T83) → f86_out1(T84)

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

(8) UsableRulesProof (EQUIVALENT transformation)

We can use the usable rules and reduction pair processor [LPAR04] with the Ce-compatible extension of the polynomial order that maps every function symbol to the sum of its arguments. Then, we can delete all non-usable rules [FROCOS05] from R.

(9) Obligation:

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

F55_IN(s(T63), s(T64)) → F55_IN(T63, T64)

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

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

  • F55_IN(s(T63), s(T64)) → F55_IN(T63, T64)
    The graph contains the following edges 1 > 1, 2 > 2

(11) YES

(12) Obligation:

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

F2_IN(T44, tree(T45, T48, T47)) → F51_IN(T44, T45, T48)
F51_IN(T44, T45, T48) → U41(f55_in(T44, T45), T44, T45, T48)
U41(f55_out1, T44, T45, T48) → F2_IN(T44, T48)
F2_IN(T79, tree(T80, T81, T83)) → F86_IN(T80, T79, T83)
F86_IN(T80, T79, T83) → U61(f55_in(T80, T79), T80, T79, T83)
U61(f55_out1, T80, T79, T83) → F2_IN(T79, T83)

The TRS R consists of the following rules:

f2_in(T8, tree(T8, void, void)) → f2_out1(void)
f2_in(T21, tree(T21, T22, T23)) → f2_out1(tree(T21, T22, T23))
f2_in(T44, tree(T45, T48, T47)) → U1(f51_in(T44, T45, T48), T44, tree(T45, T48, T47))
U1(f51_out1(T49), T44, tree(T45, T48, T47)) → f2_out1(tree(T45, T49, T47))
f2_in(T79, tree(T80, T81, T83)) → U2(f86_in(T80, T79, T83), T79, tree(T80, T81, T83))
U2(f86_out1(T84), T79, tree(T80, T81, T83)) → f2_out1(tree(T80, T81, T84))
f55_in(0, s(T58)) → f55_out1
f55_in(s(T63), s(T64)) → U3(f55_in(T63, T64), s(T63), s(T64))
U3(f55_out1, s(T63), s(T64)) → f55_out1
f51_in(T44, T45, T48) → U4(f55_in(T44, T45), T44, T45, T48)
U4(f55_out1, T44, T45, T48) → U5(f2_in(T44, T48), T44, T45, T48)
U5(f2_out1(T49), T44, T45, T48) → f51_out1(T49)
f86_in(T80, T79, T83) → U6(f55_in(T80, T79), T80, T79, T83)
U6(f55_out1, T80, T79, T83) → U7(f2_in(T79, T83), T80, T79, T83)
U7(f2_out1(T84), T80, T79, T83) → f86_out1(T84)

Q is empty.
We have to consider all minimal (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:

  • F51_IN(T44, T45, T48) → U41(f55_in(T44, T45), T44, T45, T48)
    The graph contains the following edges 1 >= 2, 2 >= 3, 3 >= 4

  • U41(f55_out1, T44, T45, T48) → F2_IN(T44, T48)
    The graph contains the following edges 2 >= 1, 4 >= 2

  • U61(f55_out1, T80, T79, T83) → F2_IN(T79, T83)
    The graph contains the following edges 3 >= 1, 4 >= 2

  • F2_IN(T44, tree(T45, T48, T47)) → F51_IN(T44, T45, T48)
    The graph contains the following edges 1 >= 1, 2 > 2, 2 > 3

  • F2_IN(T79, tree(T80, T81, T83)) → F86_IN(T80, T79, T83)
    The graph contains the following edges 2 > 1, 1 >= 2, 2 > 3

  • F86_IN(T80, T79, T83) → U61(f55_in(T80, T79), T80, T79, T83)
    The graph contains the following edges 1 >= 2, 2 >= 3, 3 >= 4

(14) YES