Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

# how to copy/paste InfinitePolynomialRings?

Reported by: Owned by: Paul Zimmermann Alex Ghitza minor sage-duplicate/invalid/wontfix basic arithmetic Mike Hansen, Simon King, Jeroen Demeyer Simon King N/A

### Description

when one creates an object with `InfinitePolynomialRing`:

```sage: R.<a> = InfinitePolynomialRing(ZZ)
sage: f = a[0]+a[1]+a[2]
```

the variables are printed `a_i` instead of `a[i]`:

```sage: f
a_2 + a_1 + a_0
```

and one cannot copy/paste the result of a computation:

```sage: a_2 + a_1 + a_0
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/users/caramel/zimmerma/try/<ipython console> in <module>()

NameError: name 'a_2' is not defined
```

Is there a workaround?

### comment:1 follow-up:  2 Changed 12 years ago by Karl-Dieter Crisman

Cc: Mike Hansen Simon King added calculus → basic arithmetic changed from Burcin Erocal to Alex Ghitza

I don't know that there is.

```sage: sage.rings.polynomial.infinite_polynomial_ring??
```

has some very extensive documentation that clearly states what the representations are.

This isn't the only place this happens in Sage:

```sage: vector([1,2,3])
(1, 2, 3)
sage: (1, 2, 3) # this is a tuple, not a vector
(1, 2, 3)
sage: V = vector([1,2,3]); V
(1, 2, 3)
sage: v = (1, 2, 3)
sage: V.base_ring()
Integer Ring
sage: v.base_ring()
AttributeError: 'tuple' object has no attribute 'base_ring'
```

Ordinarily I would be more eager to try to resolve such conflicts, but anyone using an infinite polynomial ring probably knows what they are doing.

I would just assign the result of the computation to a variable. Otherwise I don't see much happening here. I'm cc:ing the authors of this file in just to be sure, but probably this should be closed as 'wontfix'.

Also changing component, though 'rings' would be nice to have there as an option...

### comment:2 in reply to:  1 ; follow-ups:  3  5 Changed 12 years ago by Paul Zimmermann

Replying to kcrisman:

contrary to your example, the problem is that you can't even copy/paste `a_2 + a_1 + a_0` without defining at hand the corresponding variables, which then questions the usefulness of `InfinitePolynomialRings`...

Paul

### comment:3 in reply to:  2 Changed 12 years ago by Karl-Dieter Crisman

contrary to your example, the problem is that you can't even copy/paste `a_2 + a_1 + a_0` without defining at hand the corresponding variables, which then questions the usefulness of `InfinitePolynomialRings`...

Perhaps, but I'll leave answering that to the people who wrote it. Presumably one uses it only in the form of putting `f` in some other computation, leaving the printed output just for viewing, not for computation.

I'm just pointing out that there are other times where pasting the output of a command does not give the same thing as the output, and that it can't always be treated as a bug. Matrices are another example where the string representation is not 'useful' in that way. Whether it raises an error or not would depend on the context. At the same time, I agree that it would be annoying in the context of (say) a finite polynomial ring, or the Symbolic 'ring'.

### comment:4 Changed 12 years ago by Simon King

Resolution: → wontfix new → closed
1. I see no reason whatsoever to expect that the string representation of any object should return the object by copy-and-paste. Just think of any element of a finite prime field: Its string representation will yield an integer by copy-and-paste - not a prime field element. Or just think of `ZZ`: Try to copy-and-paste its string representation...

This is why I resolve the ticket as wontfix.

1. There are two or three reasons why I decided to represent the elements of an infinite polynomial ring the way they are. (i) In the literature, the notation for the indices of variables is by subscript. Hence, Latex style, `_`.

(ii) The arithmetic and, in particular, the Gröbner machinery, is based on finite polynomial rings. It is reasonable to have the same variable names both for the finite and the infinite polynomial ring. But `x[3]` is no valid variable name of a finite polynomial ring.

(ii+1/2) I find `x_1` nicer to read than `x[1]`.

1. Here is your workaround:
```sage: R.<a> = InfinitePolynomialRing(ZZ)
sage: f = a[0]+a[1]+a[2]
sage: f
a_2 + a_1 + a_0
sage: R('a_2 + a_1 + a_0')
a_2 + a_1 + a_0
sage: R('a_2 + a_1 + a_0')==f
True
```

### comment:5 in reply to:  2 Changed 12 years ago by Simon King

Replying to zimmerma:

Replying to kcrisman:

contrary to your example, the problem is that you can't even copy/paste `a_2 + a_1 + a_0` without defining at hand the corresponding variables, which then questions the usefulness of `InfinitePolynomialRings`...

The purpose of `InfinitePolynomialRing` is certainly not to insert infinitely many identifiers into the global name space. Its main purpose is not even to have a convenient way to create a countable set of variables and do arithmetic with it.

The main purpose is described in the documentation: Do computations related with finitely generated ideals in countably infinitely many variables that are set-wise invariant under permutation of the variables (ideal containment, etc). The background is the theory of symmetric Gröbner bases due to Aschenbrenner and Hillar.

### comment:6 follow-up:  7 Changed 12 years ago by Karl-Dieter Crisman

Cc: Jeroen Demeyer added

I think in general the release manager likes to do the official closing. I'm cc:ing him, though, so that this gets recorded; there shouldn't be any objection to this. Nice workaround, by the way - that is extremely natural.

### comment:7 in reply to:  6 ; follow-up:  9 Changed 12 years ago by Simon King

Replying to kcrisman:

I think in general the release manager likes to do the official closing.

Oops, sorry!

I think there really should be the possibility to just mark a ticket as "invalid" or "wontfix" or "duplicate", without actually closing it. I mean, what else should I have done? Change it to "positive review"???

### comment:8 Changed 12 years ago by Minh Van Nguyen

Milestone: sage-4.7 → sage-duplicate/invalid/wontfix

### comment:9 in reply to:  7 Changed 12 years ago by Jeroen Demeyer

Replying to SimonKing:

I mean, what else should I have done? Change it to "positive review"???

Yes please.

### comment:10 follow-up:  11 Changed 12 years ago by Jeroen Demeyer

To clarfiy: if you put a ticket to positive review with a milestone of sage-duplicate/invalid/wontfix, it will show up in Tickets with positive review and I will see that it needs to be closed.

### comment:11 in reply to:  10 Changed 12 years ago by Simon King

Replying to jdemeyer:

To clarfiy: if you put a ticket to positive review with a milestone of sage-duplicate/invalid/wontfix, it will show up in Tickets with positive review and I will see that it needs to be closed.

Thank you, that makes sense. I wasn't aware that duplicate etc. exists as milestone. Should I do so with this particular ticket as well, or shall I leave it closed now?

### comment:12 Changed 12 years ago by Jeroen Demeyer

Reviewers: → Simon King

Now just leave it as it is.

I am also adding your name as Reviewer with the meaning of "it was Simon King who 'reviewed' the fact that this ticket should be closed".

Note: See TracTickets for help on using tickets.