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 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 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
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
Exemple #5
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))
 def hecke(self):
     return lambda w, i: InsertionAlgorithm.hecke(
         w, i, multisetvalued=self.multisetvalued)