48
48
49
49
from sage .arith .misc import integer_ceil as ceil
50
50
from sage .arith .misc import binomial
51
+ from sage .categories .algebras import Algebras
51
52
from sage .functions .log import log
52
53
from sage .matrix .constructor import matrix
53
54
from sage .misc .cachefunc import cached_method
72
73
from sage .rings .laurent_series_ring import is_LaurentSeriesRing
73
74
from sage .rings .padics .factory import Qp as pAdicField
74
75
from sage .rings .polynomial .polynomial_element import Polynomial
75
- from sage .rings .ring import CommutativeAlgebra
76
76
from sage .schemes .elliptic_curves .constructor import EllipticCurve
77
77
from sage .schemes .elliptic_curves .ell_generic import is_EllipticCurve
78
78
from sage .schemes .hyperelliptic_curves .constructor import HyperellipticCurve
79
79
from sage .schemes .hyperelliptic_curves .hyperelliptic_generic import is_HyperellipticCurve
80
- from sage .structure .element import CommutativeAlgebraElement , ModuleElement
80
+ from sage .structure .element import Element , ModuleElement
81
+ from sage .structure .parent import Parent
81
82
from sage .structure .richcmp import richcmp
82
83
from sage .structure .unique_representation import UniqueRepresentation
83
84
84
85
85
- class SpecialCubicQuotientRingElement (CommutativeAlgebraElement ):
86
+ class SpecialCubicQuotientRingElement (ModuleElement ):
86
87
"""
87
88
An element of a :class:`SpecialCubicQuotientRing`.
88
89
"""
@@ -108,11 +109,19 @@ def __init__(self, parent, p0, p1, p2, check=True):
108
109
sage: from sage.schemes.hyperelliptic_curves.monsky_washnitzer import SpecialCubicQuotientRingElement
109
110
sage: SpecialCubicQuotientRingElement(R, 2, 3, 4)
110
111
(2) + (3)*x + (4)*x^2
112
+
113
+ TESTS::
114
+
115
+ sage: B.<t> = PolynomialRing(Integers(125))
116
+ sage: R = monsky_washnitzer.SpecialCubicQuotientRing(t^3 - t + B(1/4))
117
+ sage: p = R.create_element(t, t^2 - 2, 3)
118
+ sage: -p
119
+ (124*T) + (124*T^2 + 2)*x + (122)*x^2
111
120
"""
112
121
if not isinstance (parent , SpecialCubicQuotientRing ):
113
122
raise TypeError (f"parent (={ parent } ) must be a SpecialCubicQuotientRing" )
114
123
115
- CommutativeAlgebraElement .__init__ (self , parent )
124
+ ModuleElement .__init__ (self , parent )
116
125
117
126
if check :
118
127
poly_ring = parent ._poly_ring
@@ -145,7 +154,7 @@ def coeffs(self):
145
154
column .extend ([base_ring (0 )] * (degree - len (column )))
146
155
return coeffs
147
156
148
- def __bool__ (self ):
157
+ def __bool__ (self ) -> bool :
149
158
"""
150
159
EXAMPLES::
151
160
@@ -161,7 +170,7 @@ def __bool__(self):
161
170
"""
162
171
return bool (self ._triple [0 ]) or bool (self ._triple [1 ]) or bool (self ._triple [2 ])
163
172
164
- def _richcmp_ (self , other , op ):
173
+ def _richcmp_ (self , other , op ) -> bool :
165
174
"""
166
175
EXAMPLES::
167
176
@@ -176,7 +185,7 @@ def _richcmp_(self, other, op):
176
185
"""
177
186
return richcmp (self ._triple , other ._triple , op )
178
187
179
- def _repr_ (self ):
188
+ def _repr_ (self ) -> str :
180
189
"""
181
190
EXAMPLES::
182
191
@@ -188,7 +197,7 @@ def _repr_(self):
188
197
"""
189
198
return "(%s) + (%s)*x + (%s)*x^2" % self ._triple
190
199
191
- def _latex_ (self ):
200
+ def _latex_ (self ) -> str :
192
201
"""
193
202
EXAMPLES::
194
203
@@ -387,7 +396,7 @@ def _mul_(self, other):
387
396
check = False )
388
397
389
398
390
- class SpecialCubicQuotientRing (CommutativeAlgebra ):
399
+ class SpecialCubicQuotientRing (Parent ):
391
400
r"""
392
401
Specialised class for representing the quotient ring
393
402
`R[x,T]/(T - x^3 - ax - b)`, where `R` is an
@@ -513,12 +522,12 @@ def __init__(self, Q, laurent_series=False):
513
522
raise ArithmeticError ("2 and 3 must be invertible in the "
514
523
"coefficient ring (=%s) of Q" % base_ring )
515
524
516
- # CommutativeAlgebra .__init__ tries to establish a coercion
525
+ # .__init__ tries to establish a coercion
517
526
# from the base ring, by github issue #9138. The corresponding
518
527
# hom set is cached. In order to use self as cache key, its
519
528
# string representation is used. In otder to get the string
520
529
# representation, we need to know the attributes _a and
521
- # _b. Hence, in #9138, we have to move CommutativeAlgebra .__init__
530
+ # _b. Hence, in #9138, we have to move .__init__
522
531
# further down:
523
532
self ._a = Q [1 ]
524
533
self ._b = Q [0 ]
@@ -527,7 +536,8 @@ def __init__(self, Q, laurent_series=False):
527
536
else :
528
537
self ._poly_ring = PolynomialRing (base_ring , 'T' ) # R[T]
529
538
self ._poly_generator = self ._poly_ring .gen (0 ) # the generator T
530
- CommutativeAlgebra .__init__ (self , base_ring )
539
+ Parent .__init__ (self , base = base_ring ,
540
+ category = Algebras (base_ring ).Commutative ())
531
541
532
542
# Precompute a matrix that is used in the Toom-Cook multiplication.
533
543
# This is where we need 2 and 3 invertible.
@@ -654,7 +664,7 @@ def _coerce_map_from_(self, R):
654
664
Element = SpecialCubicQuotientRingElement
655
665
656
666
657
- def transpose_list (input ):
667
+ def transpose_list (input ) -> list [ list ] :
658
668
"""
659
669
INPUT:
660
670
@@ -1854,7 +1864,7 @@ def matrix_of_frobenius_hyperelliptic(Q, p=None, prec=None, M=None):
1854
1864
return M .transpose (), [f for f , a in reduced ]
1855
1865
1856
1866
1857
- class SpecialHyperellipticQuotientElement (CommutativeAlgebraElement ):
1867
+ class SpecialHyperellipticQuotientElement (ModuleElement ):
1858
1868
r"""
1859
1869
Element in the Hyperelliptic quotient ring.
1860
1870
@@ -1880,7 +1890,7 @@ def __init__(self, parent, val=0, offset=0, check=True):
1880
1890
sage: elt = MW(x + x**2 + y - 77)
1881
1891
sage: TestSuite(elt).run()
1882
1892
"""
1883
- CommutativeAlgebraElement .__init__ (self , parent )
1893
+ ModuleElement .__init__ (self , parent )
1884
1894
if not check :
1885
1895
self ._f = parent ._poly_ring (val , check = False )
1886
1896
return
@@ -1896,7 +1906,7 @@ def __init__(self, parent, val=0, offset=0, check=True):
1896
1906
if offset != 0 :
1897
1907
self ._f = self ._f .parent ()([a << offset for a in self ._f ], check = False )
1898
1908
1899
- def _richcmp_ (self , other , op ):
1909
+ def _richcmp_ (self , other , op ) -> bool :
1900
1910
"""
1901
1911
Compare the elements.
1902
1912
@@ -2358,7 +2368,8 @@ def coeffs(self, R=None):
2358
2368
coeffs = transpose_list (coeffs )
2359
2369
return [V (a ) for a in coeffs ], y_offset
2360
2370
2361
- class SpecialHyperellipticQuotientRing (UniqueRepresentation , CommutativeAlgebra ):
2371
+
2372
+ class SpecialHyperellipticQuotientRing (UniqueRepresentation , Parent ):
2362
2373
"""
2363
2374
The special hyperelliptic quotient ring.
2364
2375
"""
@@ -2385,12 +2396,12 @@ def __init__(self, Q, R=None, invert_y=True):
2385
2396
if R is None :
2386
2397
R = Q .base_ring ()
2387
2398
2388
- # Github issue #9138: CommutativeAlgebra .__init__ must not be
2399
+ # Github issue #9138: .__init__ must not be
2389
2400
# done so early. It tries to register a coercion, but that
2390
2401
# requires the hash being available. But the hash, in its
2391
2402
# default implementation, relies on the string representation,
2392
2403
# which is not available at this point.
2393
- # CommutativeAlgebra .__init__(self, R) # moved to below.
2404
+ # .__init__(self, R) # moved to below.
2394
2405
2395
2406
x = PolynomialRing (R , 'xx' ).gen ()
2396
2407
if is_EllipticCurve (Q ):
@@ -2428,10 +2439,10 @@ def __init__(self, Q, R=None, invert_y=True):
2428
2439
self ._series_ring_y = self ._series_ring .gen (0 )
2429
2440
self ._series_ring_0 = self ._series_ring .zero ()
2430
2441
2431
- # Github issue #9138: Initialise the commutative algebra here!
2442
+ # Github issue #9138: Initialise the parent here!
2432
2443
# Below, we do self(self._poly_ring.gen(0)), which requires
2433
2444
# the initialisation being finished.
2434
- CommutativeAlgebra .__init__ (self , R )
2445
+ Parent .__init__ (self , base = R , category = Algebras ( R ). Commutative () )
2435
2446
2436
2447
self ._poly_ring = PolynomialRing (self ._series_ring , 'x' )
2437
2448
@@ -2495,7 +2506,7 @@ def change_ring(self, R):
2495
2506
over Integer Ring
2496
2507
"""
2497
2508
return SpecialHyperellipticQuotientRing (self ._Q .change_ring (R ), R ,
2498
- is_LaurentSeriesRing (self ._series_ring ))
2509
+ is_LaurentSeriesRing (self ._series_ring ))
2499
2510
2500
2511
def _element_constructor_ (self , val , offset = 0 , check = True ):
2501
2512
r"""
@@ -2787,7 +2798,7 @@ def monsky_washnitzer(self):
2787
2798
"""
2788
2799
return self ._monsky_washnitzer
2789
2800
2790
- def is_field (self , proof = True ):
2801
+ def is_field (self , proof = True ) -> bool :
2791
2802
"""
2792
2803
Return ``False`` as ``self`` is not a field.
2793
2804
@@ -2893,24 +2904,6 @@ def _sub_(self, other):
2893
2904
P = self .parent ()
2894
2905
return P .element_class (P , self ._coeff - other ._coeff )
2895
2906
2896
- def __neg__ (self ):
2897
- r"""
2898
- Return the additive inverse of ``self``.
2899
-
2900
- EXAMPLES::
2901
-
2902
- sage: R.<x> = QQ['x']
2903
- sage: C = HyperellipticCurve(x^5 - 4*x + 4)
2904
- sage: x,y = C.monsky_washnitzer_gens()
2905
- sage: w = C.invariant_differential()
2906
- sage: -w
2907
- -1 dx/2y
2908
- sage: -((y-x)*w)
2909
- (-y*1 + x) dx/2y
2910
- """
2911
- P = self .parent ()
2912
- return P .element_class (P , - self ._coeff )
2913
-
2914
2907
def _lmul_ (self , a ):
2915
2908
r"""
2916
2909
Return `self * a`.
0 commit comments