### Compute minimal number of generators of subring

Hi all,

Given a polynomial ring $R = k[x_1,...,x_n]$ over a field $k$ (say $\mathbb{Q}$) and a list of polynomials $p_1,..,p_n$ in ~~$R$, ~~$R$ (homogeneous say), is Sage capable of computing the minimal number of generators of the subring generated by $p_1,...,p_n$ over $k$?

Next, suppose $I$ is a homogeneous ideal of $R$. Can the same approach be used to compute the minimal number of generators of this subring after being projected to $R / I$ ?

Edit: Sorry for the bad formatting (see source), please help me fix it if you can!

Edit2: For example, let $R = \mathbb{Q} [x,y]$ and let $p_1 = x^2, p_2 = x^2 y, p_3 = x^4 y$. This generates a principal ideal, but as a subring it has 2 generators and it is those 2 generators that I want.

Edit3: In case it is helpful, the case I'm looking at is a ring with an action of a group, and its subring of invariants for which I have generators.

Edit4: Here's a suggested algorithm: sort the generators by degree. Then sequentially add them, and check if they were already in the subring. Does Sage even have suitable subring capabilities?