0 Prolog
↳1 PrologToPiTRSProof (⇐)
↳2 PiTRS
↳3 DependencyPairsProof (⇔)
↳4 PiDP
↳5 DependencyGraphProof (⇔)
↳6 AND
↳7 PiDP
↳8 UsableRulesProof (⇔)
↳9 PiDP
↳10 PiDPToQDPProof (⇐)
↳11 QDP
↳12 UsableRulesReductionPairsProof (⇔)
↳13 QDP
↳14 PisEmptyProof (⇔)
↳15 TRUE
↳16 PiDP
↳17 UsableRulesProof (⇔)
↳18 PiDP
↳19 PiDPToQDPProof (⇐)
↳20 QDP
↳21 UsableRulesReductionPairsProof (⇔)
↳22 QDP
↳23 QReductionProof (⇔)
↳24 QDP
↳25 MRRProof (⇔)
↳26 QDP
↳27 PisEmptyProof (⇔)
↳28 TRUE
↳29 PrologToPiTRSProof (⇐)
↳30 PiTRS
↳31 DependencyPairsProof (⇔)
↳32 PiDP
↳33 DependencyGraphProof (⇔)
↳34 AND
↳35 PiDP
↳36 UsableRulesProof (⇔)
↳37 PiDP
↳38 PiDPToQDPProof (⇐)
↳39 QDP
↳40 UsableRulesReductionPairsProof (⇔)
↳41 QDP
↳42 PisEmptyProof (⇔)
↳43 TRUE
↳44 PiDP
↳45 UsableRulesProof (⇔)
↳46 PiDP
↳47 PiDPToQDPProof (⇐)
↳48 QDP
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → U3_GA(X, Y, Z, count_in_ga(Y, Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
COUNT_IN_GA(cons(cons(U, V), W), Z) → FLATTEN_IN_GA(cons(cons(U, V), W), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → U1_GA(X, U, Y, flatten_in_ga(U, Y))
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
FLATTEN_IN_GA(cons(cons(U, V), W), X) → U2_GA(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_GA(U, V, W, Z, count_in_ga(X, Z))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → U3_GA(X, Y, Z, count_in_ga(Y, Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
COUNT_IN_GA(cons(cons(U, V), W), Z) → FLATTEN_IN_GA(cons(cons(U, V), W), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → U1_GA(X, U, Y, flatten_in_ga(U, Y))
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
FLATTEN_IN_GA(cons(cons(U, V), W), X) → U2_GA(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_GA(U, V, W, Z, count_in_ga(X, Z))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
FLATTEN_IN_GA(cons(cons(U, V), W)) → FLATTEN_IN_GA(cons(U, cons(V, W)))
FLATTEN_IN_GA(cons(atom(X), U)) → FLATTEN_IN_GA(U)
No rules are removed from R.
FLATTEN_IN_GA(cons(cons(U, V), W)) → FLATTEN_IN_GA(cons(U, cons(V, W)))
FLATTEN_IN_GA(cons(atom(X), U)) → FLATTEN_IN_GA(U)
POL(FLATTEN_IN_GA(x1)) = 2·x1
POL(atom(x1)) = x1
POL(cons(x1, x2)) = 2 + 2·x1 + x2
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
COUNT_IN_GA(cons(cons(U, V), W)) → U4_GA(flatten_in_ga(cons(cons(U, V), W)))
U4_GA(flatten_out_ga(X)) → COUNT_IN_GA(X)
COUNT_IN_GA(cons(atom(X), Y)) → COUNT_IN_GA(Y)
flatten_in_ga(cons(cons(U, V), W)) → U2_ga(flatten_in_ga(cons(U, cons(V, W))))
U2_ga(flatten_out_ga(X)) → flatten_out_ga(X)
flatten_in_ga(cons(atom(X), U)) → U1_ga(X, flatten_in_ga(U))
U1_ga(X, flatten_out_ga(Y)) → flatten_out_ga(.(X, Y))
flatten_in_ga(atom(X)) → flatten_out_ga(.(X, []))
flatten_in_ga(x0)
U2_ga(x0)
U1_ga(x0, x1)
The following rules are removed from R:
COUNT_IN_GA(cons(atom(X), Y)) → COUNT_IN_GA(Y)
Used ordering: POLO with Polynomial interpretation [POLO]:
flatten_in_ga(cons(atom(X), U)) → U1_ga(X, flatten_in_ga(U))
flatten_in_ga(atom(X)) → flatten_out_ga(.(X, []))
U1_ga(X, flatten_out_ga(Y)) → flatten_out_ga(.(X, Y))
POL(.(x1, x2)) = x1 + x2
POL(COUNT_IN_GA(x1)) = x1
POL(U1_ga(x1, x2)) = 1 + 2·x1 + x2
POL(U2_ga(x1)) = x1
POL(U4_GA(x1)) = x1
POL([]) = 0
POL(atom(x1)) = 1 + 2·x1
POL(cons(x1, x2)) = 2·x1 + x2
POL(flatten_in_ga(x1)) = x1
POL(flatten_out_ga(x1)) = 2·x1
COUNT_IN_GA(cons(cons(U, V), W)) → U4_GA(flatten_in_ga(cons(cons(U, V), W)))
U4_GA(flatten_out_ga(X)) → COUNT_IN_GA(X)
flatten_in_ga(cons(cons(U, V), W)) → U2_ga(flatten_in_ga(cons(U, cons(V, W))))
U2_ga(flatten_out_ga(X)) → flatten_out_ga(X)
flatten_in_ga(x0)
U2_ga(x0)
U1_ga(x0, x1)
U1_ga(x0, x1)
COUNT_IN_GA(cons(cons(U, V), W)) → U4_GA(flatten_in_ga(cons(cons(U, V), W)))
U4_GA(flatten_out_ga(X)) → COUNT_IN_GA(X)
flatten_in_ga(cons(cons(U, V), W)) → U2_ga(flatten_in_ga(cons(U, cons(V, W))))
U2_ga(flatten_out_ga(X)) → flatten_out_ga(X)
flatten_in_ga(x0)
U2_ga(x0)
COUNT_IN_GA(cons(cons(U, V), W)) → U4_GA(flatten_in_ga(cons(cons(U, V), W)))
U4_GA(flatten_out_ga(X)) → COUNT_IN_GA(X)
POL(COUNT_IN_GA(x1)) = 1 + x1
POL(U2_ga(x1)) = x1
POL(U4_GA(x1)) = x1
POL(cons(x1, x2)) = x1 + x2
POL(flatten_in_ga(x1)) = x1
POL(flatten_out_ga(x1)) = 2 + x1
flatten_in_ga(cons(cons(U, V), W)) → U2_ga(flatten_in_ga(cons(U, cons(V, W))))
U2_ga(flatten_out_ga(X)) → flatten_out_ga(X)
flatten_in_ga(x0)
U2_ga(x0)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → U3_GA(X, Y, Z, count_in_ga(Y, Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
COUNT_IN_GA(cons(cons(U, V), W), Z) → FLATTEN_IN_GA(cons(cons(U, V), W), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → U1_GA(X, U, Y, flatten_in_ga(U, Y))
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
FLATTEN_IN_GA(cons(cons(U, V), W), X) → U2_GA(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_GA(U, V, W, Z, count_in_ga(X, Z))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → U3_GA(X, Y, Z, count_in_ga(Y, Z))
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
COUNT_IN_GA(cons(cons(U, V), W), Z) → FLATTEN_IN_GA(cons(cons(U, V), W), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → U1_GA(X, U, Y, flatten_in_ga(U, Y))
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
FLATTEN_IN_GA(cons(cons(U, V), W), X) → U2_GA(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_GA(U, V, W, Z, count_in_ga(X, Z))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
FLATTEN_IN_GA(cons(cons(U, V), W), X) → FLATTEN_IN_GA(cons(U, cons(V, W)), X)
FLATTEN_IN_GA(cons(atom(X), U), .(X, Y)) → FLATTEN_IN_GA(U, Y)
FLATTEN_IN_GA(cons(cons(U, V), W)) → FLATTEN_IN_GA(cons(U, cons(V, W)))
FLATTEN_IN_GA(cons(atom(X), U)) → FLATTEN_IN_GA(U)
No rules are removed from R.
FLATTEN_IN_GA(cons(cons(U, V), W)) → FLATTEN_IN_GA(cons(U, cons(V, W)))
FLATTEN_IN_GA(cons(atom(X), U)) → FLATTEN_IN_GA(U)
POL(FLATTEN_IN_GA(x1)) = 2·x1
POL(atom(x1)) = x1
POL(cons(x1, x2)) = 2 + 2·x1 + x2
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
count_in_ga(atom(X), s(0)) → count_out_ga(atom(X), s(0))
count_in_ga(cons(atom(X), Y), s(Z)) → U3_ga(X, Y, Z, count_in_ga(Y, Z))
count_in_ga(cons(cons(U, V), W), Z) → U4_ga(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
U4_ga(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → U5_ga(U, V, W, Z, count_in_ga(X, Z))
U5_ga(U, V, W, Z, count_out_ga(X, Z)) → count_out_ga(cons(cons(U, V), W), Z)
U3_ga(X, Y, Z, count_out_ga(Y, Z)) → count_out_ga(cons(atom(X), Y), s(Z))
COUNT_IN_GA(cons(cons(U, V), W), Z) → U4_GA(U, V, W, Z, flatten_in_ga(cons(cons(U, V), W), X))
U4_GA(U, V, W, Z, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X, Z)
COUNT_IN_GA(cons(atom(X), Y), s(Z)) → COUNT_IN_GA(Y, Z)
flatten_in_ga(cons(cons(U, V), W), X) → U2_ga(U, V, W, X, flatten_in_ga(cons(U, cons(V, W)), X))
U2_ga(U, V, W, X, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
flatten_in_ga(cons(atom(X), U), .(X, Y)) → U1_ga(X, U, Y, flatten_in_ga(U, Y))
U1_ga(X, U, Y, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
flatten_in_ga(atom(X), .(X, [])) → flatten_out_ga(atom(X), .(X, []))
COUNT_IN_GA(cons(cons(U, V), W)) → U4_GA(U, V, W, flatten_in_ga(cons(cons(U, V), W)))
U4_GA(U, V, W, flatten_out_ga(cons(cons(U, V), W), X)) → COUNT_IN_GA(X)
COUNT_IN_GA(cons(atom(X), Y)) → COUNT_IN_GA(Y)
flatten_in_ga(cons(cons(U, V), W)) → U2_ga(U, V, W, flatten_in_ga(cons(U, cons(V, W))))
U2_ga(U, V, W, flatten_out_ga(cons(U, cons(V, W)), X)) → flatten_out_ga(cons(cons(U, V), W), X)
flatten_in_ga(cons(atom(X), U)) → U1_ga(X, U, flatten_in_ga(U))
U1_ga(X, U, flatten_out_ga(U, Y)) → flatten_out_ga(cons(atom(X), U), .(X, Y))
flatten_in_ga(atom(X)) → flatten_out_ga(atom(X), .(X, []))
flatten_in_ga(x0)
U2_ga(x0, x1, x2, x3)
U1_ga(x0, x1, x2)