sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.2k stars 413 forks source link

inheriting methods from backend of ring extension is dangerous #34907

Open yyyyx4 opened 1 year ago

yyyyx4 commented 1 year ago

For example:

sage: GF(5^6).over(GF(5^2)).random_element().minpoly().parent()
Univariate Polynomial Ring in x over Finite Field in z2 of size 5^2
sage: GF(5^4).over(GF(5^2)).random_element().minpoly().parent()
Univariate Polynomial Ring in x over Finite Field in z2 of size 5^2
sage: GF(5^2).over(GF(5^2)).random_element().minpoly().parent()
Univariate Polynomial Ring in x over Finite Field of size 5

This is apparently because RingExtensionWithBasisElement defines its own .minpoly() method, whereas RingExtensionElement simply calls the one from the backend — which returns the absolute minimal polynomial.

I first discovered the inconsistency above while working on #34906, but the core issue actually runs much deeper. Here's another example:

sage: GF(5^6).over(GF(5^2)).galois_group() is GF(5^6).over(GF(5^3)).galois_group()
True

CC: @xcaruso

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/34907

yyyyx4 commented 1 year ago

Description changed:

--- 
+++ 
@@ -10,3 +10,10 @@

This is apparently because RingExtensionWithBasisElement defines its own .minpoly() method, whereas RingExtensionElement simply calls the one from the backend — which returns the absolute minimal polynomial. + +I first discovered the inconsistency above while working on #34906, but the core issue actually runs much deeper. Here's another example: + +sage +sage: GF(5^6).over(GF(5^2)).galois_group() is GF(5^6).over(GF(5^3)).galois_group() +True +

yyyyx4 commented 5 months ago

Another example: GF(5^2).over(GF(5^2)).modulus().