Left Termination of the query pattern hbal_tree_in_2(g, a) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof

Clauses:

hbal_tree(zero, nil).
hbal_tree(s(zero), t(x, nil, nil)).
hbal_tree(s(s(X)), t(x, L, R)) :- ','(distr(s(X), X, DL, DR), ','(hbal_tree(DL, L), hbal_tree(DR, R))).
distr(D1, X, D1, D1).
distr(D1, D2, D1, D2).
distr(D1, D2, D2, D1).

Queries:

hbal_tree(g,a).

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

hbal_tree_in_ga(zero, nil) → hbal_tree_out_ga(zero, nil)
hbal_tree_in_ga(s(zero), t(x, nil, nil)) → hbal_tree_out_ga(s(zero), t(x, nil, nil))
hbal_tree_in_ga(s(s(X)), t(x, L, R)) → U1_ga(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
distr_in_ggaa(D1, X, D1, D1) → distr_out_ggaa(D1, X, D1, D1)
distr_in_ggaa(D1, D2, D1, D2) → distr_out_ggaa(D1, D2, D1, D2)
distr_in_ggaa(D1, D2, D2, D1) → distr_out_ggaa(D1, D2, D2, D1)
U1_ga(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_ga(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U2_ga(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_ga(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U3_ga(X, L, R, DL, DR, hbal_tree_out_ga(DR, R)) → hbal_tree_out_ga(s(s(X)), t(x, L, R))

The argument filtering Pi contains the following mapping:
hbal_tree_in_ga(x1, x2)  =  hbal_tree_in_ga(x1)
zero  =  zero
hbal_tree_out_ga(x1, x2)  =  hbal_tree_out_ga(x2)
s(x1)  =  s(x1)
U1_ga(x1, x2, x3, x4)  =  U1_ga(x4)
distr_in_ggaa(x1, x2, x3, x4)  =  distr_in_ggaa(x1, x2)
distr_out_ggaa(x1, x2, x3, x4)  =  distr_out_ggaa(x3, x4)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x5, x6)
U3_ga(x1, x2, x3, x4, x5, x6)  =  U3_ga(x2, x6)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

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

hbal_tree_in_ga(zero, nil) → hbal_tree_out_ga(zero, nil)
hbal_tree_in_ga(s(zero), t(x, nil, nil)) → hbal_tree_out_ga(s(zero), t(x, nil, nil))
hbal_tree_in_ga(s(s(X)), t(x, L, R)) → U1_ga(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
distr_in_ggaa(D1, X, D1, D1) → distr_out_ggaa(D1, X, D1, D1)
distr_in_ggaa(D1, D2, D1, D2) → distr_out_ggaa(D1, D2, D1, D2)
distr_in_ggaa(D1, D2, D2, D1) → distr_out_ggaa(D1, D2, D2, D1)
U1_ga(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_ga(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U2_ga(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_ga(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U3_ga(X, L, R, DL, DR, hbal_tree_out_ga(DR, R)) → hbal_tree_out_ga(s(s(X)), t(x, L, R))

The argument filtering Pi contains the following mapping:
hbal_tree_in_ga(x1, x2)  =  hbal_tree_in_ga(x1)
zero  =  zero
hbal_tree_out_ga(x1, x2)  =  hbal_tree_out_ga(x2)
s(x1)  =  s(x1)
U1_ga(x1, x2, x3, x4)  =  U1_ga(x4)
distr_in_ggaa(x1, x2, x3, x4)  =  distr_in_ggaa(x1, x2)
distr_out_ggaa(x1, x2, x3, x4)  =  distr_out_ggaa(x3, x4)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x5, x6)
U3_ga(x1, x2, x3, x4, x5, x6)  =  U3_ga(x2, x6)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

HBAL_TREE_IN_GA(s(s(X)), t(x, L, R)) → U1_GA(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
HBAL_TREE_IN_GA(s(s(X)), t(x, L, R)) → DISTR_IN_GGAA(s(X), X, DL, DR)
U1_GA(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_GA(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U1_GA(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → HBAL_TREE_IN_GA(DL, L)
U2_GA(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_GA(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U2_GA(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → HBAL_TREE_IN_GA(DR, R)

The TRS R consists of the following rules:

hbal_tree_in_ga(zero, nil) → hbal_tree_out_ga(zero, nil)
hbal_tree_in_ga(s(zero), t(x, nil, nil)) → hbal_tree_out_ga(s(zero), t(x, nil, nil))
hbal_tree_in_ga(s(s(X)), t(x, L, R)) → U1_ga(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
distr_in_ggaa(D1, X, D1, D1) → distr_out_ggaa(D1, X, D1, D1)
distr_in_ggaa(D1, D2, D1, D2) → distr_out_ggaa(D1, D2, D1, D2)
distr_in_ggaa(D1, D2, D2, D1) → distr_out_ggaa(D1, D2, D2, D1)
U1_ga(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_ga(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U2_ga(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_ga(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U3_ga(X, L, R, DL, DR, hbal_tree_out_ga(DR, R)) → hbal_tree_out_ga(s(s(X)), t(x, L, R))

The argument filtering Pi contains the following mapping:
hbal_tree_in_ga(x1, x2)  =  hbal_tree_in_ga(x1)
zero  =  zero
hbal_tree_out_ga(x1, x2)  =  hbal_tree_out_ga(x2)
s(x1)  =  s(x1)
U1_ga(x1, x2, x3, x4)  =  U1_ga(x4)
distr_in_ggaa(x1, x2, x3, x4)  =  distr_in_ggaa(x1, x2)
distr_out_ggaa(x1, x2, x3, x4)  =  distr_out_ggaa(x3, x4)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x5, x6)
U3_ga(x1, x2, x3, x4, x5, x6)  =  U3_ga(x2, x6)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x
U2_GA(x1, x2, x3, x4, x5, x6)  =  U2_GA(x5, x6)
U3_GA(x1, x2, x3, x4, x5, x6)  =  U3_GA(x2, x6)
HBAL_TREE_IN_GA(x1, x2)  =  HBAL_TREE_IN_GA(x1)
U1_GA(x1, x2, x3, x4)  =  U1_GA(x4)
DISTR_IN_GGAA(x1, x2, x3, x4)  =  DISTR_IN_GGAA(x1, x2)

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

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

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

HBAL_TREE_IN_GA(s(s(X)), t(x, L, R)) → U1_GA(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
HBAL_TREE_IN_GA(s(s(X)), t(x, L, R)) → DISTR_IN_GGAA(s(X), X, DL, DR)
U1_GA(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_GA(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U1_GA(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → HBAL_TREE_IN_GA(DL, L)
U2_GA(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_GA(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U2_GA(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → HBAL_TREE_IN_GA(DR, R)

The TRS R consists of the following rules:

hbal_tree_in_ga(zero, nil) → hbal_tree_out_ga(zero, nil)
hbal_tree_in_ga(s(zero), t(x, nil, nil)) → hbal_tree_out_ga(s(zero), t(x, nil, nil))
hbal_tree_in_ga(s(s(X)), t(x, L, R)) → U1_ga(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
distr_in_ggaa(D1, X, D1, D1) → distr_out_ggaa(D1, X, D1, D1)
distr_in_ggaa(D1, D2, D1, D2) → distr_out_ggaa(D1, D2, D1, D2)
distr_in_ggaa(D1, D2, D2, D1) → distr_out_ggaa(D1, D2, D2, D1)
U1_ga(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_ga(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U2_ga(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_ga(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U3_ga(X, L, R, DL, DR, hbal_tree_out_ga(DR, R)) → hbal_tree_out_ga(s(s(X)), t(x, L, R))

The argument filtering Pi contains the following mapping:
hbal_tree_in_ga(x1, x2)  =  hbal_tree_in_ga(x1)
zero  =  zero
hbal_tree_out_ga(x1, x2)  =  hbal_tree_out_ga(x2)
s(x1)  =  s(x1)
U1_ga(x1, x2, x3, x4)  =  U1_ga(x4)
distr_in_ggaa(x1, x2, x3, x4)  =  distr_in_ggaa(x1, x2)
distr_out_ggaa(x1, x2, x3, x4)  =  distr_out_ggaa(x3, x4)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x5, x6)
U3_ga(x1, x2, x3, x4, x5, x6)  =  U3_ga(x2, x6)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x
U2_GA(x1, x2, x3, x4, x5, x6)  =  U2_GA(x5, x6)
U3_GA(x1, x2, x3, x4, x5, x6)  =  U3_GA(x2, x6)
HBAL_TREE_IN_GA(x1, x2)  =  HBAL_TREE_IN_GA(x1)
U1_GA(x1, x2, x3, x4)  =  U1_GA(x4)
DISTR_IN_GGAA(x1, x2, x3, x4)  =  DISTR_IN_GGAA(x1, x2)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 1 SCC with 2 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
PiDP
              ↳ PiDPToQDPProof

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

U2_GA(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → HBAL_TREE_IN_GA(DR, R)
HBAL_TREE_IN_GA(s(s(X)), t(x, L, R)) → U1_GA(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
U1_GA(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_GA(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U1_GA(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → HBAL_TREE_IN_GA(DL, L)

The TRS R consists of the following rules:

hbal_tree_in_ga(zero, nil) → hbal_tree_out_ga(zero, nil)
hbal_tree_in_ga(s(zero), t(x, nil, nil)) → hbal_tree_out_ga(s(zero), t(x, nil, nil))
hbal_tree_in_ga(s(s(X)), t(x, L, R)) → U1_ga(X, L, R, distr_in_ggaa(s(X), X, DL, DR))
distr_in_ggaa(D1, X, D1, D1) → distr_out_ggaa(D1, X, D1, D1)
distr_in_ggaa(D1, D2, D1, D2) → distr_out_ggaa(D1, D2, D1, D2)
distr_in_ggaa(D1, D2, D2, D1) → distr_out_ggaa(D1, D2, D2, D1)
U1_ga(X, L, R, distr_out_ggaa(s(X), X, DL, DR)) → U2_ga(X, L, R, DL, DR, hbal_tree_in_ga(DL, L))
U2_ga(X, L, R, DL, DR, hbal_tree_out_ga(DL, L)) → U3_ga(X, L, R, DL, DR, hbal_tree_in_ga(DR, R))
U3_ga(X, L, R, DL, DR, hbal_tree_out_ga(DR, R)) → hbal_tree_out_ga(s(s(X)), t(x, L, R))

The argument filtering Pi contains the following mapping:
hbal_tree_in_ga(x1, x2)  =  hbal_tree_in_ga(x1)
zero  =  zero
hbal_tree_out_ga(x1, x2)  =  hbal_tree_out_ga(x2)
s(x1)  =  s(x1)
U1_ga(x1, x2, x3, x4)  =  U1_ga(x4)
distr_in_ggaa(x1, x2, x3, x4)  =  distr_in_ggaa(x1, x2)
distr_out_ggaa(x1, x2, x3, x4)  =  distr_out_ggaa(x3, x4)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x5, x6)
U3_ga(x1, x2, x3, x4, x5, x6)  =  U3_ga(x2, x6)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x
U2_GA(x1, x2, x3, x4, x5, x6)  =  U2_GA(x5, x6)
HBAL_TREE_IN_GA(x1, x2)  =  HBAL_TREE_IN_GA(x1)
U1_GA(x1, x2, x3, x4)  =  U1_GA(x4)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ PiDPToQDPProof
QDP
                  ↳ QDPOrderProof

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

HBAL_TREE_IN_GA(s(s(X))) → U1_GA(distr_in_ggaa(s(X), X))
U1_GA(distr_out_ggaa(DL, DR)) → HBAL_TREE_IN_GA(DL)
U2_GA(DR, hbal_tree_out_ga(L)) → HBAL_TREE_IN_GA(DR)
U1_GA(distr_out_ggaa(DL, DR)) → U2_GA(DR, hbal_tree_in_ga(DL))

The TRS R consists of the following rules:

hbal_tree_in_ga(zero) → hbal_tree_out_ga(nil)
hbal_tree_in_ga(s(zero)) → hbal_tree_out_ga(t(x, nil, nil))
hbal_tree_in_ga(s(s(X))) → U1_ga(distr_in_ggaa(s(X), X))
distr_in_ggaa(D1, X) → distr_out_ggaa(D1, D1)
distr_in_ggaa(D1, D2) → distr_out_ggaa(D1, D2)
distr_in_ggaa(D1, D2) → distr_out_ggaa(D2, D1)
U1_ga(distr_out_ggaa(DL, DR)) → U2_ga(DR, hbal_tree_in_ga(DL))
U2_ga(DR, hbal_tree_out_ga(L)) → U3_ga(L, hbal_tree_in_ga(DR))
U3_ga(L, hbal_tree_out_ga(R)) → hbal_tree_out_ga(t(x, L, R))

The set Q consists of the following terms:

hbal_tree_in_ga(x0)
distr_in_ggaa(x0, x1)
U1_ga(x0)
U2_ga(x0, x1)
U3_ga(x0, x1)

We have to consider all (P,Q,R)-chains.
We use the reduction pair processor [15].


The following pairs can be oriented strictly and are deleted.


HBAL_TREE_IN_GA(s(s(X))) → U1_GA(distr_in_ggaa(s(X), X))
U1_GA(distr_out_ggaa(DL, DR)) → HBAL_TREE_IN_GA(DL)
U2_GA(DR, hbal_tree_out_ga(L)) → HBAL_TREE_IN_GA(DR)
U1_GA(distr_out_ggaa(DL, DR)) → U2_GA(DR, hbal_tree_in_ga(DL))
The remaining pairs can at least be oriented weakly.
none
Used ordering: Combined order from the following AFS and order.
HBAL_TREE_IN_GA(x1)  =  HBAL_TREE_IN_GA(x1)
s(x1)  =  s(x1)
U1_GA(x1)  =  U1_GA(x1)
distr_in_ggaa(x1, x2)  =  distr_in_ggaa(x1, x2)
distr_out_ggaa(x1, x2)  =  distr_out_ggaa(x1, x2)
U2_GA(x1, x2)  =  U2_GA(x1, x2)
hbal_tree_out_ga(x1)  =  hbal_tree_out_ga
hbal_tree_in_ga(x1)  =  hbal_tree_in_ga
zero  =  zero
t(x1, x2, x3)  =  x2
x  =  x
nil  =  nil
U3_ga(x1, x2)  =  x2
U1_ga(x1)  =  U1_ga
U2_ga(x1, x2)  =  x2

Recursive path order with status [2].
Quasi-Precedence:
[HBALTREEINGA1, s1, U1GA1, U2GA2, hbaltreeoutga, hbaltreeinga, zero, U1ga] > distringgaa2 > distroutggaa2
x > distroutggaa2
nil > distroutggaa2

Status:
U2GA2: [1,2]
nil: multiset
U1ga: []
distringgaa2: multiset
zero: multiset
hbaltreeinga: []
HBALTREEINGA1: [1]
s1: multiset
distroutggaa2: multiset
hbaltreeoutga: []
x: multiset
U1GA1: [1]


The following usable rules [17] were oriented:

distr_in_ggaa(D1, D2) → distr_out_ggaa(D2, D1)
hbal_tree_in_ga(s(zero)) → hbal_tree_out_ga(t(x, nil, nil))
distr_in_ggaa(D1, X) → distr_out_ggaa(D1, D1)
U3_ga(L, hbal_tree_out_ga(R)) → hbal_tree_out_ga(t(x, L, R))
hbal_tree_in_ga(zero) → hbal_tree_out_ga(nil)
U1_ga(distr_out_ggaa(DL, DR)) → U2_ga(DR, hbal_tree_in_ga(DL))
distr_in_ggaa(D1, D2) → distr_out_ggaa(D1, D2)
hbal_tree_in_ga(s(s(X))) → U1_ga(distr_in_ggaa(s(X), X))
U2_ga(DR, hbal_tree_out_ga(L)) → U3_ga(L, hbal_tree_in_ga(DR))



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ PiDPToQDPProof
                ↳ QDP
                  ↳ QDPOrderProof
QDP
                      ↳ PisEmptyProof

Q DP problem:
P is empty.
The TRS R consists of the following rules:

hbal_tree_in_ga(zero) → hbal_tree_out_ga(nil)
hbal_tree_in_ga(s(zero)) → hbal_tree_out_ga(t(x, nil, nil))
hbal_tree_in_ga(s(s(X))) → U1_ga(distr_in_ggaa(s(X), X))
distr_in_ggaa(D1, X) → distr_out_ggaa(D1, D1)
distr_in_ggaa(D1, D2) → distr_out_ggaa(D1, D2)
distr_in_ggaa(D1, D2) → distr_out_ggaa(D2, D1)
U1_ga(distr_out_ggaa(DL, DR)) → U2_ga(DR, hbal_tree_in_ga(DL))
U2_ga(DR, hbal_tree_out_ga(L)) → U3_ga(L, hbal_tree_in_ga(DR))
U3_ga(L, hbal_tree_out_ga(R)) → hbal_tree_out_ga(t(x, L, R))

The set Q consists of the following terms:

hbal_tree_in_ga(x0)
distr_in_ggaa(x0, x1)
U1_ga(x0)
U2_ga(x0, x1)
U3_ga(x0, x1)

We have to consider all (P,Q,R)-chains.
The TRS P is empty. Hence, there is no (P,Q,R) chain.