Description
Relatively often on sage-support, users run into a problem since they mix symbolics and polynomials. Typically, they do
sage: z = var('z')
sage: P = QQ[z]
and expect that z
is the generator of P
- which is of course
wrong and will soon mean trouble.
I find even worse that one can do
sage: QQ[x,gap,singular]
Multivariate Polynomial Ring in x, Gap, Singular over Rational Field
since the variable names are obtained from the string representation of the given objects.
It should be clear that the preferred way of constructing a polynomial (or quotient) ring together with its generators is
sage: R.<x,y,z> = QQ[]
Hence, it is quite amazing that in the documentation one occasionally finds the "wrong" usage
sage: x,y,z = var('x y z')
sage: P = QQ[x,y,z]
I suggest to deprecate the possibility of providing the variable names by anything but strings (potentially plus an integer, like PolynomialRing(QQ,'x',5)
).
With my patch, one has
sage: QQ[x,gap,singular]
/mnt/local/king/SAGE/sage-4.6/local/bin/sage-ipython:1: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'x' should be a string, but we obtained <type 'sage.symbolic.expression.Expression'>.
In an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'.
#!/usr/bin/env python
/mnt/local/king/SAGE/sage-4.6/local/bin/sage-ipython:1: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'Gap' should be a string, but we obtained <class 'sage.interfaces.gap.Gap'>.
In an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'.
#!/usr/bin/env python
/mnt/local/king/SAGE/sage-4.6/local/bin/sage-ipython:1: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'Singular' should be a string, but we obtained <class 'sage.interfaces.singular.Singular'>.
In an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'.
#!/usr/bin/env python
Multivariate Polynomial Ring in x, Gap, Singular over Rational Field
See also #13187 where the problem of this ticket had the wrong solution (allowing for other types than string).
Depends on #23337
Depends on #23338
Depends on #23343
Depends on #23377
Depends on #23638
Depends on #23640
Component: basic arithmetic
Keywords: deprecation symbolic polynomial variable
Author: Simon King, Ralf Stephan, Jeroen Demeyer
Branch/Commit: public/10483-4 @ 938beb0
Reviewer: Karl-Dieter Crisman, Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/10483