Left Termination of the query pattern flatten(b,f) w.r.t. the given Prolog program could successfully be proven:



PROLOG
  ↳ PrologToPiTRSProof

flatten2(atom1(X), .2(X, {}0)).
flatten2(cons2(atom1(X), U), .2(X, Y)) :- flatten2(U, Y).
flatten2(cons2(cons2(U, V), W), X) :- flatten2(cons2(U, cons2(V, W)), X).


With regard to the inferred argument filtering the predicates were used in the following modes:
flatten2: (b,f)
Transforming PROLOG into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:


flatten_2_in_ga2(atom_11(X), ._22(X, []_0)) -> flatten_2_out_ga2(atom_11(X), ._22(X, []_0))
flatten_2_in_ga2(cons_22(atom_11(X), U), ._22(X, Y)) -> if_flatten_2_in_1_ga4(X, U, Y, flatten_2_in_ga2(U, Y))
flatten_2_in_ga2(cons_22(cons_22(U, V), W), X) -> if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_out_ga2(cons_22(U, cons_22(V, W)), X)) -> flatten_2_out_ga2(cons_22(cons_22(U, V), W), X)
if_flatten_2_in_1_ga4(X, U, Y, flatten_2_out_ga2(U, Y)) -> flatten_2_out_ga2(cons_22(atom_11(X), U), ._22(X, Y))

The argument filtering Pi contains the following mapping:
flatten_2_in_ga2(x1, x2)  =  flatten_2_in_ga1(x1)
atom_11(x1)  =  atom_11(x1)
._22(x1, x2)  =  ._22(x1, x2)
[]_0  =  []_0
cons_22(x1, x2)  =  cons_22(x1, x2)
flatten_2_out_ga2(x1, x2)  =  flatten_2_out_ga1(x2)
if_flatten_2_in_1_ga4(x1, x2, x3, x4)  =  if_flatten_2_in_1_ga2(x1, x4)
if_flatten_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_flatten_2_in_2_ga1(x5)

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:

flatten_2_in_ga2(atom_11(X), ._22(X, []_0)) -> flatten_2_out_ga2(atom_11(X), ._22(X, []_0))
flatten_2_in_ga2(cons_22(atom_11(X), U), ._22(X, Y)) -> if_flatten_2_in_1_ga4(X, U, Y, flatten_2_in_ga2(U, Y))
flatten_2_in_ga2(cons_22(cons_22(U, V), W), X) -> if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_out_ga2(cons_22(U, cons_22(V, W)), X)) -> flatten_2_out_ga2(cons_22(cons_22(U, V), W), X)
if_flatten_2_in_1_ga4(X, U, Y, flatten_2_out_ga2(U, Y)) -> flatten_2_out_ga2(cons_22(atom_11(X), U), ._22(X, Y))

The argument filtering Pi contains the following mapping:
flatten_2_in_ga2(x1, x2)  =  flatten_2_in_ga1(x1)
atom_11(x1)  =  atom_11(x1)
._22(x1, x2)  =  ._22(x1, x2)
[]_0  =  []_0
cons_22(x1, x2)  =  cons_22(x1, x2)
flatten_2_out_ga2(x1, x2)  =  flatten_2_out_ga1(x2)
if_flatten_2_in_1_ga4(x1, x2, x3, x4)  =  if_flatten_2_in_1_ga2(x1, x4)
if_flatten_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_flatten_2_in_2_ga1(x5)


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

FLATTEN_2_IN_GA2(cons_22(atom_11(X), U), ._22(X, Y)) -> IF_FLATTEN_2_IN_1_GA4(X, U, Y, flatten_2_in_ga2(U, Y))
FLATTEN_2_IN_GA2(cons_22(atom_11(X), U), ._22(X, Y)) -> FLATTEN_2_IN_GA2(U, Y)
FLATTEN_2_IN_GA2(cons_22(cons_22(U, V), W), X) -> IF_FLATTEN_2_IN_2_GA5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
FLATTEN_2_IN_GA2(cons_22(cons_22(U, V), W), X) -> FLATTEN_2_IN_GA2(cons_22(U, cons_22(V, W)), X)

The TRS R consists of the following rules:

flatten_2_in_ga2(atom_11(X), ._22(X, []_0)) -> flatten_2_out_ga2(atom_11(X), ._22(X, []_0))
flatten_2_in_ga2(cons_22(atom_11(X), U), ._22(X, Y)) -> if_flatten_2_in_1_ga4(X, U, Y, flatten_2_in_ga2(U, Y))
flatten_2_in_ga2(cons_22(cons_22(U, V), W), X) -> if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_out_ga2(cons_22(U, cons_22(V, W)), X)) -> flatten_2_out_ga2(cons_22(cons_22(U, V), W), X)
if_flatten_2_in_1_ga4(X, U, Y, flatten_2_out_ga2(U, Y)) -> flatten_2_out_ga2(cons_22(atom_11(X), U), ._22(X, Y))

The argument filtering Pi contains the following mapping:
flatten_2_in_ga2(x1, x2)  =  flatten_2_in_ga1(x1)
atom_11(x1)  =  atom_11(x1)
._22(x1, x2)  =  ._22(x1, x2)
[]_0  =  []_0
cons_22(x1, x2)  =  cons_22(x1, x2)
flatten_2_out_ga2(x1, x2)  =  flatten_2_out_ga1(x2)
if_flatten_2_in_1_ga4(x1, x2, x3, x4)  =  if_flatten_2_in_1_ga2(x1, x4)
if_flatten_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_flatten_2_in_2_ga1(x5)
FLATTEN_2_IN_GA2(x1, x2)  =  FLATTEN_2_IN_GA1(x1)
IF_FLATTEN_2_IN_2_GA5(x1, x2, x3, x4, x5)  =  IF_FLATTEN_2_IN_2_GA1(x5)
IF_FLATTEN_2_IN_1_GA4(x1, x2, x3, x4)  =  IF_FLATTEN_2_IN_1_GA2(x1, x4)

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:

FLATTEN_2_IN_GA2(cons_22(atom_11(X), U), ._22(X, Y)) -> IF_FLATTEN_2_IN_1_GA4(X, U, Y, flatten_2_in_ga2(U, Y))
FLATTEN_2_IN_GA2(cons_22(atom_11(X), U), ._22(X, Y)) -> FLATTEN_2_IN_GA2(U, Y)
FLATTEN_2_IN_GA2(cons_22(cons_22(U, V), W), X) -> IF_FLATTEN_2_IN_2_GA5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
FLATTEN_2_IN_GA2(cons_22(cons_22(U, V), W), X) -> FLATTEN_2_IN_GA2(cons_22(U, cons_22(V, W)), X)

The TRS R consists of the following rules:

flatten_2_in_ga2(atom_11(X), ._22(X, []_0)) -> flatten_2_out_ga2(atom_11(X), ._22(X, []_0))
flatten_2_in_ga2(cons_22(atom_11(X), U), ._22(X, Y)) -> if_flatten_2_in_1_ga4(X, U, Y, flatten_2_in_ga2(U, Y))
flatten_2_in_ga2(cons_22(cons_22(U, V), W), X) -> if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_out_ga2(cons_22(U, cons_22(V, W)), X)) -> flatten_2_out_ga2(cons_22(cons_22(U, V), W), X)
if_flatten_2_in_1_ga4(X, U, Y, flatten_2_out_ga2(U, Y)) -> flatten_2_out_ga2(cons_22(atom_11(X), U), ._22(X, Y))

The argument filtering Pi contains the following mapping:
flatten_2_in_ga2(x1, x2)  =  flatten_2_in_ga1(x1)
atom_11(x1)  =  atom_11(x1)
._22(x1, x2)  =  ._22(x1, x2)
[]_0  =  []_0
cons_22(x1, x2)  =  cons_22(x1, x2)
flatten_2_out_ga2(x1, x2)  =  flatten_2_out_ga1(x2)
if_flatten_2_in_1_ga4(x1, x2, x3, x4)  =  if_flatten_2_in_1_ga2(x1, x4)
if_flatten_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_flatten_2_in_2_ga1(x5)
FLATTEN_2_IN_GA2(x1, x2)  =  FLATTEN_2_IN_GA1(x1)
IF_FLATTEN_2_IN_2_GA5(x1, x2, x3, x4, x5)  =  IF_FLATTEN_2_IN_2_GA1(x5)
IF_FLATTEN_2_IN_1_GA4(x1, x2, x3, x4)  =  IF_FLATTEN_2_IN_1_GA2(x1, x4)

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

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
PiDP
              ↳ UsableRulesProof

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

FLATTEN_2_IN_GA2(cons_22(atom_11(X), U), ._22(X, Y)) -> FLATTEN_2_IN_GA2(U, Y)
FLATTEN_2_IN_GA2(cons_22(cons_22(U, V), W), X) -> FLATTEN_2_IN_GA2(cons_22(U, cons_22(V, W)), X)

The TRS R consists of the following rules:

flatten_2_in_ga2(atom_11(X), ._22(X, []_0)) -> flatten_2_out_ga2(atom_11(X), ._22(X, []_0))
flatten_2_in_ga2(cons_22(atom_11(X), U), ._22(X, Y)) -> if_flatten_2_in_1_ga4(X, U, Y, flatten_2_in_ga2(U, Y))
flatten_2_in_ga2(cons_22(cons_22(U, V), W), X) -> if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_in_ga2(cons_22(U, cons_22(V, W)), X))
if_flatten_2_in_2_ga5(U, V, W, X, flatten_2_out_ga2(cons_22(U, cons_22(V, W)), X)) -> flatten_2_out_ga2(cons_22(cons_22(U, V), W), X)
if_flatten_2_in_1_ga4(X, U, Y, flatten_2_out_ga2(U, Y)) -> flatten_2_out_ga2(cons_22(atom_11(X), U), ._22(X, Y))

The argument filtering Pi contains the following mapping:
flatten_2_in_ga2(x1, x2)  =  flatten_2_in_ga1(x1)
atom_11(x1)  =  atom_11(x1)
._22(x1, x2)  =  ._22(x1, x2)
[]_0  =  []_0
cons_22(x1, x2)  =  cons_22(x1, x2)
flatten_2_out_ga2(x1, x2)  =  flatten_2_out_ga1(x2)
if_flatten_2_in_1_ga4(x1, x2, x3, x4)  =  if_flatten_2_in_1_ga2(x1, x4)
if_flatten_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_flatten_2_in_2_ga1(x5)
FLATTEN_2_IN_GA2(x1, x2)  =  FLATTEN_2_IN_GA1(x1)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting we can delete all non-usable rules from R.

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
PiDP
                  ↳ PiDPToQDPProof

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

FLATTEN_2_IN_GA2(cons_22(atom_11(X), U), ._22(X, Y)) -> FLATTEN_2_IN_GA2(U, Y)
FLATTEN_2_IN_GA2(cons_22(cons_22(U, V), W), X) -> FLATTEN_2_IN_GA2(cons_22(U, cons_22(V, W)), X)

R is empty.
The argument filtering Pi contains the following mapping:
atom_11(x1)  =  atom_11(x1)
._22(x1, x2)  =  ._22(x1, x2)
cons_22(x1, x2)  =  cons_22(x1, x2)
FLATTEN_2_IN_GA2(x1, x2)  =  FLATTEN_2_IN_GA1(x1)

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

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
QDP
                      ↳ RuleRemovalProof

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

FLATTEN_2_IN_GA1(cons_22(atom_11(X), U)) -> FLATTEN_2_IN_GA1(U)
FLATTEN_2_IN_GA1(cons_22(cons_22(U, V), W)) -> FLATTEN_2_IN_GA1(cons_22(U, cons_22(V, W)))

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
The head symbols of this DP problem are {FLATTEN_2_IN_GA1}.
By using a polynomial ordering, at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

FLATTEN_2_IN_GA1(cons_22(atom_11(X), U)) -> FLATTEN_2_IN_GA1(U)


Used ordering: POLO with Polynomial interpretation:

POL(FLATTEN_2_IN_GA1(x1)) = 1 + x1   
POL(atom_11(x1)) = 1 + x1   
POL(cons_22(x1, x2)) = x1 + x2   



↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
                    ↳ QDP
                      ↳ RuleRemovalProof
QDP
                          ↳ QDPSizeChangeProof

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

FLATTEN_2_IN_GA1(cons_22(cons_22(U, V), W)) -> FLATTEN_2_IN_GA1(cons_22(U, cons_22(V, W)))

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
The head symbols of this DP problem are {FLATTEN_2_IN_GA1}.
We used the following order and afs together with the size-change analysis to show that there are no infinite chains for this DP problem.

Order:Homeomorphic Embedding Order

AFS:
cons_22(x1, x2)  =  cons_21(x1)

From the DPs we obtained the following set of size-change graphs:

We oriented the following set of usable rules. none