Esempio n. 1
0
def test_AlternatingGroup():
    G = AlternatingGroup(5)
    elements = list(G.generate())
    assert len(elements) == 60
    assert [perm.is_even for perm in elements] == [True] * 60
    H = AlternatingGroup(1)
    assert H.order() == 1
    L = AlternatingGroup(2)
    assert L.order() == 1
Esempio n. 2
0
def test_handle_precomputed_bsgs():
    A = AlternatingGroup(5)
    A.schreier_sims()
    base = A.base
    strong_gens = A.strong_gens
    result = _handle_precomputed_bsgs(base, strong_gens)
    strong_gens_distr = _distribute_gens_by_base(base, strong_gens)
    assert strong_gens_distr == result[2]
    transversals = result[0]
    orbits = result[1]
    base_len = len(base)
    for i in range(base_len):
        for el in orbits[i]:
            assert transversals[i][el](base[i]) == el
            for j in range(i):
                assert transversals[i][el](base[j]) == base[j]
    order = 1
    for i in range(base_len):
        order *= len(orbits[i])
    assert A.order() == order

    _, transversals = _orbits_transversals_from_bsgs(base, strong_gens_distr)
    assert transversals == _handle_precomputed_bsgs(base, strong_gens,
                                                    transversals)[0]
    assert transversals == _handle_precomputed_bsgs(
        base,
        strong_gens,
        transversals,
        basic_orbits=transversals,
        strong_gens_distr=strong_gens_distr)[0]

    D = DihedralGroup(3)
    D.schreier_sims()
    assert (_handle_precomputed_bsgs(D.base,
                                     D.strong_gens,
                                     basic_orbits=D.basic_orbits) == ([{
                                         0:
                                         Permutation(2),
                                         1:
                                         Permutation(0, 1, 2),
                                         2:
                                         Permutation(0, 2)
                                     }, {
                                         1:
                                         Permutation(2),
                                         2:
                                         Permutation(1, 2)
                                     }], [[0, 1, 2], [1, 2]], [[
                                         Permutation(0, 1, 2),
                                         Permutation(0, 2),
                                         Permutation(1, 2)
                                     ], [Permutation(1, 2)]]))