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

Commit

Permalink
Merge branch 'u/gh-ChamanAgrawal/24894_superRSK' into u/gh-ChamanAgra…
Browse files Browse the repository at this point in the history
…wal/28222_shiftedKnuth
  • Loading branch information
ChamanAgrawal committed Aug 20, 2019
2 parents b48ef92 + 6fc5e67 commit 124b8b3
Show file tree
Hide file tree
Showing 6 changed files with 471 additions and 187 deletions.
2 changes: 2 additions & 0 deletions src/doc/en/reference/combinat/module_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,11 @@ Comprehensive Module list
sage/combinat/subsets_pairwise
sage/combinat/subword
sage/combinat/subword_complex
sage/combinat/super_tableau
sage/combinat/superpartition
sage/combinat/symmetric_group_algebra
sage/combinat/symmetric_group_representations
sage/combinat/super_tableau
sage/combinat/tableau
sage/combinat/tableau_residues
sage/combinat/tableau_tuple
Expand Down
4 changes: 4 additions & 0 deletions src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3715,6 +3715,10 @@ REFERENCES:
.. [RL1971] \J. Rokne, P. Lancaster. Complex interval arithmetic.
Communications of the ACM 14. 1971.
.. [RM2017] Robert Muth.
*Super RSK correspondence with symmetry*.
:arXiv:`1711.00420v1`.
.. [RMA2009] \P. Réal and H. Molina-Abril, *Cell AT-models for digital
volumes* in Torsello, Escolano, Brun (eds.), Graph-Based
Representations in Pattern Recognition, Lecture Notes in
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
'ShiftedPrimedTableau'])

#SuperTableaux
from .super_tableau import *
lazy_import('sage.combinat.super_tableau',["StandardSuperTableau", "SemistandardSuperTableau", "StandardSuperTableaux", "SemistandardSuperTableaux"])

#Words
from .words.all import *
Expand Down
117 changes: 61 additions & 56 deletions src/sage/combinat/rsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
of columns).
- Dual RSK insertion (:class:`~sage.combinat.rsk.RuleDualRSK`).
- CoRSK insertion (:class:`~sage.combinat.rsk.RuleCoRSK`), defined in [GR2018v5sol]_.
- Super RSK insertion (:class:`~sage.combinat.rsk.RuleSuperRSK`), a combiantion of row
and column insertions defined in [RM2017]_.
Implementing your own insertion rule
------------------------------------
Expand Down Expand Up @@ -143,6 +145,10 @@
*Hopf Algebras In Combinatorics*,
:arXiv:`1409.8356v5`, available with solutions at
https://arxiv.org/src/1409.8356v5/anc/HopfComb-v73-with-solutions.pdf
.. [RM2017] Robert Muth.
*Super RSK correspondence with symmetry*.
:arXiv:`1711.00420v1`.
"""

# *****************************************************************************
Expand Down Expand Up @@ -1156,6 +1162,7 @@ def _backward_format_output(self, lower_row, upper_row, output,
return list(reversed(lower_row))
raise ValueError("invalid output option")


class RuleDualRSK(Rule):
r"""
A rule modeling the Dual RSK insertion.
Expand Down Expand Up @@ -1476,7 +1483,7 @@ def reverse_insertion(self, x, row):
x, row[y_pos] = row[y_pos], x
return x

def _backward_format_output(self, lower_row, upper_row, output,
def _backward_format_output(self, lower_row, upper_row, output,
p_is_standard, q_is_standard):
r"""
Return the final output of the ``RSK_inverse`` correspondence
Expand Down Expand Up @@ -1903,10 +1910,10 @@ class RuleSuperRSK(RuleRSK):
r"""
A rule modeling the SuperRSK insertion.
SuperRSK is based on :math:`\epsilon`-insertion which itself is a
combination of row and column classical RSK insertion.
SuperRSK is based on :math:`\epsilon`-insertion, a combination of row
and column classical RSK insertion.
Super RSK insertion differs from classical RSK insertion in the
Super RSK insertion differs from the classical RSK insertion in the
following ways:
* The input (in terms of biwords) is no longer an arbitrary biword,
Expand All @@ -1920,11 +1927,11 @@ class RuleSuperRSK(RuleRSK):
they are semistandard super tableax.
* The main difference is in the way bumping works. Instead of having
only row bumping SuperRSK is based on :math:`\epsilon`-insertion
which is a combination of classical RSK bumping along the row and
a Dual RSK like bumping (i.e. when a number `k_i` is inserted into
the `i`-th row of `P`,it bumps out the first integer greater **or
equal to** `k_i` in the column) along the column.
only row bumping SuperRSK uses :math:`\epsilon`-insertion, a combination
of classical RSK bumping along the rows and a Dual RSK like bumping
(i.e. when a number `k_i` is inserted into the `i`-th row of `P`,it
bumps out the first integer greater **or equal to** `k_i` in the column)
along the column.
EXAMPLES::
Expand All @@ -1939,7 +1946,6 @@ class RuleSuperRSK(RuleRSK):
sage: RSK(["1p", "2p", 2, 2, "3p", "3p", 3, 3],
....: ["1p", 1, "2p", 2, "3p", "3p", "3p", 3], insertion='superRSK')
[[[1', 2, 3', 3], [1, 3'], [2'], [3']], [[1', 2, 3', 3], [2', 3'], [2], [3]]]
sage: from sage.combinat.super_tableau import SemistandardSuperTableau
sage: P = SemistandardSuperTableau([[1, '3p', 3], ['2p']])
sage: Q = SemistandardSuperTableau([['1p', 1, '2p'], [2]])
sage: RSK_inverse(P, Q, insertion=RSK.rules.superRSK)
Expand Down Expand Up @@ -1980,7 +1986,6 @@ class RuleSuperRSK(RuleRSK):
sage: t2 = Tableau([[1, 2, 3], [4], [5]])
sage: RSK_inverse(t1, t2, insertion=RSK.rules.RSK)
[[1, 2, 3, 4, 5], [1, 4, 5, 3, 2]]
sage: from sage.combinat.super_tableau import SemistandardSuperTableau
sage: t1 = SemistandardSuperTableau([[1, 2, 5], [3], [4]])
sage: t2 = SemistandardSuperTableau([[1, 2, 3], [4], [5]])
sage: RSK_inverse(t1, t2, insertion=RSK.rules.superRSK)
Expand All @@ -2006,12 +2011,7 @@ class RuleSuperRSK(RuleRSK):
[[], []]
sage: f = lambda p: RSK_inverse(*RSK(p, insertion=RSK.rules.superRSK),
....: insertion=RSK.rules.superRSK)
sage: def toPrimedEntry(p):
....: p1 = list(p)
....: for i in range(len(p)):
....: p1[i] = PrimedEntry(p[i])
....: return p1
sage: all(toPrimedEntry(p) == f(list(p))[1] for n in range(5)
sage: all(p == f(p)[1] for n in range(5)
....: for p in Permutations(n))
True
Expand Down Expand Up @@ -2056,30 +2056,22 @@ def to_pairs(self, obj1=None, obj2=None, check=True):
ValueError: invalid restricted superbiword
"""
from sage.combinat.shifted_primed_tableau import PrimedEntry
# Initializing itr for itr = None case
itr = None
if obj2 is None:
try:
itr = obj1._rsk_iter()
except AttributeError:
# If this is (something which looks like) a matrix
if obj1 and hasattr(obj1[0], '__getitem__'):
raise NotImplementedError("forward rule for matrices is not yet implemented")
# set recording list to default value [1', 1, 2', 2, ...]
rec = []
a = PrimedEntry('1p')
for i in range(len(obj1)):
rec.append(a)
a = a.increase_half()
# Converting entries of obj1 to PrimedEntry
for i in range(len(obj1)):
obj1[i] = PrimedEntry(obj1[i])
itr = zip(rec, obj1)
# set recording list (obj1) to default value [1', 1, 2', 2, ...]
obj2, obj1 = obj1, []
a = 0.5
for i in range(len(obj2)):
obj1.append(a)
a = a + 0.5
else:
# Converting entries of obj1 to PrimedEntry
for i in range(len(obj1)):
obj1[i] = PrimedEntry(obj1[i])
# Converting entries of obj2 to PrimedEntry
for i in range(len(obj2)):
obj2[i] = PrimedEntry(obj2[i])
if check:
if len(obj1) != len(obj2):
raise ValueError("the two arrays must be the same length")
Expand All @@ -2089,19 +2081,29 @@ def to_pairs(self, obj1=None, obj2=None, check=True):
# the pairs of corresponding entries of obj1
# and obj2 with mixed-parity is not allowed
for t, b in zip(obj1, obj2):
if t.is_primed() != b.is_primed():
if PrimedEntry(t).is_primed() != PrimedEntry(b).is_primed():
if (t, b) in mixed_parity:
raise ValueError("invalid restricted superbiword")
else:
mixed_parity.append((t, b))
itr = zip(obj1, obj2)
return itr
# Since the _rsk_iter() gives unprimed entries
# We will create obj1 and obj2 from it.
if itr:
obj1, obj2 = [], []
for i, j in itr:
obj1.append(i)
obj2.append(j)
# Converting entries of obj1 and obj2 to PrimedEntry
for i in range(len(obj1)):
obj1[i] = PrimedEntry(obj1[i])
obj2[i] = PrimedEntry(obj2[i])
return zip(obj1, obj2)

def _get_col(self, t, col_index):
r"""
Return the column as a list of a given tableau ``t`` (list of lists)
at index ``col_index`` (Indexing starting from zero).
EXAMPLES::
sage: from sage.combinat.rsk import RuleSuperRSK
Expand Down Expand Up @@ -2138,7 +2140,7 @@ def _set_col(self, t, col_index, col):
those entries of the corresponding column in ``t`` which have row
index less than ``length(col)`` will be set, rest will remain
unchanged.
EXAMPLES::
sage: from sage.combinat.rsk import RuleSuperRSK
Expand All @@ -2159,7 +2161,7 @@ def _set_col(self, t, col_index, col):
t[row_index].append(None)
# set value
t[row_index][col_index] = val

def forward_rule(self, obj1, obj2, check_standard=False, check=True):
r"""
Return a pair of tableaux obtained by applying forward
Expand Down Expand Up @@ -2201,7 +2203,6 @@ def forward_rule(self, obj1, obj2, check_standard=False, check=True):
EXAMPLES::
sage: from sage.combinat.rsk import RuleSuperRSK
sage: from sage.combinat.super_tableau import SemistandardSuperTableau
sage: p, q = RuleSuperRSK().forward_rule([1, 2], [1, 3]); p
[[1, 3]]
sage: q
Expand Down Expand Up @@ -2316,7 +2317,6 @@ def _forward_format_output(self, p, q, check_standard):
EXAMPLES::
sage: from sage.combinat.rsk import RuleSuperRSK
sage: from sage.combinat.super_tableau import SemistandardSuperTableau, StandardSuperTableau
sage: isinstance(RuleSuperRSK()._forward_format_output(
....: [['1p', 1, '2p']], [['1p', '1', '2p']], True)[0],
....: StandardSuperTableau)
Expand Down Expand Up @@ -2368,7 +2368,6 @@ def backward_rule(self, p, q, output='array'):
EXAMPLES::
sage: from sage.combinat.rsk import RuleSuperRSK
sage: from sage.combinat.super_tableau import SemistandardSuperTableau
sage: t1 = SemistandardSuperTableau([['1p', '3p', '4p'], [2], [3]])
sage: t2 = SemistandardSuperTableau([[1, 2, 4], [3], [5]])
sage: RuleSuperRSK().backward_rule(t1, t2, 'array')
Expand Down Expand Up @@ -2396,10 +2395,10 @@ def backward_rule(self, p, q, output='array'):
for value, iter_dict in sorted(d.items(), reverse=True, key=lambda x: x[0]):
epsilon = 1 if value.is_primed() else 0
if epsilon == 1:
iter_dict = {v: k for k, v in iter_dict.iteritems()}
iter_dict = {v: k for k, v in iter_dict.items()}
for key in sorted(iter_dict, reverse=True):
row_index, col_index = (iter_dict[key], key) if epsilon == 0 else (key, iter_dict[key])
x = p_copy[row_index].pop() # Always the right-most entry
x = p_copy[row_index].pop() # Always the right-most entry
while True:
if value.is_primed() == x.is_primed():
# row bumping
Expand Down Expand Up @@ -2434,27 +2433,27 @@ def reverse_insertion(self, x, row, epsilon=0):
sage: from bisect import bisect_left, bisect_right
sage: r = [1, 3, 3, 3, 4]
sage: j = 2
sage: j, y_pos = RuleSuperRSK().reverse_insertion(j, r, epsilon=0); r
sage: j, y = RuleSuperRSK().reverse_insertion(j, r, epsilon=0); r
[2, 3, 3, 3, 4]
sage: j
1
sage: y_pos
sage: y
0
sage: r = [1, 3, 3, 3, 4]
sage: j = 3
sage: j, y_pos = RuleSuperRSK().reverse_insertion(j, r, epsilon=0); r
sage: j, y = RuleSuperRSK().reverse_insertion(j, r, epsilon=0); r
[3, 3, 3, 3, 4]
sage: j
1
sage: y_pos
sage: y
0
sage: r = [1, 3, 3, 3, 4]
sage: j = (3)
sage: j, y_pos = RuleSuperRSK().reverse_insertion(j, r, epsilon=1); r
sage: j, y = RuleSuperRSK().reverse_insertion(j, r, epsilon=1); r
[1, 3, 3, 3, 4]
sage: j
3
sage: y_pos
sage: y
3
"""
bisect = bisect_left if epsilon == 0 else bisect_right
Expand Down Expand Up @@ -2495,24 +2494,26 @@ def _backward_format_output(self, lower_row, upper_row, output,
....: [PrimedEntry('1p'), PrimedEntry(1), PrimedEntry('2p'),
....: PrimedEntry(2)], 'word', True)
word: 4321
sage: RuleSuperRSK()._backward_format_output([PrimedEntry('1p'),
....: PrimedEntry(1), PrimedEntry('3p'), PrimedEntry(9)],
....: [PrimedEntry(1), PrimedEntry('2p'), PrimedEntry('3p'),
sage: RuleSuperRSK()._backward_format_output([PrimedEntry('1p'),
....: PrimedEntry(1), PrimedEntry('3p'), PrimedEntry(9)],
....: [PrimedEntry(1), PrimedEntry('2p'), PrimedEntry('3p'),
....: PrimedEntry(4)], 'matrix', True)
Traceback (most recent call last):
...
NotImplementedError: backward rule for matrices is not yet implemented
"""
if output == 'matrix':
raise NotImplementedError("backward rule for matrices is not yet implemented")
raise NotImplementedError("backward rule for matrices is not "
"yet implemented")
if output == 'array':
return [list(reversed(upper_row)), list(reversed(lower_row))]
if output == 'word':
if q_is_standard:
from sage.combinat.words.word import Word
return Word(reversed(lower_row))
else:
raise TypeError("q must be standard to have a %s as valid output" %output)
raise TypeError("q must be standard to have a %s as "
"valid output" %output)
raise ValueError("invalid output option")


Expand Down Expand Up @@ -2985,6 +2986,8 @@ def RSK(obj1=None, obj2=None, insertion=InsertionRules.RSK, check_standard=False
(only for strict biwords) (:class:`~sage.combinat.rsk.RuleDualRSK`)
- ``RSK.rules.coRSK`` (or ``'coRSK'``) -- CoRSK insertion (only
for strict cobiwords) (:class:`~sage.combinat.rsk.RuleCoRSK`)
- ``RSK.rules.superRSK`` (or ``'super'``) -- Super RSK insertion (only for
restricted super biwords) (:class:`~sage.combinat.rsk.RuleSuperRSK`)
- ``check_standard`` -- (default: ``False``) check if either of the
resulting tableaux is a standard tableau, and if so, typecast it
Expand Down Expand Up @@ -3139,6 +3142,8 @@ def RSK_inverse(p, q, output='array', insertion=InsertionRules.RSK):
(only for strict biwords) (:class:`~sage.combinat.rsk.RuleDualRSK`)
- ``RSK.rules.coRSK`` (or ``'coRSK'``) -- CoRSK insertion (only
for strict cobiwords) (:class:`~sage.combinat.rsk.RuleCoRSK`)
- ``RSK.rules.superRSK`` (or ``'super'``) -- Super RSK insertion (only for
restricted super biwords) (:class:`~sage.combinat.rsk.RuleSuperRSK`)
For precise information about constraints on the input and
output, see the particular :class:`~sage.combinat.rsk.Rule` class.
Expand Down Expand Up @@ -3284,6 +3289,7 @@ def RSK_inverse(p, q, output='array', insertion=InsertionRules.RSK):

robinson_schensted_knuth_inverse = RSK_inverse


def to_matrix(t, b):
r"""
Return the integer matrix corresponding to a two-line array.
Expand Down Expand Up @@ -3322,4 +3328,3 @@ def to_matrix(t, b):
else:
entries[pos] = 1
return matrix(entries, sparse=True)

Loading

0 comments on commit 124b8b3

Please sign in to comment.