1 | initial version |
Here is a possible approach. It first finds one permutation p
that sorts a given list, then constructs a subgroup a permutations that fix the sorted list, and then reports the product of p
and the subgroup elements:
import itertools import sage.combinat.permutation as permutation
import itertools
import sage.combinat.permutation as permutation
dP = [3,4,3,2,4]
n = len(dP)
S = SymmetricGroup(n)
s_dP = sorted(dP) # sorted list
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() )
P = [ permutation.from_cycles(n,[[i+1 for i,_ in g]]) for _,g in itertools.groupby(enumerate(s_dP),key=lambda t:t[1]) ]
G = S.subgroup(P) # subgroup that fix s_dP
for q in G:
r = Permutation( q * p )
assert [dP[i-1] for i in r] == s_dP # verification, just in case
print(r)
2 | No.2 Revision |
Here is a possible approach. It first finds one permutation p
that sorts a given list, then constructs a subgroup a permutations that fix the sorted list, and then reports the product of p
and the subgroup elements:
import itertools import sage.combinat.permutation as permutation
import itertools
import sage.combinat.permutation as permutation
dP = [3,4,3,2,4]
n = len(dP)
S = SymmetricGroup(n)
s_dP = sorted(dP) # sorted list
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() )
P = [ permutation.from_cycles(n,[[i+1 for i,_ in g]]) permutation.from_cycles(n,[list(g)]) for _,g in itertools.groupby(enumerate(s_dP),key=lambda t:t[1]) itertools.groupby(range(1,n+1),key=lambda t:s_dP[t-1]) ]
G = S.subgroup(P) # subgroup that fix s_dP
for q in G:
r = Permutation( q * p )
assert [dP[i-1] for i in r] == s_dP # verification, just in case
print(r)
3 | No.3 Revision |
Here is a possible approach. It first finds one permutation p
that sorts a given list, then constructs a subgroup a permutations that fix the sorted list, and then reports the product of p
and the subgroup elements:
import itertools import sage.combinat.permutation as permutation
import itertools
import sage.combinat.permutation as permutation
dP = [3,4,3,2,4]
n = len(dP)
S = SymmetricGroup(n)
s_dP = sorted(dP) # sorted list
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() )
P = [ permutation.from_cycles(n,[list(g)]) for _,g in itertools.groupby(range(1,n+1),key=lambda t:s_dP[t-1]) ]
G = S.subgroup(P) # subgroup that fix s_dP
for q in G:
r = Permutation( q * p )
assert [dP[i-1] for i in r] == s_dP # verification, just in case
print(r)
4 | No.4 Revision |
Here is a possible approach. It first finds one permutation p
that sorts a given list, then constructs a subgroup a permutations that fix the sorted list, and then reports the product of p
and the subgroup elements:
import itertools
import sage.combinat.permutation as permutation
dP = [3,4,3,2,4]
n = len(dP)
S = SymmetricGroup(n)
s_dP = sorted(dP) # sorted list
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() )
P = [ permutation.from_cycles(n,[list(g)]) permutation.from_cycles(n,[(i,i+1)]) for _,g in itertools.groupby(range(1,n+1),key=lambda t:s_dP[t-1]) for i in list(g)[:-1] ]
G = S.subgroup(P) # subgroup that fix s_dP
for q in G:
r = Permutation( q * p )
assert [dP[i-1] for i in r] == s_dP # verification, just in case
print(r)
5 | No.5 Revision |
Here is a possible approach. It first finds one permutation p
that sorts a given list, then constructs a subgroup a permutations that fix the sorted list, and then reports the product of p
and the subgroup elements:
import itertools
import sage.combinat.permutation as permutation
dP = [3,4,3,2,4]
n = len(dP)
S = SymmetricGroup(n)
s_dP = sorted(dP) # sorted list
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() )
P = [ permutation.from_cycles(n,[(i,i+1)]) for _,g in itertools.groupby(range(1,n+1),key=lambda t:s_dP[t-1]) itertools.groupby(range(n),key=lambda t:s_dP[t]) for i in list(g)[:-1] itertools.islice(g,1,None) ]
G = S.subgroup(P) # subgroup that fix s_dP
for q in G:
r = Permutation( q * p )
assert [dP[i-1] for i in r] == s_dP # verification, just in case
print(r)