From 501a25411904ead8d9b097f465cd40b984eaa701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leudi=C3=A8re?= Date: Mon, 14 Nov 2022 16:20:02 +0100 Subject: [PATCH 1/4] Implement `characteristic` method for rings extensions See ticket #34692. --- src/sage/rings/ring_extension.pyx | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index 2b649359ad4..9f53d42f80f 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -1885,6 +1885,48 @@ cdef class RingExtension_generic(CommutativeAlgebra): parent = self.Hom(codomain, category=category) return RingExtensionHomomorphism(parent, im_gens, base_map, check) + def characteristic(self): + r""" + Return the characteristic of the extension as a ring. + + OUTPUT: + + A prime number. + + EXAMPLES:: + + sage: F = GF(5^2).over() # over GF(5) + sage: K = GF(5^4).over(F) + sage: L = GF(5^12).over(K) + sage: F.characteristic() + 5 + sage: K.characteristic() + 5 + sage: L.characteristic() + 5 + + :: + + sage: F = RR.over(ZZ) + sage: F.characteristic() + 0 + + :: + + sage: F = GF(11) + sage: A. = F[] + sage: K = Frac(F).over(F) + sage: K.characteristic() + 11 + + :: + + sage: R = Zp(7).over(ZZ) + sage: R.characteristic() + 0 + """ + return self._backend.characteristic() + # Fraction fields ################# From bcffa0cf0842ebef2403d5c8b6aa88514beb86e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leudi=C3=A8re?= Date: Mon, 14 Nov 2022 17:18:21 +0100 Subject: [PATCH 2/4] Fix imprecision in documentation See David's comment: https://trac.sagemath.org/ticket/34692#comment:5. --- src/sage/rings/ring_extension.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index 9f53d42f80f..bbc082d2e77 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -1891,7 +1891,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): OUTPUT: - A prime number. + A prime number or zero. EXAMPLES:: From 675e24988a07f58d092a7ddb976c9e6ee04f3ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leudi=C3=A8re?= Date: Mon, 14 Nov 2022 18:03:12 +0100 Subject: [PATCH 3/4] Add tests for characteristic method See https://trac.sagemath.org/ticket/34692#comment:9. --- src/sage/rings/ring_extension.pyx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index bbc082d2e77..c761314585c 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -1921,9 +1921,21 @@ cdef class RingExtension_generic(CommutativeAlgebra): :: - sage: R = Zp(7).over(ZZ) - sage: R.characteristic() - 0 + sage: E = Fp(7).over(ZZ) + sage: E.characteristic() + 7 + + TESTS:: + + Ensure ticket :trac:`34692` is fixed. + + sage: Fq = GF(11) + sage: FqX. = Fq[] + sage: k = Frac(FqX) + sage: i = Hom(FqX, k).natural_map() + sage: K = k.over(i) + sage: K.frobenius_endomorphism() + Frobenius endomorphism x |--> x^11 of Fraction Field of Univariate Polynomial Ring in X over Finite Field of size 11 over its base """ return self._backend.characteristic() From ab2c211033e15fa5237b20690a715d50577d06f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leudi=C3=A8re?= Date: Mon, 14 Nov 2022 18:52:42 +0100 Subject: [PATCH 4/4] Fix doctest See https://trac.sagemath.org/ticket/34692#comment:11. --- src/sage/rings/ring_extension.pyx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index c761314585c..b493f57bed9 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -1921,19 +1921,18 @@ cdef class RingExtension_generic(CommutativeAlgebra): :: - sage: E = Fp(7).over(ZZ) + sage: E = GF(7).over(ZZ) sage: E.characteristic() 7 - TESTS:: + TESTS: - Ensure ticket :trac:`34692` is fixed. + Ensure ticket :trac:`34692` is fixed:: sage: Fq = GF(11) sage: FqX. = Fq[] sage: k = Frac(FqX) - sage: i = Hom(FqX, k).natural_map() - sage: K = k.over(i) + sage: K = k.over(FqX) sage: K.frobenius_endomorphism() Frobenius endomorphism x |--> x^11 of Fraction Field of Univariate Polynomial Ring in X over Finite Field of size 11 over its base """