Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- """ Shifted primed tableaux
AUTHORS:
- Kirill Paramonov (2017-08-18): initial implementation """
#***************************************************************************** # Copyright (C) 2017 Kirill Paramonov <kbparamonov at ucdavis.edu>, # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ #*****************************************************************************
from __future__ import print_function, absolute_import, division from six import add_metaclass
from sage.combinat.partition import Partition, Partitions, _Partitions, OrderedPartitions from sage.combinat.partitions import ZS1_iterator from sage.combinat.tableau import Tableaux from sage.combinat.skew_partition import SkewPartition from sage.combinat.integer_vector import IntegerVectors from sage.rings.integer import Integer from sage.rings.rational_field import QQ from sage.rings.rational import Rational from sage.rings.integer_ring import ZZ
from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass from sage.misc.lazy_attribute import lazy_attribute
from sage.structure.list_clone import ClonableArray from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.structure.sage_object import SageObject
from sage.categories.regular_crystals import RegularCrystals from sage.categories.classical_crystals import ClassicalCrystals from sage.categories.sets_cat import Sets from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets from sage.combinat.root_system.cartan_type import CartanType
@add_metaclass(InheritComparisonClasscallMetaclass) class ShiftedPrimedTableau(ClonableArray): r""" A shifted primed tableau.
A primed tableau is a tableau of shifted shape in the alphabet `X' = \{1' < 1 < 2' < 2 < \cdots < n' < n\}` such that
1. the entries are weakly increasing along rows and columns; 2. a row cannot have two repeated primed elements, and a column cannot have two repeated non-primed elements; 3. there are only non-primed elements on the main diagonal.
Skew shape of the shifted primed tableaux is specified either with an optional argument ``skew`` or with ``None`` entries.
EXAMPLES::
sage: T = ShiftedPrimedTableaux([4,2]) sage: T([[1,"2'","3'",3],[2,"3'"]])[1] (2, 3') sage: t = ShiftedPrimedTableau([[1,"2p",2.5,3],[2,2.5]]) sage: t[1] (2, 3') sage: ShiftedPrimedTableau([["2p",2,3],["2p","3p"],[2]], skew=[2,1]) [(None, None, 2', 2, 3), (None, 2', 3'), (2,)] sage: ShiftedPrimedTableau([[None,None,"2p"],[None,"2p"]]) [(None, None, 2'), (None, 2')]
TESTS::
sage: t = ShiftedPrimedTableau([[1,2,2.5,3],[2,2.5]]) Traceback (most recent call last): ... ValueError: [[1, 2, 2.50000000000000, 3], [2, 2.50000000000000]] is not an element of Shifted Primed Tableaux """ @staticmethod def __classcall_private__(cls, T, skew=None): r""" Ensure that a shifted tableau is only ever constructed as an ``element_class`` call of an appropriate parent.
EXAMPLES::
sage: data = [[1,"2'","2",3],[2,"3'"]] sage: t = ShiftedPrimedTableau(data) sage: T = ShiftedPrimedTableaux(shape=[4,2],weight=(1,3,2)) sage: t == T(data) True sage: S = ShiftedPrimedTableaux(shape=[4,2]) sage: t == S(data) True sage: t = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) sage: t.parent() Shifted Primed Tableaux skewed by [2, 1] sage: s = ShiftedPrimedTableau([[None, None,"2p",2,3],[None,"2p"]]) sage: s.parent() Shifted Primed Tableaux skewed by [2, 1]
TESTS::
sage: ShiftedPrimedTableau([]) [] sage: ShiftedPrimedTableau([tuple([])]) [] """ return T
raise ValueError("skew shape does not agree with None entries")
def __init__(self, parent, T, skew=None, check=True, preprocessed=False): r""" Initialize a shifted tableau.
TESTS::
sage: s = ShiftedPrimedTableau([[1,"2'","3'",3], [2,"3'"]]) sage: t = ShiftedPrimedTableaux([4,2])([[1,"2p","3p",3], [2,"3p"]]) sage: s == t True sage: t.parent() Shifted Primed Tableaux of shape [4, 2] sage: s.parent() Shifted Primed Tableaux sage: r = ShiftedPrimedTableaux([4, 2])(s); r.parent() Shifted Primed Tableaux of shape [4, 2] sage: s is t # identical shifted tableaux are distinct objects False
A shifted primed tableau is deeply immutable as the rows are stored as tuples::
sage: t = ShiftedPrimedTableau([[1,"2p","3p",3],[2,"3p"]]) sage: t[0][1] = 3 Traceback (most recent call last): ... TypeError: 'tuple' object does not support item assignment """
@staticmethod def _preprocess(T, skew=None): """ Preprocessing list ``T`` to initialize the tableau. The output is a list of rows as tuples, with explicit ``None``'s to indicate the skew shape, and entries being ``PrimedEntry``s.
Trailing empty rows are removed.
TESTS::
sage: ShiftedPrimedTableau._preprocess([["2'", "3p", 3.5]], ....: skew=[1]) [(None, 2', 3', 4')] sage: ShiftedPrimedTableau._preprocess([[None]], skew=[1]) [(None,)] sage: ShiftedPrimedTableau._preprocess([], skew=[2,1]) [(None, None), (None,)] sage: ShiftedPrimedTableau._preprocess([], skew=[]) [] """ # Preprocessing list t for primes and other symbols for row in T]
def check(self): """ Check that ``self`` is a valid primed tableau.
EXAMPLES::
sage: T = ShiftedPrimedTableaux([4,2]) sage: t = T([[1,'2p',2,2],[2,'3p']]) sage: t.check() sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"],[2]],skew=[2,1]) sage: s.check() sage: t = T([['1p','2p',2,2],[2,'3p']]) Traceback (most recent call last): .... ValueError: [['1p', '2p', 2, 2], [2, '3p']] is not an element of Shifted Primed Tableaux of shape [4, 2] """
def __eq__(self, other): """ Check whether ``self`` is equal to ``other``.
INPUT:
- ``other`` -- the element that ``self`` is compared to
OUTPUT: Boolean
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,"2p"]]) sage: t == ShiftedPrimedTableaux([2])([[1,3/2]]) True sage: s = ShiftedPrimedTableau([["2p",3]], skew=[1]) sage: s == [[None, "2p", 3]] True """
def __ne__(self, other): """ Check whether ``self`` is not equal to ``other``.
INPUT:
- ``other`` -- the element that ``self`` is compared to
OUTPUT: Boolean
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,"2p"]]) sage: t != ShiftedPrimedTableaux([2])([[1,1]]) True sage: s = ShiftedPrimedTableau([["2p",3]], skew=[1]) sage: s != [[None, "2p", 3]] False """
def _repr_(self): """ Return a string representation of ``self``.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: t [(1, 2', 2, 2), (2, 3')] sage: ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) [(None, None, 2', 2, 3), (None, 2')] """
def _repr_list(self): """ Return a string representation of ``self`` as a list of tuples.
EXAMPLES::
sage: ShiftedPrimedTableau([['2p',3],[2,2]], skew=[2])._repr_list() "[(None, None, 2', 3), (2, 2)]" """
def _repr_tab(self): """ Return a nested list of strings representing the elements.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: t._repr_tab() [[' 1 ', " 2'", ' 2 ', ' 2 '], [' 2 ', " 3'"]] sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) sage: s._repr_tab() [[' . ', ' . ', " 2'", ' 2 ', ' 3 '], [' . ', " 2'"]] """
def _repr_diagram(self): """ Return a string representation of ``self`` as an array.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: print(t._repr_diagram()) 1 2' 2 2 2 3' sage: t = ShiftedPrimedTableau([[10,'11p',11,11],[11,'12']]) sage: print(t._repr_diagram()) 10 11' 11 11 11 12 sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) sage: print(s._repr_diagram()) . . 2' 2 3 . 2' """ for i, val in enumerate(self._repr_tab())])
_repr_compact = _repr_diagram
def _ascii_art_(self): """ Return ASCII representation of ``self``.
EXAMPLES::
sage: ascii_art(ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']])) +---+---+---+---+ | 1 | 2'| 2 | 2 | +---+---+---+---+ | 2 | 3'| +---+---+ sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) sage: ascii_art(s) +---+---+---+---+---+ | . | . | 2'| 2 | 3 | +---+---+---+---+---+ | . | 2'| +---+---+
TESTS::
sage: ascii_art(ShiftedPrimedTableau([])) ++ ++
sage: ascii_art(ShiftedPrimedTableau([], skew=[1])) +---+ | . | +---+
"""
def _unicode_art_(self): """ Return a Unicode representation of ``self``.
EXAMPLES::
sage: unicode_art(ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']])) ┌───┬───┬───┬───┐ │ 1 │ 2'│ 2 │ 2 │ └───┼───┼───┼───┘ │ 2 │ 3'│ └───┴───┘ sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) sage: unicode_art(s) ┌───┬───┬───┬───┬───┐ │ . │ . │ 2'│ 2 │ 3 │ └───┼───┼───┼───┴───┘ │ . │ 2'│ └───┴───┘
TESTS::
sage: unicode_art(ShiftedPrimedTableau([])) ┌┐ └┘ sage: unicode_art(ShiftedPrimedTableau([], skew=[1])) ┌───┐ │ . │ └───┘ """
def _ascii_art_table(self, unicode=False): """ TESTS::
sage: t = ShiftedPrimedTableau([[1,'2p',2],[2,'3p']]) sage: print(t._ascii_art_table(unicode=True)) ┌───┬───┬───┐ │ 1 │ 2'│ 2 │ └───┼───┼───┤ │ 2 │ 3'│ └───┴───┘ sage: print(t._ascii_art_table()) +---+---+---+ | 1 | 2'| 2 | +---+---+---+ | 2 | 3'| +---+---+ sage: s = ShiftedPrimedTableau([[1,'2p',2, 23],[2,'30p']]) sage: print(s._ascii_art_table(unicode=True)) ┌────┬────┬────┬────┐ │ 1 │ 2'│ 2 │ 23 │ └────┼────┼────┼────┘ │ 2 │ 30'│ └────┴────┘ sage: print(s._ascii_art_table(unicode=False)) +----+----+----+----+ | 1 | 2'| 2 | 23 | +----+----+----+----+ | 2 | 30'| +----+----+ sage: s = ShiftedPrimedTableau([["2p",2,10],["2p"]],skew=[2,1]) sage: print(s._ascii_art_table(unicode=True)) ┌────┬────┬────┬────┬────┐ │ . │ . │ 2'│ 2 │ 10 │ └────┼────┼────┼────┴────┘ │ . │ 2'│ └────┴────┘ """ 'BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL') else:
# Get the widths of the columns else: else: else:
def pp(self): """ Pretty print ``self``.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: t.pp() 1 2' 2 2 2 3' sage: t = ShiftedPrimedTableau([[10,'11p',11,11],[11,'12']]) sage: t.pp() 10 11' 11 11 11 12 sage: s = ShiftedPrimedTableau([['2p',2,3],['2p']],skew=[2,1]) sage: s.pp() . . 2' 2 3 . 2'
TESTS::
sage: ShiftedPrimedTableau([],skew=[1]).pp() . sage: ShiftedPrimedTableau([]).pp() <BLANKLINE> """
def _latex_(self): r""" Return LaTex code for ``self``.
EXAMPLES::
sage: T = ShiftedPrimedTableaux([4,2]) sage: latex(T([[1,"2p",2,"3p"],[2,3]])) {\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}} \raisebox{-.6ex}{$\begin{array}[b]{*{4}c}\cline{1-4} \lr{ 1 }&\lr{ 2'}&\lr{ 2 }&\lr{ 3'}\\\cline{1-4} &\lr{ 2 }&\lr{ 3 }\\\cline{2-3} \end{array}$} } """
def max_entry(self): r""" Return the minimum unprimed letter `x > y` for all `y` in ``self``.
EXAMPLES::
sage: Tab = ShiftedPrimedTableau([(1,1,'2p','3p'),(2,2)]) sage: Tab.max_entry() 3
TESTS::
sage: Tab = ShiftedPrimedTableau([], skew=[2,1]) sage: Tab.max_entry() 0 sage: Tab = ShiftedPrimedTableau([["1p"]], skew=[2,1]) sage: Tab.max_entry() 1 """ for entry in row if entry is not None]
def shape(self): r""" Return the shape of the underlying partition of ``self``.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: t.shape() [4, 2] sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1]) sage: s.shape() [5, 2] / [2, 1] """
def restrict(self, n): """ Return the restriction of the shifted tableau to all the numbers less than or equal to ``n``.
.. NOTE::
If only the outer shape of the restriction, rather than the whole restriction, is needed, then the faster method :meth:`restriction_outer_shape` is preferred. Similarly if only the skew shape is needed, use :meth:`restriction_shape`.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: t.restrict(2).pp() 1 2' 2 2 2
sage: t.restrict("2p").pp() 1 2'
sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1]) sage: s.restrict(2).pp() . . 2' 2 . 2' sage: s.restrict(1.5).pp() . . 2' . 2' """ for x in t] if z], skew=self._skew)
def restriction_outer_shape(self, n): """ Return the outer shape of the restriction of the shifted tableau ``self`` to `n`.
If `T` is a (skew) shifted tableau and `n` is a half-integer, then the restriction of `T` to `n` is defined as the (skew) shifted tableau obtained by removing all cells filled with entries greater than `n` from `T`.
This method computes merely the outer shape of the restriction. For the restriction itself, use :meth:`restrict`.
EXAMPLES::
sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1]); s.pp() . . 2' 2 3 . 2' sage: s.restriction_outer_shape(2) [4, 2] sage: s.restriction_outer_shape("2p") [3, 2]
""" else: for i, row in enumerate(self)]
def restriction_shape(self, n): """ Return the skew shape of the restriction of the skew tableau ``self`` to ``n``.
If `T` is a shifted tableau and `n` is a half-integer, then the restriction of `T` to `n` is defined as the (skew) shifted tableau obtained by removing all cells filled with entries greater than `n` from `T`.
This method computes merely the skew shape of the restriction. For the restriction itself, use :meth:`restrict`.
EXAMPLES::
sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1]); s.pp() . . 2' 2 3 . 2'
sage: s.restriction_shape(2) [4, 2] / [2, 1] """ return Partition(self.restriction_outer_shape(n)) else:
def to_chain(self): """ Return the chain of partitions corresponding to the (skew) shifted tableau ``self``, interlaced by one of the colours ``1`` is the added cell is on the diagonal, ``2`` if an ordinary entry is added and ``3`` if a primed entry is added.
EXAMPLES::
sage: s = ShiftedPrimedTableau([(1, 2, 3.5, 5, 6.5), (3, 5.5)]); s.pp() 1 2 4' 5 7' 3 6'
sage: s.to_chain() [[], 1, [1], 2, [2], 1, [2, 1], 3, [3, 1], 2, [4, 1], 3, [4, 2], 3, [5, 2]]
sage: s = ShiftedPrimedTableau([(1, 3.5), (2.5,), (6,)], skew=[2,1]); s.pp() . . 1 4' . 3' 6
sage: s.to_chain() [[2, 1], 2, [3, 1], 0, [3, 1], 3, [3, 2], 3, [4, 2], 0, [4, 2], 1, [4, 2, 1]]
TESTS::
sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1]); s.pp() . . 2' 2 3 . 2' sage: s.to_chain() Traceback (most recent call last): ... AssertionError: can compute a chain of partitions only for skew shifted tableaux without repeated entries.
""" else: else: else:
def weight(self): r""" Return the weight of ``self``.
The weight of a shifted primed tableau is defined to be the vector with `i`-th component equal to the number of entries `i` and `i'` in the tableau.
EXAMPLES::
sage: t = ShiftedPrimedTableau([['2p',2,2],[2,'3p']], skew=[1]) sage: t.weight() (0, 4, 1) """ for entry in row if entry is not None] return ()
class CrystalElementShiftedPrimedTableau(ShiftedPrimedTableau): """ Class for elements of ``crystals.ShiftedPrimedTableau``. """ def _to_matrix(self): """ Return a 2-dimensional array representation of a shifted tableau.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux([4,2,1]) sage: t = SPT([[1,'2p',2,2],[2,'3p'],[3]]) sage: mat = t._to_matrix() sage: mat [[1, 2', 2, 2], [None, 2, 3', None], [None, None, 3, None]] """ for i, row in enumerate(self)]
def _reading_word_with_positions(self): """ Iterate over the reading word of ``self`` together with positions of the corresponding letters in ``self``.
The reading word of a shifted primed tableau is constructed as follows:
1. List all primed entries in the tableau, column by column, in decreasing order within each column, moving from the rightmost column to the left, and with all the primes removed (i.e. all entries are increased by half a unit).
2. Then list all unprimed entries, row by row, in increasing order within each row, moving from the bottommost row to the top.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux([4,2]) sage: t = SPT([[1,'2p',2,2],[2,'3p']]) sage: list(t._reading_word_with_positions()) [((1, 2), 3), ((0, 1), 2), ((1, 1), 2), ((0, 0), 1), ((0, 2), 2), ((0, 3), 2)] """
def reading_word(self): """ Return the reading word of ``self``.
The reading word of a shifted primed tableau is constructed as follows:
1. List all primed entries in the tableau, column by column, in decreasing order within each column, moving from the rightmost column to the left, and with all the primes removed (i.e. all entries are increased by half a unit).
2. Then list all unprimed entries, row by row, in increasing order within each row, moving from the bottommost row to the top.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux([4,2]) sage: t = SPT([[1,'2p',2,2],[2,'3p']]) sage: t.reading_word() [3, 2, 2, 1, 2, 2] """ raise NotImplementedError('skew tableau must be empty')
def f(self, ind): r""" Compute the action of the crystal operator `f_i` on a shifted primed tableau using cases from the paper [HPS2017]_.
INPUT:
- ``ind`` -- element in the index set of the crystal
OUTPUT:
Primed tableau or ``None``.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux([5,4,2]) sage: t = SPT([[1,1,1,1,'3p'],[2,2,2,'3p'],[3,3]]) sage: t.pp() 1 1 1 1 3' 2 2 2 3' 3 3 sage: s = t.f(2) sage: s is None True
sage: t = SPT([[1,1,1,'2p','3p'],[2,2,3,3],[3,4]]) sage: t.pp() 1 1 1 2' 3' 2 2 3 3 3 4 sage: s = t.f(2) sage: s.pp() 1 1 1 2' 3' 2 3' 3 3 3 4
""" if num[1] == ind or num[1] == ind+1]
else:
for elt in row] for row in T]
if ind_plus_half not in T[tp_r+1]: break tp_r += 1 tp_c = T[tp_r].index(ind_plus_half)
else: T[r][c] = T[r][c].increase_half() T[tp_r][tp_c] = T[tp_r][tp_c].increase_half()
elif T[r][c+1] == ind_plus_half: T[r][c+1] = T[r][c+1].increase_half() T[r][c] = T[r][c].increase_half()
for elt in row] for row in T]
def e(self, ind): r""" Compute the action of the crystal operator `e_i` on a shifted primed tableau using cases from the paper [HPS2017]_.
INPUT:
- ``ind`` -- an element in the index set of the crystal
OUTPUT:
Primed tableau or ``None``.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux([5,4,2]) sage: t = SPT([[1,1,1,'2p','3p'], [2,'3p',3,3],[3,4]]) sage: t.pp() 1 1 1 2' 3' 2 3' 3 3 3 4 sage: s = t.e(2) sage: s.pp() 1 1 1 2' 3' 2 2 3 3 3 4 sage: t == s.f(2) True """ if num[1] == ind or num[1] == ind+1]
else:
return None
for elt in row] for row in T]
break
T[r][c] = T[r][c].decrease_one() else: T[r][c] = T[r][c].decrease_half() T[tp_r][tp_c] = T[tp_r][tp_c].decrease_half()
elif T[r][c-1] == ind_plus_half: T[r][c-1] = T[r][c-1].decrease_half() T[r][c] = T[r][c].decrease_half() for elt in row] for row in T]
def is_highest_weight(self, index_set=None): r""" Return whether ``self`` is a highest weight element of the crystal.
An element is highest weight if it vanishes under all crystal operators `e_i`.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux([5,4,2]) sage: t = SPT([(1, 1, 1, 1, 1), (2, 2, 2, "3p"), (3, 3)]) sage: t.is_highest_weight() True
sage: SPT = ShiftedPrimedTableaux([5,4]) sage: s = SPT([(1, 1, 1, 1, 1), (2, 2, "3p", 3)]) sage: s.is_highest_weight(index_set=[1]) True """
def weight(self): r""" Return the weight of ``self``.
The weight of a shifted primed tableau is defined to be the vector with `i`-th component equal to the number of entries `i` and `i'` in the tableau.
EXAMPLES::
sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']]) sage: t.weight() (1, 4, 1) """ max_ind = 0 else:
class PrimedEntry(SageObject): r""" The class of entries in shifted primed tableaux.
An entry in a shifted primed tableau is an element in the alphabet `\{1' < 1 < 2' < 2 < \cdots < n' < n\}`. The difference between two elements `i` and `i-1` counts as a whole unit, whereas the difference between `i` and `i'` counts as half a unit. Internally, we represent an unprimed element `x` as `2x` and the primed elements as the corresponding odd integer that respects the total order.
INPUT:
- ``entry`` -- a half integer or a string of an integer possibly ending in ``p`` or ``'`` - ``double`` -- the doubled value """ def __init__(self, entry=None, double=None): """ Normalize the entry.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: PrimedEntry(2) 2 sage: PrimedEntry("2p") 2' sage: PrimedEntry("2'") 2' sage: a = PrimedEntry(2.5) sage: PrimedEntry(a) 3' sage: PrimedEntry(None) Traceback (most recent call last): .... ValueError: primed entry must not be None """ # store primed numbers as odd, unprimed numbers as even integers
# Check if an element has "'" or "p" at the end else:
except (TypeError, ValueError): raise ValueError("primed entries must be half-integers")
def __hash__(self): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: b = PrimedEntry("2'") sage: a == b True """ return self._entry
def __repr__(self): """ Represent ``self`` as primed or unprimed integer.
TESTS::
sage: ShiftedPrimedTableau([[1,"2p"]])[0][1] 2' """ else:
def integer(self): """ Return the corresponding integer `i` for primed entries of the form `i` or `i'`.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: b = PrimedEntry("2p").integer() sage: b 2 sage: b.category() Category of elements of Integer Ring """
def __eq__(self, other): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: b = PrimedEntry("2'") sage: a == b True """
def __ne__(self, other): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("1") sage: b = PrimedEntry(1) sage: a != b False """ except ValueError: return True
def __lt__(self, other): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: b = PrimedEntry(2) sage: a < b True """
def __le__(self, other): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry(2) sage: b = PrimedEntry("3p") sage: a <= b True """
def __gt__(self, other): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: b = PrimedEntry(2) sage: b > a True """
def __ge__(self, other): """ TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry(2) sage: b = PrimedEntry("3p") sage: a >= b False """
def is_unprimed(self): """ Checks if ``self`` is an unprimed element.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: a.is_unprimed() False """
def is_primed(self): """ Checks if ``self`` is a primed element.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("3p") sage: a.is_primed() True """
def unprimed(self): """ Unprime ``self`` if it is a primed element.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: a.unprimed() 2 """ else:
def primed(self): """ Prime ``self`` if it is an unprimed element.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry(1) sage: a.primed() 1' """ else: return self
def increase_half(self): """ Increase ``self`` by half a unit.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry(1) sage: a.increase_half() 2' """
def decrease_half(self): """ Decrease ``self`` by half a unit.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry(1) sage: a.decrease_half() 1' """
def increase_one(self): """ Increase ``self`` by one unit.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: a.increase_one() 3' """
def decrease_one(self): """ Decrease ``self`` by one unit.
TESTS::
sage: from sage.combinat.shifted_primed_tableau import PrimedEntry sage: a = PrimedEntry("2p") sage: a.decrease_one() 1' """
class ShiftedPrimedTableaux(UniqueRepresentation, Parent): r""" Returns the combinatorial class of shifted primed tableaux subject to the constraints given by the arguments.
A primed tableau is a tableau of shifted shape on the alphabet `X' = \{1' < 1 < 2' < 2 < \cdots < n' < n\}` such that
1. the entries are weakly increasing along rows and columns
2. a row cannot have two repeated primed entries, and a column cannot have two repeated non-primed entries
3. there are only non-primed entries along the main diagonal
INPUT:
Valid optional keywords:
- ``shape`` -- the (outer skew) shape of tableaux
- ``weight`` -- the weight of tableaux
- ``max_entry`` -- the maximum entry of tableaux
- ``skew`` -- the inner skew shape of tableaux
The weight of a tableau is defined to be the vector with `i`-th component equal to the number of entries `i` and `i'` in the tableau. The sum of the coordinates in the weight vector must be equal to the number of entries in the partition.
The ``shape`` and ``skew`` must be strictly decreasing partitions.
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux(weight=(1,2,2), shape=[3,2]); SPT Shifted Primed Tableaux of weight (1, 2, 2) and shape [3, 2] sage: SPT.list() [[(1, 2, 2), (3, 3)], [(1, 2', 3'), (2, 3)], [(1, 2', 3'), (2, 3')], [(1, 2', 2), (3, 3)]] sage: SPT = ShiftedPrimedTableaux(weight=(1,2)); SPT Shifted Primed Tableaux of weight (1, 2) sage: list(SPT) [[(1, 2, 2)], [(1, 2', 2)], [(1, 2'), (2,)]] sage: SPT = ShiftedPrimedTableaux([3,2], max_entry = 2); SPT Shifted Primed Tableaux of shape [3, 2] and maximum entry 2 sage: list(SPT) [[(1, 1, 1), (2, 2)], [(1, 1, 2'), (2, 2)]]
TESTS::
sage: [(1,'2p',2,2),(2,'3p')] in ShiftedPrimedTableaux() True sage: [(1,1),(2,2)] in ShiftedPrimedTableaux() False sage: [] in ShiftedPrimedTableaux() True
.. SEEALSO::
- :class:`ShiftedPrimedTableau` """ Element = ShiftedPrimedTableau options = Tableaux.options
@staticmethod def __classcall_private__(cls, shape=None, weight=None, max_entry=None, skew=None): r""" Normalize and process input to return the correct parent and ensure a unique representation.
TESTS::
sage: ShiftedPrimedTableaux([]) Shifted Primed Tableaux of shape [] sage: ShiftedPrimedTableaux(3) Traceback (most recent call last): ... ValueError: invalid shape argument sage: ShiftedPrimedTableaux(weight=(2,2,2), shape=[3,2]) Traceback (most recent call last): ... ValueError: weight and shape are incompatible sage: ShiftedPrimedTableaux([[1]]) Traceback (most recent call last): ... ValueError: invalid shape argument sage: ShiftedPrimedTableaux(weight=(2,2,2), max_entry=2) Traceback (most recent call last): ... ValueError: maximum entry is incompatible with the weight sage: ShiftedPrimedTableaux(shape=[4,1],skew=[3,2]) Traceback (most recent call last): ... ValueError: skew shape must be inside the given tableau shape
sage: SPT1 = ShiftedPrimedTableaux(weight=()) sage: SPT2 = ShiftedPrimedTableaux(weight=(0,0,0)) sage: SPT1 is SPT2 True """ except ValueError: raise ValueError('invalid skew argument') raise ValueError('skew shape must be a strict partition')
skew = shape.inner() shape = shape.outer()
raise ValueError("shape {} is not a strict partition".format(shape))
for i in range(len(skew)))):
raise ValueError("specify shape or weight argument") else: else:
or skew is None and sum(shape) != sum(weight)):
def __init__(self, skew=None): """ Initialization of the parent class with given skew shape.
TESTS::
sage: SPT = ShiftedPrimedTableaux(skew=[1]) sage: TestSuite(SPT).run() # known bug """
def _element_constructor_(self, T): """ Construct an object from ``T`` as an element of shifted primed tableaux, if possible.
INPUT:
- ``T`` -- data which can be interpreted as a primed tableau
OUTPUT:
- the corresponding primed tableau object
EXAMPLES::
sage: SPT = ShiftedPrimedTableaux() sage: tab = SPT([[1,1,"2p"]]); tab [(1, 1, 2')] sage: tab.parent() is SPT True sage: tab = SPT([[1,1,2],[2,2]]) Traceback (most recent call last): ... ValueError: [[1, 1, 2], [2, 2]] is not an element of Shifted Primed Tableaux sage: SPT([[1,"2p","2p"]]) Traceback (most recent call last): ... ValueError: [[1, '2p', '2p']] is not an element of Shifted Primed Tableaux
sage: SPT = ShiftedPrimedTableaux(skew=[1]) sage: SPT([["2p",2]]) [(None, 2', 2)]
sage: SPT = ShiftedPrimedTableaux(weight=(2,1)) sage: tab = SPT([[1,1,1.5]]); tab [(1, 1, 2')] sage: tab.parent() is SPT True
sage: SPT = ShiftedPrimedTableaux([3]) sage: tab = SPT([[1,1,1.5]]); tab [(1, 1, 2')] sage: tab.parent() is SPT True sage: SPT([[1,1]]) Traceback (most recent call last): ... ValueError: [[1, 1]] is not an element of Shifted Primed Tableaux of shape [3]
sage: SPT = ShiftedPrimedTableaux([3], weight=(2,1)) sage: tab = SPT([[1,1,1.5]]); tab [(1, 1, 2')] sage: tab.parent() is SPT True sage: SPT([[1,1]]) Traceback (most recent call last): ... ValueError: [[1, 1]] is not an element of Shifted Primed Tableaux of weight (2, 1) and shape [3] """
def _contains_tableau(self, T): """ Check if ``self`` contains preprocessed tableau ``T``.
TESTS::
sage: Tabs = ShiftedPrimedTableaux() sage: tab = ShiftedPrimedTableau._preprocess( ....: [[1,"2p","3p","3p"]]) sage: tab [(1, 2', 3', 3')] sage: Tabs._contains_tableau(tab) False sage: Tabs = ShiftedPrimedTableaux(skew=[1]) sage: tab = ShiftedPrimedTableau._preprocess( ....: [["2p","3p",3]], skew=[1]) sage: tab [(None, 2', 3', 3)] sage: Tabs._contains_tableau(tab) True """ else: for j, val in enumerate(row) if j+1 >= skew[i-1] and val.is_unprimed()): for j, val in enumerate(row) if j+1 >= skew[i-1] and val.is_primed()): return False for j in range(skew[i], len(row)-1) if row[j].is_unprimed()): return False for j in range(skew[i], len(row)-1) if row[j].is_primed()): for i, row in enumerate(T) if skew[i] == 0):
class ShiftedPrimedTableaux_all(ShiftedPrimedTableaux): """ The class of all shifted primed tableaux. """ def __init__(self, skew=None): """ Initialize the class of all shifted tableaux.
TESTS::
sage: SPT = ShiftedPrimedTableaux() sage: [[1,1.5],[2]] in SPT True sage: [[1,1.5],[1.5]] in SPT False sage: [[1,1],[1]] in SPT False sage: [[1,1],[2,2]] in SPT False sage: TestSuite(SPT).run() # long time """ else:
def _repr_(self): """ Return a string representation of ``self``.
TESTS::
sage: ShiftedPrimedTableaux() Shifted Primed Tableaux """
def __iter__(self): """ Iterate over ``self``.
EXAMPLES::
sage: Tabs = ShiftedPrimedTableaux() sage: Tabs[:5] [[], [(1,)], [(2,)], [(1, 2)], [(1, 2')]] """ raise NotImplementedError('skew tableau must be empty')
k=max_entry): weight=weight): preprocessed=True)
class ShiftedPrimedTableaux_shape(ShiftedPrimedTableaux): r""" Shifted primed tableaux of a fixed shape.
Shifted primed tableaux admit a type `A_n` classical crystal structure with highest weights corresponding to a given shape.
The list of module generators consists of all elements of the crystal with nonincreasing weight entries.
The crystal is constructed following operations described in [HPS2017]_.
EXAMPLES::
sage: ShiftedPrimedTableaux([4,3,1], max_entry=4) Shifted Primed Tableaux of shape [4, 3, 1] and maximum entry 4 sage: ShiftedPrimedTableaux([4,3,1], max_entry=4).cardinality() 384
We compute some of the crystal structure::
sage: SPTC = crystals.ShiftedPrimedTableaux([3,2], 3) sage: T = SPTC.module_generators[-1] sage: T [(1, 1, 2'), (2, 3')] sage: T.f(2) [(1, 1, 3'), (2, 3')] sage: len(SPTC.module_generators) 7 sage: SPTC[0] [(1, 1, 1), (2, 2)] sage: SPTC.cardinality() 24 """ @staticmethod def __classcall_private__(cls, shape, max_entry=None, skew=None): """ Normalize the attributes for the class.
TESTS::
sage: SPT = ShiftedPrimedTableaux(shape=[2,1]) sage: SPT._shape.parent() Partitions
sage: SPT1 = ShiftedPrimedTableaux(shape=(2,1), max_entry=3) sage: SPT2 = ShiftedPrimedTableaux(shape=[2,1], max_entry=3) sage: SPT1 is SPT2 True """ shape=shape, max_entry=max_entry, skew=skew)
def __init__(self, shape, max_entry, skew): """ Initialize the class of shifted primed tableaux of a given shape.
If ``max_elt`` is specified, a finite set with entries smaller or equal to ``max_elt``.
TESTS::
sage: SPT = ShiftedPrimedTableaux([4,2,1], max_entry=4) sage: TestSuite(SPT).run() # long time """ # Determine the correct category else: category = Sets().Infinite() else: else: category = Sets().Finite()
else: self._shape = SkewPartition((shape, skew))
def _repr_(self): """ Return a string representation of ``self``.
TESTS::
sage: ShiftedPrimedTableaux([3,2,1]) Shifted Primed Tableaux of shape [3, 2, 1] """
def _contains_tableau(self, T): """ TESTS::
sage: t = ShiftedPrimedTableau._preprocess([[1,'2p',2,2],[2,'3p']]) sage: ShiftedPrimedTableaux([4,2],max_entry=4)._contains_tableau(t) True sage: s = ShiftedPrimedTableau._preprocess([[1,'2p',2],[2,'3p']]) sage: ShiftedPrimedTableaux([4,2])._contains_tableau(s) False """
else: shape = SkewPartition((shape, skew))
max_entry = 0 else: return False
@lazy_attribute def module_generators(self): """ Return the generators of ``self`` as a crystal.
TESTS::
sage: SPT = ShiftedPrimedTableaux(shape=[2,1]) sage: SPT.module_generators ([(1, 1), (2,)], [(1, 2), (3,)], [(1, 2'), (3,)]) """ raise NotImplementedError("only for non-skew shapes") else: preprocessed=True) for T in ShiftedPrimedTableaux(weight=tuple(weight), shape=self._shape)])
def shape(self): """ Return the shape of the shifted tableaux ``self``.
TESTS::
sage: ShiftedPrimedTableaux([6,4,3,1]).shape() [6, 4, 3, 1] """
class ShiftedPrimedTableaux_weight(ShiftedPrimedTableaux): """ Shifted primed tableaux of fixed weight.
EXAMPLES::
sage: ShiftedPrimedTableaux(weight=(2,3,1)) Shifted Primed Tableaux of weight (2, 3, 1) sage: ShiftedPrimedTableaux(weight=(2,3,1)).cardinality() 17 """ def __init__(self, weight, skew=None): """ Initialize the class of shifted primed tableaux of a given weight.
TESTS::
sage: TestSuite( ShiftedPrimedTableaux(weight=(3,2,1)) ).run() """ else: Parent.__init__(self, category=Sets().Finite())
def _repr_(self): """ Return a string representation of ``self``.
TESTS::
sage: ShiftedPrimedTableaux(weight=(3,2,1)) Shifted Primed Tableaux of weight (3, 2, 1) """ return "Shifted Primed Tableaux of weight {} skewed by {}".format(self._weight, self._skew)
def _contains_tableau(self, T): """ Check if ``self`` contains preprocessed tableau ``T``.
TESTS:: sage: t = ShiftedPrimedTableau._preprocess([[1,1.5],[2]]) sage: ShiftedPrimedTableaux(weight=(1,2))._contains_tableau(t) True sage: s = ShiftedPrimedTableau._preprocess([[1,1.5],[3]]) sage: ShiftedPrimedTableaux(weight=(1,2))._contains_tableau(s) False
sage: u = ShiftedPrimedTableau._preprocess([]) sage: ShiftedPrimedTableaux(weight=())._contains_tableau(u) True sage: ShiftedPrimedTableaux(weight=(1,2))._contains_tableau(u) False """ return False
def __iter__(self): """ Iterate over ``self``.
EXAMPLES::
sage: Tabs = ShiftedPrimedTableaux(weight=(2,3)) sage: Tabs[:4] [[(1, 1, 2, 2, 2)], [(1, 1, 2', 2, 2)], [(1, 1, 2, 2), (2,)], [(1, 1, 2', 2), (2,)]] sage: len(list(Tabs)) 5 """ skew=self._skew): preprocessed=True)
class ShiftedPrimedTableaux_weight_shape(ShiftedPrimedTableaux): """ Shifted primed tableaux of the fixed weight and shape.
EXAMPLES::
sage: ShiftedPrimedTableaux([4,2,1], weight=(2,3,2)) Shifted Primed Tableaux of weight (2, 3, 2) and shape [4, 2, 1] sage: ShiftedPrimedTableaux([4,2,1], weight=(2,3,2)).cardinality() 4 """ def __init__(self, weight, shape, skew=None): """ Initialize the class of shifted primed tableaux of the given weight and shape.
TESTS::
sage: TestSuite( ShiftedPrimedTableaux([4,2,1], weight=(3,2,2)) ).run() """ else: Parent.__init__(self, category=Sets().Finite()) else: self._shape = SkewPartition((shape, skew))
def _repr_(self): """ Return a string representation of ``self``.
TESTS::
sage: ShiftedPrimedTableaux([3,2,1], weight=(4,2)) Shifted Primed Tableaux of weight (4, 2) and shape [3, 2, 1] """ .format(self._weight, self._shape))
def _contains_tableau(self, T): """ Check if ``self`` contains preprocessed tableau ``T``.
TESTS::
sage: t = ShiftedPrimedTableau._preprocess([[1,1.5],[2]]) sage: ShiftedPrimedTableaux([2,1], weight=(1,2))._contains_tableau(t) True sage: ShiftedPrimedTableaux([2,1], weight=(2,1))._contains_tableau(t) False sage: s = ShiftedPrimedTableau._preprocess([[1,1.5,2,3],[3]]) sage: ShiftedPrimedTableaux([3,2], weight=(1,2,2))._contains_tableau(s) False
sage: u = ShiftedPrimedTableau._preprocess([]) sage: ShiftedPrimedTableaux([3,2], weight=(1,2,2))._contains_tableau(u) False sage: ShiftedPrimedTableaux([], weight=())._contains_tableau(u) True """ return False
# It is sufficient only to check this because the weight # and shape must be compatible
else: shape = SkewPartition((shape, skew))
def __iter__(self): """ Iterate over ``self``.
EXAMPLES::
sage: Tabs = ShiftedPrimedTableaux([3,2], weight=(1,2,2)) sage: Tabs[:4] [[(1, 2, 2), (3, 3)], [(1, 2', 3'), (2, 3)], [(1, 2', 3'), (2, 3')], [(1, 2', 2), (3, 3)]] sage: len(list(Tabs)) 4
TESTS::
sage: Tabs = ShiftedPrimedTableaux([3,2], weight=(1,4)) sage: list(Tabs) [] """ raise NotImplementedError('skew tableau must be empty')
for r in range(l-1)] else: for r in range(l)]
#################### # Helper functions # ####################
def _add_strip(sub_tab, full_tab, length): """ Helper function used in the algorithm to generate all shifted primed tableaux of the fixed weight and shape.
TESTS::
sage: list(ShiftedPrimedTableaux([3,1], weight=(2,2))) # indirect doctest [[(1, 1, 2), (2,)], [(1, 1, 2'), (2,)]] """ raise ValueError("strip does not fit")
else:
else:
outer=cliff_list): for j in range(cliff)])
full_tab[len(sub_tab)])) min(sub_tab[row-1]+primed_strip[row-1]-1, full_tab[row]) - sub_tab[row] - primed_strip[row]) else:
k=len(plat_list), outer=plat_list): |