Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10317 closed defect (wontfix)

how to copy/paste InfinitePolynomialRings?

Reported by: zimmerma Owned by: AlexGhitza
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic Keywords:
Cc: mhansen, SimonKing, jdemeyer Merged in:
Authors: Reviewers: Simon King
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

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?

Change History (12)

comment:1 follow-up: Changed 11 years ago by kcrisman

  • Cc mhansen SimonKing added
  • Component changed from calculus to basic arithmetic
  • Owner changed from burcin to AlexGhitza

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: Changed 11 years ago by 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...

Paul

comment:3 in reply to: ↑ 2 Changed 11 years ago by 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...

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 11 years ago by SimonKing

  • Resolution set to wontfix
  • Status changed from new to 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 11 years ago by SimonKing

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: Changed 11 years ago by kcrisman

  • Cc jdemeyer 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: Changed 11 years ago by SimonKing

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 11 years ago by mvngu

  • Milestone changed from sage-4.7 to sage-duplicate/invalid/wontfix

comment:9 in reply to: ↑ 7 Changed 11 years ago by jdemeyer

Replying to SimonKing:

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

Yes please.

comment:10 follow-up: Changed 11 years ago by 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.

comment:11 in reply to: ↑ 10 Changed 11 years ago by SimonKing

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 11 years ago by jdemeyer

  • Reviewers set to 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.