def test_permutation_methods():
    from sympy.combinatorics.fp_groups import FpSubgroup
    F, x, y = free_group("x, y")
    # DihedralGroup(8)
    G = FpGroup(F, [x**2, y**8, x * y * x**-1 * y])
    T = G._to_perm_group()[1]
    assert T.is_isomorphism()
    assert G.center() == [y**4]

    # DiheadralGroup(4)
    G = FpGroup(F, [x**2, y**4, x * y * x**-1 * y])
    S = FpSubgroup(G, G.normal_closure([x]))
    assert x in S
    assert y**-1 * x * y in S

    # Z_5xZ_4
    G = FpGroup(F, [x * y * x**-1 * y**-1, y**5, x**4])
    assert G.is_abelian
    assert G.is_solvable

    # AlternatingGroup(5)
    G = FpGroup(F, [x**3, y**2, (x * y)**5])
    assert not G.is_solvable

    # AlternatingGroup(4)
    G = FpGroup(F, [x**3, y**2, (x * y)**3])
    assert len(G.derived_series()) == 3
    S = FpSubgroup(G, G.derived_subgroup())
    assert S.order() == 4
Exemplo n.º 2
0
def test_fp_subgroup():
    def _test_subgroup(K, T, S):
        _gens = T(K.generators)
        assert all(elem in S for elem in _gens)
        assert T.is_injective()
        assert T.image().order() == S.order()

    F, x, y = free_group("x, y")
    f = FpGroup(F, [x**4, y**2, x * y * x**-1 * y])
    S = FpSubgroup(f, [x * y])
    assert (x * y)**-3 in S
    K, T = f.subgroup([x * y], homomorphism=True)
    assert T(K.generators) == [y * x**-1]
    _test_subgroup(K, T, S)

    S = FpSubgroup(f, [x**-1 * y * x])
    assert x**-1 * y**4 * x in S
    assert x**-1 * y**4 * x**2 not in S
    K, T = f.subgroup([x**-1 * y * x], homomorphism=True)
    assert T(K.generators[0]**3) == y**3
    _test_subgroup(K, T, S)

    f = FpGroup(F, [x**3, y**5, (x * y)**2])
    H = [x * y, x**-1 * y**-1 * x * y * x]
    K, T = f.subgroup(H, homomorphism=True)
    S = FpSubgroup(f, H)
    _test_subgroup(K, T, S)
Exemplo n.º 3
0
def test_fp_subgroup():
    F, x, y = free_group("x, y")
    f = FpGroup(F, [x**4, y**2, x*y*x**-1*y])
    S = FpSubgroup(f, [x*y])
    assert (x*y)**-3 in S

    S = FpSubgroup(F, [x**-1*y*x])
    assert x**-1*y**4*x in S
    assert x**-1*y**4*x**2 not in S
Exemplo n.º 4
0
 def _compute_kernel(self):
     from sympy import S
     G = self.domain
     G_order = G.order()
     if G_order == S.Infinity:
         raise NotImplementedError(
             "Kernel computation is not implemented for infinite groups")
     gens = []
     K = FpSubgroup(G, gens)
     i = self.image().order()
     while K.order()*i != G_order:
         r = G.random_element()
         k = r*self.invert(self(r))
         if not k in K:
             gens.append(k)
             K = FpSubgroup(G, gens)
     return K
Exemplo n.º 5
0
    def image(self):
        '''
        Compute the image of `self`.

        '''
        if self._image is None:
            values = list(set(self.images.values()))
            if isinstance(self.codomain, PermutationGroup):
                self._image = self.codomain.subgroup(values)
            else:
                self._image = FpSubgroup(self.codomain, values)
        return self._image
Exemplo n.º 6
0
 def _compute_kernel(self):
     G = self.domain
     G_order = G.order()
     if G_order is S.Infinity:
         raise NotImplementedError(
             "Kernel computation is not implemented for infinite groups")
     gens = []
     if isinstance(G, PermutationGroup):
         K = PermutationGroup(G.identity)
     else:
         K = FpSubgroup(G, gens, normal=True)
     i = self.image().order()
     while K.order() * i != G_order:
         r = G.random()
         k = r * self.invert(self(r))**-1
         if k not in K:
             gens.append(k)
             if isinstance(G, PermutationGroup):
                 K = PermutationGroup(gens)
             else:
                 K = FpSubgroup(G, gens, normal=True)
     return K