Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/categories/coalgebras.py
8817 views
1
r"""
2
Coalgebras
3
"""
4
#*****************************************************************************
5
# Copyright (C) 2008 Teresa Gomez-Diaz (CNRS) <[email protected]>
6
# Copyright (C) 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
7
#
8
# Distributed under the terms of the GNU General Public License (GPL)
9
# http://www.gnu.org/licenses/
10
#******************************************************************************
11
12
from category_types import Category_over_base_ring
13
from sage.categories.all import Modules, Algebras
14
from sage.categories.tensor import TensorProductsCategory, tensor
15
from sage.categories.dual import DualObjectsCategory
16
from sage.categories.realizations import RealizationsCategory
17
from sage.categories.with_realizations import WithRealizationsCategory
18
from sage.misc.abstract_method import abstract_method
19
from sage.misc.cachefunc import cached_method
20
21
class Coalgebras(Category_over_base_ring):
22
"""
23
The category of coalgebras
24
25
EXAMPLES::
26
27
sage: Coalgebras(QQ)
28
Category of coalgebras over Rational Field
29
sage: Coalgebras(QQ).super_categories()
30
[Category of vector spaces over Rational Field]
31
32
TESTS::
33
34
sage: TestSuite(Coalgebras(ZZ)).run()
35
"""
36
def super_categories(self):
37
"""
38
EXAMPLES::
39
40
sage: Coalgebras(QQ).super_categories()
41
[Category of vector spaces over Rational Field]
42
"""
43
return [Modules(self.base_ring())]
44
45
class ParentMethods:
46
#def __init_add__(self): # The analogue of initDomainAdd
47
# # Will declare the coproduct of self to the coercion mechanism when it exists
48
# pass
49
50
@cached_method
51
def tensor_square(self):
52
"""
53
Returns the tensor square of ``self``
54
55
EXAMPLES::
56
57
sage: A = HopfAlgebrasWithBasis(QQ).example()
58
sage: A.tensor_square()
59
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field # An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
60
"""
61
return tensor([self, self])
62
63
@abstract_method
64
def counit(self, x):
65
"""
66
Returns the counit of x.
67
68
Eventually, there will be a default implementation,
69
delegating to the overloading mechanism and forcing the
70
conversion back
71
72
EXAMPLES::
73
74
sage: A = HopfAlgebrasWithBasis(QQ).example(); A
75
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
76
sage: [a,b] = A.algebra_generators()
77
sage: a, A.counit(a)
78
(B[(1,2,3)], 1)
79
sage: b, A.counit(b)
80
(B[(1,3)], 1)
81
82
TODO: implement some tests of the axioms of coalgebras, bialgebras
83
and Hopf algebras using the counit.
84
"""
85
86
87
@abstract_method
88
def coproduct(self, x):
89
"""
90
Returns the coproduct of x.
91
92
Eventually, there will be a default implementation,
93
delegating to the overloading mechanism and forcing the
94
conversion back
95
96
EXAMPLES::
97
98
sage: A = HopfAlgebrasWithBasis(QQ).example(); A
99
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
100
sage: [a,b] = A.algebra_generators()
101
sage: a, A.coproduct(a)
102
(B[(1,2,3)], B[(1,2,3)] # B[(1,2,3)])
103
sage: b, A.coproduct(b)
104
(B[(1,3)], B[(1,3)] # B[(1,3)])
105
"""
106
#return self.tensor_square()(overloaded_coproduct(x))
107
108
class ElementMethods:
109
def coproduct(self):
110
"""
111
Returns the coproduct of ``self``
112
113
EXAMPLES::
114
115
sage: A = HopfAlgebrasWithBasis(QQ).example(); A
116
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
117
sage: [a,b] = A.algebra_generators()
118
sage: a, a.coproduct()
119
(B[(1,2,3)], B[(1,2,3)] # B[(1,2,3)])
120
sage: b, b.coproduct()
121
(B[(1,3)], B[(1,3)] # B[(1,3)])
122
"""
123
return self.parent().coproduct(self)
124
125
def counit(self):
126
"""
127
Returns the counit of ``self``
128
129
EXAMPLES::
130
131
sage: A = HopfAlgebrasWithBasis(QQ).example(); A
132
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
133
sage: [a,b] = A.algebra_generators()
134
sage: a, a.counit()
135
(B[(1,2,3)], 1)
136
sage: b, b.counit()
137
(B[(1,3)], 1)
138
"""
139
return self.parent().counit(self)
140
141
class TensorProducts(TensorProductsCategory):
142
143
@cached_method
144
def extra_super_categories(self):
145
"""
146
EXAMPLES::
147
148
sage: Coalgebras(QQ).TensorProducts().extra_super_categories()
149
[Category of coalgebras over Rational Field]
150
sage: Coalgebras(QQ).TensorProducts().super_categories()
151
[Category of coalgebras over Rational Field]
152
153
Meaning: a tensor product of coalgebras is a coalgebra
154
"""
155
return [self.base_category()]
156
157
class ParentMethods:
158
# TODO: provide this default implementation of one if one_basis is not implemented
159
#def one(self):
160
# return tensor(module.one() for module in self.modules)
161
pass
162
163
class ElementMethods:
164
pass
165
166
class DualObjects(DualObjectsCategory):
167
168
def extra_super_categories(self):
169
r"""
170
Returns the dual category
171
172
EXAMPLES:
173
174
The category of coalgebras over the Rational Field is dual
175
to the category of algebras over the same field::
176
177
sage: C = Coalgebras(QQ)
178
sage: C.dual()
179
Category of duals of coalgebras over Rational Field
180
sage: C.dual().super_categories() # indirect doctest
181
[Category of algebras over Rational Field, Category of duals of vector spaces over Rational Field]
182
183
"""
184
from sage.categories.algebras import Algebras
185
return [Algebras(self.base_category().base_ring())]
186
187
class WithRealizations(WithRealizationsCategory):
188
189
class ParentMethods:
190
191
def coproduct(self, x):
192
r"""
193
Returns the coproduct of ``x``.
194
195
EXAMPLES::
196
197
sage: N = NonCommutativeSymmetricFunctions(QQ)
198
sage: S = N.complete()
199
sage: N.coproduct.__module__
200
'sage.categories.coalgebras'
201
sage: N.coproduct(S[2])
202
S[] # S[2] + S[1] # S[1] + S[2] # S[]
203
"""
204
return self.a_realization()(x).coproduct()
205
206
def counit(self, x):
207
r"""
208
Returns the counit of ``x``.
209
210
EXAMPLES::
211
212
sage: Sym = SymmetricFunctions(QQ)
213
sage: s = Sym.schur()
214
sage: f = s[2,1]
215
sage: f.counit.__module__
216
'sage.categories.coalgebras'
217
sage: f.counit()
218
0
219
220
::
221
222
sage: N = NonCommutativeSymmetricFunctions(QQ)
223
sage: N.counit.__module__
224
'sage.categories.coalgebras'
225
sage: N.counit(N.one())
226
1
227
sage: x = N.an_element(); x
228
2*S[] + 2*S[1] + 3*S[1, 1]
229
sage: N.counit(x)
230
2
231
"""
232
return self.a_realization()(x).counit()
233
234
class Realizations(RealizationsCategory):
235
236
class ParentMethods:
237
238
def coproduct_by_coercion(self, x):
239
r"""
240
Returns the coproduct by coercion if coproduct_by_basis is not implemented.
241
242
EXAMPLES::
243
244
sage: Sym = SymmetricFunctions(QQ)
245
sage: m = Sym.monomial()
246
sage: f = m[2,1]
247
sage: f.coproduct.__module__
248
'sage.categories.coalgebras'
249
sage: m.coproduct_on_basis
250
NotImplemented
251
sage: m.coproduct == m.coproduct_by_coercion
252
True
253
sage: f.coproduct()
254
m[] # m[2, 1] + m[1] # m[2] + m[2] # m[1] + m[2, 1] # m[]
255
256
::
257
258
sage: N = NonCommutativeSymmetricFunctions(QQ)
259
sage: R = N.ribbon()
260
sage: R.coproduct_by_coercion.__module__
261
'sage.categories.coalgebras'
262
sage: R.coproduct_on_basis
263
NotImplemented
264
sage: R.coproduct == R.coproduct_by_coercion
265
True
266
sage: R[1].coproduct()
267
R[] # R[1] + R[1] # R[]
268
"""
269
from sage.categories.tensor import tensor
270
R = self.realization_of().a_realization()
271
return self.tensor_square().sum(coeff * tensor([self(R[I]), self(R[J])])
272
for ((I, J), coeff) in R(x).coproduct())
273
274