# symmetric group: get back conjugacy class from its generators

The function below returns a list r of elements of the symmetric group that leave a certain polynomial f fixed. I know (by the properties of f that I'm not specifiying here) that the list of g's that leave it fixed generate one of the 11 conjugacy subclasses of S(4). What is the best way to output from my code below a number between 1 and 11 that corresponds to such subclass?

R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1 + q1 +q2 # in general, it is a polynomial with unit coefficients in the ring R
G = SymmetricGroup(4)
cl = G.conjugacy_classes_subgroups()
r = []
for g in G:
if (f * g) == f: r.append(g)
return r

edit retag close merge delete

Sort by » oldest newest most voted Unfortunately the method conjugacy_classes_subgroups returns representatives, unlike GAP, which returns objects representing conjugacy classes. It would be nicer to have such objects in SageMath as well.

Fortunately we can still use the underlying interface to GAP:

H = G.subgroup(r)
gap_cl = G.gap().ConjugacyClassesSubgroups()
gap_H = H.gap()
cl_index_of_H = next(k for (k,gap_c) in enumerate(gap_cl) if gap_H in gap_c)


and then (using that the ordering of cl is the same as gap_cl):

sage: cl[cl_index_of_H]
Subgroup generated by [(3,4), (1,2)(3,4)] of (Symmetric group of order 4! as a permutation group)

more

Looking at both your answer and mine, would it be possible to outpu a number between 1 and 11 instead of 'Subgroup generated by...'?

1

This is my attempt (edit):

R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1+q1+q2 # for example
G = SymmetricGroup(4)
r = []
for g in G:
if (f * g) == f: r.append(g)
H = PermutationGroup(r)
return ConjugacyClass(H, G)

more

Be careful that isomorphism is weaker than conjugacy, so this doesn't always work (it gives "false positives").