From 38441b3d2e9d9e228ce3a2827c48cda66e432703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 31 Dec 2024 11:32:08 +0100 Subject: [PATCH] minor tweaks in Ore polynomials --- .../rings/polynomial/ore_function_element.py | 9 +- .../rings/polynomial/ore_function_field.py | 65 +++++++------- .../rings/polynomial/ore_polynomial_ring.py | 84 +++++++++---------- 3 files changed, 75 insertions(+), 83 deletions(-) diff --git a/src/sage/rings/polynomial/ore_function_element.py b/src/sage/rings/polynomial/ore_function_element.py index d858838f53c..a97eb60d268 100644 --- a/src/sage/rings/polynomial/ore_function_element.py +++ b/src/sage/rings/polynomial/ore_function_element.py @@ -16,14 +16,13 @@ # https://www.gnu.org/licenses/ # *************************************************************************** -from sage.structure.richcmp import richcmp, op_EQ, op_NE -from sage.misc.cachefunc import cached_method -from sage.misc.latex import latex - +from sage.categories.homset import Hom from sage.categories.map import Map from sage.categories.morphism import Morphism -from sage.categories.homset import Hom +from sage.misc.cachefunc import cached_method +from sage.misc.latex import latex from sage.structure.element import AlgebraElement +from sage.structure.richcmp import op_EQ, op_NE, richcmp class OreFunction(AlgebraElement): diff --git a/src/sage/rings/polynomial/ore_function_field.py b/src/sage/rings/polynomial/ore_function_field.py index 1c78217508b..4b509688450 100644 --- a/src/sage/rings/polynomial/ore_function_field.py +++ b/src/sage/rings/polynomial/ore_function_field.py @@ -128,6 +128,23 @@ sage: g^(-1) * f (d - 1/t)^(-1) * (d + (t^2 - 1)/t) +TESTS: + +The Ore function field is commutative if the twisting morphism is the +identity and the twisting derivation vanishes. :: + + sage: # needs sage.rings.finite_rings + sage: k. = GF(5^3) + sage: Frob = k.frobenius_endomorphism() + sage: S. = k['x', Frob] + sage: K = S.fraction_field() + sage: K.is_commutative() + False + sage: T. = k['y', Frob^3] + sage: L = T.fraction_field() + sage: L.is_commutative() + True + AUTHOR: - Xavier Caruso (2020-05) @@ -144,21 +161,21 @@ # https://www.gnu.org/licenses/ # *************************************************************************** -import sage - -from sage.structure.richcmp import op_EQ -from sage.structure.category_object import normalize_names -from sage.structure.unique_representation import UniqueRepresentation -from sage.structure.parent import Parent from sage.categories.algebras import Algebras +from sage.categories.commutative_rings import CommutativeRings from sage.categories.fields import Fields - -from sage.rings.morphism import RingHomomorphism from sage.categories.homset import Hom from sage.categories.map import Section - +from sage.rings.morphism import RingHomomorphism +from sage.rings.polynomial.ore_function_element import ( + OreFunction_with_large_center, + OreFunctionBaseringInjection, +) from sage.rings.polynomial.ore_polynomial_ring import OrePolynomialRing -from sage.rings.polynomial.ore_function_element import OreFunctionBaseringInjection +from sage.structure.category_object import normalize_names +from sage.structure.parent import Parent +from sage.structure.richcmp import op_EQ +from sage.structure.unique_representation import UniqueRepresentation WORKING_CENTER_MAX_TRIES = 1000 @@ -200,7 +217,10 @@ def __init__(self, ring, category=None): self._simplification = False self._ring = ring base = ring.base_ring() - category = Algebras(base).or_subcategory(category) + if ring in CommutativeRings(): + category = Algebras(base).Commutative().or_subcategory(category) + else: + category = Algebras(base).or_subcategory(category) Parent.__init__(self, base=base, names=ring.variable_name(), normalize=True, category=category) @@ -614,27 +634,6 @@ def random_element(self, degree=2, monic=False, *args, **kwds): denominator = self._ring.random_element(degdenom, True, *args, **kwds) return self(numerator, denominator) - def is_commutative(self) -> bool: - r""" - Return ``True`` if this Ore function field is commutative, i.e. if the - twisting morphism is the identity and the twisting derivation vanishes. - - EXAMPLES:: - - sage: # needs sage.rings.finite_rings - sage: k. = GF(5^3) - sage: Frob = k.frobenius_endomorphism() - sage: S. = k['x', Frob] - sage: K = S.fraction_field() - sage: K.is_commutative() - False - sage: T. = k['y', Frob^3] - sage: L = T.fraction_field() - sage: L.is_commutative() - True - """ - return self._ring.is_commutative() - def is_field(self, proof=False) -> bool: r""" Return always ``True`` since Ore function field are (skew) fields. @@ -892,7 +891,7 @@ def __init__(self, ring, category=None): sage: TestSuite(K).run() """ if self.Element is None: - self.Element = sage.rings.polynomial.ore_function_element.OreFunction_with_large_center + self.Element = OreFunction_with_large_center OreFunctionField.__init__(self, ring, category) self._center = {} self._center_variable_name = 'z' diff --git a/src/sage/rings/polynomial/ore_polynomial_ring.py b/src/sage/rings/polynomial/ore_polynomial_ring.py index f28b90ad198..7866221cfad 100644 --- a/src/sage/rings/polynomial/ore_polynomial_ring.py +++ b/src/sage/rings/polynomial/ore_polynomial_ring.py @@ -7,6 +7,30 @@ which constructs a general dense univariate Ore polynomial ring over a commutative base with equipped with an endomorphism and/or a derivation. +TESTS: + +The Ore polynomial ring is commutative if the twisting morphism is the +identity and the twisting derivation vanishes. :: + + sage: # needs sage.rings.finite_rings + sage: k. = GF(5^3) + sage: Frob = k.frobenius_endomorphism() + sage: S. = k['x', Frob] + sage: S.is_commutative() + False + sage: T. = k['y', Frob^3] + sage: T.is_commutative() + True + + sage: R. = GF(5)[] + sage: der = R.derivation() + sage: A. = R['d', der] + sage: A.is_commutative() + False + sage: B. = R['b', 5*der] + sage: B.is_commutative() + True + AUTHOR: - Xavier Caruso (2020-04) @@ -21,25 +45,21 @@ # https://www.gnu.org/licenses/ # *************************************************************************** -from sage.misc.prandom import randint +from sage.categories.algebras import Algebras +from sage.categories.commutative_rings import CommutativeRings +from sage.categories.morphism import Morphism from sage.misc.cachefunc import cached_method from sage.misc.lazy_import import lazy_import +from sage.misc.prandom import randint from sage.rings.infinity import Infinity +from sage.rings.integer import Integer +from sage.rings.polynomial.ore_polynomial_element import OrePolynomialBaseringInjection +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing +from sage.rings.ring import _Fields from sage.structure.category_object import normalize_names +from sage.structure.element import Element from sage.structure.parent import Parent - from sage.structure.unique_representation import UniqueRepresentation -from sage.rings.integer import Integer -from sage.structure.element import Element - -from sage.categories.commutative_rings import CommutativeRings -from sage.categories.algebras import Algebras -from sage.rings.ring import _Fields - -from sage.categories.morphism import Morphism - -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.polynomial.ore_polynomial_element import OrePolynomialBaseringInjection lazy_import('sage.rings.derivation', 'RingDerivation') @@ -421,7 +441,11 @@ def __init__(self, base_ring, morphism, derivation, name, sparse, category=None) self._morphism = morphism self._derivation = derivation self._fraction_field = None - category = Algebras(base_ring).or_subcategory(category) + if morphism is None and derivation is None: + cat = Algebras(base_ring).Commutative() + else: + cat = Algebras(base_ring) + category = cat.or_subcategory(category) Parent.__init__(self, base_ring, names=name, normalize=True, category=category) @@ -506,7 +530,7 @@ def build(check): pass if isinstance(a, str): try: - from sage.misc.parser import Parser, LookupNameMaker + from sage.misc.parser import LookupNameMaker, Parser R = self.base_ring() p = Parser(Integer, R, LookupNameMaker({self.variable_name(): self.gen()}, R)) return self(p.parse(a)) @@ -1095,36 +1119,6 @@ def random_irreducible(self, degree=2, monic=True, *args, **kwds): if irred.is_irreducible(): return irred - def is_commutative(self) -> bool: - r""" - Return ``True`` if this Ore polynomial ring is commutative. - - This holds if the twisting morphism is the identity and the - twisting derivation vanishes. - - EXAMPLES:: - - sage: # needs sage.rings.finite_rings - sage: k. = GF(5^3) - sage: Frob = k.frobenius_endomorphism() - sage: S. = k['x', Frob] - sage: S.is_commutative() - False - sage: T. = k['y', Frob^3] - sage: T.is_commutative() - True - - sage: R. = GF(5)[] - sage: der = R.derivation() - sage: A. = R['d', der] - sage: A.is_commutative() - False - sage: B. = R['b', 5*der] - sage: B.is_commutative() - True - """ - return self._morphism is None and self._derivation is None - def is_field(self, proof=False) -> bool: r""" Return always ``False`` since Ore polynomial rings are never fields.