Using Sage for Symmetric Groups Calculations

Permutations

In [3]:
Permutations(4)
Out[3]:
Standard permutations of 4
In [4]:
S4 = Permutations(4) 
In [5]:
list(S4)
Out[5]:
[[1, 2, 3, 4],
 [1, 2, 4, 3],
 [1, 3, 2, 4],
 [1, 3, 4, 2],
 [1, 4, 2, 3],
 [1, 4, 3, 2],
 [2, 1, 3, 4],
 [2, 1, 4, 3],
 [2, 3, 1, 4],
 [2, 3, 4, 1],
 [2, 4, 1, 3],
 [2, 4, 3, 1],
 [3, 1, 2, 4],
 [3, 1, 4, 2],
 [3, 2, 1, 4],
 [3, 2, 4, 1],
 [3, 4, 1, 2],
 [3, 4, 2, 1],
 [4, 1, 2, 3],
 [4, 1, 3, 2],
 [4, 2, 1, 3],
 [4, 2, 3, 1],
 [4, 3, 1, 2],
 [4, 3, 2, 1]]
In [6]:
w = Permutations(4)[3]
In [7]:
w
Out[7]:
[1, 3, 4, 2]
In [8]:
u = Permutation([3, 4, 1, 2])
In [9]:
u*w
Out[9]:
[4, 2, 1, 3]
In [10]:
w.cycle_type()
Out[10]:
[3, 1]
In [11]:
u.cycle_tuples()
Out[11]:
[(1, 3), (2, 4)]

Partitions

In [12]:
Partitions(5)
Out[12]:
Partitions of the integer 5
In [13]:
list(Partitions(5))
Out[13]:
[[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]]
In [14]:
for la in Partitions(5):
    print la, la.conjugate()
[5] [1, 1, 1, 1, 1]
[4, 1] [2, 1, 1, 1]
[3, 2] [2, 2, 1]
[3, 1, 1] [3, 1, 1]
[2, 2, 1] [3, 2]
[2, 1, 1, 1] [4, 1]
[1, 1, 1, 1, 1] [5]
In [15]:
la = Partition([3,3,3])
In [16]:
la.dimension()
Out[16]:
42

Tableaux

In [17]:
StandardTableaux(la)
Out[17]:
Standard tableaux of shape [3, 3, 3]
In [18]:
S = StandardTableaux([3, 3, 3])
In [19]:
S.cardinality()
Out[19]:
42
In [20]:
T = S[5]; T
Out[20]:
[[1, 4, 6], [2, 5, 8], [3, 7, 9]]
In [21]:
T.column_stabilizer()
Out[21]:
Permutation Group with generators [(), (8,9), (6,8), (5,7), (4,5), (2,3), (1,2)]
In [22]:
T.schuetzenberger_involution()
Out[22]:
[[1, 3, 7], [2, 5, 8], [4, 6, 9]]

Constructing Representations

In [23]:
la = Partition([3, 2, 1])
In [24]:
SymmetricGroupRepresentation(la)
Out[24]:
Specht representation of the symmetric group corresponding to [3, 2, 1]
In [25]:
V = SymmetricGroupRepresentation(la)
In [26]:
w = Permutations(6).random_element(); w
Out[26]:
[2, 1, 3, 4, 5, 6]
In [27]:
V.representation_matrix(w)
Out[27]:
[ 0  0  0  0  0 -1  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0 -1  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0 -1  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0 -1  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0 -1  0  0  0]
[-1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0 -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0 -1  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0 -1  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0 -1  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 -1]
[ 0  0  0 -1  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0 -1  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0 -1  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0 -1  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0 -1  0  0  0  0  0]
In [28]:
V = SymmetricGroupRepresentation([3, 2, 1], implementation='seminormal')
In [29]:
V.representation_matrix(w)
Out[29]:
[ 1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0 -1  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0 -1  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0 -1  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0 -1  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0 -1  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0 -1  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0 -1  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 -1]
In [30]:
A = V.representation_matrix(w)
In [31]:
w.cycle_type()
Out[31]:
[2, 1, 1, 1, 1]
In [32]:
A^6
Out[32]:
[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]

Character Values of the Symmetric Group

Uses symmetrica

In [33]:
symmetrica.charvalue([3, 2, 1], [3, 3])
Out[33]:
-2
In [34]:
symmetrica.chartafel(3)
Out[34]:
[ 1  1  1]
[-1  0  2]
[ 1 -1  1]
In [35]:
symmetrica.kostka_number([3, 3], [3, 2, 1])
Out[35]:
1
In [36]:
symmetrica.kostka_tab([3, 1], [2, 1, 1])
Out[36]:
[[[1, 1, 2], [3]], [[1, 1, 3], [2]]]
In [37]:
symmetrica.kostka_tafel(3)
Out[37]:
[1 0 0]
[1 1 0]
[1 2 1]

Symmetric Functions

Transition matrices

In [38]:
S = SymmetricFunctions(ZZ)
s = S.schur()
h = S.complete()
e = S.elementary()
p = S.powersum()
m = S.monomial()
In [39]:
M = lambda n: Matrix([[m(h[la]).coefficient(mu) for mu in Partitions(n)] for la in Partitions(n)]); M(3)
Out[39]:
[1 1 1]
[1 2 3]
[1 3 6]
In [40]:
N = lambda n: Matrix([[m(e[la]).coefficient(mu) for mu in Partitions(n)] for la in Partitions(n)]); N(3)
Out[40]:
[0 0 1]
[0 1 3]
[1 3 6]
In [41]:
K = lambda n: Matrix([[s(h[mu]).coefficient(la) for mu in Partitions(n)] for la in Partitions(n)]); K(5)
Out[41]:
[1 1 1 1 1 1 1]
[0 1 1 2 2 3 4]
[0 0 1 1 2 3 5]
[0 0 0 1 1 3 6]
[0 0 0 0 1 2 5]
[0 0 0 0 0 1 4]
[0 0 0 0 0 0 1]
In [42]:
J = lambda n: Matrix([[int(la==mu.conjugate()) for mu in Partitions(n)] for la in Partitions(n)]); J(3)
Out[42]:
[0 0 1]
[0 1 0]
[1 0 0]
In [43]:
P = lambda n: Matrix([[m(p[la]).coefficient(mu) for mu in Partitions(n)] for la in Partitions(n)]); P(3)
Out[43]:
[1 0 0]
[1 1 0]
[1 3 6]
In [44]:
M(5), K(5).transpose()*K(5)
Out[44]:
(
[  1   1   1   1   1   1   1]  [  1   1   1   1   1   1   1]
[  1   2   2   3   3   4   5]  [  1   2   2   3   3   4   5]
[  1   2   3   4   5   7  10]  [  1   2   3   4   5   7  10]
[  1   3   4   7   8  13  20]  [  1   3   4   7   8  13  20]
[  1   3   5   8  11  18  30]  [  1   3   5   8  11  18  30]
[  1   4   7  13  18  33  60]  [  1   4   7  13  18  33  60]
[  1   5  10  20  30  60 120], [  1   5  10  20  30  60 120]
)
In [45]:
X = lambda n: Matrix([[s(p[mu]).coefficient(la) for mu in Partitions(n)] for la in Partitions(n)]); X(3)
Out[45]:
[ 1  1  1]
[-1  0  2]
[ 1 -1  1]
In [46]:
P(5), X(5).transpose()*K(5)
Out[46]:
(
[  1   0   0   0   0   0   0]  [  1   0   0   0   0   0   0]
[  1   1   0   0   0   0   0]  [  1   1   0   0   0   0   0]
[  1   0   1   0   0   0   0]  [  1   0   1   0   0   0   0]
[  1   2   1   2   0   0   0]  [  1   2   1   2   0   0   0]
[  1   1   2   0   2   0   0]  [  1   1   2   0   2   0   0]
[  1   3   4   6   6   6   0]  [  1   3   4   6   6   6   0]
[  1   5  10  20  30  60 120], [  1   5  10  20  30  60 120]
)

Pieri's rule and Littlewood-Richardson coefficients

In [47]:
s(s[2, 1]*s[1])
Out[47]:
s[2, 1, 1] + s[2, 2] + s[3, 1]

The Littlewood-Richardson coefficient $^\lambda_{\mu\nu}$ is the coefficient of $s_\lambda$ in the expansion of $s_\lambda s_\mu$ in terms of Schur functions.

In [48]:
def littlewood_richardson_coefficient(la, mu, nu):
    return s(s[mu]*s[nu]).coefficient(la)
In [49]:
littlewood_richardson_coefficient([3, 2, 1], [2, 1], [2, 1])
Out[49]:
2
In [ ]: