Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/categories/bimodules.py
8817 views
1
r"""
2
Bimodules
3
"""
4
#*****************************************************************************
5
# Copyright (C) 2005 David Kohel <[email protected]>
6
# William Stein <[email protected]>
7
# 2008 Teresa Gomez-Diaz (CNRS) <[email protected]>
8
# 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
9
#
10
# Distributed under the terms of the GNU General Public License (GPL)
11
# http://www.gnu.org/licenses/
12
#******************************************************************************
13
14
from sage.misc.unknown import Unknown
15
from sage.categories.category import Category, CategoryWithParameters
16
from sage.categories.left_modules import LeftModules
17
from sage.categories.right_modules import RightModules
18
19
from sage.categories.rings import Rings
20
_Rings = Rings()
21
22
#?class Bimodules(Category_over_base_rng, Category_over_base_rng):
23
class Bimodules(CategoryWithParameters):
24
"""
25
The category of `(R,S)`-bimodules
26
27
For `R` and `S` rings, a `(R,S)`-bimodule `X` is a left `R`-module
28
and right `S`-module such that the left and right actions commute:
29
`r*(x*s) = (r*x)*s`.
30
31
EXAMPLES::
32
33
sage: Bimodules(QQ, ZZ)
34
Category of bimodules over Rational Field on the left and Integer Ring on the right
35
sage: Bimodules(QQ, ZZ).super_categories()
36
[Category of left modules over Rational Field, Category of right modules over Integer Ring]
37
"""
38
39
def __init__(self, left_base, right_base, name=None):
40
"""
41
EXAMPLES::
42
43
sage: C = Bimodules(QQ, ZZ)
44
sage: TestSuite(C).run()
45
"""
46
assert left_base in _Rings, "The left base must be a ring"
47
assert right_base in _Rings, "The right base must be a ring"
48
self._left_base_ring = left_base
49
self._right_base_ring = right_base
50
Category.__init__(self, name)
51
52
def _make_named_class_key(self, name):
53
r"""
54
Return what the element/parent/... classes depend on.
55
56
Since :trac:`11935`, the element and parent classes of a
57
bimodule only depend on the categories of the left and right
58
base ring.
59
60
.. SEEALSO::
61
62
- :meth:`CategoryWithParameters`
63
- :meth:`CategoryWithParameters._make_named_class_key`
64
65
EXAMPLES::
66
67
sage: Bimodules(QQ,ZZ)._make_named_class_key('parent_class')
68
(Category of quotient fields, Category of euclidean domains)
69
"""
70
return (self._left_base_ring.category(), self._right_base_ring.category())
71
72
@classmethod
73
def an_instance(cls):
74
"""
75
Returns an instance of this class
76
77
EXAMPLES::
78
79
sage: Bimodules.an_instance()
80
Category of bimodules over Rational Field on the left and Real Field with 53 bits of precision on the right
81
"""
82
from sage.rings.all import QQ, RR
83
return cls(QQ, RR)
84
85
def _repr_object_names(self):
86
"""
87
EXAMPLES::
88
89
sage: Bimodules(QQ, ZZ) # indirect doctest
90
Category of bimodules over Rational Field on the left and Integer Ring on the right
91
"""
92
return "bimodules over %s on the left and %s on the right" \
93
%(self._left_base_ring, self._right_base_ring)
94
95
def left_base_ring(self):
96
"""
97
Returns the left base ring over which elements of this category are
98
defined.
99
100
EXAMPLES::
101
102
sage: Bimodules(QQ, ZZ).left_base_ring()
103
Rational Field
104
"""
105
return self._left_base_ring
106
107
def right_base_ring(self):
108
"""
109
Returns the right base ring over which elements of this category are
110
defined.
111
112
EXAMPLES::
113
114
sage: Bimodules(QQ, ZZ).right_base_ring()
115
Integer Ring
116
"""
117
return self._right_base_ring
118
119
def _latex_(self):
120
"""
121
EXAMPLES::
122
123
sage: print Bimodules(QQ, ZZ)._latex_()
124
{\mathbf{Bimodules}}_{\Bold{Q}}_{\Bold{Z}}
125
"""
126
from sage.misc.latex import latex
127
return "{%s}_{%s}_{%s}"%(Category._latex_(self), latex(self._left_base_ring), latex(self._right_base_ring))
128
129
def super_categories(self):
130
"""
131
EXAMPLES::
132
133
sage: Bimodules(QQ, ZZ).super_categories()
134
[Category of left modules over Rational Field, Category of right modules over Integer Ring]
135
"""
136
R = self.left_base_ring()
137
S = self.right_base_ring()
138
return [LeftModules(R), RightModules(S)]
139
140
class ParentMethods:
141
pass
142
143
class ElementMethods:
144
pass
145
146