(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,g,a)

(1) PrologToTRSTransformerProof (SOUND transformation)

Transformed Prolog program to TRS.

(2) Obligation:

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

f1_in(T8, void) → f1_out1(tree(T8, void, void))
f1_in(T21, tree(T21, T22, T23)) → f1_out1(tree(T21, T22, T23))
f1_in(T44, tree(T45, T46, T47)) → U1(f38_in(T44, T45, T46), T44, tree(T45, T46, T47))
U1(f38_out1(T49), T44, tree(T45, T46, T47)) → f1_out1(tree(T45, T49, T47))
f1_in(T79, tree(T80, T81, T82)) → U2(f92_in(T80, T79, T82), T79, tree(T80, T81, T82))
U2(f92_out1(T84), T79, tree(T80, T81, T82)) → f1_out1(tree(T80, T81, T84))
f56_in(0, s(T58)) → f56_out1
f56_in(s(T63), s(T64)) → U3(f56_in(T63, T64), s(T63), s(T64))
U3(f56_out1, s(T63), s(T64)) → f56_out1
f38_in(T44, T45, T46) → U4(f56_in(T44, T45), T44, T45, T46)
U4(f56_out1, T44, T45, T46) → U5(f1_in(T44, T46), T44, T45, T46)
U5(f1_out1(T49), T44, T45, T46) → f38_out1(T49)
f92_in(T80, T79, T82) → U6(f56_in(T80, T79), T80, T79, T82)
U6(f56_out1, T80, T79, T82) → U7(f1_in(T79, T82), T80, T79, T82)
U7(f1_out1(T84), T80, T79, T82) → f92_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:

F1_IN(T44, tree(T45, T46, T47)) → U11(f38_in(T44, T45, T46), T44, tree(T45, T46, T47))
F1_IN(T44, tree(T45, T46, T47)) → F38_IN(T44, T45, T46)
F1_IN(T79, tree(T80, T81, T82)) → U21(f92_in(T80, T79, T82), T79, tree(T80, T81, T82))
F1_IN(T79, tree(T80, T81, T82)) → F92_IN(T80, T79, T82)
F56_IN(s(T63), s(T64)) → U31(f56_in(T63, T64), s(T63), s(T64))
F56_IN(s(T63), s(T64)) → F56_IN(T63, T64)
F38_IN(T44, T45, T46) → U41(f56_in(T44, T45), T44, T45, T46)
F38_IN(T44, T45, T46) → F56_IN(T44, T45)
U41(f56_out1, T44, T45, T46) → U51(f1_in(T44, T46), T44, T45, T46)
U41(f56_out1, T44, T45, T46) → F1_IN(T44, T46)
F92_IN(T80, T79, T82) → U61(f56_in(T80, T79), T80, T79, T82)
F92_IN(T80, T79, T82) → F56_IN(T80, T79)
U61(f56_out1, T80, T79, T82) → U71(f1_in(T79, T82), T80, T79, T82)
U61(f56_out1, T80, T79, T82) → F1_IN(T79, T82)

The TRS R consists of the following rules:

f1_in(T8, void) → f1_out1(tree(T8, void, void))
f1_in(T21, tree(T21, T22, T23)) → f1_out1(tree(T21, T22, T23))
f1_in(T44, tree(T45, T46, T47)) → U1(f38_in(T44, T45, T46), T44, tree(T45, T46, T47))
U1(f38_out1(T49), T44, tree(T45, T46, T47)) → f1_out1(tree(T45, T49, T47))
f1_in(T79, tree(T80, T81, T82)) → U2(f92_in(T80, T79, T82), T79, tree(T80, T81, T82))
U2(f92_out1(T84), T79, tree(T80, T81, T82)) → f1_out1(tree(T80, T81, T84))
f56_in(0, s(T58)) → f56_out1
f56_in(s(T63), s(T64)) → U3(f56_in(T63, T64), s(T63), s(T64))
U3(f56_out1, s(T63), s(T64)) → f56_out1
f38_in(T44, T45, T46) → U4(f56_in(T44, T45), T44, T45, T46)
U4(f56_out1, T44, T45, T46) → U5(f1_in(T44, T46), T44, T45, T46)
U5(f1_out1(T49), T44, T45, T46) → f38_out1(T49)
f92_in(T80, T79, T82) → U6(f56_in(T80, T79), T80, T79, T82)
U6(f56_out1, T80, T79, T82) → U7(f1_in(T79, T82), T80, T79, T82)
U7(f1_out1(T84), T80, T79, T82) → f92_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:

F56_IN(s(T63), s(T64)) → F56_IN(T63, T64)

The TRS R consists of the following rules:

f1_in(T8, void) → f1_out1(tree(T8, void, void))
f1_in(T21, tree(T21, T22, T23)) → f1_out1(tree(T21, T22, T23))
f1_in(T44, tree(T45, T46, T47)) → U1(f38_in(T44, T45, T46), T44, tree(T45, T46, T47))
U1(f38_out1(T49), T44, tree(T45, T46, T47)) → f1_out1(tree(T45, T49, T47))
f1_in(T79, tree(T80, T81, T82)) → U2(f92_in(T80, T79, T82), T79, tree(T80, T81, T82))
U2(f92_out1(T84), T79, tree(T80, T81, T82)) → f1_out1(tree(T80, T81, T84))
f56_in(0, s(T58)) → f56_out1
f56_in(s(T63), s(T64)) → U3(f56_in(T63, T64), s(T63), s(T64))
U3(f56_out1, s(T63), s(T64)) → f56_out1
f38_in(T44, T45, T46) → U4(f56_in(T44, T45), T44, T45, T46)
U4(f56_out1, T44, T45, T46) → U5(f1_in(T44, T46), T44, T45, T46)
U5(f1_out1(T49), T44, T45, T46) → f38_out1(T49)
f92_in(T80, T79, T82) → U6(f56_in(T80, T79), T80, T79, T82)
U6(f56_out1, T80, T79, T82) → U7(f1_in(T79, T82), T80, T79, T82)
U7(f1_out1(T84), T80, T79, T82) → f92_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:

F56_IN(s(T63), s(T64)) → F56_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:

  • F56_IN(s(T63), s(T64)) → F56_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:

F1_IN(T44, tree(T45, T46, T47)) → F38_IN(T44, T45, T46)
F38_IN(T44, T45, T46) → U41(f56_in(T44, T45), T44, T45, T46)
U41(f56_out1, T44, T45, T46) → F1_IN(T44, T46)
F1_IN(T79, tree(T80, T81, T82)) → F92_IN(T80, T79, T82)
F92_IN(T80, T79, T82) → U61(f56_in(T80, T79), T80, T79, T82)
U61(f56_out1, T80, T79, T82) → F1_IN(T79, T82)

The TRS R consists of the following rules:

f1_in(T8, void) → f1_out1(tree(T8, void, void))
f1_in(T21, tree(T21, T22, T23)) → f1_out1(tree(T21, T22, T23))
f1_in(T44, tree(T45, T46, T47)) → U1(f38_in(T44, T45, T46), T44, tree(T45, T46, T47))
U1(f38_out1(T49), T44, tree(T45, T46, T47)) → f1_out1(tree(T45, T49, T47))
f1_in(T79, tree(T80, T81, T82)) → U2(f92_in(T80, T79, T82), T79, tree(T80, T81, T82))
U2(f92_out1(T84), T79, tree(T80, T81, T82)) → f1_out1(tree(T80, T81, T84))
f56_in(0, s(T58)) → f56_out1
f56_in(s(T63), s(T64)) → U3(f56_in(T63, T64), s(T63), s(T64))
U3(f56_out1, s(T63), s(T64)) → f56_out1
f38_in(T44, T45, T46) → U4(f56_in(T44, T45), T44, T45, T46)
U4(f56_out1, T44, T45, T46) → U5(f1_in(T44, T46), T44, T45, T46)
U5(f1_out1(T49), T44, T45, T46) → f38_out1(T49)
f92_in(T80, T79, T82) → U6(f56_in(T80, T79), T80, T79, T82)
U6(f56_out1, T80, T79, T82) → U7(f1_in(T79, T82), T80, T79, T82)
U7(f1_out1(T84), T80, T79, T82) → f92_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:

  • F38_IN(T44, T45, T46) → U41(f56_in(T44, T45), T44, T45, T46)
    The graph contains the following edges 1 >= 2, 2 >= 3, 3 >= 4

  • U41(f56_out1, T44, T45, T46) → F1_IN(T44, T46)
    The graph contains the following edges 2 >= 1, 4 >= 2

  • U61(f56_out1, T80, T79, T82) → F1_IN(T79, T82)
    The graph contains the following edges 3 >= 1, 4 >= 2

  • F1_IN(T44, tree(T45, T46, T47)) → F38_IN(T44, T45, T46)
    The graph contains the following edges 1 >= 1, 2 > 2, 2 > 3

  • F1_IN(T79, tree(T80, T81, T82)) → F92_IN(T80, T79, T82)
    The graph contains the following edges 2 > 1, 1 >= 2, 2 > 3

  • F92_IN(T80, T79, T82) → U61(f56_in(T80, T79), T80, T79, T82)
    The graph contains the following edges 1 >= 2, 2 >= 3, 3 >= 4

(14) YES