Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 06ec5d9

Browse files
author
Release Manager
committed
Trac #31987: Adding category options to Representations
Add the option to give a specific choice of category for the `Representation` class. URL: https://trac.sagemath.org/31987 Reported by: tkarn Ticket author(s): Trevor K. Karn Reviewer(s): Travis Scrimshaw
2 parents a8a5110 + 5351ebb commit 06ec5d9

File tree

3 files changed

+104
-9
lines changed

3 files changed

+104
-9
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=b10a655e0030836822876a5784312df9cdee99e2
3-
md5=edcbbd6c72a7b66dc66bf63038305b4e
4-
cksum=3213804089
2+
sha1=6c57f29a40da0d59930469bb1f42d4bc5f597ce7
3+
md5=8071fb87383998629b18fd416b6be631
4+
cksum=1343198753
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
437bad4c16ae061e0e977d1285c5d7e28ee90878
1+
f325f588ed6fe34ecacae25cde4dd8ace2551c79

src/sage/modules/with_basis/representation.py

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Representation(Representation_abstract):
152152
153153
- :wikipedia:`Group_representation`
154154
"""
155-
def __init__(self, semigroup, module, on_basis, side="left"):
155+
def __init__(self, semigroup, module, on_basis, side="left", **kwargs):
156156
"""
157157
Initialize ``self``.
158158
@@ -164,18 +164,66 @@ def __init__(self, semigroup, module, on_basis, side="left"):
164164
sage: on_basis = lambda g,m: M.term(m, g.sign())
165165
sage: R = Representation(G, M, on_basis)
166166
sage: R._test_representation()
167-
"""
167+
168+
sage: G = CyclicPermutationGroup(3)
169+
sage: M = algebras.Exterior(QQ, 'x', 3)
170+
sage: from sage.modules.with_basis.representation import Representation
171+
sage: on_basis = lambda g,m: M.prod([M.monomial((g(j+1)-1,)) for j in m]) #cyclically permute generators
172+
sage: from sage.categories.algebras import Algebras
173+
sage: R = Representation(G, M, on_basis, category=Algebras(QQ).WithBasis().FiniteDimensional())
174+
sage: r = R.an_element(); r
175+
1 + 2*x0 + x0*x1 + 3*x1
176+
sage: r*r
177+
1 + 4*x0 + 2*x0*x1 + 6*x1
178+
sage: x0, x1, x2 = M.gens()
179+
sage: s = R(x0*x1)
180+
sage: g = G.an_element()
181+
sage: g*s
182+
x1*x2
183+
sage: g*R(x1*x2)
184+
-x0*x2
185+
sage: g*r
186+
1 + 2*x1 + x1*x2 + 3*x2
187+
sage: g^2*r
188+
1 + 3*x0 - x0*x2 + 2*x2
189+
190+
sage: G = SymmetricGroup(4)
191+
sage: A = SymmetricGroup(4).algebra(QQ)
192+
sage: from sage.categories.algebras import Algebras
193+
sage: from sage.modules.with_basis.representation import Representation
194+
sage: action = lambda g,x: A.monomial(g*x)
195+
sage: category = Algebras(QQ).WithBasis().FiniteDimensional()
196+
sage: R = Representation(G, A, action, 'left', category=category)
197+
sage: r = R.an_element(); r
198+
() + (2,3,4) + 2*(1,3)(2,4) + 3*(1,4)(2,3)
199+
sage: r^2
200+
14*() + 2*(2,3,4) + (2,4,3) + 12*(1,2)(3,4) + 3*(1,2,4) + 2*(1,3,2) + 4*(1,3)(2,4) + 5*(1,4,3) + 6*(1,4)(2,3)
201+
sage: g = G.an_element(); g
202+
(2,3,4)
203+
sage: g*r
204+
(2,3,4) + (2,4,3) + 2*(1,3,2) + 3*(1,4,3)
205+
"""
206+
try:
207+
self.product_on_basis = module.product_on_basis
208+
except AttributeError:
209+
pass
210+
211+
category = kwargs.pop('category', Modules(module.base_ring()).WithBasis())
212+
168213
if side not in ["left", "right"]:
169214
raise ValueError('side must be "left" or "right"')
215+
170216
self._left_repr = (side == "left")
171217
self._on_basis = on_basis
172218
self._module = module
219+
173220
indices = module.basis().keys()
174-
cat = Modules(module.base_ring()).WithBasis()
221+
175222
if 'FiniteDimensional' in module.category().axioms():
176-
cat = cat.FiniteDimensional()
223+
category = category.FiniteDimensional()
224+
177225
Representation_abstract.__init__(self, semigroup, module.base_ring(), indices,
178-
category=cat, **module.print_options())
226+
category=category, **module.print_options())
179227

180228
def _test_representation(self, **options):
181229
"""
@@ -273,6 +321,51 @@ def _element_constructor_(self, x):
273321
return self._from_dict(x.monomial_coefficients(copy=False), remove_zeros=False)
274322
return super(Representation, self)._element_constructor_(x)
275323

324+
def product_by_coercion(self, left, right):
325+
"""
326+
Return the product of ``left`` and ``right`` by passing to ``self._module``
327+
and then building a new element of ``self``.
328+
329+
EXAMPLES::
330+
331+
sage: G = groups.permutation.KleinFour()
332+
sage: E = algebras.Exterior(QQ,'e',4)
333+
sage: on_basis = lambda g,m: E.monomial(m) # the trivial representation
334+
sage: from sage.modules.with_basis.representation import Representation
335+
sage: R = Representation(G, E, on_basis)
336+
sage: r = R.an_element(); r
337+
1 + 2*e0 + 3*e1 + e1*e2
338+
sage: g = G.an_element();
339+
sage: g*r == r
340+
True
341+
sage: r*r
342+
Traceback (most recent call last):
343+
...
344+
TypeError: unsupported operand parent(s) for *:
345+
'Representation of The Klein 4 group of order 4, as a permutation
346+
group indexed by Subsets of {0, 1, 2, 3} over Rational Field' and
347+
'Representation of The Klein 4 group of order 4, as a permutation
348+
group indexed by Subsets of {0, 1, 2, 3} over Rational Field'
349+
350+
sage: from sage.categories.algebras import Algebras
351+
sage: category = Algebras(QQ).FiniteDimensional().WithBasis()
352+
sage: T = Representation(G, E, on_basis, category=category)
353+
sage: t = T.an_element(); t
354+
1 + 2*e0 + 3*e1 + e1*e2
355+
sage: g*t == t
356+
True
357+
sage: t*t
358+
1 + 4*e0 + 4*e0*e1*e2 + 6*e1 + 2*e1*e2
359+
360+
"""
361+
M = self._module
362+
363+
# Multiply in self._module
364+
p = M._from_dict(left._monomial_coefficients, False, False) * M._from_dict(right._monomial_coefficients, False, False)
365+
366+
# Convert from a term in self._module to a term in self
367+
return self._from_dict(p.monomial_coefficients(copy=False), False, False)
368+
276369
def side(self):
277370
"""
278371
Return whether ``self`` is a left or a right representation.
@@ -293,6 +386,7 @@ def side(self):
293386
"""
294387
return "left" if self._left_repr else "right"
295388

389+
296390
class Element(CombinatorialFreeModule.Element):
297391
def _acted_upon_(self, scalar, self_on_left=False):
298392
"""
@@ -369,6 +463,7 @@ def _acted_upon_(self, scalar, self_on_left=False):
369463
ret += P.linear_combination(((P._on_basis(ms, m), cs*c)
370464
for m,c in self), not self_on_left)
371465
return ret
466+
372467
return CombinatorialFreeModule.Element._acted_upon_(self, scalar, self_on_left)
373468

374469
_rmul_ = _lmul_ = _acted_upon_

0 commit comments

Comments
 (0)