Dear all,
I found some unexpected/inconsistent behavior when specializing a polynomial in a tower of polynomial rings to a special value. Consider the case when the base of the tower is QQ:
sage: K.<t> = QQ[]
sage: R.<x> = K[]
sage: f = x + t
sage: f1 = f.specialization({t: 1}); f1
x + 1
sage: f1.parent()
Univariate Polynomial Ring in x over Rational Field
On the other hand, if the base of the tower is QQbar, the specialized polynomial remains a polynomial in x and t:
sage: K.<t> = QQbar[]
sage: R.<x> = K[]
sage: f = x + t
sage: f1 = f.specialization({t: 1}); f1
x + 1
sage: f1.parent()
Univariate Polynomial Ring in x over Univariate Polynomial Ring in t over Algebraic Field
Note that the value is substituted correctly, but unlike for QQ f1's parent is R and not QQbar["x"] as I would expect.
I can see that this happens because a different SpecializationMorphism is constructed in the two cases. I believe the difference lies in line 547 of src/sage/rings/polynomial/flatten.py (
https://git.sagemath.org/sage.git/tree/src/sage/rings/polynomial/flatten.py?h=9.2#n547), where for QQ the list "new" is empty (when dealing with the ring K) while for QQbar the list "new" contains the variable t. This causes the tower to be reconstructed differently.
Is this behavior a bug? I tried searching on trac, but could not find anything.
My version of sage is: SageMath version 9.2, Release Date: 2020-10-24
OS: Linux x86_64
Best regards,
Matthias