Hello, @ianncunha. Here is the modified code. You can use a program like diff or meld to make comparisons with the original code. (By the way, this is a modification of the file <sage>/rings/polynomial/infinite_polynomial_ring.py. I have removed most of the comments to able to reverse-engineer the code. However, I have kept the copyright note and added my name as "modified by". I hope this is enough to respect the authorship and legal notices. If somebody finds I made something wrong regarding license/authorship, please DO let me know so I can make the corrections.) You just have to save the code in a file, let's say "poly.py", and make `from poly import *`

; this rest is like using regular Sage commands for infinite polynomial rings.

On the other hand, I can share with you an alternative less complicated that I just discovered a few hours ago. You can manually add members to an infinite polynomial ring as follows. First, you need to import the `PolynomialRing`

constructor:

```
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
```

Then, you can create a Polynomial ring over $\mathbb{Z}$ by calling

```
P = PolynomialRing(ZZ, ('x_0_0'))
```

In this case, the only generator of `P`

is `x_0_0`

. You can make algebra with this element like this:

```
5*P('x_0_0')+7*P('x_0_0')
```

This will return `12*x_0_0`

, which is beautiful. You can also check the structure with

```
print(P)
```

which will return

```
Univariate Polynomial Ring in x_0_0 over Integer Ring
```

Of course, this is far from what you wanted, but fear not. You can add a new generator as required. For example, suppose you need a `x_0_1`

. You just have to write the following:

```
P = PolynomialRing(P.base_ring(), P.gens()+('x_0_1',))
```

The last comma is so that Sage recognizes the tuple; otherwise, it assumes it's a string inside parentheses.
Anyway, now you can make algebra with this new element too. For example,

```
4*R('x_0_1')+5*R('x_0_0')+3*R('x_0_0')
```

will return

```
8*x_0_0 + 4*x_0_1
```

You will also notice that

```
print(P)
```

now says

```
Multivariate Polynomial Ring in x_0_0, x_0_1 over Integer Ring
```

so Sage automatically recognizes when you have univariate and multivariate rings. You keep adding variables as needed, without the need for them to be defined sequentially. For example, next you can create `x_3_27`

.

In the depths of the Sage code that deals with Polynomial Rings, this is ROUGHLY equivalent to a "sparse" construction, which is an efficient way. You can wrap all of this code into a new Python class, so that dealing with it is easier.

A minimal working implementation can be found here. You can save the code inside a file, e.g. "poly_rings.py" (in the same folder where you call Sage), and, in SageMath, you just have to "`from poly_rings.py import *`

". You can then define an infinite polynomial ring with bi-indexed variables using

```
P.<x> = PolyRing(ZZ)
```

That's it!

This needs to be completed as required. For example, you can't call `P.one()`

, unless you define it first. However, it is a functional implementation. Besides that, the actual Polynomial Ring is stored inside `P._P`

, so you could also call `P._P.one()`

. Finally, I have created a minimal test file here that will show you the usage (copy-and-paste it on the REPL).

I really hope this helps! Please, let me know if this solves your problem.

How much of the

`InfinitePolynomialRing`

do you need? I have modified the code of Sage that implements this function and related ones, but I don't have complete functionality. For now, I only have polynomial algebra implemented. Also, it is not possible to use "x_(a,b)", since there is a Sage function that validates variable names, and that is not a valid one. What I used is "`x[a,b]`

" which creates a "`x_a_b`

".I could send you the modified code, so you can complete the implementation as needed by you.

Nice! If you can send it to me it would be great!