diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index 2b649359ad4..b493f57bed9 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -1885,6 +1885,59 @@ 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 or zero. + + 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: E = GF(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: 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 + """ + return self._backend.characteristic() + # Fraction fields #################