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

Commit

Permalink
Trac #31987: Adding category options to Representations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Release Manager committed Jun 30, 2021
2 parents a8a5110 + 5351ebb commit 06ec5d9
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 9 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=b10a655e0030836822876a5784312df9cdee99e2
md5=edcbbd6c72a7b66dc66bf63038305b4e
cksum=3213804089
sha1=6c57f29a40da0d59930469bb1f42d4bc5f597ce7
md5=8071fb87383998629b18fd416b6be631
cksum=1343198753
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
437bad4c16ae061e0e977d1285c5d7e28ee90878
f325f588ed6fe34ecacae25cde4dd8ace2551c79
105 changes: 100 additions & 5 deletions src/sage/modules/with_basis/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Representation(Representation_abstract):
- :wikipedia:`Group_representation`
"""
def __init__(self, semigroup, module, on_basis, side="left"):
def __init__(self, semigroup, module, on_basis, side="left", **kwargs):
"""
Initialize ``self``.
Expand All @@ -164,18 +164,66 @@ def __init__(self, semigroup, module, on_basis, side="left"):
sage: on_basis = lambda g,m: M.term(m, g.sign())
sage: R = Representation(G, M, on_basis)
sage: R._test_representation()
"""
sage: G = CyclicPermutationGroup(3)
sage: M = algebras.Exterior(QQ, 'x', 3)
sage: from sage.modules.with_basis.representation import Representation
sage: on_basis = lambda g,m: M.prod([M.monomial((g(j+1)-1,)) for j in m]) #cyclically permute generators
sage: from sage.categories.algebras import Algebras
sage: R = Representation(G, M, on_basis, category=Algebras(QQ).WithBasis().FiniteDimensional())
sage: r = R.an_element(); r
1 + 2*x0 + x0*x1 + 3*x1
sage: r*r
1 + 4*x0 + 2*x0*x1 + 6*x1
sage: x0, x1, x2 = M.gens()
sage: s = R(x0*x1)
sage: g = G.an_element()
sage: g*s
x1*x2
sage: g*R(x1*x2)
-x0*x2
sage: g*r
1 + 2*x1 + x1*x2 + 3*x2
sage: g^2*r
1 + 3*x0 - x0*x2 + 2*x2
sage: G = SymmetricGroup(4)
sage: A = SymmetricGroup(4).algebra(QQ)
sage: from sage.categories.algebras import Algebras
sage: from sage.modules.with_basis.representation import Representation
sage: action = lambda g,x: A.monomial(g*x)
sage: category = Algebras(QQ).WithBasis().FiniteDimensional()
sage: R = Representation(G, A, action, 'left', category=category)
sage: r = R.an_element(); r
() + (2,3,4) + 2*(1,3)(2,4) + 3*(1,4)(2,3)
sage: r^2
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)
sage: g = G.an_element(); g
(2,3,4)
sage: g*r
(2,3,4) + (2,4,3) + 2*(1,3,2) + 3*(1,4,3)
"""
try:
self.product_on_basis = module.product_on_basis
except AttributeError:
pass

category = kwargs.pop('category', Modules(module.base_ring()).WithBasis())

if side not in ["left", "right"]:
raise ValueError('side must be "left" or "right"')

self._left_repr = (side == "left")
self._on_basis = on_basis
self._module = module

indices = module.basis().keys()
cat = Modules(module.base_ring()).WithBasis()

if 'FiniteDimensional' in module.category().axioms():
cat = cat.FiniteDimensional()
category = category.FiniteDimensional()

Representation_abstract.__init__(self, semigroup, module.base_ring(), indices,
category=cat, **module.print_options())
category=category, **module.print_options())

def _test_representation(self, **options):
"""
Expand Down Expand Up @@ -273,6 +321,51 @@ def _element_constructor_(self, x):
return self._from_dict(x.monomial_coefficients(copy=False), remove_zeros=False)
return super(Representation, self)._element_constructor_(x)

def product_by_coercion(self, left, right):
"""
Return the product of ``left`` and ``right`` by passing to ``self._module``
and then building a new element of ``self``.
EXAMPLES::
sage: G = groups.permutation.KleinFour()
sage: E = algebras.Exterior(QQ,'e',4)
sage: on_basis = lambda g,m: E.monomial(m) # the trivial representation
sage: from sage.modules.with_basis.representation import Representation
sage: R = Representation(G, E, on_basis)
sage: r = R.an_element(); r
1 + 2*e0 + 3*e1 + e1*e2
sage: g = G.an_element();
sage: g*r == r
True
sage: r*r
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for *:
'Representation of The Klein 4 group of order 4, as a permutation
group indexed by Subsets of {0, 1, 2, 3} over Rational Field' and
'Representation of The Klein 4 group of order 4, as a permutation
group indexed by Subsets of {0, 1, 2, 3} over Rational Field'
sage: from sage.categories.algebras import Algebras
sage: category = Algebras(QQ).FiniteDimensional().WithBasis()
sage: T = Representation(G, E, on_basis, category=category)
sage: t = T.an_element(); t
1 + 2*e0 + 3*e1 + e1*e2
sage: g*t == t
True
sage: t*t
1 + 4*e0 + 4*e0*e1*e2 + 6*e1 + 2*e1*e2
"""
M = self._module

# Multiply in self._module
p = M._from_dict(left._monomial_coefficients, False, False) * M._from_dict(right._monomial_coefficients, False, False)

# Convert from a term in self._module to a term in self
return self._from_dict(p.monomial_coefficients(copy=False), False, False)

def side(self):
"""
Return whether ``self`` is a left or a right representation.
Expand All @@ -293,6 +386,7 @@ def side(self):
"""
return "left" if self._left_repr else "right"


class Element(CombinatorialFreeModule.Element):
def _acted_upon_(self, scalar, self_on_left=False):
"""
Expand Down Expand Up @@ -369,6 +463,7 @@ def _acted_upon_(self, scalar, self_on_left=False):
ret += P.linear_combination(((P._on_basis(ms, m), cs*c)
for m,c in self), not self_on_left)
return ret

return CombinatorialFreeModule.Element._acted_upon_(self, scalar, self_on_left)

_rmul_ = _lmul_ = _acted_upon_
Expand Down

0 comments on commit 06ec5d9

Please sign in to comment.