Esempio n. 1
0
def test_orthogonal_hecke_insertion():
    w = (4, 5, 1, 1, 3, 2)
    i = (1, 1, 3, 4, 4, 6)

    insertion, recording = InsertionAlgorithm.orthogonal_hecke(w)

    p = Tableau({(1, 1): 1, (1, 2): 2, (1, 3): 4, (1, 4): 5, (2, 2): 3})
    q = Tableau({
        (1, 1): 1,
        (1, 2): 2,
        (1, 3): (-3, -4),
        (1, 4): -6,
        (2, 2): 5
    })
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_orthogonal_hecke(p, q) == (w, (1, 2, 3,
                                                                     4, 5, 6))

    insertion, recording = InsertionAlgorithm.orthogonal_hecke(w, i)

    q = Tableau({
        (1, 1): 1,
        (1, 2): 1,
        (1, 3): (-3, -4),
        (1, 4): -6,
        (2, 2): 4
    })
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_orthogonal_hecke(p, q) == (w, i)
Esempio n. 2
0
 def backward(self):
     if not self.is_symplectic:
         return lambda x, y: InsertionAlgorithm.inverse_orthogonal_hecke(
             x, y, self.multisetvalued)
     else:
         return lambda x, y: InsertionAlgorithm.inverse_symplectic_hecke(
             x, y, self.multisetvalued)
Esempio n. 3
0
def test_symplectic_hecke_insertion():
    w = (4, 2, 6, 1, 7, 5, 3, 4, 2, 1, 3, 2)
    i = (1, 2, 2, 3, 3, 4, 5, 5, 6, 8, 8, 9)

    insertion, recording = InsertionAlgorithm.symplectic_hecke(w)

    p = Tableau({
        (1, 1): 2,
        (1, 2): 3,
        (1, 3): 4,
        (1, 4): 5,
        (1, 5): 6,
        (1, 6): 7,
        (2, 2): 4,
        (2, 3): 5,
        (2, 4): 6,
        (2, 5): 7,
        (3, 3): 6,
        (3, 4): 7,
    })
    q = Tableau({
        (1, 1): 1,
        (1, 2): -2,
        (1, 3): 3,
        (1, 4): -4,
        (1, 5): 5,
        (1, 6): -10,
        (2, 2): 6,
        (2, 3): -7,
        (2, 4): -9,
        (2, 5): -12,
        (3, 3): 8,
        (3, 4): -11,
    })
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(
        p, q) == (w, tuple(range(1, 13)))

    insertion, recording = InsertionAlgorithm.symplectic_hecke(w, i)

    q = Tableau({
        (1, 1): 1,
        (1, 2): -2,
        (1, 3): 2,
        (1, 4): -3,
        (1, 5): 3,
        (1, 6): -8,
        (2, 2): 4,
        (2, 3): -5,
        (2, 4): -6,
        (2, 5): -9,
        (3, 3): 5,
        (3, 4): -8,
    })
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p, q) == (w, i)
Esempio n. 4
0
 def f_crystal_operator(self, element_index, operator_index):
     multisetvalued = not self._decreasing
     w, i = self.factorizations[element_index]
     p, q = InsertionAlgorithm.hecke(w, i, multisetvalued=multisetvalued)
     q = q.f_crystal_operator(operator_index, multisetvalued=multisetvalued)
     if q is None:
         return None
     else:
         ans = InsertionAlgorithm.inverse_hecke(
             p, q, multisetvalued=multisetvalued)
         element_indices = [x for x in range(len(self)) if self[x] == ans]
         assert len(element_indices) == 1
         return element_indices[0]
def rsk(pi, n=None):
    if n is None:
        n = pi.rank
    oneline = list(pi.oneline)
    while len(oneline) < n:
        oneline += [len(oneline) + 1]
    return InsertionAlgorithm.hecke(oneline)
def test_decreasing_word_crystal_locality():
    def to_tuple(word, record, k):
        tup = tuple(
            tuple(word[x] for x in range(len(record)) if record[x] == y)
            for y in range(1, k + 1))
        return ' | '.join([' '.join([str(a) for a in w]) for w in tup])

    for word in Permutation.hecke_words(5):
        for k in range(len(word)):
            for f in WordCrystalGenerator.get_increasing_factorizations(
                    word, k, decreasing=True):
                for op_index in range(1, len(f) - 1):
                    w, i = WordCrystalGenerator.factorization_tuple_to_array(f)
                    p, q = InsertionAlgorithm.hecke(w, i, multisetvalued=False)
                    q = q.f_crystal_operator(op_index)
                    if q is not None:
                        v, j = InsertionAlgorithm.inverse_hecke(
                            p, q, multisetvalued=False)

                        omit = [op_index, op_index + 1]

                        t = {
                            w[x]
                            for x in range(len(w))
                            if i[x] not in omit and w[x] != v[x]
                        }
                        t1 = tuple(w[x] for x in range(len(w))
                                   if i[x] not in omit)
                        t2 = tuple(v[x] for x in range(len(v))
                                   if j[x] not in omit)

                        if len(t) > 1:
                            print('t =', t)
                            print(op_index)
                            # print(w)
                            # print(i)
                            print(to_tuple(w, i, k))
                            print(to_tuple(v, j, k))
                            print()
                            # print(v)
                            # print(j)
                            print()
                        assert len(t) <= 1
def irsk(pi, n=None):
    if n is None:
        n = pi.rank
    cycles = sorted([(pi(i), i) for i in range(1, n + 1) if i <= pi(i)])
    tab = Tableau()
    for b, a in cycles:
        if a == b:
            tab = tab.add(1, tab.max_column() + 1, a)
        else:
            p, q = InsertionAlgorithm.hecke(tab.row_reading_word() + (a, ))
            i, j = q.find(len(q))[0]
            while j > 1 and (i + 1, j - 1) not in p:
                j = j - 1
            tab = p.add(i + 1, j, b)
    return tab
Esempio n. 8
0
def test_shifted_growth_words(n=4):
    c = True
    reasons = set()
    for a in Permutation.involutions(n):
        for w in a.get_involution_words():
            print(w)
            p, q = InsertionAlgorithm.orthogonal_hecke(w)
            g, e, c, r = Partition.shifted_growth_diagram(w)
            reasons |= set([x for row in r for x in row])
            # Partition.print_growth_diagram(g)
            # Partition.print_growth_diagram(e)
            # Partition.print_growth_diagram(c)
            # print(p)
            # print(q)
            pp, qq = Tableau.from_shifted_growth_diagram(g, e, c)
            # print(pp)
            # print(qq)
            assert p == pp and q == qq
    print(sorted(reasons))
Esempio n. 9
0
def test_hecke_insertion():
    w = (3, 2, 1, 1)
    i = (1, 1, 1, 2)
    insertion, recording = InsertionAlgorithm.hecke(w, i, multisetvalued=False)
    p = Tableau({(1, 1): 1, (1, 2): 2, (1, 3): 3})
    q = Tableau({(1, 1): 1, (1, 2): 1, (1, 3): (1, 2)})
    print(insertion)
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_hecke(p, q,
                                            multisetvalued=False) == (w, i)

    p = Tableau({(1, 1): 1, (1, 2): 2, (2, 1): 2})
    q = Tableau({(1, 1): 2, (1, 2): 3, (2, 1): 3})
    assert InsertionAlgorithm.inverse_hecke(
        p, q, multisetvalued=False) == ((1, 2, 1), (2, 3, 3))

    i = (1, 2, 3, 3)
    insertion, recording = InsertionAlgorithm.hecke(w, i)
    p = Tableau({(1, 1): 1, (2, 1): 2, (3, 1): 3})
    q = Tableau({(1, 1): 1, (2, 1): 2, (3, 1): (3, 3)})
    print(insertion)
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_hecke(p, q) == (w, i)

    w = (1, 5, 1, 3, 3)
    i = (1, 1, 3, 3, 3)
    insertion, recording = InsertionAlgorithm.hecke(w)

    p = Tableau({(1, 1): 1, (1, 2): 3, (2, 1): 5})
    q = Tableau({(1, 1): 1, (1, 2): (2, 5), (2, 1): (3, 4)})

    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_hecke(p, q) == (w, (1, 2, 3, 4, 5))

    insertion, recording = InsertionAlgorithm.hecke(w, i)

    q = Tableau({(1, 1): 1, (1, 2): (1, 3), (2, 1): (3, 3)})

    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_hecke(p, q) == (w, i)

    insertion, q = InsertionAlgorithm.hecke((3, 4, 1, 2, 4))

    p = Tableau({
        (1, 1): 1,
        (1, 2): 2,
        (1, 3): 4,
        (2, 1): 3,
        (2, 2): 4,
    })
    assert insertion == p
    assert InsertionAlgorithm.inverse_hecke(p, q) == ((3, 4, 1, 2, 4),
                                                      (1, 2, 3, 4, 5))

    insertion, q = InsertionAlgorithm.hecke((3, 1, 2, 4))

    p = Tableau({(1, 1): 1, (1, 2): 2, (1, 3): 4, (2, 1): 3})
    assert insertion == p
    assert InsertionAlgorithm.inverse_hecke(p,
                                            q) == ((3, 1, 2, 4), (1, 2, 3, 4))
Esempio n. 10
0
def test_symplectic_hecke_insertion_setvalued():
    w = (2, 2, 4, 3)
    i = (1, 1, 1, 4)

    insertion, recording = InsertionAlgorithm.symplectic_hecke(w)

    p = Tableau({(1, 1): 2, (1, 2): 3, (2, 2): 4})
    q = Tableau({(1, 1): (1, 2), (1, 2): 3, (2, 2): 4})
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p,
                                                       q) == (w, (1, 2, 3, 4))

    insertion, recording = InsertionAlgorithm.symplectic_hecke(w, i)

    q = Tableau({(1, 1): (1, 1), (1, 2): 1, (2, 2): 4})
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p, q) == (w, i)

    i = (1, 2, 3, 3)
    insertion, recording = InsertionAlgorithm.symplectic_hecke(w, i, False)

    q = Tableau({(1, 1): (1, 2), (1, 2): -3, (2, 2): 3})
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p, q, False) == (w, i)

    w = (4, 2, 2, 3)
    i = (2, 4, 4, 4)

    insertion, recording = InsertionAlgorithm.symplectic_hecke(w)

    p = Tableau({(1, 1): 2, (1, 2): 3, (2, 2): 4})
    q = Tableau({(1, 1): 1, (1, 2): (-3, -2), (2, 2): 4})
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p,
                                                       q) == (w, (1, 2, 3, 4))

    insertion, recording = InsertionAlgorithm.symplectic_hecke(w, i)

    q = Tableau({(1, 1): 2, (1, 2): (-4, -4), (2, 2): 4})
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p, q) == (w, i)

    i = (1, 1, 2, 3)
    insertion, recording = InsertionAlgorithm.symplectic_hecke(w, i, False)

    q = Tableau({(1, 1): 1, (1, 2): (1, 2), (2, 2): 3})
    assert insertion == p
    assert recording == q
    assert InsertionAlgorithm.inverse_symplectic_hecke(p, q, False) == (w, i)
Esempio n. 11
0
 def inverse_hecke(self):
     return lambda p, q: InsertionAlgorithm.inverse_hecke(
         p, q, multisetvalued=self.multisetvalued)
Esempio n. 12
0
 def hecke(self):
     return lambda w, i: InsertionAlgorithm.hecke(
         w, i, multisetvalued=self.multisetvalued)
def irsk_inverse(tab):
    return Permutation(*InsertionAlgorithm.inverse_hecke(tab, tab)[0])
def anti_representative_m(mu):
    t = Tableau(
        {box: i + 1
         for i, box in enumerate(sorted(Partition.shape(mu)))})
    oneline, _ = InsertionAlgorithm.inverse_hecke(t, t)
    return Permutation(*oneline)
Esempio n. 15
0
def test_shifted_growth_diagram():
    w = (4, 2, 1, 1, 2, 3, 2)
    g, e, c, r = Partition.shifted_growth_diagram(w)
    Partition.print_growth_diagram(g)
    Partition.print_growth_diagram(e)
    Partition.print_growth_diagram(c)

    gtest = [[[], [], [], [], [], [], [], []],
             [[], [], [], [1], [1], [1], [1], [1]],
             [[], [], [1], [2], [2], [2], [2], [2]],
             [[], [], [1], [2], [2], [2], [3], [3, 1]],
             [[], [1], [2], [3], [3], [3, 1], [3, 1], [3, 2]]]
    gtest = [[tuple(x) for x in row] for row in gtest]
    assert g == gtest

    etest = [[False, False, False, False, False, False, False, False],
             [False, False, False, False, False, False, False, False],
             [False, False, False, True, True, False, False, False],
             [False, False, False, True, True, False, False, False],
             [False, False, True, True, True, False, False, True]]
    assert e == etest

    ctest = [[None, None, None, None, None, None, None, None],
             [None, None, None, None, 1, None, None, None],
             [None, None, None, None, 2, 1, None, 1],
             [None, None, None, None, 2, 1, None, None],
             [None, None, None, None, 3, None, 2, None]]
    assert c == ctest

    p, q = Tableau.from_shifted_growth_diagram(g, e, c)
    pp, qq = InsertionAlgorithm.orthogonal_hecke(w)
    print(p)
    print(q)
    assert p == pp and q == qq

    w = (4, 5, 1, 2, 3, 4, 6, 5, 6, 4)
    g, e, c, r = Partition.shifted_growth_diagram(w)
    Partition.print_growth_diagram(g)
    Partition.print_growth_diagram(e)
    Partition.print_growth_diagram(c)
    Partition.print_growth_diagram(r)

    p, q = Tableau.from_shifted_growth_diagram(g, e, c)
    pp, qq = InsertionAlgorithm.orthogonal_hecke(w)
    print(p)
    print(q)
    assert p == pp and q == qq

    w = (1, 3, 2, 5, 6, 4, 3, 5, 2, 4, 5, 6)
    g, e, c, r = Partition.shifted_growth_diagram(w)
    Partition.print_growth_diagram(g)
    Partition.print_growth_diagram(e)
    Partition.print_growth_diagram(c)
    Partition.print_growth_diagram(r)

    p, q = Tableau.from_shifted_growth_diagram(g, e, c)
    pp, qq = InsertionAlgorithm.orthogonal_hecke(w)
    print(p)
    print(q)
    assert p == pp and q == qq

    w = (3, 2, 1)
    g, e, c, r = Partition.shifted_growth_diagram(w)
    Partition.print_growth_diagram(g)
    Partition.print_growth_diagram(e)
    Partition.print_growth_diagram(c)
    Partition.print_growth_diagram(r)

    p, q = Tableau.from_shifted_growth_diagram(g, e, c)
    pp, qq = InsertionAlgorithm.orthogonal_hecke(w)
    print(p)
    print(q)
    assert p == pp and q == qq