Path: blob/master/sage/combinat/crystals/direct_sum.py
4069 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)67"""6869r"""70The following is required, because :class:`DirectSumOfCrystals`71takes the same arguments as :class:`DisjointUnionEnumeratedSets`72(which see for details).7374TESTS::7576sage: C = CrystalOfLetters(['A',2])77sage: B = DirectSumOfCrystals([C,C], keepkey=True)78sage: B79Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2])8081sage: TestSuite(C).run()82"""83__classcall_private__ = staticmethod(DisjointUnionEnumeratedSets.__classcall_private__)848586def __init__(self, crystals, **options):87"""88TESTS::8990sage: C = CrystalOfLetters(['A',2])91sage: B = DirectSumOfCrystals([C,C], keepkey=True)92sage: B93Direct sum of the crystals Family (The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2])94sage: B.cartan_type()95['A', 2]9697sage: isinstance(B, DirectSumOfCrystals)98True99"""100if options.has_key('keepkey'):101keepkey = options['keepkey']102else:103keepkey = False104# facade = options['facade']105if keepkey:106facade = False107else:108facade = True109category = Category.meet([Category.join(crystal.categories()) for crystal in crystals])110Parent.__init__(self, category = category)111DisjointUnionEnumeratedSets.__init__(self, crystals, keepkey = keepkey, facade = facade)112self.rename("Direct sum of the crystals %s"%(crystals,))113self._keepkey = keepkey114self.crystals = crystals115if len(crystals) == 0:116raise ValueError, "The direct sum is empty"117else:118assert(crystal.cartan_type() == crystals[0].cartan_type() for crystal in crystals)119self._cartan_type = crystals[0].cartan_type()120if keepkey:121self.module_generators = [ self(tuple([i,b])) for i in range(len(crystals))122for b in crystals[i].module_generators ]123else:124self.module_generators = sum( (list(B.module_generators) for B in crystals), [])125126127class Element(ElementWrapper):128r"""129A class for elements of direct sums of crystals130"""131132def e(self, i):133r"""134Returns the action of `e_i` on self.135136EXAMPLES::137138sage: C = CrystalOfLetters(['A',2])139sage: B = DirectSumOfCrystals([C,C], keepkey=True)140sage: [[b, b.e(2)] for b in B]141[[(0, 1), None], [(0, 2), None], [(0, 3), (0, 2)], [(1, 1), None], [(1, 2), None], [(1, 3), (1, 2)]]142"""143v = self.value144vn = v[1].e(i)145if vn is None:146return None147else:148return self.parent()(tuple([v[0],vn]))149150def f(self, i):151r"""152Returns the action of `f_i` on self.153154EXAMPLES::155156sage: C = CrystalOfLetters(['A',2])157sage: B = DirectSumOfCrystals([C,C], keepkey=True)158sage: [[b,b.f(1)] for b in B]159[[(0, 1), (0, 2)], [(0, 2), None], [(0, 3), None], [(1, 1), (1, 2)], [(1, 2), None], [(1, 3), None]]160"""161v = self.value162vn = v[1].f(i)163if vn is None:164return None165else:166return self.parent()(tuple([v[0],vn]))167168def weight(self):169r"""170Returns the weight of self.171172EXAMPLES::173174sage: C = CrystalOfLetters(['A',2])175sage: B = DirectSumOfCrystals([C,C], keepkey=True)176sage: b = B( tuple([0,C(2)]) )177sage: b178(0, 2)179sage: b.weight()180(0, 1, 0)181"""182return self.value[1].weight()183184def phi(self, i):185r"""186EXAMPLES::187188sage: C = CrystalOfLetters(['A',2])189sage: B = DirectSumOfCrystals([C,C], keepkey=True)190sage: b = B( tuple([0,C(2)]) )191sage: b.phi(2)1921193"""194return self.value[1].phi(i)195196def epsilon(self, i):197r"""198EXAMPLES::199200sage: C = CrystalOfLetters(['A',2])201sage: B = DirectSumOfCrystals([C,C], keepkey=True)202sage: b = B( tuple([0,C(2)]) )203sage: b.epsilon(2)2040205"""206return self.value[1].epsilon(i)207208209210