Beispiel #1
0
def test_atoms():
    y = Permutation(3, 4, 1, 2, 7, 9, 5, 10, 6, 8, 12, 11)
    assert y.get_min_atom() in y.get_atoms()

    y = Permutation(3, 4, 1, 2)
    assert Permutation(3, 1, 4, 2).inverse() in y.get_atoms()
    assert Permutation(3, 1, 4, 2) not in y.get_atoms()
def test_generate():
    assert set(Permutation.fpf_involutions(2)) == {Permutation(2, 1)}
    assert set(Permutation.fpf_involutions(3)) == set()
    assert set(Permutation.fpf_involutions(4)) == {
        Permutation(2, 1, 4, 3),
        Permutation(3, 4, 1, 2),
        Permutation(4, 3, 2, 1),
    }
Beispiel #3
0
def test_fpf_transitions_simple():
    y = Permutation(2, 1, 4, 3)
    p = 1
    q = 2

    def t(i, j):
        return Permutation.transposition(i, j)

    phi_plus = {t(q, j) * y * t(q, j) for j in y.upper_fpf_involution_transitions(q)}
    assert phi_plus == {Permutation(3, 4, 1, 2)}
Beispiel #4
0
def test_s_i():
    assert Permutation.s_i(1) == Permutation(2, 1)
    assert Permutation.s_i(1) == Permutation(2, 1, 3)
    assert Permutation.s_i(2) == Permutation(1, 3, 2)

    w = Permutation.s_i(5)
    assert w(5) == 6
    assert w(6) == 5
    assert w(55) == 55
    assert w(56) == 56
def test_fpf_involution_shape():
    w = Permutation(2, 1)
    assert w.fpf_involution_shape() == ()
    assert w._fpf_grassmannian_shape() == ()

    w = Permutation(4, 3, 2, 1)
    print(w.fpf_involution_code())
    assert w.fpf_involution_shape() == (2, )
    assert w._fpf_grassmannian_shape() == (2, )

    w = Permutation(3, 4, 1, 2)
    assert w.fpf_involution_shape() == (1, )
    assert w._fpf_grassmannian_shape() == (1, )
Beispiel #6
0
def test_involution_words():
    w = Permutation.identity()
    assert set(w.get_involution_words()) == {tuple()}
    assert set(w.involution_words) == {tuple()}

    r = Permutation.s_i(1)
    s = Permutation.s_i(2)
    t = Permutation.s_i(3)

    # can only access this property for affine permutations which are involutions
    try:
        set((r * s).involution_words)
        assert False
    except:
        pass

    assert set(r.involution_words) == {(1,)}
    assert set((s * r * s).involution_words) == {(1, 2), (2, 1)}
    assert set((t * s * r * s * t).involution_words) == {(1, 2, 3), (2, 1, 3), (2, 3, 1), (3, 2, 1)}

    n = 5
    w = Permutation(*reversed(range(1, n + 1)))
    words = set(w.get_involution_words())
    assert len(words) == 80
    for e in words:
        v = Permutation.identity()
        for i in e:
            s = Permutation.s_i(i)
            v = s % v % s
        assert v == w
Beispiel #7
0
def test_descents():
    w = Permutation(3, 5, -6, 1, -2, 4)
    assert w.right_descent_set == {2, 4}
    assert w.left_descent_set == {1, 4, 5}

    w = Permutation.identity()
    assert w.right_descent_set == set()
    assert w.left_descent_set == set()
Beispiel #8
0
def test_grothendieck():
    n = 3
    w = Permutation(4, 3, 2, 1)
    f = G(n, (3, 2, 1))
    print(f)
    g = G(n, w)
    print(g)
    assert f == g
def representative_m(mu):
    a = 0
    w = Permutation()
    for b in Partition.transpose(mu):
        for i in range(b // 2):
            w *= Permutation.transposition(a + i + 1, a + b - i)
        a += b
    return w
Beispiel #10
0
def test_grothendieck_s():
    n = 3
    w = Permutation(-1)
    f = GS(n, (1, ))
    print(f)
    g = GS(n, w)
    print(g)
    assert f == g
Beispiel #11
0
def test_fpf_atoms():
    y = Permutation(4, 3, 2, 1)
    s = Permutation.s_i(1)
    t = Permutation.s_i(2)
    u = Permutation.s_i(3)
    assert set(y.get_fpf_atoms()) == {t * s, t * u}

    n = 6
    for w in Permutation.fpf_involutions(n):
        atoms = set()
        for word in w.get_fpf_involution_words():
            atoms.add(Permutation.from_word(word))
        assert atoms == set(w.get_fpf_atoms())
 def __init__(self, oneline, k, length, decreasing=False):
     self.oneline = oneline
     self.words = [
         w
         for w in Permutation(*oneline).get_hecke_words(length_bound=length)
         if len(w) == length
     ]
     self.num_factors = k
     self.max_length = length
     self._factorizations = None
     self._edges = None
     self._components = None
     self._decreasing = decreasing
def representative_n(mu):
    shape = {(i, j): (i, min(j, mu[i - 1] + 1 - j)) if j !=
             (mu[i - 1] + 1 - j) else (2 * ((i + 1) // 2), j)
             for (i, j) in Partition.shape(mu)}
    word = [
        shape[key] for key in sorted(shape, key=lambda ij: (ij[1], -ij[0]))
    ]
    pairs = defaultdict(list)
    for i, key in enumerate(word):
        pairs[key].append(i + 1)
    w = Permutation()
    for pair in pairs.values():
        i, j = tuple(pair)
        w *= Permutation.transposition(i, j)
    return w
    def contain(self, sigma):
        decomposition = []
        id = Permutation(list(range(self.n)))
        for i in range(len(self.base)):
            u = sigma.perm[self.base[i]]
            if u not in self.chain[i].orbit:
                return False, None
            h = ~self.chain[i].orbit[u]
            sigma = h * sigma
            decomposition.extend(
                self.chain[i].decomposition[self.chain[i].orbit[u]])

        if sigma == id:
            return True, decomposition
        return False, None
Beispiel #15
0
def test_constructor():
    try:
        Permutation(3)
        assert False
    except:
        pass

    # valid constructions
    w = Permutation(1, 2)
    assert all(w(i) == i for i in range(10))

    w = Permutation(-2, 1)
    assert w(1) == -2
    assert w(-1) == 2
    assert w(0) == 0
    assert w(2) == 1
    assert w(-2) == -1

    # input args must represent each congruence class exactly once
    try:
        Permutation(3, 2, 5, 15)
        assert False
    except:
        pass
Beispiel #16
0
def test_reduced_words():
    w = Permutation.identity()
    assert set(w.get_reduced_words()) == {tuple()}
    assert set(w.reduced_words) == {tuple()}

    r = Permutation.s_i(1)
    s = Permutation.s_i(2)
    t = Permutation.s_i(3)

    assert set(r.reduced_words) == {(1,)}
    assert set((r * s).reduced_words) == {(1, 2)}
    assert set((r * s * t).reduced_words) == {(1, 2, 3)}
    assert set((r * s * t * r).reduced_words) == {(1, 2, 3, 1), (1, 2, 1, 3), (2, 1, 2, 3)}
    assert set((r * s * r).reduced_words) == {(1, 2, 1), (2, 1, 2)}

    n = 5
    w = Permutation(*reversed(range(1, n + 1)))
    words = set(w.get_reduced_words())
    assert len(words) == 768
    for e in words:
        v = Permutation.identity()
        for i in e:
            v *= Permutation.s_i(i)
        assert v == w
Beispiel #17
0
   
    Calculated answer in answer.txt"""

from StabChain import StabilizerChain
from permutations import Permutation

outputFile = open('answer.txt', 'w')

N = 54

#Generation of generators
list1 = list(range(N // 2, N)) + list(range(0, N // 2))
list2 = []
for i in range(N // 2):
    list2.append(i)
    list2.append(i + N // 2)
formS = {Permutation(list1), Permutation(list2)}

#Build of stabilizers' chain
myStab = StabilizerChain(N, formS, list(range(N - 1)))

#Calculation of group size
outputFile.write(str(myStab.groupSize()) + '\n\n')

#Calculation of the generators of the stabilazer
fS = myStab.getFormingSet(2)
for sigma in fS:
    outputFile.write(str(sigma) + '\n')
outputFile.close()

def irsk_inverse(tab):
    return Permutation(*InsertionAlgorithm.inverse_hecke(tab, tab)[0])
Beispiel #19
0
def test_lt():
    assert Permutation(1, 2, 3) < Permutation(1, 3, 2)
    assert not (Permutation(1, 2, 3) < Permutation(1, 2, 3))
    assert not (Permutation(1, 3, 2) < Permutation(1, 2, 3))
def dual_irsk_inverse(tab):
    ans = Permutation()
    for a, b in _dual_irsk_inverse_helper(tab):
        if a != b:
            ans *= Permutation.transposition(a, b)
    return ans
Beispiel #21
0
def test_init():
    w = Permutation(1)
    v = Permutation([1])
    u = Permutation(*[1])
    assert u == v == w
Beispiel #22
0
def test_identity():
    w = Permutation.identity()
    assert w == Permutation(1, 2)
    assert w.is_identity()
    assert w.is_involution()
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)
Beispiel #24
0
def test_involutions():
    assert set(Permutation.involutions(1)) == {Permutation()}
    assert set(Permutation.involutions(1, True)) == {Permutation(), Permutation(-1)}
    assert set(Permutation.involutions(2)) == {Permutation(), Permutation(2, 1)}
    assert set(Permutation.involutions(2, True)) == {
        Permutation(),
        Permutation(-1),
        Permutation(2, 1),
        Permutation(-2, -1),
        Permutation(-1, -2),
        Permutation(1, -2)
    }

    n = 6
    assert set(Permutation.involutions(n)) == {
        w for w in Permutation.all(n) if w.inverse() == w
    }
    assert set(Permutation.involutions(n, True)) == {
        w for w in Permutation.all(n, True) if w.inverse() == w
    }
    assert len(set(Permutation.involutions(n))) == len(list(Permutation.involutions(n)))

    assert set(Permutation.fpf_involutions(4)) == {
        Permutation(2, 1, 4, 3),
        Permutation(3, 4, 1, 2),
        Permutation(4, 3, 2, 1),
    }