(0) Obligation:

Clauses:

flatten(atom(X), .(X, [])).
flatten(cons(atom(X), U), .(X, Y)) :- flatten(U, Y).
flatten(cons(cons(U, V), W), X) :- flatten(cons(U, cons(V, W)), X).

Query: flatten(g,a)

(1) PrologToPiTRSViaGraphTransformerProof (SOUND transformation)

Transformed Prolog program to (Pi-)TRS.

(2) Obligation:

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

flattenA_in_ga(atom(T4), .(T4, [])) → flattenA_out_ga(atom(T4), .(T4, []))
flattenA_in_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, []))) → flattenA_out_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, [])))
flattenA_in_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → U1_ga(T8, T29, T30, T32, flattenA_in_ga(T30, T32))
flattenA_in_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → U2_ga(T8, T51, T52, T53, T55, flattenA_in_ga(cons(T51, cons(T52, T53)), T55))
flattenA_in_ga(cons(cons(atom(T81), T82), T83), .(T81, T85)) → U3_ga(T81, T82, T83, T85, flattenA_in_ga(cons(T82, T83), T85))
flattenA_in_ga(cons(cons(cons(T96, T97), T98), T99), T101) → U4_ga(T96, T97, T98, T99, T101, flattenA_in_ga(cons(T96, cons(T97, cons(T98, T99))), T101))
U4_ga(T96, T97, T98, T99, T101, flattenA_out_ga(cons(T96, cons(T97, cons(T98, T99))), T101)) → flattenA_out_ga(cons(cons(cons(T96, T97), T98), T99), T101)
U3_ga(T81, T82, T83, T85, flattenA_out_ga(cons(T82, T83), T85)) → flattenA_out_ga(cons(cons(atom(T81), T82), T83), .(T81, T85))
U2_ga(T8, T51, T52, T53, T55, flattenA_out_ga(cons(T51, cons(T52, T53)), T55)) → flattenA_out_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55))
U1_ga(T8, T29, T30, T32, flattenA_out_ga(T30, T32)) → flattenA_out_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32)))

The argument filtering Pi contains the following mapping:
flattenA_in_ga(x1, x2)  =  flattenA_in_ga(x1)
atom(x1)  =  atom(x1)
flattenA_out_ga(x1, x2)  =  flattenA_out_ga(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U1_ga(x1, x2, x3, x4, x5)  =  U1_ga(x1, x2, x3, x5)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x1, x2, x3, x4, x6)
U3_ga(x1, x2, x3, x4, x5)  =  U3_ga(x1, x2, x3, x5)
U4_ga(x1, x2, x3, x4, x5, x6)  =  U4_ga(x1, x2, x3, x4, x6)
.(x1, x2)  =  .(x1, 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:

FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → U1_GA(T8, T29, T30, T32, flattenA_in_ga(T30, T32))
FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → FLATTENA_IN_GA(T30, T32)
FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → U2_GA(T8, T51, T52, T53, T55, flattenA_in_ga(cons(T51, cons(T52, T53)), T55))
FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → FLATTENA_IN_GA(cons(T51, cons(T52, T53)), T55)
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83), .(T81, T85)) → U3_GA(T81, T82, T83, T85, flattenA_in_ga(cons(T82, T83), T85))
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83), .(T81, T85)) → FLATTENA_IN_GA(cons(T82, T83), T85)
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99), T101) → U4_GA(T96, T97, T98, T99, T101, flattenA_in_ga(cons(T96, cons(T97, cons(T98, T99))), T101))
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99), T101) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))), T101)

The TRS R consists of the following rules:

flattenA_in_ga(atom(T4), .(T4, [])) → flattenA_out_ga(atom(T4), .(T4, []))
flattenA_in_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, []))) → flattenA_out_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, [])))
flattenA_in_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → U1_ga(T8, T29, T30, T32, flattenA_in_ga(T30, T32))
flattenA_in_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → U2_ga(T8, T51, T52, T53, T55, flattenA_in_ga(cons(T51, cons(T52, T53)), T55))
flattenA_in_ga(cons(cons(atom(T81), T82), T83), .(T81, T85)) → U3_ga(T81, T82, T83, T85, flattenA_in_ga(cons(T82, T83), T85))
flattenA_in_ga(cons(cons(cons(T96, T97), T98), T99), T101) → U4_ga(T96, T97, T98, T99, T101, flattenA_in_ga(cons(T96, cons(T97, cons(T98, T99))), T101))
U4_ga(T96, T97, T98, T99, T101, flattenA_out_ga(cons(T96, cons(T97, cons(T98, T99))), T101)) → flattenA_out_ga(cons(cons(cons(T96, T97), T98), T99), T101)
U3_ga(T81, T82, T83, T85, flattenA_out_ga(cons(T82, T83), T85)) → flattenA_out_ga(cons(cons(atom(T81), T82), T83), .(T81, T85))
U2_ga(T8, T51, T52, T53, T55, flattenA_out_ga(cons(T51, cons(T52, T53)), T55)) → flattenA_out_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55))
U1_ga(T8, T29, T30, T32, flattenA_out_ga(T30, T32)) → flattenA_out_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32)))

The argument filtering Pi contains the following mapping:
flattenA_in_ga(x1, x2)  =  flattenA_in_ga(x1)
atom(x1)  =  atom(x1)
flattenA_out_ga(x1, x2)  =  flattenA_out_ga(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U1_ga(x1, x2, x3, x4, x5)  =  U1_ga(x1, x2, x3, x5)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x1, x2, x3, x4, x6)
U3_ga(x1, x2, x3, x4, x5)  =  U3_ga(x1, x2, x3, x5)
U4_ga(x1, x2, x3, x4, x5, x6)  =  U4_ga(x1, x2, x3, x4, x6)
.(x1, x2)  =  .(x1, x2)
FLATTENA_IN_GA(x1, x2)  =  FLATTENA_IN_GA(x1)
U1_GA(x1, x2, x3, x4, x5)  =  U1_GA(x1, x2, x3, x5)
U2_GA(x1, x2, x3, x4, x5, x6)  =  U2_GA(x1, x2, x3, x4, x6)
U3_GA(x1, x2, x3, x4, x5)  =  U3_GA(x1, x2, x3, x5)
U4_GA(x1, x2, x3, x4, x5, x6)  =  U4_GA(x1, x2, x3, x4, x6)

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

(4) Obligation:

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

FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → U1_GA(T8, T29, T30, T32, flattenA_in_ga(T30, T32))
FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → FLATTENA_IN_GA(T30, T32)
FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → U2_GA(T8, T51, T52, T53, T55, flattenA_in_ga(cons(T51, cons(T52, T53)), T55))
FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → FLATTENA_IN_GA(cons(T51, cons(T52, T53)), T55)
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83), .(T81, T85)) → U3_GA(T81, T82, T83, T85, flattenA_in_ga(cons(T82, T83), T85))
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83), .(T81, T85)) → FLATTENA_IN_GA(cons(T82, T83), T85)
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99), T101) → U4_GA(T96, T97, T98, T99, T101, flattenA_in_ga(cons(T96, cons(T97, cons(T98, T99))), T101))
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99), T101) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))), T101)

The TRS R consists of the following rules:

flattenA_in_ga(atom(T4), .(T4, [])) → flattenA_out_ga(atom(T4), .(T4, []))
flattenA_in_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, []))) → flattenA_out_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, [])))
flattenA_in_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → U1_ga(T8, T29, T30, T32, flattenA_in_ga(T30, T32))
flattenA_in_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → U2_ga(T8, T51, T52, T53, T55, flattenA_in_ga(cons(T51, cons(T52, T53)), T55))
flattenA_in_ga(cons(cons(atom(T81), T82), T83), .(T81, T85)) → U3_ga(T81, T82, T83, T85, flattenA_in_ga(cons(T82, T83), T85))
flattenA_in_ga(cons(cons(cons(T96, T97), T98), T99), T101) → U4_ga(T96, T97, T98, T99, T101, flattenA_in_ga(cons(T96, cons(T97, cons(T98, T99))), T101))
U4_ga(T96, T97, T98, T99, T101, flattenA_out_ga(cons(T96, cons(T97, cons(T98, T99))), T101)) → flattenA_out_ga(cons(cons(cons(T96, T97), T98), T99), T101)
U3_ga(T81, T82, T83, T85, flattenA_out_ga(cons(T82, T83), T85)) → flattenA_out_ga(cons(cons(atom(T81), T82), T83), .(T81, T85))
U2_ga(T8, T51, T52, T53, T55, flattenA_out_ga(cons(T51, cons(T52, T53)), T55)) → flattenA_out_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55))
U1_ga(T8, T29, T30, T32, flattenA_out_ga(T30, T32)) → flattenA_out_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32)))

The argument filtering Pi contains the following mapping:
flattenA_in_ga(x1, x2)  =  flattenA_in_ga(x1)
atom(x1)  =  atom(x1)
flattenA_out_ga(x1, x2)  =  flattenA_out_ga(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U1_ga(x1, x2, x3, x4, x5)  =  U1_ga(x1, x2, x3, x5)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x1, x2, x3, x4, x6)
U3_ga(x1, x2, x3, x4, x5)  =  U3_ga(x1, x2, x3, x5)
U4_ga(x1, x2, x3, x4, x5, x6)  =  U4_ga(x1, x2, x3, x4, x6)
.(x1, x2)  =  .(x1, x2)
FLATTENA_IN_GA(x1, x2)  =  FLATTENA_IN_GA(x1)
U1_GA(x1, x2, x3, x4, x5)  =  U1_GA(x1, x2, x3, x5)
U2_GA(x1, x2, x3, x4, x5, x6)  =  U2_GA(x1, x2, x3, x4, x6)
U3_GA(x1, x2, x3, x4, x5)  =  U3_GA(x1, x2, x3, x5)
U4_GA(x1, x2, x3, x4, x5, x6)  =  U4_GA(x1, x2, x3, x4, x6)

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

(5) DependencyGraphProof (EQUIVALENT transformation)

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

(6) Obligation:

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

FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → FLATTENA_IN_GA(cons(T51, cons(T52, T53)), T55)
FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → FLATTENA_IN_GA(T30, T32)
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83), .(T81, T85)) → FLATTENA_IN_GA(cons(T82, T83), T85)
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99), T101) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))), T101)

The TRS R consists of the following rules:

flattenA_in_ga(atom(T4), .(T4, [])) → flattenA_out_ga(atom(T4), .(T4, []))
flattenA_in_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, []))) → flattenA_out_ga(cons(atom(T8), atom(T16)), .(T8, .(T16, [])))
flattenA_in_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → U1_ga(T8, T29, T30, T32, flattenA_in_ga(T30, T32))
flattenA_in_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → U2_ga(T8, T51, T52, T53, T55, flattenA_in_ga(cons(T51, cons(T52, T53)), T55))
flattenA_in_ga(cons(cons(atom(T81), T82), T83), .(T81, T85)) → U3_ga(T81, T82, T83, T85, flattenA_in_ga(cons(T82, T83), T85))
flattenA_in_ga(cons(cons(cons(T96, T97), T98), T99), T101) → U4_ga(T96, T97, T98, T99, T101, flattenA_in_ga(cons(T96, cons(T97, cons(T98, T99))), T101))
U4_ga(T96, T97, T98, T99, T101, flattenA_out_ga(cons(T96, cons(T97, cons(T98, T99))), T101)) → flattenA_out_ga(cons(cons(cons(T96, T97), T98), T99), T101)
U3_ga(T81, T82, T83, T85, flattenA_out_ga(cons(T82, T83), T85)) → flattenA_out_ga(cons(cons(atom(T81), T82), T83), .(T81, T85))
U2_ga(T8, T51, T52, T53, T55, flattenA_out_ga(cons(T51, cons(T52, T53)), T55)) → flattenA_out_ga(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55))
U1_ga(T8, T29, T30, T32, flattenA_out_ga(T30, T32)) → flattenA_out_ga(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32)))

The argument filtering Pi contains the following mapping:
flattenA_in_ga(x1, x2)  =  flattenA_in_ga(x1)
atom(x1)  =  atom(x1)
flattenA_out_ga(x1, x2)  =  flattenA_out_ga(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U1_ga(x1, x2, x3, x4, x5)  =  U1_ga(x1, x2, x3, x5)
U2_ga(x1, x2, x3, x4, x5, x6)  =  U2_ga(x1, x2, x3, x4, x6)
U3_ga(x1, x2, x3, x4, x5)  =  U3_ga(x1, x2, x3, x5)
U4_ga(x1, x2, x3, x4, x5, x6)  =  U4_ga(x1, x2, x3, x4, x6)
.(x1, x2)  =  .(x1, x2)
FLATTENA_IN_GA(x1, x2)  =  FLATTENA_IN_GA(x1)

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:

FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53)), .(T8, T55)) → FLATTENA_IN_GA(cons(T51, cons(T52, T53)), T55)
FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30)), .(T8, .(T29, T32))) → FLATTENA_IN_GA(T30, T32)
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83), .(T81, T85)) → FLATTENA_IN_GA(cons(T82, T83), T85)
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99), T101) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))), T101)

R is empty.
The argument filtering Pi contains the following mapping:
atom(x1)  =  atom(x1)
cons(x1, x2)  =  cons(x1, x2)
.(x1, x2)  =  .(x1, x2)
FLATTENA_IN_GA(x1, x2)  =  FLATTENA_IN_GA(x1)

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:

FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53))) → FLATTENA_IN_GA(cons(T51, cons(T52, T53)))
FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30))) → FLATTENA_IN_GA(T30)
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83)) → FLATTENA_IN_GA(cons(T82, T83))
FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99)) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))))

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

(11) UsableRulesReductionPairsProof (EQUIVALENT transformation)

By using the usable rules with reduction pair processor [LPAR04] with a polynomial ordering [POLO], all dependency pairs and the corresponding usable rules [FROCOS05] can be oriented non-strictly. All non-usable rules are removed, and those dependency pairs and usable rules that have been oriented strictly or contain non-usable symbols in their left-hand side are removed as well.

The following dependency pairs can be deleted:

FLATTENA_IN_GA(cons(atom(T8), cons(cons(T51, T52), T53))) → FLATTENA_IN_GA(cons(T51, cons(T52, T53)))
FLATTENA_IN_GA(cons(atom(T8), cons(atom(T29), T30))) → FLATTENA_IN_GA(T30)
FLATTENA_IN_GA(cons(cons(atom(T81), T82), T83)) → FLATTENA_IN_GA(cons(T82, T83))
No rules are removed from R.

Used ordering: POLO with Polynomial interpretation [POLO]:

POL(FLATTENA_IN_GA(x1)) = 2·x1   
POL(atom(x1)) = x1   
POL(cons(x1, x2)) = x1 + x2   

(12) Obligation:

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

FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99)) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))))

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

(13) MRRProof (EQUIVALENT transformation)

By using the rule removal processor [LPAR04] with the following ordering, at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

FLATTENA_IN_GA(cons(cons(cons(T96, T97), T98), T99)) → FLATTENA_IN_GA(cons(T96, cons(T97, cons(T98, T99))))


Used ordering: Knuth-Bendix order [KBO] with precedence:
cons2 > FLATTENAINGA1

and weight map:

FLATTENA_IN_GA_1=1
cons_2=0

The variable weight is 1

(14) Obligation:

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

(15) PisEmptyProof (EQUIVALENT transformation)

The TRS P is empty. Hence, there is no (P,Q,R) chain.

(16) YES