Hello,

We have substitution available for various objects (e.g. matrices when the base ring is a polynomial ring). I would like to fix the conventions of the parent of

 my_object.subs(var1=val1, var2=val2)

versus

 my_object(var1=val1, var2=val2)

With .subs, univariate polynomial ring somehow chooses the "minimal ring"

    sage: R.<x> = ZZ[]
    sage: (x+3).subs(x=2).parent()
    Integer Ring
    sage: (x+3).subs(x=x+4).parent()
    Univariate Polynomial Ring in x over Integer Ring
    sage: (x+3).subs(x=4.).parent()
    Real Field with 53 bits of precision

Whereas multivariate are somehow "undecided"

    sage: (x+3).subs(x=2).parent()
    Multivariate Polynomial Ring in x, y over Integer Ring
    sage: (x+3).subs(x=x+4).parent()
    Multivariate Polynomial Ring in x, y over Integer Ring
    sage: (x+3).subs(x=4.).parent()
    Real Field with 53 bits of precision

Whereas the symbolic ring is as always a black hole

    sage: x = SR('x')
    sage: x.subs(x=3.).parent()
    Symbolic Ring
    sage: x(x=3.).parent()
    Symbolic Ring

My proposition is:

- .subs should be considered as an *internal* operation. Hence, the result will always be in the same parent (or the result of a pushout). In particular we would have

    sage: R.<x> = ZZ[]
    sage: x.subs(x=4).parent()
    Univariate Polynomial Ring in x over Integer Ring
    sage: x.subs(x=4.).parent()
    Univariate Polynomial Ring in x over Real Double Field

- __call__ is considered as an external operation. The result should (more or less) be the smallest parent in which the result belong.

    sage: R.<x,y> = ZZ[]
    sage: x(3,5).parent()
    Integer Ring
    sage: (x+y)(3., polygen(ZZ))
Univariate Polynomial Ring in x over Real Field with 53 bits of precision

Does it look reasonable?

Best,
Vincent

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to