Fix leading_coefficient for zero polynomials#5231
Fix leading_coefficient for zero polynomials#5231SirToby25 wants to merge 1 commit intooscar-system:masterfrom
leading_coefficient for zero polynomials#5231Conversation
|
This needs to be discussed. |
leading_coefficient for zero polynomials
|
The change looks fine to me and in line to how we define this method to work in AbstractAlgebra. But if there is need to discuss this at triage, so be it! |
|
There are several problems to be discussed here. One problem is that this PR creates a lot of inconsistencies. For example, there are also functions like
So given a polynomial which is zero, we now learn from calling I do not know who introduced |
|
Let me take this opportunity to point out that there are lots of serious inconsisties between AA and Oscar in the general context of what we discuss here. This is due to the fact that in AA, the concept of monomial orderings is way too rudimentary to be used in commutative algebra. In AA, you can associate an In Oscar, you can additionally associate a As one consequence you have, for example, this:
Another consequence is that polynomials are printed according to the AA ordering, and not to the Oscar ordering which certainly can be confusing. I do not claim that we should/can change all this, sometimes early unfortunate design decisions cannot be reversed. We have to live with these, so why creating new problems by "fixing" a minor inconsistency such as the leading coefficient of the zero polynomial. In any case I do not see a bug or unexpected error here: That this error should be thrown was decided following serious discussions and we could live with it for many years. |
|
It does not make sense to define the leading coefficient of the zero polynomial. Since the zero polynomial does not have any terms, it does not have a leading term, hence no leading coefficient (and obviously not a leading monomial or exponent vector). The printing stuff we can't do much about (and probably should also not, since a polynomial does not have per se an ordering of terms). |
|
Small historic remark: as we added the commutative algebra capabilities to Oscar, we discovered that some of the AbstractAlgebra conventions and implementations are not really suited. To mitigate this, in Oscar we have introduced in #1696
So this change here is not something we want to add back. |
|
Another comment: should there be a fallback for @lgoettgens pointed out that universal polynomial rings also needed to be dealt with.... however this raises more questions and problems in the end it might be easiest to also adjust AA to throw an error in leading/trailing coefficient for zero polynomials -- this would be a breaking change but we already plan a breaking release of AA to happen real soon now... ping @thofma regarding the AA change bit... |
|
@wdecker will fix |
|
I finally remembered to check with Magma. They do the opposite: throw an error in the univariate case and return zero in the multivariate case: So I would say we are in good company. |
|
We changed the behavior in AA so that So I think this can be closed now. |
Currently, the Oscar implementation of leading_coefficient for zero MPolys is inconsistent with AbstractAlgebra. In AbstractAlgebra it is zero but in Oscar an error is raised. Additionally, this is neither the case for univariate zero polynomials nor any trailing coefficients.
This pull request should fix this.