# How to flatten polynomial rings?

It is possible in Sage to create a polynomial ring over a polynomial ring. But Sage stores this as a two-tiered structure that is sometimes inconvenient. I would like to flatten it.

For example,

```
sage: P = PolynomialRing(QQ, 'c', 6)
sage: S = PolynomialRing(P, 't', 6)
```

creates a polynomial ring in t0, t1, t2, ...., t5 over a polynomial ring in c0, c1, ..., c5. But then

```
sage: clist = list( P.gens()[i] for i in range(6)) # get names for variables
sage: tlist = list( S.gens()[i] for i in range(6))
sage: poly = clist[0]*tlist[0] # produces polynomial c0*t0 in S
sage: poly.polynomial(clist[0]) # asks for poly as a polynomial in c0
```

fails with "var must be one of the generators of the parent polynomial ring."

I would like to `flatten' S so it is simply a single polynomial ring over QQ in 12 variables.

You may ask, why don't I just construct a single ring in the first place? In this instance, because I want to create a polynomial ring in c0, ...., cn and t0, ...., tn where n is a variable, and I don't know how to do this (I'd prefer to avoid just making c0, ..., c2n and trying to keep track of which are actually t's). I can imagine other situations where one would like to be able to flatten also.