Skip to content

Commit 32ac5a3

Browse files
author
Release Manager
committed
gh-39232: minor tweaks in Ore polynomials a few minor changes in Ore polynomials - sort imports - better categories - no custom "is_commutative" ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39232 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents bfa809d + 38441b3 commit 32ac5a3

File tree

3 files changed

+75
-83
lines changed

3 files changed

+75
-83
lines changed

src/sage/rings/polynomial/ore_function_element.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
# https://www.gnu.org/licenses/
1717
# ***************************************************************************
1818

19-
from sage.structure.richcmp import richcmp, op_EQ, op_NE
20-
from sage.misc.cachefunc import cached_method
21-
from sage.misc.latex import latex
22-
19+
from sage.categories.homset import Hom
2320
from sage.categories.map import Map
2421
from sage.categories.morphism import Morphism
25-
from sage.categories.homset import Hom
22+
from sage.misc.cachefunc import cached_method
23+
from sage.misc.latex import latex
2624
from sage.structure.element import AlgebraElement
25+
from sage.structure.richcmp import op_EQ, op_NE, richcmp
2726

2827

2928
class OreFunction(AlgebraElement):

src/sage/rings/polynomial/ore_function_field.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@
128128
sage: g^(-1) * f
129129
(d - 1/t)^(-1) * (d + (t^2 - 1)/t)
130130
131+
TESTS:
132+
133+
The Ore function field is commutative if the twisting morphism is the
134+
identity and the twisting derivation vanishes. ::
135+
136+
sage: # needs sage.rings.finite_rings
137+
sage: k.<a> = GF(5^3)
138+
sage: Frob = k.frobenius_endomorphism()
139+
sage: S.<x> = k['x', Frob]
140+
sage: K = S.fraction_field()
141+
sage: K.is_commutative()
142+
False
143+
sage: T.<y> = k['y', Frob^3]
144+
sage: L = T.fraction_field()
145+
sage: L.is_commutative()
146+
True
147+
131148
AUTHOR:
132149
133150
- Xavier Caruso (2020-05)
@@ -144,21 +161,21 @@
144161
# https://www.gnu.org/licenses/
145162
# ***************************************************************************
146163

147-
import sage
148-
149-
from sage.structure.richcmp import op_EQ
150-
from sage.structure.category_object import normalize_names
151-
from sage.structure.unique_representation import UniqueRepresentation
152-
from sage.structure.parent import Parent
153164
from sage.categories.algebras import Algebras
165+
from sage.categories.commutative_rings import CommutativeRings
154166
from sage.categories.fields import Fields
155-
156-
from sage.rings.morphism import RingHomomorphism
157167
from sage.categories.homset import Hom
158168
from sage.categories.map import Section
159-
169+
from sage.rings.morphism import RingHomomorphism
170+
from sage.rings.polynomial.ore_function_element import (
171+
OreFunction_with_large_center,
172+
OreFunctionBaseringInjection,
173+
)
160174
from sage.rings.polynomial.ore_polynomial_ring import OrePolynomialRing
161-
from sage.rings.polynomial.ore_function_element import OreFunctionBaseringInjection
175+
from sage.structure.category_object import normalize_names
176+
from sage.structure.parent import Parent
177+
from sage.structure.richcmp import op_EQ
178+
from sage.structure.unique_representation import UniqueRepresentation
162179

163180
WORKING_CENTER_MAX_TRIES = 1000
164181

@@ -200,7 +217,10 @@ def __init__(self, ring, category=None):
200217
self._simplification = False
201218
self._ring = ring
202219
base = ring.base_ring()
203-
category = Algebras(base).or_subcategory(category)
220+
if ring in CommutativeRings():
221+
category = Algebras(base).Commutative().or_subcategory(category)
222+
else:
223+
category = Algebras(base).or_subcategory(category)
204224
Parent.__init__(self, base=base, names=ring.variable_name(),
205225
normalize=True, category=category)
206226

@@ -614,27 +634,6 @@ def random_element(self, degree=2, monic=False, *args, **kwds):
614634
denominator = self._ring.random_element(degdenom, True, *args, **kwds)
615635
return self(numerator, denominator)
616636

617-
def is_commutative(self) -> bool:
618-
r"""
619-
Return ``True`` if this Ore function field is commutative, i.e. if the
620-
twisting morphism is the identity and the twisting derivation vanishes.
621-
622-
EXAMPLES::
623-
624-
sage: # needs sage.rings.finite_rings
625-
sage: k.<a> = GF(5^3)
626-
sage: Frob = k.frobenius_endomorphism()
627-
sage: S.<x> = k['x', Frob]
628-
sage: K = S.fraction_field()
629-
sage: K.is_commutative()
630-
False
631-
sage: T.<y> = k['y', Frob^3]
632-
sage: L = T.fraction_field()
633-
sage: L.is_commutative()
634-
True
635-
"""
636-
return self._ring.is_commutative()
637-
638637
def is_field(self, proof=False) -> bool:
639638
r"""
640639
Return always ``True`` since Ore function field are (skew) fields.
@@ -892,7 +891,7 @@ def __init__(self, ring, category=None):
892891
sage: TestSuite(K).run()
893892
"""
894893
if self.Element is None:
895-
self.Element = sage.rings.polynomial.ore_function_element.OreFunction_with_large_center
894+
self.Element = OreFunction_with_large_center
896895
OreFunctionField.__init__(self, ring, category)
897896
self._center = {}
898897
self._center_variable_name = 'z'

src/sage/rings/polynomial/ore_polynomial_ring.py

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@
77
which constructs a general dense univariate Ore polynomial ring over a
88
commutative base with equipped with an endomorphism and/or a derivation.
99
10+
TESTS:
11+
12+
The Ore polynomial ring is commutative if the twisting morphism is the
13+
identity and the twisting derivation vanishes. ::
14+
15+
sage: # needs sage.rings.finite_rings
16+
sage: k.<a> = GF(5^3)
17+
sage: Frob = k.frobenius_endomorphism()
18+
sage: S.<x> = k['x', Frob]
19+
sage: S.is_commutative()
20+
False
21+
sage: T.<y> = k['y', Frob^3]
22+
sage: T.is_commutative()
23+
True
24+
25+
sage: R.<t> = GF(5)[]
26+
sage: der = R.derivation()
27+
sage: A.<d> = R['d', der]
28+
sage: A.is_commutative()
29+
False
30+
sage: B.<b> = R['b', 5*der]
31+
sage: B.is_commutative()
32+
True
33+
1034
AUTHOR:
1135
1236
- Xavier Caruso (2020-04)
@@ -21,25 +45,21 @@
2145
# https://www.gnu.org/licenses/
2246
# ***************************************************************************
2347

24-
from sage.misc.prandom import randint
48+
from sage.categories.algebras import Algebras
49+
from sage.categories.commutative_rings import CommutativeRings
50+
from sage.categories.morphism import Morphism
2551
from sage.misc.cachefunc import cached_method
2652
from sage.misc.lazy_import import lazy_import
53+
from sage.misc.prandom import randint
2754
from sage.rings.infinity import Infinity
55+
from sage.rings.integer import Integer
56+
from sage.rings.polynomial.ore_polynomial_element import OrePolynomialBaseringInjection
57+
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
58+
from sage.rings.ring import _Fields
2859
from sage.structure.category_object import normalize_names
60+
from sage.structure.element import Element
2961
from sage.structure.parent import Parent
30-
3162
from sage.structure.unique_representation import UniqueRepresentation
32-
from sage.rings.integer import Integer
33-
from sage.structure.element import Element
34-
35-
from sage.categories.commutative_rings import CommutativeRings
36-
from sage.categories.algebras import Algebras
37-
from sage.rings.ring import _Fields
38-
39-
from sage.categories.morphism import Morphism
40-
41-
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
42-
from sage.rings.polynomial.ore_polynomial_element import OrePolynomialBaseringInjection
4363

4464
lazy_import('sage.rings.derivation', 'RingDerivation')
4565

@@ -421,7 +441,11 @@ def __init__(self, base_ring, morphism, derivation, name, sparse, category=None)
421441
self._morphism = morphism
422442
self._derivation = derivation
423443
self._fraction_field = None
424-
category = Algebras(base_ring).or_subcategory(category)
444+
if morphism is None and derivation is None:
445+
cat = Algebras(base_ring).Commutative()
446+
else:
447+
cat = Algebras(base_ring)
448+
category = cat.or_subcategory(category)
425449
Parent.__init__(self, base_ring, names=name,
426450
normalize=True, category=category)
427451

@@ -506,7 +530,7 @@ def build(check):
506530
pass
507531
if isinstance(a, str):
508532
try:
509-
from sage.misc.parser import Parser, LookupNameMaker
533+
from sage.misc.parser import LookupNameMaker, Parser
510534
R = self.base_ring()
511535
p = Parser(Integer, R, LookupNameMaker({self.variable_name(): self.gen()}, R))
512536
return self(p.parse(a))
@@ -1095,36 +1119,6 @@ def random_irreducible(self, degree=2, monic=True, *args, **kwds):
10951119
if irred.is_irreducible():
10961120
return irred
10971121

1098-
def is_commutative(self) -> bool:
1099-
r"""
1100-
Return ``True`` if this Ore polynomial ring is commutative.
1101-
1102-
This holds if the twisting morphism is the identity and the
1103-
twisting derivation vanishes.
1104-
1105-
EXAMPLES::
1106-
1107-
sage: # needs sage.rings.finite_rings
1108-
sage: k.<a> = GF(5^3)
1109-
sage: Frob = k.frobenius_endomorphism()
1110-
sage: S.<x> = k['x', Frob]
1111-
sage: S.is_commutative()
1112-
False
1113-
sage: T.<y> = k['y', Frob^3]
1114-
sage: T.is_commutative()
1115-
True
1116-
1117-
sage: R.<t> = GF(5)[]
1118-
sage: der = R.derivation()
1119-
sage: A.<d> = R['d', der]
1120-
sage: A.is_commutative()
1121-
False
1122-
sage: B.<b> = R['b', 5*der]
1123-
sage: B.is_commutative()
1124-
True
1125-
"""
1126-
return self._morphism is None and self._derivation is None
1127-
11281122
def is_field(self, proof=False) -> bool:
11291123
r"""
11301124
Return always ``False`` since Ore polynomial rings are never fields.

0 commit comments

Comments
 (0)