This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
/
symmetric_group_algebra.py
2225 lines (1787 loc) · 80.7 KB
/
symmetric_group_algebra.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
r"""
Symmetric Group Algebra
"""
#*****************************************************************************
# Copyright (C) 2007 Mike Hansen <mhansen@gmail.com>,
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#*****************************************************************************
from sage.misc.cachefunc import cached_method
from combinatorial_algebra import CombinatorialAlgebra
from free_module import CombinatorialFreeModule
from sage.categories.all import FiniteDimensionalAlgebrasWithBasis
from sage.combinat.permutation import Permutation, Permutations, Permutations_nk, PermutationOptions
import partition
from tableau import Tableau, StandardTableaux_size, StandardTableaux_shape, StandardTableaux
from sage.interfaces.all import gap
from sage.rings.all import QQ, PolynomialRing
from sage.rings.arith import factorial
from sage.matrix.all import matrix
from sage.modules.all import vector
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
from sage.categories.all import GroupAlgebras
permutation_options = PermutationOptions
def SymmetricGroupAlgebra(R, n):
"""
Return the symmetric group algebra of order ``n`` over the ring ``R``.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3); QS3
Symmetric group algebra of order 3 over Rational Field
sage: QS3(1)
[1, 2, 3]
sage: QS3(2)
2*[1, 2, 3]
sage: basis = [QS3(p) for p in Permutations(3)]
sage: a = sum(basis); a
[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
sage: a^2
6*[1, 2, 3] + 6*[1, 3, 2] + 6*[2, 1, 3] + 6*[2, 3, 1] + 6*[3, 1, 2] + 6*[3, 2, 1]
sage: a^2 == 6*a
True
sage: b = QS3([3, 1, 2])
sage: b
[3, 1, 2]
sage: b*a
[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
sage: b*a == a
True
The canonical embedding from the symmetric group algebra of order
`n` to the symmetric group algebra of order `p > n` is available as
a coercion::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: QS4 = SymmetricGroupAlgebra(QQ, 4)
sage: QS4.coerce_map_from(QS3)
Generic morphism:
From: Symmetric group algebra of order 3 over Rational Field
To: Symmetric group algebra of order 4 over Rational Field
sage: x3 = QS3([3,1,2]) + 2 * QS3([2,3,1]); x3
2*[2, 3, 1] + [3, 1, 2]
sage: QS4(x3)
2*[2, 3, 1, 4] + [3, 1, 2, 4]
This allows for mixed expressions::
sage: x4 = 3*QS4([3, 1, 4, 2])
sage: x3 + x4
2*[2, 3, 1, 4] + [3, 1, 2, 4] + 3*[3, 1, 4, 2]
sage: QS0 = SymmetricGroupAlgebra(QQ, 0)
sage: QS1 = SymmetricGroupAlgebra(QQ, 1)
sage: x0 = QS0([])
sage: x1 = QS1([1])
sage: x0 * x1
[1]
sage: x3 - (2*x0 + x1) - x4
-3*[1, 2, 3, 4] + 2*[2, 3, 1, 4] + [3, 1, 2, 4] - 3*[3, 1, 4, 2]
Caveat: to achieve this, constructing ``SymmetricGroupAlgebra(QQ,
10)`` currently triggers the construction of all symmetric group
algebras of smaller order. Is this a feature we really want to have?
.. WARNING::
The semantics of multiplication in symmetric group algebras is
determined by the order in which permutations are multiplied,
which currently defaults to "in such a way that multiplication
is associative with permutations acting on integers from the
right", but can be changed to the opposite order at runtime
by setting a global variable (see
:meth:`sage.combinat.permutation.Permutations.global_options` ).
In view of this, it is recommended that code not rely on the
usual multiplication function, but rather use the methods
:meth:`left_action_product` and :meth:`right_action_product`
for multiplying permutations (these methods don't depend on the
setting). See :trac:`14885` for more information.
TESTS::
sage: TestSuite(QS3).run()
"""
return SymmetricGroupAlgebra_n(R,n)
class SymmetricGroupAlgebra_n(CombinatorialFreeModule):
def __init__(self, R, n):
"""
TESTS::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: TestSuite(QS3).run()
"""
self.n = n
self._name = "Symmetric group algebra of order %s"%self.n
CombinatorialFreeModule.__init__(self, R, Permutations(n), prefix='', latex_prefix='', category = (GroupAlgebras(R),FiniteDimensionalAlgebrasWithBasis(R)))
# This is questionable, and won't be inherited properly
if n > 0:
S = SymmetricGroupAlgebra(R, n-1)
self.register_coercion(S.canonical_embedding(self))
# _repr_ customization: output the basis element indexed by [1,2,3] as [1,2,3]
_repr_option_bracket = False
def group(self):
"""
Return the underlying group.
EXAMPLES::
sage: SymmetricGroupAlgebra(QQ,4).group()
Symmetric group of order 4! as a permutation group
"""
return SymmetricGroup(self.n)
@cached_method
def one_basis(self):
"""
Return the identity of the symmetric group, as per
``AlgebrasWithBasis.ParentMethods.one_basis``.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: QS3.one_basis()
[1, 2, 3]
"""
P = self.basis().keys()
return P(range(1,self.n+1))
def product_on_basis(self, left, right):
"""
Return the product of the basis elements indexed by ``left`` and
``right``.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: p1 = Permutation([1,2,3])
sage: p2 = Permutation([2,1,3])
sage: QS3.product_on_basis(p1,p2)
[2, 1, 3]
"""
return self.monomial(left * right)
def left_action_product(self, left, right):
"""
Return the product of two elements ``left`` and ``right`` of
``self``, where multiplication is defined in such a way that
for two permutations `p` and `q`, the product `pq` is the
permutation obtained by first applying `q` and then applying
`p`. This definition of multiplication is tailored to make
multiplication of permutations associative with their action on
numbers if permutations are to act on numbers from the left.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: p1 = Permutation([2, 1, 3])
sage: p2 = Permutation([3, 1, 2])
sage: QS3.left_action_product(QS3(p1), QS3(p2))
[3, 2, 1]
sage: x = QS3([1, 2, 3]) - 2*QS3([1, 3, 2])
sage: y = 1/2 * QS3([3, 1, 2]) + 3*QS3([1, 2, 3])
sage: QS3.left_action_product(x, y)
3*[1, 2, 3] - 6*[1, 3, 2] - [2, 1, 3] + 1/2*[3, 1, 2]
sage: QS3.left_action_product(0, x)
0
The method coerces its input into the algebra ``self``::
sage: QS4 = SymmetricGroupAlgebra(QQ, 4)
sage: QS4.left_action_product(QS3([1, 2, 3]), QS3([2, 1, 3]))
[2, 1, 3, 4]
sage: QS4.left_action_product(1, Permutation([4, 1, 2, 3]))
[4, 1, 2, 3]
.. WARNING::
Note that coercion presently works from permutations of ``n``
into the ``n``-th symmetric group algebra, and also from all
smaller symmetric group algebras into the ``n``-th symmetric
group algebra, but not from permutations of integers smaller
than ``n`` into the ``n``-th symmetric group algebra.
"""
a = self(left)
b = self(right)
P = self.basis().keys()
return self.sum_of_terms([(P([p[i-1] for i in q]), x * y)
for (p, x) in a for (q, y) in b])
# Why did we use P([p[i-1] for i in q])
# instead of p.left_action_product(q) ?
# Because having cast a and b into self, we already know that
# p and q are permutations of the same number of elements,
# and thus we don't need to waste our time on the input
# sanitizing of left_action_product.
def right_action_product(self, left, right):
"""
Return the product of two elements ``left`` and ``right`` of
``self``, where multiplication is defined in such a way that
for two permutations `p` and `q`, the product `pq` is the
permutation obtained by first applying `p` and then applying
`q`. This definition of multiplication is tailored to make
multiplication of permutations associative with their action on
numbers if permutations are to act on numbers from the right.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: p1 = Permutation([2, 1, 3])
sage: p2 = Permutation([3, 1, 2])
sage: QS3.right_action_product(QS3(p1), QS3(p2))
[1, 3, 2]
sage: x = QS3([1, 2, 3]) - 2*QS3([1, 3, 2])
sage: y = 1/2 * QS3([3, 1, 2]) + 3*QS3([1, 2, 3])
sage: QS3.right_action_product(x, y)
3*[1, 2, 3] - 6*[1, 3, 2] + 1/2*[3, 1, 2] - [3, 2, 1]
sage: QS3.right_action_product(0, x)
0
The method coerces its input into the algebra ``self``::
sage: QS4 = SymmetricGroupAlgebra(QQ, 4)
sage: QS4.right_action_product(QS3([1, 2, 3]), QS3([2, 1, 3]))
[2, 1, 3, 4]
sage: QS4.right_action_product(1, Permutation([4, 1, 2, 3]))
[4, 1, 2, 3]
.. WARNING::
Note that coercion presently works from permutations of ``n``
into the ``n``-th symmetric group algebra, and also from all
smaller symmetric group algebras into the ``n``-th symmetric
group algebra, but not from permutations of integers smaller
than ``n`` into the ``n``-th symmetric group algebra.
"""
a = self(left)
b = self(right)
P = self.basis().keys()
return self.sum_of_terms([(P([q[i-1] for i in p]), x * y)
for (p, x) in a for (q, y) in b])
# Why did we use P([q[i-1] for i in p])
# instead of p.right_action_product(q) ?
# Because having cast a and b into self, we already know that
# p and q are permutations of the same number of elements,
# and thus we don't need to waste our time on the input
# sanitizing of right_action_product.
def canonical_embedding(self, other):
"""
Return the canonical embedding of ``self`` into ``other``.
INPUT:
- ``other`` -- a symmetric group algebra with order `p`
satisfying `p \leq n` where `n` is the order of ``self``.
EXAMPLES::
sage: QS2 = SymmetricGroupAlgebra(QQ, 2)
sage: QS4 = SymmetricGroupAlgebra(QQ, 4)
sage: phi = QS2.canonical_embedding(QS4); phi
Generic morphism:
From: Symmetric group algebra of order 2 over Rational Field
To: Symmetric group algebra of order 4 over Rational Field
sage: x = QS2([2,1]) + 2 * QS2([1,2])
sage: phi(x)
2*[1, 2, 3, 4] + [2, 1, 3, 4]
sage: loads(dumps(phi))
Generic morphism:
From: Symmetric group algebra of order 2 over Rational Field
To: Symmetric group algebra of order 4 over Rational Field
"""
if not isinstance(other, SymmetricGroupAlgebra_n) or self.n > other.n:
raise ValueError("There is no canonical embedding from {0} to {1}".format(other, self))
return self.module_morphism(other.monomial_from_smaller_permutation, codomain = other) # category = self.category() (currently broken)
def monomial_from_smaller_permutation(self, permutation):
"""
Convert ``permutation`` into a permutation, possibly extending it
to the appropriate size, and return the corresponding basis
element of ``self``.
EXAMPLES::
sage: QS5 = SymmetricGroupAlgebra(QQ, 5)
sage: QS5.monomial_from_smaller_permutation([])
[1, 2, 3, 4, 5]
sage: QS5.monomial_from_smaller_permutation(Permutation([3,1,2]))
[3, 1, 2, 4, 5]
sage: QS5.monomial_from_smaller_permutation([5,3,4,1,2])
[5, 3, 4, 1, 2]
TESTS::
sage: QS5.monomial_from_smaller_permutation([5,3,4,1,2]).parent()
Symmetric group algebra of order 5 over Rational Field
"""
P = self.basis().keys()
return self.monomial( P(permutation) )
def antipode(self, x):
r"""
Return the image of the element ``x`` of ``self`` under the
antipode of the Hopf algebra ``self`` (where the
comultiplication is the usual one on a group algebra).
Explicitly, this is obtained by replacing each permutation
`\sigma` by `\sigma^{-1}` in ``x`` while keeping all
coefficients as they are.
EXAMPLES::
sage: QS4 = SymmetricGroupAlgebra(QQ, 4)
sage: QS4.antipode(2 * QS4([1, 3, 4, 2]) - 1/2 * QS4([1, 4, 2, 3]))
-1/2*[1, 3, 4, 2] + 2*[1, 4, 2, 3]
sage: all( QS4.antipode(QS4(p)) == QS4(p.inverse())
....: for p in Permutations(4) )
True
sage: ZS3 = SymmetricGroupAlgebra(ZZ, 3)
sage: ZS3.antipode(ZS3.zero())
0
sage: ZS3.antipode(-ZS3(Permutation([2, 3, 1])))
-[3, 1, 2]
"""
return self.sum_of_terms([(p.inverse(), coeff) for
(p, coeff) in self(x)],
distinct=True)
def retract_plain(self, f, m):
r"""
Return the plain retract of the element `f \in R S_n`
to `R S_m`, where `m \leq n` (and where `R S_n` is ``self``).
If `m` is a nonnegative integer less or equal to `n`, then the
plain retract from `S_n` to `S_m` is defined as an `R`-linear
map `S_n \to S_m` which sends every permutation `p \in S_n`
to
.. MATH::
\begin{cases} \mbox{pret}(p) &\mbox{if } \mbox{pret}(p)\mbox{ is defined;} \\
0 & \mbox{otherwise} \end{cases}.
Here `\mbox{pret}(p)` denotes the plain retract of the
permutation `p` to `S_m`, which is defined in
:meth:`~sage.combinat.permutation.Permutation.retract_plain`.
EXAMPLES::
sage: SGA3 = SymmetricGroupAlgebra(QQ, 3)
sage: SGA3.retract_plain(2*SGA3([1,2,3]) - 4*SGA3([2,1,3]) + 7*SGA3([1,3,2]), 2)
2*[1, 2] - 4*[2, 1]
sage: SGA3.retract_plain(2*SGA3([1,3,2]) - 5*SGA3([2,3,1]), 2)
0
sage: SGA5 = SymmetricGroupAlgebra(QQ, 5)
sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 4)
11*[3, 2, 1, 4]
sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 3)
11*[3, 2, 1]
sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 2)
0
sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 1)
0
sage: SGA5.retract_plain(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 3)
8*[1, 2, 3] - 6*[1, 3, 2]
sage: SGA5.retract_plain(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 1)
8*[1]
sage: SGA5.retract_plain(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 0)
8*[]
.. SEEALSO::
:meth:`retract_direct_product`, :meth:`retract_okounkov_vershik`
"""
RSm = SymmetricGroupAlgebra(self.base_ring(), m)
pairs = []
for (p, coeff) in f.monomial_coefficients().iteritems():
p_ret = p.retract_plain(m)
if p_ret is not None:
pairs.append((p_ret, coeff))
return RSm.sum_of_terms(pairs, distinct=True)
def retract_direct_product(self, f, m):
r"""
Return the direct-product retract of the element `f \in R S_n`
to `R S_m`, where `m \leq n` (and where `R S_n` is ``self``).
If `m` is a nonnegative integer less or equal to `n`, then the
direct-product retract from `S_n` to `S_m` is defined as an
`R`-linear map `S_n \to S_m` which sends every permutation
`p \in S_n` to
.. MATH::
\begin{cases} \mbox{dret}(p) &\mbox{if } \mbox{dret}(p)\mbox{ is defined;} \\
0 & \mbox{otherwise} \end{cases}.
Here `\mbox{dret}(p)` denotes the direct-product retract of the
permutation `p` to `S_m`, which is defined in
:meth:`~sage.combinat.permutation.Permutation.retract_direct_product`.
EXAMPLES::
sage: SGA3 = SymmetricGroupAlgebra(QQ, 3)
sage: SGA3.retract_direct_product(2*SGA3([1,2,3]) - 4*SGA3([2,1,3]) + 7*SGA3([1,3,2]), 2)
2*[1, 2] - 4*[2, 1]
sage: SGA3.retract_direct_product(2*SGA3([1,3,2]) - 5*SGA3([2,3,1]), 2)
0
sage: SGA5 = SymmetricGroupAlgebra(QQ, 5)
sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 4)
11*[3, 2, 1, 4]
sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 3)
-6*[1, 3, 2] + 11*[3, 2, 1]
sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 2)
0
sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 1)
2*[1]
sage: SGA5.retract_direct_product(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 3)
8*[1, 2, 3] - 6*[1, 3, 2]
sage: SGA5.retract_direct_product(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 1)
2*[1]
sage: SGA5.retract_direct_product(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 0)
2*[]
.. SEEALSO::
:meth:`retract_plain`, :meth:`retract_okounkov_vershik`
"""
RSm = SymmetricGroupAlgebra(self.base_ring(), m)
dct = {}
for (p, coeff) in f.monomial_coefficients().iteritems():
p_ret = p.retract_direct_product(m)
if not (p_ret is None):
if not p_ret in dct.keys():
dct[p_ret] = coeff
else:
dct[p_ret] += coeff
return RSm._from_dict(dct)
def retract_okounkov_vershik(self, f, m):
r"""
Return the Okounkov-Vershik retract of the element `f \in R S_n`
to `R S_m`, where `m \leq n` (and where `R S_n` is ``self``).
If `m` is a nonnegative integer less or equal to `n`, then the
Okounkov-Vershik retract from `S_n` to `S_m` is defined as an
`R`-linear map `S_n \to S_m` which sends every permutation
`p \in S_n` to the Okounkov-Vershik retract of the permutation
`p` to `S_m`, which is defined in
:meth:`~sage.combinat.permutation.Permutation.retract_okounkov_vershik`.
EXAMPLES::
sage: SGA3 = SymmetricGroupAlgebra(QQ, 3)
sage: SGA3.retract_okounkov_vershik(2*SGA3([1,2,3]) - 4*SGA3([2,1,3]) + 7*SGA3([1,3,2]), 2)
9*[1, 2] - 4*[2, 1]
sage: SGA3.retract_okounkov_vershik(2*SGA3([1,3,2]) - 5*SGA3([2,3,1]), 2)
2*[1, 2] - 5*[2, 1]
sage: SGA5 = SymmetricGroupAlgebra(QQ, 5)
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 4)
-6*[1, 3, 2, 4] + 8*[1, 4, 2, 3] + 11*[3, 2, 1, 4]
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 3)
2*[1, 3, 2] + 11*[3, 2, 1]
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 2)
13*[1, 2]
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 1)
13*[1]
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 3)
8*[1, 2, 3] - 6*[1, 3, 2]
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 1)
2*[1]
sage: SGA5.retract_okounkov_vershik(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 0)
2*[]
.. SEEALSO::
:meth:`retract_plain`, :meth:`retract_direct_product`
"""
RSm = SymmetricGroupAlgebra(self.base_ring(), m)
dct = {}
for (p, coeff) in f.monomial_coefficients().iteritems():
p_ret = p.retract_okounkov_vershik(m)
if not p_ret in dct.keys():
dct[p_ret] = coeff
else:
dct[p_ret] += coeff
return RSm._from_dict(dct)
# def _coerce_start(self, x):
# """
# Coerce things into the symmetric group algebra.
# EXAMPLES::
# sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
# sage: QS3._coerce_start([])
# [1, 2, 3]
# sage: QS3._coerce_start([2,1])
# [2, 1, 3]
# sage: _.parent()
# Symmetric group algebra of order 3 over Rational Field
# """
# if x == []:
# return self( self._one )
# if len(x) < self.n and x in permutation.Permutations():
# return self( list(x) + range(len(x)+1, self.n+1) )
# raise TypeError
def cpis(self):
"""
Return a list of the centrally primitive idempotents of
``self``.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ,3)
sage: a = QS3.cpis()
sage: a[0] # [3]
1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
sage: a[1] # [2, 1]
2/3*[1, 2, 3] - 1/3*[2, 3, 1] - 1/3*[3, 1, 2]
"""
return [self.cpi(p) for p in partition.Partitions_n(self.n)]
def cpi(self, p):
"""
Return the centrally primitive idempotent for the symmetric group
of order `n` corresponding to the irreducible representation
indexed by the partition ``p``.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ,3)
sage: QS3.cpi([2,1])
2/3*[1, 2, 3] - 1/3*[2, 3, 1] - 1/3*[3, 1, 2]
sage: QS3.cpi([3])
1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
sage: QS3.cpi([1,1,1])
1/6*[1, 2, 3] - 1/6*[1, 3, 2] - 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] - 1/6*[3, 2, 1]
sage: QS0 = SymmetricGroupAlgebra(QQ, 0)
sage: QS0.cpi(Partition([]))
[]
TESTS::
sage: QS3.cpi([2,2])
Traceback (most recent call last):
...
TypeError: p (= [2, 2]) must be a partition of n (= 3)
"""
if p not in partition.Partitions_n(self.n):
raise TypeError("p (= {p}) must be a partition of n (= {n})".format(p=p, n=self.n))
character_table = eval(gap.eval("Display(Irr(SymmetricGroup(%d)));"%self.n))
np = partition.Partitions_n(self.n).list()
np.reverse()
p_index = np.index(p)
big_coeff = character_table[p_index][0] / factorial(self.n)
character_row = character_table[p_index]
P = self.basis().keys()
dct = { g : big_coeff * character_row[np.index(g.cycle_type())] for g in P }
return self._from_dict(dct)
def algebra_generators(self):
r"""
Return generators of this group algebra (as algebra) as a
list of permutations.
The generators used for the group algebra of `S_n` are the
transposition `(2, 1)` and the `n`-cycle `(1, 2, \ldots, n)`,
unless `n \leq 1` (in which case no generators are needed).
EXAMPLES::
sage: SymmetricGroupAlgebra(ZZ,5).algebra_generators()
[[2, 1, 3, 4, 5], [2, 3, 4, 5, 1]]
sage: SymmetricGroupAlgebra(QQ,0).algebra_generators()
[]
sage: SymmetricGroupAlgebra(QQ,1).algebra_generators()
[]
TESTS:
Check that :trac:`15309` is fixed::
sage: S3 = SymmetricGroupAlgebra(QQ, 3)
sage: S3.algebra_generators()
[[2, 1, 3], [2, 3, 1]]
sage: C = CombinatorialFreeModule(ZZ, ZZ)
sage: M = C.module_morphism(lambda x: S3.zero(), codomain=S3)
sage: M.register_as_coercion()
"""
if self.n <= 1:
return []
a = range(1, self.n+1)
a[0] = 2
a[1] = 1
b = range(2, self.n+2)
b[self.n-1] = 1
return [self.monomial(self._basis_keys(a)), self.monomial(self._basis_keys(b))]
def _conjugacy_classes_representatives_underlying_group(self):
r"""
Return a complete list of representatives of conjugacy
classes of the underlying symmetric group.
EXAMPLES::
sage: SG=SymmetricGroupAlgebra(ZZ,3)
sage: SG._conjugacy_classes_representatives_underlying_group()
[[2, 3, 1], [2, 1, 3], [1, 2, 3]]
"""
P = self.basis().keys()
return [P.element_in_conjugacy_classes(nu) for nu in partition.Partitions(self.n)]
def rsw_shuffling_element(self, k):
r"""
Return the `k`-th Reiner-Saliola-Welker shuffling element in
the group algebra ``self``.
The `k`-th Reiner-Saliola-Welker shuffling element in the
symmetric group algebra `R S_n` over a ring `R` is defined as the
sum `\sum_{\sigma \in S_n} \mathrm{noninv}_k(\sigma) \cdot \sigma`,
where for every permutation `\sigma`, the number
`\mathrm{noninv}_k(\sigma)` is the number of all
`k`-noninversions of `\sigma` (that is, the number of all
`k`-element subsets of `\{ 1, 2, \ldots, n \}` on which
`\sigma` restricts to a strictly increasing map). See
:meth:`sage.combinat.permutation.number_of_noninversions` for
the `\mathrm{noninv}` map.
This element is more or less the operator `\nu_{k, 1^{n-k}}`
introduced in [RSW2011]_; more precisely, `\nu_{k, 1^{n-k}}`
is the left multiplication by this element.
It is a nontrivial theorem (Theorem 1.1 in [RSW2011]_) that
the operators `\nu_{k, 1^{n-k}}` (for fixed `n` and varying
`k`) pairwise commute. It is a conjecture (Conjecture 1.2 in
[RSW2011]_) that all their eigenvalues are integers (which, in
light of their commutativity and easily established symmetry,
yields that they can be simultaneously diagonalized over `\QQ`
with only integer eigenvalues).
EXAMPLES:
The Reiner-Saliola-Welker shuffling elements on `\QQ S_3`::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: QS3.rsw_shuffling_element(0)
[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
sage: QS3.rsw_shuffling_element(1)
3*[1, 2, 3] + 3*[1, 3, 2] + 3*[2, 1, 3] + 3*[2, 3, 1] + 3*[3, 1, 2] + 3*[3, 2, 1]
sage: QS3.rsw_shuffling_element(2)
3*[1, 2, 3] + 2*[1, 3, 2] + 2*[2, 1, 3] + [2, 3, 1] + [3, 1, 2]
sage: QS3.rsw_shuffling_element(3)
[1, 2, 3]
sage: QS3.rsw_shuffling_element(4)
0
Checking the commutativity of Reiner-Saliola-Welker shuffling
elements (we leave out the ones for which it is trivial)::
sage: def test_rsw_comm(n):
....: QSn = SymmetricGroupAlgebra(QQ, n)
....: rsws = [QSn.rsw_shuffling_element(k) for k in range(2, n)]
....: return all( all( rsws[i] * rsws[j] == rsws[j] * rsws[i]
....: for j in range(i) )
....: for i in range(len(rsws)) )
sage: test_rsw_comm(3)
True
sage: test_rsw_comm(4)
True
sage: test_rsw_comm(5) # long time
True
.. NOTE::
For large ``k`` (relative to ``n``), it might be faster to call
``QSn.left_action_product(QSn.semi_rsw_element(k), QSn.antipode(binary_unshuffle_sum(k)))``
than ``QSn.rsw_shuffling_element(n)``.
.. SEEALSO::
:meth:`semi_rsw_element`, :meth:`binary_unshuffle_sum`
"""
P = self.basis().keys()
return self.sum_of_terms([(p, p.number_of_noninversions(k)) for p in P],
distinct=True)
def semi_rsw_element(self, k):
r"""
Return the `k`-th semi-RSW element in the group algebra ``self``.
The `k`-th semi-RSW element in the symmetric group algebra
`R S_n` over a ring `R` is defined as the sum of all permutations
`\sigma \in S_n` satisfying
`\sigma(1) < \sigma(2) < \cdots < \sigma(k)`.
This element has the property that, if it is denoted by `s_k`,
then `s_k S(s_k)` is `(n-k)!` times the `k`-th
Reiner-Saliola-Welker shuffling element of `R S_n` (see
:meth:`rsw_shuffling_element`). Here, `S` denotes the antipode
of the group algebra `R S_n`.
The `k`-th semi-RSW element is the image of the complete
non-commutative symmetric function `S^{(k, 1^{n-k})}` in the
ring of non-commutative symmetric functions under the canonical
projection on the symmetric group algebra (through the descent
algebra).
EXAMPLES:
The semi-RSW elements on `\QQ S_3`::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: QS3.semi_rsw_element(0)
[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
sage: QS3.semi_rsw_element(1)
[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
sage: QS3.semi_rsw_element(2)
[1, 2, 3] + [1, 3, 2] + [2, 3, 1]
sage: QS3.semi_rsw_element(3)
[1, 2, 3]
sage: QS3.semi_rsw_element(4)
0
Let us check the relation with the `k`-th Reiner-Saliola-Welker
shuffling element stated in the docstring::
sage: def test_rsw(n):
....: ZSn = SymmetricGroupAlgebra(ZZ, n)
....: for k in range(1, n):
....: a = ZSn.semi_rsw_element(k)
....: b = ZSn.left_action_product(a, ZSn.antipode(a))
....: if factorial(n-k) * ZSn.rsw_shuffling_element(k) != b:
....: return False
....: return True
sage: test_rsw(3)
True
sage: test_rsw(4)
True
sage: test_rsw(5) # long time
True
Let us also check the statement about the complete
non-commutative symmetric function::
sage: def test_rsw_ncsf(n):
....: ZSn = SymmetricGroupAlgebra(ZZ, n)
....: NSym = NonCommutativeSymmetricFunctions(ZZ)
....: S = NSym.S()
....: for k in range(1, n):
....: a = S(Composition([k] + [1]*(n-k))).to_symmetric_group_algebra()
....: if a != ZSn.semi_rsw_element(k):
....: return False
....: return True
sage: test_rsw_ncsf(3)
True
sage: test_rsw_ncsf(4)
True
sage: test_rsw_ncsf(5) # long time
True
"""
n = self.n
if n < k:
return self.zero()
def complement(xs):
res = range(1, n+1)
for x in xs:
res.remove(x)
return res
P = Permutations()
return self.sum_of_monomials([P(complement(q) + list(q))
for q in Permutations_nk(n, n-k)])
def binary_unshuffle_sum(self, k):
r"""
Return the `k`-th binary unshuffle sum in the group algebra
``self``.
The `k`-th binary unshuffle sum in the symmetric group algebra
`R S_n` over a ring `R` is defined as the sum of all permutations
`\sigma \in S_n` satisfying
`\sigma(1) < \sigma(2) < \cdots < \sigma(k)` and
`\sigma(k+1) < \sigma(k+2) < \cdots < \sigma(n)`.
This element has the property that, if it is denoted by `t_k`,
and if the `k`-th semi-RSW element (see :meth:`semi_rsw_element`)
is denoted by `s_k`, then `s_k S(t_k)` and `t_k S(s_k)` both
equal the `k`-th Reiner-Saliola-Welker shuffling element of
`R S_n` (see :meth:`rsw_shuffling_element`).
The `k`-th binary unshuffle sum is the image of the complete
non-commutative symmetric function `S^{(k, n-k)}` in the
ring of non-commutative symmetric functions under the canonical
projection on the symmetric group algebra (through the descent
algebra).
EXAMPLES:
The binary unshuffle sums on `\QQ S_3`::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: QS3.binary_unshuffle_sum(0)
[1, 2, 3]
sage: QS3.binary_unshuffle_sum(1)
[1, 2, 3] + [2, 1, 3] + [3, 1, 2]
sage: QS3.binary_unshuffle_sum(2)
[1, 2, 3] + [1, 3, 2] + [2, 3, 1]
sage: QS3.binary_unshuffle_sum(3)
[1, 2, 3]
sage: QS3.binary_unshuffle_sum(4)
0
Let us check the relation with the `k`-th Reiner-Saliola-Welker
shuffling element stated in the docstring::
sage: def test_rsw(n):
....: ZSn = SymmetricGroupAlgebra(ZZ, n)
....: for k in range(1, n):
....: a = ZSn.semi_rsw_element(k)
....: b = ZSn.binary_unshuffle_sum(k)
....: c = ZSn.left_action_product(a, ZSn.antipode(b))
....: d = ZSn.left_action_product(b, ZSn.antipode(a))
....: e = ZSn.rsw_shuffling_element(k)
....: if c != e or d != e:
....: return False
....: return True
sage: test_rsw(3)
True
sage: test_rsw(4) # long time
True
sage: test_rsw(5) # long time
True
Let us also check the statement about the complete
non-commutative symmetric function::
sage: def test_rsw_ncsf(n):
....: ZSn = SymmetricGroupAlgebra(ZZ, n)
....: NSym = NonCommutativeSymmetricFunctions(ZZ)
....: S = NSym.S()
....: for k in range(1, n):
....: a = S(Composition([k, n-k])).to_symmetric_group_algebra()
....: if a != ZSn.binary_unshuffle_sum(k):
....: return False
....: return True
sage: test_rsw_ncsf(3)
True
sage: test_rsw_ncsf(4)
True
sage: test_rsw_ncsf(5) # long time
True
"""
n = self.n
if n < k:
return self.zero()
def complement(xs):
res = range(1, n+1)
for x in xs:
res.remove(x)
return res
from sage.combinat.subset import Subsets
P = Permutations()
return self.sum_of_monomials([P(sorted(q) + complement(q)) for q in Subsets(n, k)])
def jucys_murphy(self, k):
r"""
Return the Jucys-Murphy element `J_k` (also known as a
Young-Jucys-Murphy element) for the symmetric group
algebra ``self``.
The Jucys-Murphy element `J_k` in the symmetric group algebra
`R S_n` is defined for every `k \in \{ 1, 2, \ldots, n \}` by
.. MATH::
J_k = (1, k) + (2, k) + \cdots + (k-1, k) \in R S_n,
where the addends are transpositions in `S_n` (regarded as
elements of `R S_n`). We note that there is not a dependence on `n`,
so it is often surpressed in the notation.
EXAMPLES::
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: QS3.jucys_murphy(1)
0
sage: QS3.jucys_murphy(2)
[2, 1, 3]
sage: QS3.jucys_murphy(3)
[1, 3, 2] + [3, 2, 1]
sage: QS4 = SymmetricGroupAlgebra(QQ, 4)
sage: j3 = QS4.jucys_murphy(3); j3
[1, 3, 2, 4] + [3, 2, 1, 4]
sage: j4 = QS4.jucys_murphy(4); j4
[1, 2, 4, 3] + [1, 4, 3, 2] + [4, 2, 3, 1]
sage: j3*j4 == j4*j3
True
sage: QS5 = SymmetricGroupAlgebra(QQ, 5)
sage: QS5.jucys_murphy(4)
[1, 2, 4, 3, 5] + [1, 4, 3, 2, 5] + [4, 2, 3, 1, 5]
TESTS::
sage: QS3.jucys_murphy(4)
Traceback (most recent call last):
...
ValueError: k (= 4) must be between 1 and n (= 3) (inclusive)
"""
if k < 1 or k > self.n:
raise ValueError("k (= {k}) must be between 1 and n (= {n}) (inclusive)".format(k=k, n=self.n))
res = self.zero()
for i in range(1, k):
p = range(1, self.n+1)
p[i-1] = k
p[k-1] = i
res += self.monomial(self._basis_keys(p))
return res
def seminormal_basis(self, mult='l2r'):
r"""
Return a list of the seminormal basis elements of ``self``.
The seminormal basis of a symmetric group algebra is defined as
follows:
Let `n` be a nonnegative integer. Let `R` be a `\QQ`-algebra.
In the following, we will use the "left action" convention for
multiplying permutations. This means that for all permutations
`p` and `q` in `S_n`, the product `pq` is defined in such a way
that `(pq)(i) = p(q(i))` for each `i \in \{ 1, 2, \ldots, n \}`
(this is the same convention as in :meth:`left_action_product`,
but not the default semantics of the `*` operator on
permutations in Sage). Thus, for instance, `s_2 s_1` is the
permutation obtained by first transposing `1` with `2` and
then transposing `2` with `3` (where `s_i = (i, i+1)`).
For every partition `\lambda` of `n`, let
.. MATH::
\kappa_{\lambda} = \frac{n!}{f^{\lambda}}
where `f^{\lambda}` is the number of standard Young tableaux
of shape `\lambda`. Note that `\kappa_{\lambda}` is an integer,
namely the product of all hook lengths of `\lambda` (by the
hook length formula). In Sage, this integer can be computed by
using :func:`sage.combinat.symmetric_group_algebra.kappa()`.
Let `T` be a standard tableau of size `n`.