-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSchurRings.m2
3587 lines (3073 loc) · 105 KB
/
SchurRings.m2
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
---*- coding: utf-8 -*-
--------------------------------------------------------------------------------
-- Copyright 2007, 2011 Michael Stillman
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU General Public License as published by the Free Software
-- Foundation, either version 3 of the License, or (at your option) any later
-- version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-- details.
--
-- You should have received a copy of the GNU General Public License along with
-- this program. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------
newPackage(
"SchurRings",
Version => "1.1",
Date => "August 24, 2011",
Authors => {
{Name => "Michael Stillman", Email => "[email protected]", HomePage => "http://www.math.cornell.edu/~mike/"},
{Name => "Hal Schenck"},
{Name => "Claudiu Raicu", Email => "[email protected]", HomePage => "http://math.berkeley.edu/~claudiu/"}
},
Headline => "representation rings of general linear groups and of symmetric groups",
DebuggingMode => true
-- AuxiliaryFiles => true
)
export {"schurRing", "SchurRing", "symmetricRing",
"toS", "toE", "toP", "toH",
"jacobiTrudi", "plethysm",
"centralizerSize", "classFunction", "symmetricFunction",
"scalarProduct", "internalProduct",
"SchurRingIndexedVariableTable", "EHPVariables", "SVariable",
"ClassFunction", "schurLevel",
"schurResolution",
"SchurRingElement",
"Memoize", "Schur", "EorH", "GroupActing",
"eVariable", "pVariable", "hVariable"
}
debug Core
protect symbol symRingForE;
protect symbol mapToE;
protect symbol symRingForP;
protect symbol mapToP;
protect symbol mapFromP;
protect symbol grbE
protect symbol PtoETable
protect symbol HtoETable
protect symbol grbH
protect symbol PtoHTable
protect symbol EtoHTable
protect symbol grbP
protect symbol EtoPTable
protect symbol HtoPTable
--protect symbol plethysmMaps
protect symbol mapFromE
protect symbol sFunction
SchurRing = new Type of EngineRing
SchurRing.synonym = "Schur ring"
ClassFunction = new Type of HashTable
ClassFunction.synonym = "Class function"
expression SchurRing := S -> new FunctionApplication from { schurRing, (expression last S.baseRings, S.Symbol, S.numgens ) }
undocumented (expression, SchurRing)
toExternalString SchurRing := R -> toString expression R
undocumented (toExternalString, SchurRing),
toString SchurRing := R -> (
if hasAttribute(R,ReverseDictionary) then toString getAttribute(R,ReverseDictionary)
else toString expression R)
undocumented (toString, SchurRing)
net SchurRing := R -> (
if hasAttribute(R,ReverseDictionary) then toString getAttribute(R,ReverseDictionary)
else net expression R)
undocumented (net, SchurRing)
rawmonom2partition = (m) -> (
reverse splice apply(rawSparseListFormMonomial m, (x,e) -> e:x)
)
--various ways of addressing elements of a Schur ring
SchurRing _ List := (SR, L) -> new SR from rawSchurFromPartition(raw SR, L)
SchurRing _ Sequence := (SR, L) -> new SR from rawSchurFromPartition(raw SR, L)
SchurRing _ ZZ := (SR, L) -> new SR from rawSchurFromPartition(raw SR, 1:L)
--
coefficientRing SchurRing := Ring => R -> last R.baseRings
numgens SchurRing := Ring => R -> R.numgens
--n = schurLevel R is the number of iterations of the schurRing/symmetricRing function
--used in the construction of R
schurLevel = method()
schurLevel (Ring) := R -> if R.?schurLevel then R.schurLevel else 0
--Construction of Schur rings
newSchur2 = method()
newSchur2(Ring,Symbol) := (A,p) -> newSchur2(A,p,-1)
SchurRingElement = new Type of RingElement
newSchurEngineRing = R -> (
S := new SchurRing of SchurRingElement;
S.RawRing = R;
S#1 = 1_S;
S#0 = 0_S;
S)
newSchur2(Ring,Symbol,ZZ) := (A,p,n) -> (
if not (A.?Engine and A.Engine)
then error "expected coefficient ring handled by the engine";
SR := newSchurEngineRing rawSchurRing1(raw A,n);
SR.Symbol = p;
SR.baseRings = append(A.baseRings,A);
SR.generators = {};
SR.numgens = if n < 0 then infinity else n;
SR.degreeLength = 0;
--the basic features of SR are coded at the engine level
commonEngineRingInitializations SR;
ONE := SR#1;
if A.?char then SR.char = A.char;
toExternalString SR := r -> toString expression r;
expression SR := f -> (
(coeffs,monoms) -> sum(
coeffs,monoms,
(a,m) -> expression (if a == 1 then 1 else new A from a) *
new Subscript from {p, (
t1 := toSequence rawmonom2partition m;
if #t1 === 1 then t1#0 else t1
)})
) rawPairs(raw A, raw f);
listForm SR := (f) -> (
n := numgens SR;
(cc,mm) := rawPairs(raw A, raw f);
toList apply(cc, mm, (c,m) -> (rawmonom2partition m, new A from c)));
if (A.?schurLevel) then SR.schurLevel = A.schurLevel + 1
else SR.schurLevel = 1;
SR
)
schurRing = method(Options => {EHPVariables => (getSymbol"e",getSymbol"h",getSymbol"p"), SVariable => getSymbol"s", GroupActing => "GL"})
schurRing(Ring,Thing,ZZ) := SchurRing => opts -> (A,p,n) -> (
try p = baseName p else error "schurRing: can't use provided thing as variable";
if class p === Symbol then schurRing(A,p,n,opts)
else error "schurRing: can't use provided thing as variable"
);
schurRing(Ring,Thing) := SchurRing => opts -> (A,p) -> (
try p = baseName p else error "schurRing: can't use provided thing as variable";
if class p === Symbol then schurRing(A,p,opts)
else error "schurRing: can't use provided thing as variable"
);
dim SchurRingElement := s -> dimSchur s;
dim(List,SchurRingElement) := (lis,s) -> dimSchur(lis, s);
dim(Thing,SchurRingElement) := (n,s) -> dimSchur(n, s);
schurRing(Ring,Symbol) := opts -> (R,p) -> schurRing(R,p,infinity,opts)
schurRing(Ring,Symbol,InfiniteNumber) :=
schurRing(Ring,Symbol,ZZ) := SchurRing => opts -> (R,p,n) -> (
S := local S;
if n == infinity then S = newSchur2(R,p,-1) else S = newSchur2(R,p,n);
S.EHPVariables = opts.EHPVariables;
--S.SVariable = opts.SVariable;
S.GroupActing = opts.GroupActing;
S @ RingElement := RingElement @ S := (f1,f2) -> plethysm(f1,f2);
S^ZZ := (f,n) -> product apply(n,i->f);
symmetricPower(ZZ,S) := (n,s) -> plethysm({n},s);
exteriorPower(ZZ,S) := opts -> (n,s) -> plethysm(splice{n:1},s);
--define the multiplication on S
--in the case when the group acting is a general linear group
if opts.GroupActing == "GL" then
(
oldmult := method();
oldmult(S,S) := (f1,f2) -> new S from raw f1 * raw f2;
oldmult(RingElement, S) := (f1,f2) -> if member(ring f1,S.baseRings | {S}) then oldmult(promote(f1,S),f2);
oldmult(S, RingElement) := (f1,f2) -> if member(ring f2,S.baseRings | {S}) then oldmult(f1,promote(f2,S));
oldmult(Number, S) := (f1,f2) -> if member(ring f1,S.baseRings | {S}) then oldmult(promote(f1,S),f2);
oldmult(S, Number) := (f1,f2) -> if member(ring f2,S.baseRings | {S}) then oldmult(f1,promote(f2,S));
S * S := (f1,f2) ->
if schurLevel S == 1 then oldmult(f1,f2)
else
(
lF1 := listForm f1;
lF2 := listForm f2;
sum flatten for p1 in lF1 list
for p2 in lF2 list
(
oldmult((last p1) * (last p2), oldmult(S_(first p1),S_(first p2)))
)
);
)
--define the multiplication on S
--in the case when the group acting is a symmetric group
else if opts.GroupActing == "Sn" then
(
S ** S := (f1,f2) -> new S from raw f1 * raw f2;
-- RingElement ** S := (f,g) -> if member(ring f,S.baseRings | {S}) then promote(f,S) ** g;
-- S ** RingElement := (f,g) -> if member(ring g,S.baseRings | {S}) then f ** promote(g,S);
RingElement ** S := (f,g) -> if member(ring f,S.baseRings | {S}) then promote(f,S) ** g
else if member(S,(ring f).baseRings | {ring f}) then f ** promote(g,S);
Number ** S := (f,g) -> if member(ring f,S.baseRings | {S}) then promote(f,S) ** g;
S ** Number := (f,g) -> if member(ring g,S.baseRings | {S}) then f ** promote(g,S);
S * S := (f1,f2) ->
if schurLevel S == 1 then
(
cS := coefficientRing S;
if liftable(f1,cS) or liftable(f2,cS) then f1 ** f2 else
if f1 == 0 or f2 == 0 then 0_S else
internalProduct(f1,f2)
)
else
(
lF1 := listForm f1;
lF2 := listForm f2;
sum flatten for p1 in lF1 list
for p2 in lF2 list
(
((last p1) * (last p2)) ** internalProduct(S_(first p1),S_(first p2))
)
);
);
t := new SchurRingIndexedVariableTable from p;
t.SchurRing = S;
t#symbol _ = a -> ( S _ a);
S.use = S -> (globalAssign(p,t); S);
S.use S;
S)
--constructs the Schur ring of a symmetric ring R
--this is a ring with basis consisting of s-polynomials (Schur functions) that
--is abstractly isomorphic to R
--schurRingOf = method()
--schurRingOf (Ring) := R -> (
schurRing (Ring) := opts -> R -> (
if R.?Schur then R.Schur else
if schurLevel R > 0 then
(
if instance(R, SchurRing) then R else
(
s := R.SVariable;
if schurLevel R == 1 then R.Schur = schurRing(coefficientRing R,s,R.dim,EHPVariables => R.EHPVariables, GroupActing => R.GroupActing)
else R.Schur = schurRing(schurRing coefficientRing R,s,R.dim,EHPVariables => R.EHPVariables, GroupActing => R.GroupActing); --symmetricRing is wrong, right?
R.Schur.symmetricRing = R;
R.Schur
)
)
else error"Expected ring to have a Schur Ring"
)
schurRing(Thing,ZZ) := opts -> (s,n) -> schurRing(QQ,s,n,opts)
schurRing(Thing,InfiniteNumber) := opts -> (s,n) -> schurRing(QQ,s,n,opts)
schurRing(Thing) := opts -> (s) -> schurRing(QQ,s,-1,opts)
undocumented (schurRing,Ring,Symbol,InfiniteNumber)
undocumented (schurRing,Thing,InfiniteNumber)
--a new type that indexes the elements in the s-basis of a Schur ring
SchurRingIndexedVariableTable = new Type of IndexedVariableTable
SchurRingIndexedVariableTable _ Thing := (x,i) -> x#symbol _ i
--construction of symmetric rings
symmetricRing = method(Options => options schurRing)
symmetricRing (Ring,ZZ) := opts -> (A,n) -> (
(e,h,p) := opts.EHPVariables;
R := A[e_1..e_n,p_1..p_n,h_1..h_n,
Degrees => toList(1..n,1..n,1..n), MonomialSize => 8];
R.EHPVariables = opts.EHPVariables;
R.SVariable = opts.SVariable;
R.eVariable = (i) -> if 1 <= i and i <= n then R_(i-1) else error"Invalid index";
R.pVariable = (i) -> if 1 <= i and i <= n then R_(n+i-1) else error"Invalid index";
R.hVariable = (i) -> if 1 <= i and i <= n then R_(2*n+i-1) else error"Invalid index";
R.GroupActing = opts.GroupActing;
R.dim = n;
R ** R := (f1,f2) -> internalProduct(f1,f2); --internal product of symmetric functions
R @ RingElement := RingElement @ R := (f1,f2) -> plethysm(f1,f2);
symmetricPower(ZZ,R) := (n,r) -> plethysm({n},r);
exteriorPower(ZZ,R) := opts -> (n,r) -> plethysm(splice{n:1},r);
--the degrees of e_i,p_i,h_i are equal to i
degsEHP := toList(1..n);
--blocks#0 are indeces for e-variables
--blocks#1 are indeces for p-variables
--blocks#2 are indeces for h-variables
blocks := {toList(0..(n-1)),toList(n..(2*n-1)),toList(2*n..(3*n-1))};
--new variables for the E,H,P polynomials
vrs := symbol vrs;
locVarsE := apply(blocks#0,i->vrs_i);
locVarsP := apply(blocks#1,i->vrs_i);
locVarsH := apply(blocks#2,i->vrs_i);
--new rings used for conversion to E- and P- polynomials
--they differ from R in the order of the variables
--R is used by default for conversion to H-polynomials
R.symRingForE = A[locVarsH | locVarsP | locVarsE ,Degrees=>flatten toList(3:degsEHP),MonomialOrder=>GRevLex, MonomialSize => 8];
R.mapToE = map(R.symRingForE,R,apply(blocks#2|blocks#1|blocks#0,i->(R.symRingForE)_i));
R.mapFromE = map(R,R.symRingForE,apply(blocks#2|blocks#1|blocks#0,i->R_i));
R.symRingForP = A[locVarsH | locVarsE | locVarsP,Degrees=>flatten toList(3:degsEHP),MonomialOrder=>GRevLex, MonomialSize => 8];
R.mapToP = map(R.symRingForP,R,apply(blocks#1|blocks#2|blocks#0,i->(R.symRingForP)_i));
R.mapFromP = map(R,R.symRingForP,apply(blocks#2|blocks#0|blocks#1,i->R_i));
--compute conversion tables
--between E-,H- and P- polynomials
EtoP(n,R);
PtoE(n,R);
HtoE(n,R);
EtoH(n,R);
PtoH(n,R);
HtoP(n,R);
--define Groebner bases used for conversion between E-,H- and P- polynomials
R.grbE = forceGB matrix{flatten apply(splice{1..n},i->{R.mapToE(R_(n-1+i))-R.PtoETable#i,R.mapToE(R_(2*n-1+i))-R.HtoETable#i})};
R.grbH = forceGB matrix{flatten apply(splice{1..n},i->{R_(n-1+i)-R.PtoHTable#i,R_(-1+i)-R.EtoHTable#i})};
R.grbP = forceGB matrix{flatten apply(splice{1..n},i->{R.mapToP(R_(-1+i))-R.EtoPTable#i,R.mapToP(R_(2*n-1+i))-R.HtoPTable#i})};
collectGarbage();
--construct maps that convert a polynomial in the E-,H-,P- variables
--into one involving only one of the three variables
R.mapSymToE = (f) -> R.mapFromE(R.mapToE(f)%R.grbE);
R.mapSymToP = (f) -> R.mapFromP(R.mapToP(f)%R.grbP);
R.mapSymToH = (f) -> f%R.grbH;
--the Schur level of R is one more than that of its base ring
if (A.?schurLevel) then R.schurLevel = A.schurLevel + 1
else R.schurLevel = 1;
R)
--constructs the symmetric ring of a Schur ring
--if the Schur ring has dimension n, its symmetric ring is the polynomial ring
--in the variables e_1,...,e_n,p_1,...,p_n,h_1,...,h_n, i.e. the other types of
--symmetric functions (besides the Schur functions) that the package implements
symmetricRing (Ring) := opts -> R -> (
if R.?symmetricRing then R.symmetricRing else
if class R === SchurRing then
(
if numgens R === infinity then
error"symmetric ring expects finite schurRings";
if coefficientRing R === ZZ then
error"base ring has to be QQ";
R.symmetricRing = symmetricRing(symmetricRing coefficientRing R,numgens R,EHPVariables => R.EHPVariables, SVariable => R.Symbol, GroupActing => R.GroupActing);
R.symmetricRing.Schur = R;
R.symmetricRing
)
else R
)
symmetricRing(ZZ) := opts -> n -> symmetricRing(QQ,n,opts)
---------------------------------------------------------------
--------------Jacobi-Trudi-------------------------------------
---------------------------------------------------------------
----local variables for jacobiTrudi
----they are used in the recursive function jT
auxR = local auxR;
auxn = local auxn;
auxEH = local auxEH;
----
jacobiTrudi = method(Options => {Memoize => true, EorH => "E"})
jacobiTrudi(BasicList,Ring) := opts -> (lambda,R) ->
(
lam := new Partition from lambda;
rez := local rez;
local u;
if opts.EorH == "H" then u = R.hVariable else (u = R.eVariable;lam = conjugate lam;);
if opts.Memoize then
(
if not R.?sFunction then R.sFunction = new MutableHashTable;
if opts.EorH == "E" then
(
-----sFunction#0 records s-polynomials in terms of the e-variables
if not R.sFunction#?0 then R.sFunction#0 = new MutableHashTable;
auxEH = 0;
)
else
(
-----sFunction#1 records s-polynomials in terms of the h-variables
if not R.sFunction#?1 then R.sFunction#1 = new MutableHashTable;
auxEH = 1;
);
auxR = R;
auxn = R.dim;
rez = jT(lam);
)
else
(
n := #lam;
rez = det(map(R^n, n, (i,j) ->
(
aux := lam#i-i+j;
if aux < 0 or aux>R.dim then 0_R
else if aux == 0 then 1_R else u aux)
),
Strategy => Cofactor);
);
rez
)
--computes the Jacobi-Trudi determinant recursively
jT = (lambda) ->
(
lambda = toList lambda;
rez := local rez;
if auxR.sFunction#auxEH#?lambda then rez = auxR.sFunction#auxEH#lambda
else
(
ll := #lambda;
if ll == 0 or lambda#0 == 0 then rez = 1_auxR else
if ll == 1 then rez = auxR_(2*auxEH*auxn-1+lambda#0) else
(
l1 := drop(lambda,-1);
l2 := {};
rez = 0;
sgn := 1;
for i from 0 to ll-1 do
(
if lambda#(ll-1-i)+i<=auxn then --just added, won't work for h-polynomials
rez = rez + sgn*auxR_(2*auxEH*auxn-1+lambda#(ll-1-i)+i)*jT(l1|l2);
sgn = - sgn;
l1 = drop(l1,-1);
if lambda#(ll-1-i)>1 then
l2 = {lambda#(ll-1-i)-1} | l2;
);
);
auxR.sFunction#auxEH#lambda = rez;
);
rez
)
---------------------------------------------------------------
--------------End Jacobi-Trudi---------------------------------
---------------------------------------------------------------
---------------------------------------------------------------
--------------Plethysm-----------------------------------------
---------------------------------------------------------------
--the cycle type of the k-th power of any permutation of cycle type cyc
powerCycleType := method()
powerCycleType(ZZ,List) := (k,cyc) ->
(
rsort(flatten (for i in cyc list (g := gcd(i,k);splice{g:i//g})))
)
-- d is an integer
-- R is symmetricRing n
-- returns the plethysm map p_d : R --> R
-- which sends p_i to p_(i*d).
plethysmMap = (d,maxg,R) -> (
nS := R.dim;
nSd := nS // d;
fs := splice{nS:0_R};
topf := min(maxg,nSd);
fs = join(fs, apply(1..topf, j -> R.pVariable(d*j)));
if maxg > nSd then
fs = join(fs, apply(topf+1..maxg,j-> R.mapFromE R.PtoETable#(d*j)));
fs = join(fs, 2*nS-maxg:0_R);
map(R,R,fs)
)
-- exterior plethysm (corresponding to composition
-- of Schur functors of GL-representations)
-- f is a polynomial in symmetricRing / SchurRing SA
-- g is a polynomial in symmetricRing / SchurRing SB
-- result is in symmetricRing / SchurRing SB
plethysmGL = method()
plethysmGL(RingElement,RingElement) := (f,g) -> (
Rg := ring g;
Rf := ring f;
if schurLevel Rf > 1 then error"Undefined plethysm operation";
issy := not instance(Rg,SchurRing);
pg := toP g;
pf := toP f;
SRg := ring pg; --symmetric ring of Rg
SRf := ring pf; --symmetric ring of Rf
nf := SRf.dim;
--maxf is the maximum i for which the variable p_i appears in the expression of pf
maxf := max(support(pf)/index//max-nf+1,0);
auxS := SRg;
nS := auxS.dim;
lev := schurLevel auxS;
spg := support(pg)/index;
--maxg is the maximum i for which the variable p_i appears in the expression of pg
maxg := max(select(spg,i->i<3*nS)//max-nS+1,0);
--if p_(maxf*maxg) hasn't been computed in terms of E-polynomial, then compute it
if maxf*maxg >= #auxS.PtoETable then PtoE(maxf*maxg,auxS);
--phi is the map that sends p_i to the plethystic composition p_i\circ pg
--so that phi(f) = f \circ pg (plethysm of f and pg)
phi := map(SRg,SRf,flatten splice {nf:0_SRg,
apply(1..nf, j -> (if j<=maxf then (plethysmMap(j,maxg,SRg))pg else 0_SRg)),
nf:0_SRg});
pl := phi pf;
if issy then pl else toS pl
)
-- interior plethysm (corresponding to the result of
-- the application of a Schur functor to an S_n-representation)
-- f is a polynomial in symmetricRing N / SchurRing SA
-- g is a polynomial in symmetricRing n / SchurRing SB
-- result is in symmetricRing n / SchurRing SB
plethysmSn = method()
plethysmSn(RingElement,RingElement) := (f,g) ->
(
symmetricFunction(plethysm(f,classFunction g), ring g)
)
-- plethysm of symmetric functions
plethysm = method()
-- this function is not exported
-- it is used to compute the plethysm of f and g
-- when f is a power-sum symmetric polynomial
auxplet = method()
auxplet(RingElement,RingElement) := (f,g) ->
(
Rg := ring g;
pl := local pl;
if Rg.GroupActing == "GL" then pl = plethysmGL else
if Rg.GroupActing == "Sn" then pl = plethysmSn;
sLg := schurLevel Rg;
if sLg == 1 then return pl(f,g) else
(
lF := listForm g;
return sum for t in lF list auxplet(f,last t) * pl(f,Rg_(first t))
);
)
-- the most general form of plethysm
-- f is an arbitrary symmetric functions
-- g is an element of a representation ring of a product of general linear and/or symmetric groups
plethysm(RingElement,RingElement) := (f,g) ->
(
pf := toP f;
Rf := ring pf;
if schurLevel Rf > 1 then error"Undefined plethysm operation";
pls := new MutableHashTable from {};
lpf := listForm pf;
m := (ring pf).dim;
isSchur := instance(ring g,SchurRing);
auxg := local auxg;
if isSchur then auxg = g else auxg = toS g;
pl := sum for t in lpf list ((last t) * product select(apply(splice{0..m-1}, i -> (ex := (first t)#(m+i);
if ex > 0 then (if pls#?i then (pls#i)^ex else
(pls#i = auxplet(Rf.pVariable(i+1),auxg);(pls#i)^ex)))),j -> j =!= null)); -- this is bad when g is not in a SchurRing
if isSchur then pl else toSymm pl
)
-- plethysm of s_lambda and g
plethysm(BasicList,RingElement) := (lambda,g) -> (
d := sum toList lambda;
Rf := symmetricRing(QQ,d);
f := jacobiTrudi(lambda,Rf);
plethysm(f,g)
)
-- (inner) plethysm of symmetric function f with the class function cF (the character of a certain S_n-representation)
plethysm(RingElement,ClassFunction) := (f,cF) ->
(
R := ring(cF#(first keys cF));
pf := toP f;
n := degree cF;
k := (ring pf).dim;
pvars := (ring pf).pVariable;
parsn := toList \ partitions(n);
newHT := new MutableHashTable;
for sig in parsn do
(
sublist := for i from 1 to k list
(
pct := powerCycleType(i,sig);
if cF#?pct then cF#pct else 0
);
newHT#sig = (map(R,ring pf,splice{k:0} | sublist | splice{k:0})) pf;
);
new ClassFunction from newHT
)
-- (inner) plethysm of s_lambda with the class function cF (the character of a certain S_n-representation)
plethysm(BasicList,ClassFunction) := (lambda,cF) -> (
d := sum toList lambda;
Rf := symmetricRing(QQ,d);
f := jacobiTrudi(lambda,Rf);
plethysm(f,cF))
{*
-- degree of a polynomial in a SchurRing
-- this is no longer used
degSchurPol = method()
degSchurPol(RingElement) := ps -> (
tms := listForm ps;
tms/first/sum//max
)
*}
---------------------------------------------------------------
-----------End plethysm----------------------------------------
---------------------------------------------------------------
---------------------------------------------------------------
----Transition between various types of symmetric functions----
---------------------------------------------------------------
-- toSymm
toSymm = method()
-- if ps is an element of a schurRing R
-- toSymm returns the symmetric function corresponding to ps, as an element of a symmetricRing, the symmetricRing R;
-- otherwise ps is returned;
toSymm(RingElement) := (ps) ->
(
S := ring ps;
if instance(S, SchurRing) then
(
R := symmetricRing S;
tms := listForm ps;
--each term s_lambda in ps is transformed into an element of R using the jacobiTrudi routine
sum apply(tms,(p,a)->(
(try b:=jacobiTrudi(p,R) then b else error"Need symmetric ring of higher dimension")*
toSymm(lift(a,coefficientRing S))))
)
else return ps
)
-- this is the base case of the recursive operation in the general case
-- needed when ps is an element of ZZ or QQ, because ZZ, QQ don't have
-- RingElement as an ancestor
toSymm(Number) := (ps) -> ps
mapSymToE = method()
-- writes the symmetric functions of maximal schurLevel in f (i.e. those
-- not contained in the coefficient ring of R) in terms of the e-polynomials
mapSymToE (RingElement) := (f) -> (
R:=ring f;
if R.?mapSymToE then R.mapSymToE f else f
)
mapSymToH = method()
-- writes the symmetric functions of maximal schurLevel in f (i.e. those
-- not contained in the coefficient ring of R) in terms of the h-polynomials
mapSymToH (RingElement) := (f) -> (
R:=ring f;
if R.?mapSymToH then R.mapSymToH f else f
)
mapSymToP = method()
-- writes the symmetric functions of maximal schurLevel in f (i.e. those
-- not contained in the coefficient ring of R) in terms of the p-polynomials
mapSymToP (RingElement) := (f) -> (
R:=ring f;
if R.?mapSymToP then R.mapSymToP f else f
)
toE = method()
-- writes a symmetric function (possibly in a ring
-- with schurLevel larger than one) in terms of
-- elementary symmetric polynomials
toE (RingElement) := (f) -> (
R := ring f;
if class R === SchurRing then toE toSymm f
else
(
if not R.?schurLevel then f else
if R.schurLevel>1 then terms f/(i->(toE leadCoefficient i*(mapSymToE leadMonomial i)))//sum
else mapSymToE f
)
)
toP = method()
-- writes a symmetric function (possibly in a ring
-- with schurLevel larger than one) in terms of
-- power sums
toP (RingElement) := (f) -> (
R := ring f;
if class R === SchurRing then toP toSymm f
else
(
if not R.?schurLevel then f else
if R.schurLevel>1 then terms f/(i->(toP leadCoefficient i*(mapSymToP leadMonomial i)))//sum
else mapSymToP f
)
)
toH = method()
-- writes a symmetric function (possibly in a ring
-- with schurLevel larger than one) in terms of
-- complete symmetric polynomials
toH (RingElement) := (f) -> (
R := ring f;
if class R === SchurRing then toH toSymm f
else
(
if not R.?schurLevel then f else
if R.schurLevel>1 then terms f/(i->(toH leadCoefficient i*(mapSymToH leadMonomial i)))//sum
else mapSymToH f
)
)
-- auxiliary functions to be used in
-- the recTrans routine
leadTermFcn := local leadTermFcn;
retFcn := local retFcn;
mappingFcn := local mappingFcn;
toS = method()
toS(RingElement) := (f) -> (
R := ring f;
if (schurLevel R == 0 or class R === SchurRing) then f else
(
S := schurRing R;
local hf;
n := R.dim;
d := first degree f;
ngS := numgens S;
--mappingFcn v is used when v = h_i for some i; it returns the Schur polynomial s_i, in the correct Schur ring
mappingFcn = (v) -> (schurRing ring v)_{index v-2*(ring v).dim+1};
--leadTermFcn takes as input a polynomial pl in the h-variables,
--and returns the variable h_i, with i maximal, such that h_i appears in the expression of pl
leadTermFcn = (pl) -> (
R := ring pl;
spl := select(support pl,i->index i<numgens R);
if spl == {} then null else last spl
);
--retFcn takes as input a polynomial that's liftable to its coefficient ring, it lifts it and expresses it in the s-basis
--this is used when dealing with a symmetricRing A of positive schurLevel, and pl appears as a coefficient of some
--h-polynomial in A, so it is liftable to the coefficient ring of A
retFcn = (pl) -> toS lift(pl,(coefficientRing ring pl));
promote(recTrans(toH f),S)
)
)
toS(Thing) := (f) -> f
undocumented(toS,Thing)
toS(Thing,Ring) := (f,T) -> try(lift(f,T)) else f
undocumented(toS,Thing,Ring)
toS(RingElement,SchurRing) := (f, T) ->
(
R := ring f;
if schurLevel R == 0 then
(
U := T;
while schurLevel U > 0 do U = coefficientRing U;
toS(f,U)
)
else
(
fS := toS f;
dimT := numgens T;
(listForm fS)/(i-> if #i#0<=dimT then T_(i#0)*toS(i#1,coefficientRing T) else 0_T)//sum
)
)
--recTrans is a recursive routine that transforms an h-polynomial (in a symmetricRing of positive schurLevel)
--into an s-polynomial, by proceeding one level at a time
recTrans = method()
recTrans (RingElement) := (pl) ->
(
--lead = leading variable = h_i with i maximal
lead := leadTermFcn pl;
isSn := (ring pl).GroupActing == "Sn";
if lead === null then retFcn pl else
(
--monomials/coefficients with respect to the leading variable lead
(mon,coe) := coefficients(pl,Variables=>{lead});
mon = flatten entries mon;
coe = flatten entries coe;
rez := 0;
cdeg := degree(lead,mon#0)+1;
for i from 0 to #mon-1 do
(
fdeg := degree(lead,mon#i);
while (cdeg>fdeg+1) do
(
cdeg = cdeg - 1;
--if the group acting at a given level is the symmetric group
--use internal multiplication of symmetric functions
--otherwise use usual multiplication
if isSn then rez = rez**mappingFcn(lead) else
rez = rez*mappingFcn(lead);
);
if isSn then rez = rez**mappingFcn(lead)+recTrans(coe#i)
else rez = rez*mappingFcn(lead)+recTrans(coe#i);
cdeg = cdeg - 1;
);
while cdeg>0 do
(
cdeg = cdeg - 1;
--if the group acting at a given level is the symmetric group
--use internal multiplication of symmetric functions
--otherwise use usual multiplication
if isSn then rez = rez**mappingFcn(lead) else
rez = rez*mappingFcn(lead);
);
rez
)
)
recTrans(Thing) := p -> p
--------
--------
--given a recursive relation for a sequence a_n, given by a convolution of (a_n) with (L_n)
--convolve computes formulas for a_n in terms of L_n
--the main routine is coded in the engine
--the value of conv is used to indicate one of several types of convolution
convolve = method()
convolve(List,ZZ) := (L,conv) -> (
A := ring L_0;
toList drop(apply(rawConvolve(L/raw//toSequence, conv), f -> new A from f),1)
)
--a_n = p_n
--L_n = e_n
PtoE = (m,R) -> (
n := R.dim;
A := R.symRingForE;
p2e := prepend(1_A, for i from 1 to n list ((-1)^(i+1) * A_(2*n+i-1)));
if m>n then p2e = join(p2e,toList((m-n):0_A));
R.PtoETable = {1_A} | (- convolve(p2e,2));
)
--a_n = h_n
--L_n = e_n
HtoE = (m,R) -> (
n := R.dim;
A := R.symRingForE;
h2e := prepend(1_A, for i from 1 to n list (-1)^(i+1)*A_(2*n+i-1));
R.HtoETable = {1_A} | convolve(h2e,0);
)
--a_n = h_n
--L_n = p_n
HtoP = (m,R) -> (
n := R.dim;
A := R.symRingForP;
h2p := prepend(1_A, for i from 1 to n list A_(2*n+i-1));
R.HtoPTable = {1_A} | convolve(h2p,1);
)
--a_n = e_n
--L_n = p_n
EtoP = (m,R) -> (
n := R.dim;
A := R.symRingForP;
e2p := prepend(1_A, for i from 1 to n list (-1)^(i+1)*A_(2*n+i-1));
R.EtoPTable = {1_A} | convolve(e2p,1);
)
--a_n = p_n
--L_n = h_n
PtoH = (m,R) -> (
n := R.dim;
A := R;
p2h := prepend(1_A, for i from 1 to n list (- A_(2*n+i-1)));
R.PtoHTable = {1_A} | convolve(p2h,2);
)
--a_n = e_n
--L_n = h_n
EtoH = (m,R) -> (
n := R.dim;
A := R;
e2h := prepend(1_A, for i from 1 to n list (-1)^(i+1)*A_(2*n+i-1));
R.EtoHTable = {1_A} | convolve(e2h,0);
)
---------------------------------------------------------------
--------------End transition-----------------------------------
---------------------------------------------------------------
---------------------------------------------------------------
-------------Schur Resolutions---------------------------------
---------------------------------------------------------------
--recsyz is a recursive method that takes as input an element el of a SchurRing of positive schurLevel
--and returns the sum of the terms having negative coefficients
--it is used in the routine schurRes to determine representations that are forced to be generators
--of syzygy modules in an equivariant resolution
recsyz = method()
recsyz (Thing) := (el) -> min(el,0)
recsyz (RingElement) := (el) ->
(
T := ring el;
listForm el/((u,v)->T_u*recsyz(v))//sum
)
schurResolution = method(Options => {DegreeLimit => 0, SyzygyLimit => 0})
schurResolution(RingElement,List) := opts -> (rep,M) ->
(
d := opts.DegreeLimit;
if d == 0 then d = #M-1;
c := opts.SyzygyLimit;
T := ring rep;
n := schurLevel T;
--plets is the list of symmetric powers of the representation rep, from 0 to d
plets := new MutableList;
plets#0 = 1_T;
for i from 1 to d do plets#i = symmetricPower(i,rep);
schurRes(rep,M,new List from plets,DegreeLimit => d,SyzygyLimit => c)
)
schurResolution(RingElement,List,List) := opts -> (rep,M,plets) ->
(
d := opts.DegreeLimit;
if d == 0 then d = #M-1;
c := opts.SyzygyLimit;
schurRes(rep,M,plets,DegreeLimit => d,SyzygyLimit => c)
)
schurRes = method(Options => options schurResolution)
schurRes(RingElement,List,List) := opts -> (rep,M,plets) ->
(
T := ring rep;
d := opts.DegreeLimit;
c := opts.SyzygyLimit;
mods := new MutableList from (M | toList((d+1-#M):0));
notdone := true;
k := 0;
--syzy is the list of the characters of the generators of the syzygy modules
syzy := new MutableList;
syzy#k = {};
local mo;
local newsyz;
--syzygy modules are constructed step by step
--the stopping condition is either reaching the limit c of syzygy modules that are computed
--or not finding any new syzygies at a given step
while notdone do
(
for i from 0 to d do
(
mo = 0_T;
for sy in syzy#k do
if sy#0 <= i then mo = mo + plets#(i-sy#0) * sy#1
else break;
--mods is a sequence of representations, mods#i being the degree i of a module that needs to be ``covered''
--by the differential in the equivariant complex
--mo is the degree i part of the new syzygy module
--it needs to ``cover'' mods#i, i.e. there has to exist a surjective map of representations from
--mo to mods#i
mo = mo - mods#i;
--if there are representations with negative coefficients in mo-mods#i, it means that mo doesn't cover mods#i
--the representations with negative signs must be ``covered'' by new syzygies
newsyz = recsyz(mo);
if newsyz != 0 then syzy#k = syzy#k | {(i,-newsyz)};
mods#i = mo - newsyz;
);
if c == 0 then notdone = not (syzy#k == {})
else notdone = (k<c);
k = k + 1;
syzy#k = {};
);
select(toList syzy,i-> i != {})
)
---------------------------------------------------------------
-------------end Schur Resolutions-----------------------------
---------------------------------------------------------------
---------------------------------------------------------------
--------------Characters of Symmetric Group--------------------
---------------------------------------------------------------
--given a partition lambda as a nonincreasing sequence of positive integers
--seqToMults returns the representation of this partition as a sequence
--of multiplicities: rez#i is the number of parts of lambda of size (i+1)
seqToMults = method()
seqToMults(List) := (lambda) ->
(
lam := new Partition from lambda;
aux := toList(conjugate lam)|{0};
rez := {};
for j from 0 to #aux-2 do
(
dif := aux#j-aux#(j+1);
rez = rez | {dif};
);