(0) Obligation:

Clauses:

balance(T, TB) :- balance(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])).
balance(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)).
balance(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) :- ','(balance(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)), balance(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))).

Queries:

balance(a,g).

(1) PrologToPiTRSProof (SOUND transformation)

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

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x2, x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag(x2)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(2) Obligation:

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

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x2, x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag(x2)

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

BALANCE_IN_AG(T, TB) → U1_AG(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN_AG(T, TB) → BALANCE_IN_AAAAA(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x2, x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag(x2)
BALANCE_IN_AG(x1, x2)  =  BALANCE_IN_AG(x2)
U1_AG(x1, x2, x3)  =  U1_AG(x2, x3)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)
U3_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_AAAAA(x18)

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

(4) Obligation:

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

BALANCE_IN_AG(T, TB) → U1_AG(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN_AG(T, TB) → BALANCE_IN_AAAAA(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x2, x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag(x2)
BALANCE_IN_AG(x1, x2)  =  BALANCE_IN_AG(x2)
U1_AG(x1, x2, x3)  =  U1_AG(x2, x3)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)
U3_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_AAAAA(x18)

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

(5) DependencyGraphProof (EQUIVALENT transformation)

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

(6) Obligation:

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

U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))

The TRS R consists of the following rules:

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x2, x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag(x2)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)

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

(7) UsableRulesProof (EQUIVALENT transformation)

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

(8) Obligation:

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

U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))

The TRS R consists of the following rules:

balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))

The argument filtering Pi contains the following mapping:
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)

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

(9) PiDPToQDPProof (SOUND transformation)

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

(10) Obligation:

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

U2_AAAAA(balance_out_aaaaa) → BALANCE_IN_AAAAA
BALANCE_IN_AAAAAU2_AAAAA(balance_in_aaaaa)
BALANCE_IN_AAAAABALANCE_IN_AAAAA

The TRS R consists of the following rules:

balance_in_aaaaabalance_out_aaaaa
balance_in_aaaaaU2_aaaaa(balance_in_aaaaa)
U2_aaaaa(balance_out_aaaaa) → U3_aaaaa(balance_in_aaaaa)
U3_aaaaa(balance_out_aaaaa) → balance_out_aaaaa

The set Q consists of the following terms:

balance_in_aaaaa
U2_aaaaa(x0)
U3_aaaaa(x0)

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

(11) Narrowing (SOUND transformation)

By narrowing [LPAR04] the rule BALANCE_IN_AAAAAU2_AAAAA(balance_in_aaaaa) at position [0] we obtained the following new rules [LPAR04]:

BALANCE_IN_AAAAAU2_AAAAA(balance_out_aaaaa)
BALANCE_IN_AAAAAU2_AAAAA(U2_aaaaa(balance_in_aaaaa))

(12) Obligation:

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

U2_AAAAA(balance_out_aaaaa) → BALANCE_IN_AAAAA
BALANCE_IN_AAAAABALANCE_IN_AAAAA
BALANCE_IN_AAAAAU2_AAAAA(balance_out_aaaaa)
BALANCE_IN_AAAAAU2_AAAAA(U2_aaaaa(balance_in_aaaaa))

The TRS R consists of the following rules:

balance_in_aaaaabalance_out_aaaaa
balance_in_aaaaaU2_aaaaa(balance_in_aaaaa)
U2_aaaaa(balance_out_aaaaa) → U3_aaaaa(balance_in_aaaaa)
U3_aaaaa(balance_out_aaaaa) → balance_out_aaaaa

The set Q consists of the following terms:

balance_in_aaaaa
U2_aaaaa(x0)
U3_aaaaa(x0)

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

(13) NonTerminationProof (EQUIVALENT transformation)

We used the non-termination processor [FROCOS05] to show that the DP problem is infinite.
Found a loop by semiunifying a rule from P directly.

s = BALANCE_IN_AAAAA evaluates to t =BALANCE_IN_AAAAA

Thus s starts an infinite chain as s semiunifies with t with the following substitutions:
  • Matcher: [ ]
  • Semiunifier: [ ]




Rewriting sequence

The DP semiunifies directly so there is only one rewrite step from BALANCE_IN_AAAAA to BALANCE_IN_AAAAA.



(14) FALSE

(15) PrologToPiTRSProof (SOUND transformation)

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

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(16) Obligation:

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

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag

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

BALANCE_IN_AG(T, TB) → U1_AG(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN_AG(T, TB) → BALANCE_IN_AAAAA(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag
BALANCE_IN_AG(x1, x2)  =  BALANCE_IN_AG(x2)
U1_AG(x1, x2, x3)  =  U1_AG(x3)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)
U3_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_AAAAA(x18)

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

(18) Obligation:

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

BALANCE_IN_AG(T, TB) → U1_AG(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN_AG(T, TB) → BALANCE_IN_AAAAA(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag
BALANCE_IN_AG(x1, x2)  =  BALANCE_IN_AG(x2)
U1_AG(x1, x2, x3)  =  U1_AG(x3)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)
U3_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_AAAAA(x18)

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

(19) DependencyGraphProof (EQUIVALENT transformation)

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

(20) Obligation:

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

U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))

The TRS R consists of the following rules:

balance_in_ag(T, TB) → U1_ag(T, TB, balance_in_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1_ag(T, TB, balance_out_aaaaa(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out_ag(T, TB)

The argument filtering Pi contains the following mapping:
balance_in_ag(x1, x2)  =  balance_in_ag(x2)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
balance_out_ag(x1, x2)  =  balance_out_ag
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)

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

(21) UsableRulesProof (EQUIVALENT transformation)

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

(22) Obligation:

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

U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN_AAAAA(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_AAAAA(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN_AAAAA(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN_AAAAA(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))

The TRS R consists of the following rules:

balance_in_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out_aaaaa(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
balance_in_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U2_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3_aaaaa(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out_aaaaa(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out_aaaaa(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))

The argument filtering Pi contains the following mapping:
balance_in_aaaaa(x1, x2, x3, x4, x5)  =  balance_in_aaaaa
balance_out_aaaaa(x1, x2, x3, x4, x5)  =  balance_out_aaaaa
U2_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_aaaaa(x18)
U3_aaaaa(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3_aaaaa(x18)
BALANCE_IN_AAAAA(x1, x2, x3, x4, x5)  =  BALANCE_IN_AAAAA
U2_AAAAA(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2_AAAAA(x18)

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

(23) PiDPToQDPProof (SOUND transformation)

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

(24) Obligation:

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

U2_AAAAA(balance_out_aaaaa) → BALANCE_IN_AAAAA
BALANCE_IN_AAAAAU2_AAAAA(balance_in_aaaaa)
BALANCE_IN_AAAAABALANCE_IN_AAAAA

The TRS R consists of the following rules:

balance_in_aaaaabalance_out_aaaaa
balance_in_aaaaaU2_aaaaa(balance_in_aaaaa)
U2_aaaaa(balance_out_aaaaa) → U3_aaaaa(balance_in_aaaaa)
U3_aaaaa(balance_out_aaaaa) → balance_out_aaaaa

The set Q consists of the following terms:

balance_in_aaaaa
U2_aaaaa(x0)
U3_aaaaa(x0)

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

(25) Narrowing (SOUND transformation)

By narrowing [LPAR04] the rule BALANCE_IN_AAAAAU2_AAAAA(balance_in_aaaaa) at position [0] we obtained the following new rules [LPAR04]:

BALANCE_IN_AAAAAU2_AAAAA(balance_out_aaaaa)
BALANCE_IN_AAAAAU2_AAAAA(U2_aaaaa(balance_in_aaaaa))

(26) Obligation:

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

U2_AAAAA(balance_out_aaaaa) → BALANCE_IN_AAAAA
BALANCE_IN_AAAAABALANCE_IN_AAAAA
BALANCE_IN_AAAAAU2_AAAAA(balance_out_aaaaa)
BALANCE_IN_AAAAAU2_AAAAA(U2_aaaaa(balance_in_aaaaa))

The TRS R consists of the following rules:

balance_in_aaaaabalance_out_aaaaa
balance_in_aaaaaU2_aaaaa(balance_in_aaaaa)
U2_aaaaa(balance_out_aaaaa) → U3_aaaaa(balance_in_aaaaa)
U3_aaaaa(balance_out_aaaaa) → balance_out_aaaaa

The set Q consists of the following terms:

balance_in_aaaaa
U2_aaaaa(x0)
U3_aaaaa(x0)

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

(27) NonTerminationProof (EQUIVALENT transformation)

We used the non-termination processor [FROCOS05] to show that the DP problem is infinite.
Found a loop by semiunifying a rule from P directly.

s = BALANCE_IN_AAAAA evaluates to t =BALANCE_IN_AAAAA

Thus s starts an infinite chain as s semiunifies with t with the following substitutions:
  • Semiunifier: [ ]
  • Matcher: [ ]




Rewriting sequence

The DP semiunifies directly so there is only one rewrite step from BALANCE_IN_AAAAA to BALANCE_IN_AAAAA.



(28) FALSE