Ticket #14130: trac_14130-gyw-bs.patch

File trac_14130-gyw-bs.patch, 34.0 KB (added by bsalisbury1, 6 years ago)
  • doc/en/reference/combinat/crystals.rst

    # HG changeset patch
    # User Ben Salisbury <bsalisbury1@gmail.com>
    # Date 1360949054 18000
    # Node ID 5accb163d500b1c2f832129521238d55d1f00bca
    # Parent 12348c82f56c159b0136c25637688a3189d46d55
    #14130: Generalized Young walls
    
    diff --git a/doc/en/reference/combinat/crystals.rst b/doc/en/reference/combinat/crystals.rst
    a b  
    1414   ../sage/combinat/crystals/littelmann_path
    1515   ../sage/combinat/crystals/spins
    1616   ../sage/combinat/crystals/tensor_product
     17   ../sage/combinat/crystals/generalized_young_walls
     18
  • sage/categories/crystals.py

    diff --git a/sage/categories/crystals.py b/sage/categories/crystals.py
    a b  
    499499                sage: C = CartanType(['C',2,1])
    500500                sage: La = C.root_system().weight_lattice().fundamental_weights()
    501501                sage: T = HighestWeightCrystal(La[0])
    502                 sage: S = [b for b in T.__iter__(max_depth=3)]
     502                sage: S = T.subcrystal(max_depth=3)
    503503                sage: G = T.digraph(subset=S); G
    504504                Digraph on 5 vertices
    505505                sage: G.vertices()
  • sage/combinat/crystals/all.py

    diff --git a/sage/combinat/crystals/all.py b/sage/combinat/crystals/all.py
    a b  
    1313from alcove_path import ClassicalCrystalOfAlcovePaths
    1414from alcove_path import ClassicalCrystalOfAlcovePathsElement
    1515from littelmann_path import CrystalOfLSPaths
    16 
     16from generalized_young_walls import CrystalOfGeneralizedYoungWalls, HighestWeightCrystalOfGYW
     17 No newline at end of file
  • new file sage/combinat/crystals/generalized_young_walls.py

    diff --git a/sage/combinat/crystals/generalized_young_walls.py b/sage/combinat/crystals/generalized_young_walls.py
    new file mode 100644
    - +  
     1r"""
     2Crystals of Generalized Young Walls
     3
     4AUTHORS:
     5
     6- Lucas David-Roesler: Initial version
     7
     8- Ben Salisbury: Initial version
     9
     10- Travis Scrimshaw: Initial version
     11
     12Generalized Young walls are certain generalizations of Young tableaux
     13introduced in [KS10]_ and designed to be a realization of the crystals
     14`\mathcal{B}(\infty)` and `\mathcal{B}(\lambda)` in type `A_n^{(1)}`.
     15
     16.. WARNING::
     17
     18    Does not work with :func:`TensorProductOfCrystals`.
     19
     20REFERENCES:
     21
     22.. [KS10] J.-A. Kim and D.-U. Shin.
     23   Generalized Young walls and crystal bases for quantum affine algebra
     24   of type `A`.
     25   Proc. Amer. Math. Soc. 138(11), pp. 3877--3889, 2010.
     26"""
     27
     28#******************************************************************************
     29#  Copyright (C) 2013
     30#
     31#  Lucas David-Roesler (roesler at lvc dot edu)
     32#  Ben Salisbury (bsalisbury at ccny dot cuny dot edu)
     33#  Travis Scrimshaw (tscrim at ucdavis dot edu)
     34#
     35#  Distributed under the terms of the GNU General Public License (GPL)
     36#                  http://www.gnu.org/licenses/
     37#******************************************************************************
     38
     39import re
     40from copy import deepcopy
     41from sage.combinat import ranker
     42from sage.combinat.root_system.cartan_type import CartanType
     43from sage.structure.element import Element
     44from sage.structure.parent import Parent
     45from sage.structure.unique_representation import UniqueRepresentation
     46from sage.combinat.combinat import CombinatorialObject
     47from sage.categories.highest_weight_crystals import HighestWeightCrystals
     48from sage.combinat.root_system.root_system import RootSystem
     49
     50class GeneralizedYoungWall(CombinatorialObject, Element):
     51    r"""
     52    A generalized Young wall.
     53
     54    For more information, see :class:`CrystalOfGeneralizedYoungWalls`.
     55
     56    EXAMPLES::
     57
     58        sage: Y = CrystalOfGeneralizedYoungWalls(4)
     59        sage: mg = Y.module_generators[0]; mg.pp()
     60        0
     61        sage: mg.f_string([1,2,0,1]).pp()
     62        1|2|
     63        0|1|
     64           |
     65    """
     66    def __init__(self,parent,data):
     67        r"""
     68        EXAMPLES::
     69
     70            sage: Y = CrystalOfGeneralizedYoungWalls(2)
     71            sage: mg = Y.module_generators[0]
     72            sage: TestSuite(mg).run()
     73        """
     74        i = len(data)-1
     75        while i >= 0 and len(data[i]) == 0:
     76            data.pop()
     77            i -= 1
     78        self.rows = len(data)
     79        if data == []:
     80            self.cols = 0
     81        else:
     82            self.cols = max([len(r) for r in data])
     83        self.data = data
     84        CombinatorialObject.__init__(self, data)
     85        Element.__init__(self, parent)
     86
     87    def __repr__(self):
     88        r"""
     89        EXAMPLES::
     90
     91            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     92            sage: y
     93            [[0], [1, 0, 3, 2], [2, 1], [3, 2, 1, 0, 3, 2], [0], [], [2]]
     94        """
     95        return self.data.__repr__()
     96
     97    def __eq__(self,other):
     98        r"""
     99        EXAMPLES::
     100
     101            sage: GYW = CrystalOfGeneralizedYoungWalls(2)
     102            sage: y = GYW([[],[1,0],[2,1]])
     103            sage: x = GYW([[],[1,0],[2,1]])
     104            sage: z = GYW([[],[1],[2]])
     105            sage: x == y
     106            True
     107            sage: x == z
     108            False
     109        """
     110        if isinstance(other, GeneralizedYoungWall):
     111            return self.data == other.data
     112        return self.data == other
     113
     114    def raw_signature(self, i):
     115        r"""
     116        Return the sequence from `\{+,-\}` obtained from all `i`-admissible
     117        slots and removable `i`-boxes  without canceling any `(+,-)`-pairs.
     118        The result also notes the row and column of the sign.
     119
     120        EXAMPLES::
     121
     122            sage: x = CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     123            sage: x.raw_signature(2)
     124            [['-', 3, 6], ['-', 1, 4], ['-', 6, 1]]
     125        """
     126        sig = []
     127        rank = self.parent().cartan_type().rank() # n+1
     128        for row in range(self.rows):
     129            if self.data[row] == [] and i == ( row % rank ):
     130                sig.append(['+', row, 0])
     131            elif self.data[row] == []:
     132                continue
     133            elif self.data[row][-1] == ( (i+1) % rank ):
     134                sig.append(['+', row, len(self.data[row])+1])
     135            elif self.data[row][-1] == i:
     136                sig.append(['-', row, len(self.data[row])])
     137        return sorted(sig, key=self._sig_sort)
     138
     139    def _sig_sort(self,a):
     140        r"""
     141        Internal command used to appropriately sort the output
     142        from :meth:`raw_signature()`.
     143
     144        INPUT:
     145
     146        - `a` -- list of the form ``['s',j,k]`` where `s` is a string, `j` is an integer
     147          and `k` is an integer
     148
     149        EXAMPLES::
     150
     151            sage: hw = CrystalOfGeneralizedYoungWalls(5)([])
     152            sage: hw._sig_sort(['+',1,0])
     153            (0, 1)
     154        """
     155        return (-a[2],a[1])
     156
     157    def generate_signature(self, i):
     158        r"""
     159        The `i`-signature of ``self`` (with whitespace where cancellation
     160        occurs) together with the unreduced sequence from `\{+,-\}`.  The
     161        result also records to the row and column position of the sign.
     162
     163        EXAMPLES::
     164
     165            sage: y = CrystalOfGeneralizedYoungWalls(2)([[0],[1,0],[2,1,0,2],[],[1]])
     166            sage: y.generate_signature(1)
     167            ([['+', 2, 5], ['-', 4, 1]], '  ')
     168        """
     169        sig = []
     170        rank = self.parent().cartan_type().classical().rank()
     171        for row in range(self.rows):
     172            if self.data[row] == [] and i == ( row % (rank+1) ):
     173                sig.append(['+', row, 0])
     174            elif self.data[row] == []:
     175                continue
     176            elif self.data[row][-1] == ( (i+1) % (rank+1) ):
     177                sig.append(['+', row, len(self.data[row])+1])
     178            elif self.data[row][-1] == i:
     179                sig.append(['-', row, len(self.data[row])])
     180        sig = sorted(sig, key=self._sig_sort)
     181        strsig = ''.join( x[0] for x in sig)
     182        reducedsig = strsig
     183        while re.search(r"\+\s*-",reducedsig):
     184            reducedsig = re.sub(r"\+\s*-", lambda match : str().ljust(len(match.group(int(0)))) , reducedsig)
     185        return (sig,reducedsig)
     186
     187    def signature(self, i):
     188        r"""
     189        Return the `i`-signature of ``self``.
     190
     191        The signature is obtained by reading ``self`` in columns bottom to top starting from the left.
     192        Then add a `-` at every `i`-box which may be removed from ``self`` and still obtain a legal
     193        generalized Young wall, and add a `+` at each site for which an `i`-box may be added and still
     194        obtain a valid generalized Young wall.  Then successively cancel any `(+,-)`-pair to obtain a
     195        sequence of the form `- \cdots -+ \cdots +`.  This resulting sequence is the output.
     196
     197        EXAMPLES::
     198
     199            sage: y = CrystalOfGeneralizedYoungWalls(2)([[0],[1,0],[2,1,0,2],[],[1]])
     200            sage: y.signature(1)
     201            ''
     202
     203            sage: x = CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     204            sage: x.signature(2)
     205            '---'
     206        """
     207        return self.generate_signature(i)[1].strip()
     208
     209    def pp(self):
     210        r"""
     211        Return an ASCII drawing of ``self``.
     212
     213        EXAMPLES::
     214
     215            sage: y = CrystalOfGeneralizedYoungWalls(2)([[0,2,1],[1,0,2,1,0],[],[0],[1,0,2],[],[],[1]])
     216            sage: y.pp()
     217                    1|
     218                     |
     219                     |
     220                2|0|1|
     221                    0|
     222                     |
     223            0|1|2|0|1|
     224                1|2|0|
     225        """
     226        for row in reversed(self.data):
     227            wall = ''
     228            for elem in reversed(row):
     229                wall += str(elem)
     230                wall += '|'
     231            if row == []:
     232                wall += '|'
     233            print(wall.rjust(2*self.cols+1))
     234        if self.data==[]:
     235            print '0'
     236
     237    def content(self):
     238        r"""
     239        Return total number of blocks in ``self``.
     240
     241        EXAMPLES::
     242
     243            sage: y = CrystalOfGeneralizedYoungWalls(2)([[0],[1,0],[2,1,0,2],[],[1]])
     244            sage: y.content()
     245            8
     246
     247            sage: x = CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     248            sage: x.content()
     249            13
     250        """
     251        return sum(len(r) for r in self.data)
     252
     253    def e(self,i):
     254        r"""
     255        Return the application of the Kashiwara raising operator
     256        `\widetilde{e}_i` on ``self``.
     257
     258        This will remove the `i`-colored box corresponding to the
     259        rightmost `+` in ``self.signature(i)``.
     260
     261        EXAMPLES::
     262
     263            sage: x=CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     264            sage: x.e(2)
     265            [[], [1, 0, 3, 2], [2, 1], [3, 2, 1, 0, 3, 2]]
     266            sage: _.e(2)
     267            [[], [1, 0, 3], [2, 1], [3, 2, 1, 0, 3, 2]]
     268            sage: _.e(2)
     269            [[], [1, 0, 3], [2, 1], [3, 2, 1, 0, 3]]
     270            sage: _.e(2)
     271        """
     272        signature = self.generate_signature(i)
     273        raw_signature = signature[0]
     274        lastminus  = signature[1].rfind('-')
     275        newdata = []
     276        if lastminus > -1:
     277            deletionrow = raw_signature[lastminus][1]
     278            for r in range(self.rows):
     279                if r == deletionrow:
     280                    newdata.append(list(self.data[r][:-1]))
     281                else:
     282                    newdata.append(list(self.data[r]))
     283            return self.__class__(self.parent(),newdata)
     284        else:
     285            return None
     286
     287    def f(self,i):
     288        r"""
     289        Return the application of the Kashiwara lowering operator
     290        `\widetilde{f}_i` on ``self``.
     291
     292        This will add an `i`-colored colored box to the site corresponding
     293        to the leftmost plus in ``self.signature(i)``.
     294
     295        EXAMPLES::
     296
     297            sage: hw = CrystalOfGeneralizedYoungWalls(2)([])
     298            sage: hw.f(1)
     299            [[], [1]]
     300            sage: _.f(2)
     301            [[], [1], [2]]
     302            sage: _.f(0)
     303            [[], [1, 0], [2]]
     304            sage: _.f(0)
     305            [[0], [1, 0], [2]]
     306        """
     307        signature = self.generate_signature(i)
     308        raw_signature = signature[0]
     309        firstplus = signature[1].find('+')
     310        newdata = deepcopy(self.data)
     311        if firstplus > -1:
     312            additionrow = raw_signature[firstplus][1]
     313            newdata[additionrow].append(i)
     314        else:
     315            while len(newdata) % self.cartan_type().rank() != i:
     316                newdata.append([])
     317            newdata.append([i])
     318        return self.__class__(self.parent(), newdata)
     319
     320    def latex_large(self):
     321        r"""
     322        Generate LaTeX code for ``self`` but the output is larger.
     323        Requires TikZ.
     324
     325        EXAMPLES::
     326
     327            sage: x = CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     328            sage: x.latex_large()
     329            '\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n{{},{1,0,3,2},{2,1},{3,2,1,0,3,2},{},{},{2}} \n{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \\draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n'
     330        """
     331        s = ""
     332        if self.data == []:
     333            s += "\\emptyset"
     334        else:
     335            s += "\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n"
     336            s += "{" + ','.join("{" + ','.join( str(i) for i in r ) + "}" for r in self.data ) + "} \n"
     337            s += "{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
     338        return s
     339
     340    def _latex_(self):
     341        r"""
     342        Generate LaTeX code for ``self``.  Requires TikZ.
     343
     344        EXAMPLES::
     345
     346            sage: x = CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     347            sage: x._latex_()
     348            '\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n{{},{1,0,3,2},{2,1},{3,2,1,0,3,2},{},{},{2}} \n{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \\draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n'
     349        """
     350        s = ""
     351        if self.data == []:
     352                s += "\\emptyset"
     353        else:
     354            s += "\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n"
     355            s += "{" + ','.join("{" + ','.join( str(i) for i in r ) + "}" for r in self.data ) + "} \n"
     356            s += "{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
     357        return s
     358
     359    def weight(self):
     360        r"""
     361        Returns the weight of ``self`` as an element of the root lattice
     362        `\bigoplus_{i=0}^n \ZZ \alpha_i`.
     363
     364        EXAMPLES::
     365
     366            sage: x=CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     367            sage: x.weight()
     368            -2*alpha[0] - 3*alpha[1] - 5*alpha[2] - 3*alpha[3]
     369        """
     370        W = []
     371        L = self.cartan_type().root_system().root_lattice()
     372        alpha = L.simple_roots()
     373        for r in self.data:
     374            for i in r:
     375                W.append(-1*alpha[i])
     376        return L(sum(w for w in W))
     377
     378    def epsilon(self, i):
     379        r"""
     380        Return the number of `i`-colored arrows in the `i`-string above
     381        ``self`` in the crystal graph.
     382
     383        EXAMPLES::
     384
     385            sage: y=CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     386            sage: y.epsilon(1)
     387            0
     388            sage: y.epsilon(2)
     389            3
     390            sage: y.epsilon(0)
     391            0
     392        """
     393        if i not in self.index_set():
     394            raise ValueError("i must in in the index set")
     395        eps = 0
     396        while True:
     397            self = self.e(i)
     398            if self is None:
     399                break
     400            eps = eps+1
     401        return eps
     402
     403    def Epsilon(self):
     404        r"""
     405        Return `\sum_{i=0}^n \varepsilon_i(Y) \Lambda_i` where `Y` is ``self``.
     406
     407        EXAMPLES::
     408
     409            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     410            sage: y.Epsilon()
     411            Lambda[0] + 3*Lambda[2]
     412        """
     413        La = self.cartan_type().root_system().weight_lattice().fundamental_weights()
     414        return sum(self.epsilon(i)*La[i] for i in self.index_set())
     415
     416    def phi(self,i):
     417        r"""
     418        Return the value `\varepsilon_i(Y) + \langle h_i,
     419        \mathrm{wt}(Y)\rangle`, where `h_i` is the `i`-th simple
     420        coroot and `Y` is ``self``.
     421
     422        EXAMPLES::
     423
     424            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     425            sage: y.phi(1)
     426            3
     427            sage: y.phi(2)
     428            -1
     429        """
     430        h = self.parent().weight_lattice_realization().simple_coroots()
     431        return self.epsilon(i) + self.weight().scalar(h[i])
     432
     433    def Phi(self):
     434        r"""
     435        Return `\sum_{i=0}^n \varphi_i(Y) \Lambda_i` where `Y` is ``self``.
     436
     437        EXAMPLES::
     438
     439            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     440            sage: y.Phi()
     441            -Lambda[0] + 3*Lambda[1] - Lambda[2] + 3*Lambda[3]
     442
     443            sage: x=CrystalOfGeneralizedYoungWalls(3)([[],[1,0,3,2],[2,1],[3,2,1,0,3,2],[],[],[2]])
     444            sage: x.Phi()
     445            2*Lambda[0] + Lambda[1] - Lambda[2] + Lambda[3]
     446            """
     447        La = self.cartan_type().root_system().weight_lattice().fundamental_weights()
     448        return sum(self.phi(i)*La[i] for i in self.index_set())
     449
     450    def column(self, k):
     451        r"""
     452        Return the list of boxes from the ``k``-th column of ``self``.
     453
     454        EXAMPLES::
     455
     456            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     457            sage: y.column(2)
     458            [None, 0, 1, 2, None, None, None]
     459
     460            sage: hw = CrystalOfGeneralizedYoungWalls(5)([])
     461            sage: hw.column(1)
     462            []
     463        """
     464        C = []
     465        for row in self.data:
     466            if k-1 < len(row):
     467                C.append(row[k-1])
     468            else:
     469                C.append(None)
     470        return C
     471
     472    def a(self,i,k):
     473        r"""
     474        Return the number `a_i(k)` of `i`-colored boxes in the ``k``-th
     475        column of ``self``.
     476
     477        EXAMPLES::
     478
     479            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     480            sage: y.a(1,2)
     481            1
     482            sage: y.a(0,2)
     483            1
     484            sage: y.a(3,2)
     485            0
     486        """
     487        A = []
     488        for c in range(len(self.column(k))):
     489            if self.column(k)[c] == i:
     490                A.append(self.column(k)[c])
     491        return len(A)
     492
     493    def in_highest_weight_crystal(self,La):
     494        r"""
     495        Return a boolean indicating if the generalized Young wall element
     496        is in the highest weight crystal cut out by the given highest weight
     497        ``La``.
     498
     499        By Theorem 4.1 of [KS10]_, a generalized Young wall `Y` represents a
     500        vertex in the highest weight crystal `Y(\lambda)`, with
     501        `\lambda = \Lambda_{i_1} + \Lambda_{i_2} + \cdots + \Lambda_{i_\ell}`
     502        a dominant integral weight of level `\ell > 0`, if it satisfies the
     503        following condition. For each positive integer `k`, if there exists
     504        `j \in I` such that `a_j(k) - a_{j-1}(k) > 0`, then for some
     505        `p = 1, \ldots, \ell`,
     506
     507        .. MATH::
     508
     509            j + k \equiv i_p + 1 \bmod n+1 \text{ and } a_j(k) - a_{j-1}(k)
     510            \le \lambda(h_{i_p}),
     511
     512        where `\{h_0, h_1, \ldots, h_n\}` is the set of simple coroots attached
     513        to `A_n^{(1)}`.
     514
     515        EXAMPLES::
     516
     517            sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights()[1]
     518            sage: GYW = CrystalOfGeneralizedYoungWalls(2)
     519            sage: y = GYW([[],[1,0],[2,1]])
     520            sage: y.in_highest_weight_crystal(La)
     521            True
     522            sage: x = GYW([[],[1],[2],[],[],[2],[],[],[2]])
     523            sage: x.in_highest_weight_crystal(La)
     524            False
     525        """
     526        if not La in self.parent().weight_lattice_realization():
     527            raise TypeError("Must be an element in the weight lattice realization")
     528        ac = self.parent().weight_lattice_realization().simple_coroots()
     529        n = self.cartan_type().classical().rank()
     530        for k in range(1,self.cols+1):
     531            for j in self.index_set():
     532                if self.a(j,k) - self.a( (j-1) % (n+1) ,k) <= 0:
     533                    continue
     534                else:
     535                    p_not_found = True
     536                    for p in self.index_set():
     537                        if (j+k) % (n+1)  == (p+1) % (n+1) and self.a(j,k) - self.a( (j-1) % (n+1) ,k) <= La.scalar(ac[p]):
     538                            p_not_found = False
     539                            continue
     540                        else:
     541                            continue
     542                    if p_not_found:
     543                        return False
     544        return True
     545
     546
     547class CrystalOfGeneralizedYoungWalls(Parent,UniqueRepresentation):
     548    r"""
     549    The crystal `\mathcal{Y}(\infty)` of generalized Young walls of
     550    type `A_n^{(1)}` as defined in [KS10]_.
     551
     552    A generalized Young wall is a collection of boxes stacked on a fixed board,
     553    such that color of the box at the site located in the `j`-th row from the
     554    bottom and the `i`-th column from the right is `j-1 \bmod n+1`.  There are
     555    several growth conditions on elements in `Y \in \mathcal{Y}(\infty)`:
     556
     557    - Walls grow in rows from right to left.  That is, for every box `y\in Y`
     558      that is not in the rightmost column, there must be a box immediately to
     559      the right of `y`.
     560
     561    - For all `p>q` such that `p-q \equiv 0 \bmod n+1`, the `p`-th row has
     562      most as many boxes as the `q`-th row.
     563
     564    - There does not exist a column in the wall such that if one `i`-colored
     565      box, for every `i = 0,1,\ldots,n`, is removed from that column, then the
     566      result satisfies the above conditions.
     567
     568    There is a crystal structure on `\mathcal{Y}(\infty)` defined as follows.
     569    Define maps
     570
     571    .. MATH::
     572
     573        \widetilde{e}_i,\ \widetilde{f}_i \colon \mathcal{Y}(\infty)
     574        \longrightarrow \mathcal{Y}(\infty) \sqcup \{0\}, \qquad
     575        \varepsilon_i,\ \varphi_i \colon \mathcal{Y}(\infty)
     576        \longrightarrow \ZZ, \qquad
     577        \mathrm{wt}\colon \mathcal{Y}(\infty) \longrightarrow
     578        \bigoplus_{i=0}^n \ZZ \Lambda_i,
     579
     580    by
     581
     582    .. MATH::
     583
     584        \mathrm{wt}(Y) = -\sum_{i=0}^n m_i(Y) \alpha_i,
     585
     586    where `m_i(Y)` is the number of `i`-boxes in `Y`, `\varepsilon_i(Y)`
     587    is the number of `-` in the `i`-signature of `Y`, and
     588
     589    .. MATH::
     590
     591        \varphi_i(Y)  = \varepsilon_i(Y) + \langle h_i, \mathrm{wt}(Y) \rangle.
     592
     593    See :meth:`GeneralizedYoungWall.e()`, :meth:`GeneralizedYoungWall.f()`,
     594    and :meth:`GeneralizedYoungWall.signature()` for more about
     595    `\widetilde{e}_i`, `\widetilde{f}_i`, and `i`-signatures.
     596
     597
     598    INPUT:
     599
     600    - ``n`` -- type `A_n^{(1)}`
     601
     602    EXAMPLES::
     603
     604        sage: Yinf = CrystalOfGeneralizedYoungWalls(3)
     605        sage: y = Yinf([[0],[1,0,3,2],[],[3,2,1],[0],[1,0]])
     606        sage: y.pp()
     607            0|1|
     608              0|
     609          1|2|3|
     610               |
     611        2|3|0|1|
     612              0|
     613        sage: y.weight()
     614        -4*alpha[0] - 3*alpha[1] - 2*alpha[2] - 2*alpha[3]
     615        sage: y.f(0)
     616        [[0], [1, 0, 3, 2], [], [3, 2, 1], [0], [1, 0], [], [], [0]]
     617        sage: y.e(0).pp()
     618            0|1|
     619               |
     620          1|2|3|
     621               |
     622        2|3|0|1|
     623              0|
     624
     625    To display the crystal down to depth 3::
     626
     627        sage: S = Yinf.subcrystal(max_depth=3)
     628        sage: G = Yinf.digraph(subset=S)
     629        sage: view(G, tightpage=True) # not tested
     630    """
     631
     632    @staticmethod
     633    def __classcall_private__(cls, n):
     634        r"""
     635        Normalize input to ensure a unique representation.
     636
     637        INPUT:
     638
     639        - ``n`` -- type `A_n^{(1)}`
     640
     641        EXAMPLES::
     642
     643            sage: Yinf = CrystalOfGeneralizedYoungWalls(3)
     644            sage: Yinf2 = CrystalOfGeneralizedYoungWalls(int(3))
     645            sage: Yinf is Yinf2
     646            True
     647        """
     648        return super(CrystalOfGeneralizedYoungWalls,cls).__classcall__(cls,n)
     649
     650    def __init__(self, n):
     651        r"""
     652        EXAMPLES::
     653
     654            sage: Yinf = CrystalOfGeneralizedYoungWalls(3)
     655            sage: TestSuite(Yinf).run()
     656        """
     657        self._cartan_type = CartanType(['A',n,1])
     658        Parent.__init__(self, category=HighestWeightCrystals())
     659        self.module_generators = [self.element_class(self,[])]
     660
     661    Element = GeneralizedYoungWall
     662
     663    def _element_constructor_(self,data):
     664        r"""
     665        Construct an element of ``self`` from ``data``.
     666
     667        INPUT:
     668
     669        - ``data`` -- a multilist
     670
     671        EXAMPLES::
     672
     673            sage: GYW = CrystalOfGeneralizedYoungWalls(2)
     674            sage: y = GYW([[],[1,0],[2,1]]) # indirect doctest
     675            sage: y
     676            [[], [1, 0], [2, 1]]
     677        """
     678        return self.element_class(self,data)
     679
     680    def _repr_(self):
     681        r"""
     682        EXAMPLES::
     683
     684            sage: Y = CrystalOfGeneralizedYoungWalls(4)
     685            sage: Y
     686            Crystal of generalized Young walls of type ['A', 4, 1]
     687        """
     688        return "Crystal of generalized Young walls of type %s" % self._cartan_type
     689
     690    def subset(self, max_depth=4):
     691        r"""
     692        Construct the subcrystal of ``self`` trucated at depth ``max_depth``.
     693
     694        EXAMPLES::
     695
     696            sage: Y = CrystalOfGeneralizedYoungWalls(2)
     697            sage: S = Y.subset(max_depth=2)
     698            sage: S
     699            [[], [[], [1]], [[], [], [2]], [[0]], [[0, 2]], [[0], [1]], [[], [], [2], [], [], [2]],
     700            [[], [1], [2]], [[0], [], [], [0]], [[0], [], [2]], [[], [], [2, 1]], [[], [1], [], [], [1]], [[], [1, 0]]]
     701        """
     702        return [c for c in self.subcrystal(max_depth=max_depth, direction='lower')]
     703
     704
     705########################
     706## Highest weight GYW ##
     707########################
     708
     709class HighestWeightCrystalofGYWElement(GeneralizedYoungWall):
     710    r"""
     711    Element of the highest weight crystal of generalized Young walls.
     712    """
     713
     714    def e(self,i):
     715        r"""
     716        Compute the action of `\widetilde{e}_i` restricted to the highest weight crystal.
     717
     718        EXAMPLES::
     719
     720            sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights()[1]
     721            sage: hwy = HighestWeightCrystalOfGYW(2,La)([[],[1,0],[2,1]])
     722            sage: hwy.e(1)
     723            [[], [1, 0], [2]]
     724            sage: hwy.e(2)
     725            sage: hwy.e(3)
     726        """
     727        ret = GeneralizedYoungWall.e(self, i)
     728        if ret is None:
     729            return None
     730        if ret.in_highest_weight_crystal(self.parent().hw):
     731            return self.__class__(self.parent(),ret.data)
     732        return None
     733
     734    def f(self,i):
     735        r"""
     736        Compute the action of `\widetilde{f}_i` restricted to the highest weight crystal.
     737
     738        EXAMPLES::
     739
     740            sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights()[1]
     741            sage: GYW = CrystalOfGeneralizedYoungWalls(2)
     742            sage: y = GYW([[],[1,0],[2,1]])
     743            sage: y.f(1)
     744            [[], [1, 0], [2, 1], [], [1]]
     745            sage: hwy = HighestWeightCrystalOfGYW(2,La)([[],[1,0],[2,1]])
     746            sage: hwy.f(1)
     747        """
     748        ret = GeneralizedYoungWall.f(self, i)
     749        if ret.in_highest_weight_crystal(self.parent().hw):
     750            return self.__class__(self.parent(),ret.data)
     751        return None
     752
     753    def weight(self):
     754        r"""
     755        Return the weight of ``self`` in the highest weight crystal as an
     756        element of the weight lattice `\bigoplus_{i=0}^n \ZZ \Lambda_i`.
     757
     758        EXAMPLES::
     759
     760            sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights()[1]
     761            sage: hwy = HighestWeightCrystalOfGYW(2,La)([[],[1,0],[2,1]])
     762            sage: hwy.weight()
     763            Lambda[0] - Lambda[1] + Lambda[2]
     764        """
     765        return self.parent().weight_lattice_realization()(self.parent().hw + GeneralizedYoungWall.weight(self))
     766
     767
     768class HighestWeightCrystalOfGYW(CrystalOfGeneralizedYoungWalls):
     769    r"""
     770    The crystal `\mathcal{Y}(\lambda)` of generalized Young walls of the given
     771    type with highest weight `\lambda`.
     772
     773    These were characterized in Theorem 4.1 of [KS10]_.
     774    See :meth:`GeneralizedYoungWall.in_highest_weight_crystal()`.
     775
     776    INPUT:
     777
     778    - ``n`` -- type `A_n^{(1)}`
     779
     780    - ``weight`` -- dominant integral weight
     781
     782    EXAMPLES::
     783
     784        sage: La = RootSystem(['A',3,1]).weight_lattice().fundamental_weights()[1]
     785        sage: YLa = HighestWeightCrystalOfGYW(3,La)
     786        sage: y = YLa([[0],[1,0,3,2,1],[2,1,0],[3]])
     787        sage: y.pp()
     788                3|
     789            0|1|2|
     790        1|2|3|0|1|
     791                0|
     792        sage: y.weight()
     793        -Lambda[0] + Lambda[2] + Lambda[3]
     794        sage: y.in_highest_weight_crystal(La)
     795        True
     796        sage: y.f(1)
     797        [[0], [1, 0, 3, 2, 1], [2, 1, 0], [3], [], [1]]
     798        sage: y.f(1).f(1)
     799        sage: yy = CrystalOfGeneralizedYoungWalls(3)([[0], [1, 0, 3, 2, 1], [2, 1, 0], [3], [], [1]])
     800        sage: yy.f(1)
     801        [[0], [1, 0, 3, 2, 1], [2, 1, 0], [3], [], [1], [], [], [], [1]]
     802        sage: yyy = yy.f(1)
     803        sage: yyy.in_highest_weight_crystal(La)
     804        False
     805
     806        sage: LS = CrystalOfLSPaths(['A',3,1],[1,0,0,0])
     807        sage: C = LS.subcrystal(max_depth=4)
     808        sage: G = LS.digraph(subset=C)
     809        sage: P = LS.weight_lattice_realization()
     810        sage: La = P.fundamental_weights()
     811        sage: YW = HighestWeightCrystalOfGYW(3,La[0])
     812        sage: CW = YW.subcrystal(max_depth=4)
     813        sage: GW = YW.digraph(subset=CW)
     814        sage: GW.is_isomorphic(G,edge_labels=True)
     815        True
     816
     817    To display the crystal down to a specified depth::
     818
     819        sage: S = YLa.subset(max_depth=4)
     820        sage: sorted(list(S))
     821        [[], [[], [1]], [[], [1], [2]], [[], [1], [2], [3]], [[], [1, 0]], [[], [1, 0], [2]], [[], [1, 0], [2], [3]], [[], [1, 0], [2, 1]], [[], [1, 0, 3]], [[], [1, 0, 3], [2]], [[], [1, 0, 3, 2]]]
     822        sage: G = YLa.digraph(subset=S)
     823        sage: view(G, tightpage=True) # not tested
     824    """
     825    @staticmethod
     826    def __classcall_private__(cls, n, La):
     827        r"""
     828        EXAMPLES::
     829
     830            sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights()[2]
     831            sage: Al = RootSystem(['A',2,1]).weight_lattice().monomial(2)
     832            sage: Y = HighestWeightCrystalOfGYW(2,La)
     833            sage: Y1 = HighestWeightCrystalOfGYW(int(2),Al)
     834            sage: Y is Y1
     835            True
     836        """
     837        La = RootSystem(['A',n,1]).weight_lattice()(La)
     838        return super(HighestWeightCrystalOfGYW, cls).__classcall__(cls, n, La)
     839
     840    def __init__(self, n, La):
     841        r"""
     842        EXAMPLES::
     843
     844            sage: La = RootSystem(['A',3,1]).weight_lattice().fundamental_weights()[1]
     845            sage: YLa = HighestWeightCrystalOfGYW(3,La)
     846            sage: TestSuite(YLa).run()
     847        """
     848        CrystalOfGeneralizedYoungWalls.__init__(self, n)
     849        self.hw = La
     850
     851    Element = HighestWeightCrystalofGYWElement
     852
     853    def __repr__(self):
     854        r"""
     855        EXAMPLES::
     856
     857            sage: La = RootSystem(['A',5,1]).weight_lattice().fundamental_weights()[2]
     858            sage: Y = HighestWeightCrystalOfGYW(5,La)
     859            sage: Y
     860            Highest weight crystal of generalized Young walls of Cartan type ['A', 5, 1] and highest weight Lambda[2].
     861        """
     862        return "Highest weight crystal of generalized Young walls of Cartan type {1!s} and highest weight {0!s}.".format(self.hw, self._cartan_type)
     863
     864    def __iter__(self):
     865        r"""
     866        EXAMPLES::
     867
     868            sage: y = CrystalOfGeneralizedYoungWalls(3)([[0],[1,0,3,2],[2,1],[3,2,1,0,3,2],[0],[],[2]])
     869            sage: x = y.__iter__()
     870            sage: x.next()
     871            [0]
     872        """
     873        for c in self.subcrystal(direction='lower'):
     874            if c.in_highest_weight_crystal(self.hw) :
     875                yield c
     876
     877    def subset(self, max_depth=4):
     878        r"""
     879        Return a subset of ``self`` up to ``max_depth``.
     880
     881        EXAMPLES::
     882
     883            sage: Y = HighestWeightCrystalOfGYW(2,RootSystem(['A',2,1]).weight_lattice().fundamental_weights()[0])
     884            sage: S = Y.subset(max_depth=3)
     885            sage: S
     886            [[], [[0]], [[0, 2]], [[0], [1]], [[0, 2, 1]], [[0, 2], [1]]]
     887        """
     888        return [c for c in self.subcrystal(max_depth=max_depth, direction='lower')
     889                if c.in_highest_weight_crystal(self.hw)]
     890
  • sage/combinat/crystals/highest_weight_crystals.py

    diff --git a/sage/combinat/crystals/highest_weight_crystals.py b/sage/combinat/crystals/highest_weight_crystals.py
    a b  
    8383        sage: C = CartanType(['C',2,1])
    8484        sage: La = C.root_system().weight_lattice().fundamental_weights()
    8585        sage: T = HighestWeightCrystal(La[1])
    86         sage: [p for p in T.__iter__(max_depth=3)]
     86        sage: [p for p in T.subcrystal(max_depth=3)]
    8787        [(Lambda[1],), (Lambda[0] - Lambda[1] + Lambda[2],), (-Lambda[0] + Lambda[1] + Lambda[2] - delta,),
    8888        (Lambda[0] + Lambda[1] - Lambda[2],), (-Lambda[0] + 3*Lambda[1] - Lambda[2] - delta,), (2*Lambda[0] - Lambda[1],),
    8989        (-Lambda[1] + 2*Lambda[2] - delta,)]