def automorphism_group(self): """ Returns the group of permutations whose action on this structure leave it fixed. EXAMPLES:: sage: p = PermutationGroupElement((2,3,4)) sage: P = species.PermutationSpecies() sage: a = P.structures(["a", "b", "c", "d"]).random_element(); a ['a', 'c', 'b', 'd'] sage: a.automorphism_group() Permutation Group with generators [(2,3), (1,4)] :: sage: [a.transport(perm) for perm in a.automorphism_group()] [['a', 'c', 'b', 'd'], ['a', 'c', 'b', 'd'], ['a', 'c', 'b', 'd'], ['a', 'c', 'b', 'd']] """ from sage.groups.all import SymmetricGroup, PermutationGroup S = SymmetricGroup(len(self._labels)) p = self.permutation_group_element() return PermutationGroup(S.centralizer(p).gens())
def automorphism_group(self): """ EXAMPLES:: sage: p = PermutationGroupElement((2,3)) sage: S = species.SetSpecies() sage: F = S * S sage: a = F.structures([1,2,3,4]).random_element(); a {1}*{2, 3, 4} sage: a.automorphism_group() Permutation Group with generators [(2,3), (2,3,4)] :: sage: [a.transport(g) for g in a.automorphism_group()] [{1}*{2, 3, 4}, {1}*{2, 3, 4}, {1}*{2, 3, 4}, {1}*{2, 3, 4}, {1}*{2, 3, 4}, {1}*{2, 3, 4}] :: sage: a = F.structures([1,2,3,4]).random_element(); a {2, 3}*{1, 4} sage: [a.transport(g) for g in a.automorphism_group()] [{2, 3}*{1, 4}, {2, 3}*{1, 4}, {2, 3}*{1, 4}, {2, 3}*{1, 4}] """ from sage.groups.all import PermutationGroupElement, PermutationGroup, SymmetricGroup from sage.misc.misc import uniq from sage.combinat.species.misc import change_support left, right = self._list n = len(self._labels) #Get the supports for each of the sides l_support = self._subset._list r_support = self._subset.complement()._list #Get the automorphism group for the left object and #make it have the correct support. Do the same to the #right side. l_aut = change_support(left.automorphism_group(), l_support) r_aut = change_support(right.automorphism_group(), r_support) identity = PermutationGroupElement([]) gens = l_aut.gens() + r_aut.gens() gens = [g for g in gens if g != identity] gens = uniq(gens) if len(gens) > 0 else [[]] return PermutationGroup(gens)
def change_support(perm, support, change_perm=None): """ Changes the support of a permutation defined on [1, ..., n] to support. EXAMPLES:: sage: from sage.combinat.species.misc import change_support sage: p = PermutationGroupElement((1,2,3)); p (1,2,3) sage: change_support(p, [3,4,5]) (3,4,5) """ if change_perm is None: change_perm = prod([PermutationGroupElement((i+1,support[i])) for i in range(len(support)) if i+1 != support[i]], PermutationGroupElement([], SymmetricGroup(support))) if isinstance(perm, PermutationGroup_generic): return PermutationGroup([change_support(g, support, change_perm) for g in perm.gens()]) return change_perm*perm*~change_perm
def automorphism_group(self): """ Returns the group of permutations whose action on this subset leave it fixed. EXAMPLES:: sage: F = species.SubsetSpecies() sage: a = F.structures([1,2,3,4])[6]; a {1, 3} sage: a.automorphism_group() Permutation Group with generators [(2,4), (1,3)] :: sage: [a.transport(g) for g in a.automorphism_group()] [{1, 3}, {1, 3}, {1, 3}, {1, 3}] """ from sage.groups.all import SymmetricGroup, PermutationGroup a = SymmetricGroup(self._list) b = SymmetricGroup(self.complement()._list) return PermutationGroup(a.gens() + b.gens())
def automorphism_group(self): """ Returns the group of permutations whose action on this structure leave it fixed. EXAMPLES:: sage: P = species.CycleSpecies() sage: a = P.structures([1, 2, 3, 4]).random_element(); a (1, 2, 3, 4) sage: a.automorphism_group() Permutation Group with generators [(1,2,3,4)] :: sage: [a.transport(perm) for perm in a.automorphism_group()] [(1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4)] """ from sage.groups.all import SymmetricGroup, PermutationGroup S = SymmetricGroup(len(self._labels)) p = self.permutation_group_element() return PermutationGroup(S.centralizer(p).gens())