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

Commit

Permalink
Merge #34375
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Sep 17, 2022
2 parents 0b352a8 + abf1edc commit 6bbbdb9
Showing 1 changed file with 22 additions and 159 deletions.
181 changes: 22 additions & 159 deletions src/sage/algebras/yangian.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
from sage.misc.cachefunc import cached_method
from sage.misc.misc_c import prod

from sage.structure.unique_representation import UniqueRepresentation
from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis
from sage.categories.graded_hopf_algebras_with_basis import GradedHopfAlgebrasWithBasis
from sage.rings.integer_ring import ZZ
from sage.categories.cartesian_product import cartesian_product
from sage.rings.infinity import infinity
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.sets.family import Family
Expand All @@ -31,157 +30,6 @@
from sage.combinat.free_module import CombinatorialFreeModule
from sage.algebras.associated_graded import AssociatedGradedAlgebra

import itertools


class GeneratorIndexingSet(UniqueRepresentation):
"""
Helper class for the indexing set of the generators.
"""
def __init__(self, index_set, level=None):
"""
Initialize ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: I = GeneratorIndexingSet((1,2))
"""
self._index_set = index_set
self._level = level

def __repr__(self):
"""
Return a string representation of ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: GeneratorIndexingSet((1,2))
Cartesian product of Positive integers, (1, 2), (1, 2)
sage: GeneratorIndexingSet((1,2), 4)
Cartesian product of (1, 2, 3, 4), (1, 2), (1, 2)
"""
if self._level is None:
L = PositiveIntegers()
else:
L = tuple(range(1, self._level + 1))
return "Cartesian product of {L}, {I}, {I}".format(L=L, I=self._index_set)

def an_element(self):
"""
Initialize ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: I = GeneratorIndexingSet((1,2))
sage: I.an_element()
(3, 1, 1)
sage: I = GeneratorIndexingSet((1,2), 5)
sage: I.an_element()
(3, 1, 1)
sage: I = GeneratorIndexingSet((1,2), 1)
sage: I.an_element()
(1, 1, 1)
"""
if self._level is not None and self._level < 3:
return (1, self._index_set[0], self._index_set[0])
return (3, self._index_set[0], self._index_set[0])

def cardinality(self):
"""
Return the cardinality of ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: I = GeneratorIndexingSet((1,2))
sage: I.cardinality()
+Infinity
sage: I = GeneratorIndexingSet((1,2), level=3)
sage: I.cardinality() == 3 * 2 * 2
True
"""
if self._level is not None:
return self._level * len(self._index_set)**2
return infinity

__len__ = cardinality

def __call__(self, x):
"""
Call ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: I = GeneratorIndexingSet((1,2))
sage: I([1, 2])
(1, 2)
"""
return tuple(x)

def __contains__(self, x):
"""
Check containment of ``x`` in ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: I = GeneratorIndexingSet((1,2))
sage: (4, 1, 2) in I
True
sage: [4, 2, 1] in I
True
sage: (-1, 1, 1) in I
False
sage: (1, 3, 1) in I
False
::
sage: I3 = GeneratorIndexingSet((1,2), 3)
sage: (1, 1, 2) in I3
True
sage: (3, 1, 1) in I3
True
sage: (4, 1, 1) in I3
False
"""
return (isinstance(x, (tuple, list)) and len(x) == 3
and x[0] in ZZ and x[0] > 0
and (self._level is None or x[0] <= self._level)
and x[1] in self._index_set
and x[2] in self._index_set)

def __iter__(self):
"""
Iterate over ``self``.
TESTS::
sage: from sage.algebras.yangian import GeneratorIndexingSet
sage: I = GeneratorIndexingSet((1,2))
sage: it = iter(I)
sage: [next(it) for dummy in range(5)]
[(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), (2, 1, 1)]
sage: I = GeneratorIndexingSet((1,2), 3)
sage: list(I)
[(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2),
(2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2),
(3, 1, 1), (3, 1, 2), (3, 2, 1), (3, 2, 2)]
"""
I = self._index_set
if self._level is not None:
for x in itertools.product(range(1, self._level + 1), I, I):
yield x
return
for i in PositiveIntegers():
for x in itertools.product(I, I):
yield (i, x[0], x[1])


class Yangian(CombinatorialFreeModule):
r"""
Expand Down Expand Up @@ -392,7 +240,7 @@ def __init__(self, base_ring, n, variable_name, filtration):
category = category.Connected()
self._index_set = tuple(range(1, n + 1))
# The keys for the basis are tuples (l, i, j)
indices = GeneratorIndexingSet(self._index_set)
indices = cartesian_product([PositiveIntegers(), self._index_set, self._index_set])
# We note that the generators are non-commutative, but we always sort
# them, so they are, in effect, indexed by the free abelian monoid
basis_keys = IndexedFreeAbelianMonoid(indices, bracket=False,
Expand Down Expand Up @@ -501,7 +349,7 @@ def _element_constructor_(self, x):
True
sage: Y6 = Yangian(QQ, 4, level=6, filtration='natural')
sage: Y(Y6.an_element())
t(1)[1,1]*t(1)[1,2]^2*t(1)[1,3]^3*t(3)[1,1]
t(1)[1,1]^2*t(1)[1,2]^2*t(1)[1,3]^3 + 2*t(1)[1,1] + 3*t(1)[1,2] + 1
"""
if isinstance(x, CombinatorialFreeModule.Element):
if isinstance(x.parent(), Yangian) and x.parent()._n <= self._n:
Expand Down Expand Up @@ -543,8 +391,8 @@ def algebra_generators(self):
sage: Y = Yangian(QQ, 4)
sage: Y.algebra_generators()
Lazy family (generator(i))_{i in Cartesian product of
Positive integers, (1, 2, 3, 4), (1, 2, 3, 4)}
Lazy family (generator(i))_{i in The Cartesian product of
(Positive integers, {1, 2, 3, 4}, {1, 2, 3, 4})}
"""
return Family(self._indices._indices, self.gen, name="generator")

Expand Down Expand Up @@ -816,7 +664,8 @@ def __init__(self, base_ring, n, level, variable_name, filtration):
category = HopfAlgebrasWithBasis(base_ring).Filtered()
self._index_set = tuple(range(1,n+1))
# The keys for the basis are tuples (l, i, j)
indices = GeneratorIndexingSet(self._index_set, level)
L = range(1, self._level + 1)
indices = cartesian_product([L, self._index_set, self._index_set])
# We note that the generators are non-commutative, but we always sort
# them, so they are, in effect, indexed by the free abelian monoid
basis_keys = IndexedFreeAbelianMonoid(indices, bracket=False, prefix=variable_name)
Expand Down Expand Up @@ -1152,7 +1001,10 @@ def __init__(self, Y):
EXAMPLES::
sage: grY = Yangian(QQ, 4).graded_algebra()
sage: TestSuite(grY).run() # long time
sage: g = grY.indices().gens()
sage: x = grY(g[1,1,1] * g[1,1,2]^2 * g[1,1,3]^3 * g[3,1,1])
sage: elts = [grY(g[1,1,1]), grY(g[2,1,1]), x]
sage: TestSuite(grY).run(elements=elts) # long time
"""
if Y._filtration != 'loop':
raise ValueError("the Yangian must have the loop filtration")
Expand All @@ -1170,6 +1022,17 @@ def antipode_on_basis(self, m):
-tbar(2)[1,1]
sage: x = grY.an_element(); x
tbar(1)[1,1]*tbar(1)[1,2]^2*tbar(1)[1,3]^3*tbar(42)[1,1]
sage: grY.antipode_on_basis(x.leading_support())
-tbar(1)[1,1]*tbar(1)[1,2]^2*tbar(1)[1,3]^3*tbar(42)[1,1]
- 2*tbar(1)[1,1]*tbar(1)[1,2]*tbar(1)[1,3]^3*tbar(42)[1,2]
- 3*tbar(1)[1,1]*tbar(1)[1,2]^2*tbar(1)[1,3]^2*tbar(42)[1,3]
+ 5*tbar(1)[1,2]^2*tbar(1)[1,3]^3*tbar(42)[1,1]
+ 10*tbar(1)[1,2]*tbar(1)[1,3]^3*tbar(42)[1,2]
+ 15*tbar(1)[1,2]^2*tbar(1)[1,3]^2*tbar(42)[1,3]
sage: g = grY.indices().gens()
sage: x = grY(g[1,1,1] * g[1,1,2]^2 * g[1,1,3]^3 * g[3,1,1]); x
tbar(1)[1,1]*tbar(1)[1,2]^2*tbar(1)[1,3]^3*tbar(3)[1,1]
sage: grY.antipode_on_basis(x.leading_support())
-tbar(1)[1,1]*tbar(1)[1,2]^2*tbar(1)[1,3]^3*tbar(3)[1,1]
Expand Down

0 comments on commit 6bbbdb9

Please sign in to comment.