Path: blob/master/src/sage/combinat/crystals/direct_sum.py
8817 views
"""1Direct Sum of Crystals2"""3#*****************************************************************************4# Copyright (C) 2010 Anne Schilling <anne at math.ucdavis.edu>5#6# Distributed under the terms of the GNU General Public License (GPL)7#8# This code is distributed in the hope that it will be useful,9# but WITHOUT ANY WARRANTY; without even the implied warranty of10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11# General Public License for more details.12#13# The full text of the GPL is available at:14#15# http://www.gnu.org/licenses/16#****************************************************************************1718from sage.structure.parent import Parent19from sage.categories.category import Category20from sage.sets.disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets21from sage.structure.element_wrapper import ElementWrapper2223class DirectSumOfCrystals(DisjointUnionEnumeratedSets):24r"""25Direct sum of crystals.2627Given a list of crystals `B_0, \ldots, B_k` of the same Cartan type,28one can form the direct sum `B_0 \oplus \cdots \oplus B_k`.2930INPUT:3132- ``crystals`` -- a list of crystals of the same Cartan type33- ``keepkey`` -- a boolean3435The option ``keepkey`` is by default set to ``False``, assuming36that the crystals are all distinct. In this case the elements of37the direct sum are just represented by the elements in the38crystals `B_i`. If the crystals are not all distinct, one should39set the ``keepkey`` option to ``True``. In this case, the40elements of the direct sum are represented as tuples `(i, b)`41where `b \in B_i`.4243EXAMPLES::4445sage: C = CrystalOfLetters(['A',2])46sage: C1 = CrystalOfTableaux(['A',2],shape=[1,1])47sage: B = DirectSumOfCrystals([C,C1])48sage: B.list()49[1, 2, 3, [[1], [2]], [[1], [3]], [[2], [3]]]50sage: [b.f(1) for b in B]51[2, None, None, None, [[2], [3]], None]52sage: B.module_generators53[1, [[1], [2]]]5455::5657sage: B = DirectSumOfCrystals([C,C], keepkey=True)58sage: B.list()59[(0, 1), (0, 2), (0, 3), (1, 1), (1, 2), (1, 3)]60sage: B.module_generators61[(0, 1), (1, 1)]62sage: b = B( tuple([0,C(1)]) )63sage: b64(0, 1)65sage: b.weight()66(1, 0, 0)6768The following is required, because :class:`DirectSumOfCrystals`69takes the same arguments as :class:`DisjointUnionEnumeratedSets`70(which see for details).7172TESTS::7374sage: C = CrystalOfLetters(['A',2])75sage: B = DirectSumOfCrystals([C,C], keepkey=True)76sage: B77Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2])7879sage: TestSuite(C).run()80"""81__classcall_private__ = staticmethod(DisjointUnionEnumeratedSets.__classcall_private__)828384def __init__(self, crystals, **options):85"""86TESTS::8788sage: C = CrystalOfLetters(['A',2])89sage: B = DirectSumOfCrystals([C,C], keepkey=True)90sage: B91Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2])92sage: B.cartan_type()93['A', 2]9495sage: isinstance(B, DirectSumOfCrystals)96True97"""98if options.has_key('keepkey'):99keepkey = options['keepkey']100else:101keepkey = False102# facade = options['facade']103if keepkey:104facade = False105else:106facade = True107category = Category.meet([Category.join(crystal.categories()) for crystal in crystals])108Parent.__init__(self, category = category)109DisjointUnionEnumeratedSets.__init__(self, crystals, keepkey = keepkey, facade = facade)110self.rename("Direct sum of the crystals %s"%(crystals,))111self._keepkey = keepkey112self.crystals = crystals113if len(crystals) == 0:114raise ValueError, "The direct sum is empty"115else:116assert(crystal.cartan_type() == crystals[0].cartan_type() for crystal in crystals)117self._cartan_type = crystals[0].cartan_type()118if keepkey:119self.module_generators = [ self(tuple([i,b])) for i in range(len(crystals))120for b in crystals[i].module_generators ]121else:122self.module_generators = sum( (list(B.module_generators) for B in crystals), [])123124125class Element(ElementWrapper):126r"""127A class for elements of direct sums of crystals128"""129130def e(self, i):131r"""132Returns the action of `e_i` on self.133134EXAMPLES::135136sage: C = CrystalOfLetters(['A',2])137sage: B = DirectSumOfCrystals([C,C], keepkey=True)138sage: [[b, b.e(2)] for b in B]139[[(0, 1), None], [(0, 2), None], [(0, 3), (0, 2)], [(1, 1), None], [(1, 2), None], [(1, 3), (1, 2)]]140"""141v = self.value142vn = v[1].e(i)143if vn is None:144return None145else:146return self.parent()(tuple([v[0],vn]))147148def f(self, i):149r"""150Returns the action of `f_i` on self.151152EXAMPLES::153154sage: C = CrystalOfLetters(['A',2])155sage: B = DirectSumOfCrystals([C,C], keepkey=True)156sage: [[b,b.f(1)] for b in B]157[[(0, 1), (0, 2)], [(0, 2), None], [(0, 3), None], [(1, 1), (1, 2)], [(1, 2), None], [(1, 3), None]]158"""159v = self.value160vn = v[1].f(i)161if vn is None:162return None163else:164return self.parent()(tuple([v[0],vn]))165166def weight(self):167r"""168Returns the weight of self.169170EXAMPLES::171172sage: C = CrystalOfLetters(['A',2])173sage: B = DirectSumOfCrystals([C,C], keepkey=True)174sage: b = B( tuple([0,C(2)]) )175sage: b176(0, 2)177sage: b.weight()178(0, 1, 0)179"""180return self.value[1].weight()181182def phi(self, i):183r"""184EXAMPLES::185186sage: C = CrystalOfLetters(['A',2])187sage: B = DirectSumOfCrystals([C,C], keepkey=True)188sage: b = B( tuple([0,C(2)]) )189sage: b.phi(2)1901191"""192return self.value[1].phi(i)193194def epsilon(self, i):195r"""196EXAMPLES::197198sage: C = CrystalOfLetters(['A',2])199sage: B = DirectSumOfCrystals([C,C], keepkey=True)200sage: b = B( tuple([0,C(2)]) )201sage: b.epsilon(2)2020203"""204return self.value[1].epsilon(i)205206207208