-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathklr.gap
1750 lines (1519 loc) · 51.8 KB
/
klr.gap
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
goodies := [];
# Code to make calculations in finite type KLR algebras
# Call e.g. SetCartan("a",7) before you do anything!!!!
if not IsBound(a) then
Read("bergman.gap");
q := Indeterminate(Rationals,"q");
store := [];
stored := [];
rankedroots := []; # This is all roots separated by height
roots := []; # This is all roots in Lyndon order
lyndon := []; # This is the good Lyndon words corresponding to roots, also in Lyndon order
characters := []; # We'll store cuspidal characters globally; a list of pairs [goodlyndonword,character]
a := []; # The Cartan matrix; simply-laced only right now but only minor changes for general...
# My convention is that a[i][j] = <alpha_i^vee,alpha_j>
d := []; # d[i]'s are 1,2,3 according to root length then (alpha_i,alpha_j) = d[i] a[i][j] is symmetric
kappas := [];
highestroot := [];
block := 0; # I store the last decomp matrix and irred characters
goodwords := []; # This is the ordered list of good words in the block
D := []; # computed but only for one block at a time...
# The cols are the standards written in simples ordered by lex
IC := []; # The rows are the characters as mvp's
SC := [];
fi;
QuantumInteger := function(n,deg) local i,ans;
i:=1-n;
ans := 0*q;
while i <= n-1 do
ans := ans + q^(i*deg);
i := i+2;
od;
return ans;
end;
BarLaurent := function(laurent) local c,deg,ans,i;
c := CoefficientsOfLaurentPolynomial(laurent);
deg := -c[2]-Length(c[1])+1;
ans := 0*q;
for i in [1..Length(c[1])] do
ans := ans + q^(deg+i-1)*c[1][Length(c[1])+1-i];
od;
return ans;
end;
DimensionAt1 := function(mvp) local ans,i;
ans := 0;
for i in mvp!.coeff do
ans := ans + Sum(CoefficientsOfLaurentPolynomial(i)[1]);
od;
return ans;
end;
IsBarInvariant := function(laurent)
return laurent = BarLaurent(laurent);
end;
# In Leclerc's algorithm I need to square root something that's a product of smallish quantum integers. This tries to do it...
# Its a cludge so may well fail!
FakeSquareRoot := function(laurent) local p,pp;
Assert(0,IsLaurentPolynomial(laurent));
if laurent = q^0 then return q^0;fi;
for p in Reversed(Set([1,Maximum(d)])) do
for pp in [2..10] do
if QuotRemLaurpols(laurent,QuantumInteger(pp,p)^2,4) <> fail then
# Print("Div by q_", p, "^",pp,"\n");
return(FakeSquareRoot(laurent / QuantumInteger(pp,p)^2) * QuantumInteger(pp,p));
fi;
od;
od;
Assert(0,false);
end;
# This is to humanize Laurent polys a bit...
PrettyPrintLaurent := function(laurent) local p,pp;
Assert(0,IsLaurentPolynomial(laurent));
if laurent = q^0 then return q^0;fi;
for p in Reversed(Set([1,Maximum(d)])) do
for pp in [2..10] do
if QuotRemLaurpols(laurent,QuantumInteger(pp,p),4) <> fail then
Print("[",pp,"]_",p," ");
PrettyPrintLaurent(laurent / QuantumInteger(pp,p));
return;
fi;
od;
od;
Print("(",laurent,")");
end;
PrettyPrintMvp := function(mvp) local i;
for i in [1..Length(mvp!.elm)] do
Print("(");
PrettyPrintLaurent(mvp!.coeff[i]);
Print(")");
Print(mvp!.elm[i][1][1]);
if i < Length(mvp!.elm) then Print("+\n");fi;
od;
end;
GetCoefficient := function(mvp,word) local i;
for i in [1..Length(mvp!.elm)] do
if MvpUnpack(mvp!.elm[i][1][1]) = word then
return mvp!.coeff[i];
fi;
od;
return 0*q;
end;
Word := function(w) local s,i;
s := "[";
for i in [1..Length(w)] do
Append(s,String(w[i]));
if i < Length(w) then Append(s,"|");fi;
od;
Append(s,"]");
return Mvp(s);
end;
# Call with two words
Concatenate := function(w1,w2) local s,i;
s := "[";
if w1 = [] then return Word(w2);fi;
if w2 = [] then return Word(w1);fi;
for i in [1..Length(w1)] do
Append(s,String(w1[i]));
Append(s,"|");
od;
for i in [1..Length(w2)] do
Append(s,String(w2[i]));
if i < Length(w2) then Append(s,"|");fi;
od;
Append(s,"]");
return Mvp(s);
end;
ZeroWord := function()
return 0*Word([]);
end;
#####
# This is all about finding good lyndon words
# Given a word returns \sum_{i \in w} alpha_i
WordToAlpha := function(word) local root,i;
root := [];
for i in [1..Length(a)] do Add(root,0);od;
for i in word do root[i] := root[i]+1;od;
return root;
end;
SimpleRoot := function(i)
return WordToAlpha([i]);
end;
InnerProduct := function(root1,root2) local ans,i,j;
ans := 0;
for i in [1..Length(a)] do for j in [1..Length(a)] do
ans := ans + root1[i]*root2[j]*d[i]*a[i][j];
od;od;
return ans;
end;
NormSquared := function(root)
return InnerProduct(root,root);
end;
# The first finds the good Lyndon word corresponding to positive root beta from the algorithm in 4.3 of Leclerc
Lyndon := function(beta) local i,j,candidates,ell1,ell2,found;
# To speed things up we store the good lyndon word for root beta in the list lyndon...
found := 0;
for i in [1..Length(roots)] do
if roots[i] = beta then found := i;fi;
od;
Assert(0,found > 0);
if IsBound(lyndon[found]) then return ShallowCopy(lyndon[found]);fi;
# First if beta = alpha_i the good Lyndon word is (i)
if Sum(beta) = 1 then
for i in [1..Length(beta)] do
if beta[i] > 0 then
lyndon[found] := [i];
return([i]);
fi;
od;
Assert(0,false);
fi;
# So its not a simple root. Now write beta = beta_1 + beta_2 for positive roots beta_1, beta_2 in all
# possible ways so that Lyndon(beta_1) < Lyndon(beta_2)
# Then Lyndon(beta) is the maximum of Lyndon(beta_1).Lyndon(beta_2)'s
candidates := [];
for i in [1..Length(roots)] do
if beta - roots[i] in roots then
ell1 := Lyndon(roots[i]); ell2 := Lyndon(beta-roots[i]);
if ell1 < ell2 then Append(ell1,ell2); Add(candidates,ell1);fi;
fi;
od;
Assert(0,candidates <> []);
lyndon[found] := Maximum(candidates);
return ShallowCopy(lyndon[found]);
end;
#####
# Routines to list the positive roots
# I store these as a list with i-th entry being a list of all the roots of height i.
PositiveRoot := function(r) local i;
for i in [1..Length(r)] do
if r[i] < 0 then return false;fi;
od;
return true;
end;
GetNewRoots := function(earlier, i) local newroots,ell,root,new;
if earlier = [] then return [];fi;
newroots := [];
ell := Sum(earlier[1]);
for root in earlier do
new := ShallowCopy(root) - SimpleRoot(i)*InnerProduct(SimpleRoot(i),root)/d[i];
if PositiveRoot(new) and Sum(new) > ell then Add(newroots,new);fi;
od;
return newroots;
end;
GenerateRoots := function() local simpleroots,i,j,newlevel,w;
rankedroots := [];
simpleroots := [];
store := []; stored := [];
for i in [1..Length(a)] do
Add(simpleroots,[]);
for j in [1..Length(a)] do
Add(simpleroots[i],0);
od;
simpleroots[i][i] := 1;
od;
Add(rankedroots,simpleroots);
while true do
newlevel := [];
for i in [1..Length(a)] do
Append(newlevel, GetNewRoots(rankedroots[Length(rankedroots)], i));
od;
if newlevel = [] then
roots := Union(rankedroots);
lyndon := []; # Reset all the other stuff that we store on the way...
characters := [];
kappas := [];
block := 0;
D := [];
goodwords := [];
SC := [];
IC := [];
for i in [1..Length(a)] do
Add(characters,[SimpleRoot(i),Word([i])]);
Add(kappas, [[i],q^0]);
od;
for w in roots do Lyndon(w);od; # This puts the lyndon word into storage
SortParallel(lyndon,roots);
return;
fi;
Add(rankedroots, Set(newlevel));
od;
Assert(0,false);
end;
#####
# I've hard-coded a few Cartan matrices with a pretty random ordering of simple roots
SetCartan := function(type,rank) local i,j,this,beta;
a := [];
d := []; for i in [1..rank] do Add(d,1);od;
if type = "a" then
Assert(0,rank >= 1);
for i in [1..rank] do
this := [];
for j in [1..rank] do
this[j] := 0;
if i = j then this[j] := 2;fi;
if i = j+1 or i = j-1 then this[j] := -1;fi;
od;
Add(a,this);
od;
fi;
if type = "d" then
Assert(0,rank >= 3);
for i in [1..rank-1] do
this := [];
for j in [1..rank-1] do
this[j] := 0;
if i = j then this[j] := 2;fi;
if i = j+1 or i = j-1 then this[j] := -1;fi;
od;
if i = rank-2 then Add(this,-1); else Add(this,0);fi;
Add(a,this);
od;
this := [];
for j in [1..rank] do Add(this,0);od;
this[rank] :=2; this[rank-2] := -1;
Add(a,this);
fi;
if type = "b" then
Assert(0,rank >= 2);
for i in [1..rank] do
this := [];
for j in [1..rank] do
this[j] := 0;
if i = j then this[j] := 2;fi;
if i = j+1 or i = j-1 then this[j] := -1;fi;
od;
Add(a,this);
od;
a[rank][rank-1] := -2;
d := 2*d; d[rank] := 1;
fi;
if type = "c" then
Assert(0,rank >= 2);
for i in [1..rank] do
this := [];
for j in [1..rank] do
this[j] := 0;
if i = j then this[j] := 2;fi;
if i = j+1 or i = j-1 then this[j] := -1;fi;
od;
Add(a,this);
od;
a[rank-1][rank] := -2;
d[rank] := 2;
fi;
if type = "g" then
Assert(0,rank=2);
# a := [[2,-3],[-1,2]];
# d := [1,3];
a := [[2,-1],[-3,2]];
d := [3,1];
fi;
if type = "f" then
Assert(0,rank=4);
a := [[2,-1,0,0],[-1,2,-2,0],[0,-1,2,-1],[0,0,-1,2]];
d := [1,1,2,2];
fi;
if type = "e" and rank = 6 then
a := [[2,-1,0,0,0,0],[-1,2,-1,0,0,0],[0,-1,2,-1,0,-1],[0,0,-1,2,-1,0],[0,0,0,-1,2,0],[0,0,-1,0,0,2]];
elif type = "e" and rank = 7 then
a := [[2,-1,0,0,0,0,0],[-1,2,-1,0,0,0,0],[0,-1,2,-1,0,0,0],[0,0,-1,2,-1,0,-1],[0,0,0,-1,2,-1,0],[0,0,0,0,-1,2,0],[0,0,0,-1,0,0,2]];
elif type = "e" and rank = 8 then
a :=[ [ 2, -1, 0, 0, 0, 0, 0, 0 ], [ -1, 2, -1, 0, 0, 0, 0, 0 ], [ 0, -1, 2, -1, 0, 0, 0, 0 ],
[ 0, 0, -1, 2, -1, 0, 0, 0 ], [ 0, 0, 0, -1, 2, -1, 0, -1 ], [ 0, 0, 0, 0, -1, 2, -1, 0 ],
[ 0, 0, 0, 0, 0, -1, 2, 0 ], [ 0, 0, 0, 0, -1, 0, 0, 2 ] ];
elif type = "e" then Assert(0,false);
fi;
GenerateRoots();
highestroot:=rankedroots[Length(rankedroots)][1];
end;
CartanFlipSub := function(i,j) local b,temp,k;
b := StructuralCopy(a);
temp:=d[i];d[i]:=d[j];d[j]:=temp;
a[i] := b[j];
a[j] := b[i];
for k in [1..Length(a)] do
temp := a[k][i]; a[k][i] := a[k][j]; a[k][j] := temp;
od;
end;
CartanFlip := function(i,j)
CartanFlipSub(i,j);
GenerateRoots();
highestroot:=rankedroots[Length(rankedroots)][1];
end;
CartanPermute := function(p) local h,temp;
for h in [1..Length(p)-1] do
if p[h] > p[h+1] then
CartanFlipSub(h,h+1);
temp := p[h]; p[h] := p[h+1]; p[h+1]:=temp;
CartanPermute(p);
return;
fi;
od;
GenerateRoots();
highestroot:=rankedroots[Length(rankedroots)][1];
end;
#####
# Code to do with cuspidals
# This computes a component in the Kleschev-Ram graph
CKComponent := function(word) local i,j,k,newword,words,ans,this;
if Length(word) <= 1 then return [ShallowCopy(word)];fi;
i := word[Length(word)];
newword := ShallowCopy(word); Unbind(newword[Length(word)]);
words := CKComponent(newword);
ans := [];
for this in words do
j := Length(this)+1;
while j >= 1 and (j > Length(this) or a[this[j]][i] >= 0) do
newword := [];
for k in [1..j-1] do
Add(newword,this[k]);
od;
Add(newword,i);
for k in [j..Length(this)] do
Add(newword,this[k]);
od;
if not newword in ans then Add(ans,ShallowCopy(newword));fi;
j := j-1;
od;
od;
return ans;
end;
# Either gets homogeneous character or returns fail if its not homogeneous
HomogeneousCharacter := function(word) local words,ch,okay,i,this;
words := CKComponent(word);
ch := 0*q;
for this in words do
okay := true;
for i in [1..Length(this)-1] do
if this[i] = this[i+1] then okay := false;fi;
od;
for i in [1..Length(this)-2] do
if this[i] = this[i+2] and d[this[i+1]] <= d[this[i]] then okay := false;fi;
od;
if not okay then return fail;fi;
ch := ch + Word(this);
od;
return ch;
end;
#####
# This returns all root partitions for a given element of Q_+
# i.e. we write beta = beta_1+...+beta_k for beta_1 >= ... >- beta_k (the list roots is assumed smallest first) summing to beta
# For the output of this function I'll store just the list that is the index of beta_1,...index of beta_k in the list roots
# Normally call just with one argument, beta
RootPartitions := function(arg) local beta,lastnumber,part,i,stack,this;
if not IsList(arg[1]) then
lastnumber := arg[1];beta:=arg[2];
else
lastnumber := 1;beta:=arg[1];
fi;
if Sum(beta) = 0 then return [[]]; fi;
part := [];
for i in [lastnumber..Length(roots)] do
if PositiveRoot(beta-roots[i]) then
stack := RootPartitions(i,beta-roots[i]);
for this in stack do
Add(this,i);
if not this in part then Add(part,this);fi;
od;
fi;
od;
return part;
end;
# This returns all good words for a given element of Q_+
GoodWords := function(beta) local part,ans,this,r;
part := RootPartitions(beta);
ans := [];
for this in part do
Add(ans,[]);
for r in this do
Append(ans[Length(ans)], lyndon[r]);
od;
od;
Sort(ans);
return ans;
end;
#####
# Every (good) word has a unique factorization into a weakly decreasing sequence of (good) Lyndon words
IsLyndon := function(w) local i,j,factor;
for j in Reversed([2..Length(w)]) do
factor := []; for i in [j..Length(w)] do Add(factor,w[i]);od;
if w >= factor then return false;fi;
od;
return true;
end;
CheckFactorization := function(w) local i;
for i in [1..Length(w)-1] do
if w[i] < w[i+1] then return false;fi;
od;
for i in [1..Length(w)] do
if not IsLyndon(w[i]) then return false;fi;
od;
return true;
end;
# I think this finds the canonical factorization of a word but I wasn't sure so I
# added some check in...
# Now its Duval's slick algorithm so believe it!
Factorize := function(w) local subw,i,j,k,ans,words,start,this,n;
ans := [];
n := Length(w);
k := 0;
while k < n do
i := k+1; j := k+2;
while j <= n and w[i] <= w[j] do
if w[i] < w[j] then i := k+1; else i := i+1;fi;
j := j+1;
od;
repeat k := k+j-i; Add(ans,k); until k >= i;
od;
words := [];
for i in [1..Length(ans)] do
if i > 1 then start := ans[i-1]+1;else start := 1;fi;
this:=[];
for j in [start..ans[i]] do Add(this,w[j]);od;
Add(words,this);
od;
Assert(0,CheckFactorization(words));
return words;
end;
# Check that a word is good, i.e. all the lyndon words in its factorixation are good
IsGood := function(w) local i;
for i in Factorize(w) do
if not i in lyndon then return false;fi;
od;
return true;
end;
IsGoodLyndon := function(w)
return IsLyndon(w) and IsGood(w);
end;
#####
# Now things are getting serious. We're trying to find the characters of the cuspidals by induction on height
# For a given height, take the smallest good word. By shuffle product
ListInsert := function(list,pos,val) local ans,j;
ans := [];
for j in [1..pos-1] do Add(ans,list[j]);od;
Add(ans,val);
for j in [pos..Length(list)] do Add(ans,list[j]);od;
return ans;
end;
InvertPermutation := function(perm) local ans,i;
ans := [];
for i in [1..Length(perm)] do
ans[perm[i]] := i;
od;
return ans;
end;
ShufflePermutations := function(blocks) local ans,m,this,subans,subblocks,i;
if Length(blocks) = 0 then return [[]];fi;
subblocks := ShallowCopy(blocks);
Unbind(subblocks[Length(subblocks)]);
subans := ShufflePermutations(subblocks);
ans := [];
for m in Combinations([1..Sum(blocks)],blocks[Length(blocks)]) do
for this in subans do
for i in [1..Length(m)] do
this := ListInsert(this,m[i],Sum(subblocks)+i);
od;
Add(ans,this);
od;
od;
return ans;
end;
InverseShufflePermutations := function(blocks)
return List(ShufflePermutations(blocks),InvertPermutation);
end;
## e.g. WordShuffle([[2],[1]]) = (2,1) + q (1,2)
WordShuffle := function(w) local blocks,i,perms,ans,p,this,cf,concatenated,j;
blocks := [];
concatenated := [];
for i in w do Add(blocks,Length(i));Append(concatenated,i);od;
perms := InverseShufflePermutations(blocks);
ans := ZeroWord();
for p in perms do
this := [];
cf := q^0;
for i in [1..Length(p)] do
# Need to position concatenated[i] into position p[i]
for j in [1..i-1] do
if p[j] > p[i] then cf := cf * q^(-d[concatenated[i]]*a[concatenated[i]][concatenated[j]]);fi;
od;
this[p[i]] := concatenated[i];
od;
ans := ans+cf*Word(this);
od;
return ans;
end;
### Either pass a sequence of MVPs or a list of MVPs
Shufffle := function(arg) local lengths,places,ans,cf,w,i;
if Length(arg) = 0 then return(Word([]));fi;
if not IsMvpObj(arg[1]) then
Assert(0,Length(arg) = 1);
arg := arg[1];
fi;
if Length(arg) = 0 then return(Word([]));fi;
Assert(0,IsMvpObj(arg[1]));
# OK ready to begin, arg is now a list of MVPs
# Need to open some parentheses
lengths := [];
for i in [1..Length(arg)] do
Add(lengths,[1..Length(arg[i]!.elm)]);
od;
ans := ZeroWord();
for places in Cartesian(lengths) do
cf := q^0;
w := [];
for i in [1..Length(places)] do
cf := cf * arg[i]!.coeff[places[i]];
Add(w,MvpUnpack(arg[i]!.elm[places[i]][1][1]));
od;
ans := ans + cf * WordShuffle(w);
od;
return ans;
end;
# This takes x and y and computes y-coeff of x_1 *... * x_n
FullShuffleCoefficient := function(x,y) local bit,n,ans,i,j,xx,yy;
Assert(0,WordToAlpha(x)=WordToAlpha(y));
if Length(x) = 0 then return q^0;fi;
n := Length(x);
xx := ShallowCopy(x); Unbind(xx[n]);
ans := 0*q;
for i in [1..n] do
if y[i] = x[n] then
yy := [];
bit := q^0;
for j in [i+1..n] do
bit := bit * q^(-d[x[n]]*a[x[n]][y[j]]);
od;
for j in [1..i-1] do Add(yy,y[j]);od;
for j in [i+1..n] do Add(yy,y[j]);od;
ans := ans + bit*FullShuffleCoefficient(xx,yy);
fi;
od;
return ans;
end;
#####
# This computes the Lyndon basis for a given Lyndon word
CostandardFactorization := function(w) local i,subw,neww,j;
Assert(0,Length(w) > 1);
subw := ShallowCopy(w);
for i in Reversed([2..Length(subw)]) do
Unbind(subw[i]);
if IsLyndon(subw) then
neww := [];
for j in [i..Length(w)] do Add(neww,w[j]);od;
return [subw,neww];
fi;
od;
Assert(0,false);
end;
WordBracket := function(w1,w2,sign)
return Concatenate(w1,w2)-q^(sign*InnerProduct(WordToAlpha(w1),WordToAlpha(w2)))*Concatenate(w2,w1);
end;
Bracket := function(mvp1,mvp2,sign) local lengths,places,ans,w1,w2;
lengths := [[1..Length(mvp1!.coeff)],[1..Length(mvp2!.coeff)]];
ans := ZeroWord();
for places in Cartesian(lengths) do
w1 := MvpUnpack(mvp1!.elm[places[1]][1][1]);
w2 := MvpUnpack(mvp2!.elm[places[2]][1][1]);
ans := ans + mvp1!.coeff[places[1]]*mvp2!.coeff[places[2]]*WordBracket(w1,w2,sign);
od;
return ans;
end;
## This returns the basis element [g] essentially as in Leclerc (with q replaced by q^{sign}) for lyndon word g
Monomial := function(goodword,sign) local cf;
Assert(0,IsLyndon(goodword));
if Length(goodword)=1 then return Word(goodword);fi;
cf := CostandardFactorization(goodword);
return Bracket(Monomial(cf[1],sign),Monomial(cf[2],sign),sign);
end;
# This is Bernard's normalization from RHS of (28) in his paper (tweaked a bit by some guesswork)
NormalizationScalar := function(goodword) local beta,scalar,i;
beta := WordToAlpha(goodword);
scalar := (1-q^NormSquared(beta));
for i in [1..Length(beta)] do
scalar := scalar / ((1-q^(2*d[i]))^(beta[i]));
od;
return scalar;
end;
# This returns the dual PBW basis element for good lyndon word --- which is the dual canonical basis already! Except it needs to be scaled by NormalizationScalar then divided by kappa to get exactly
# the right thing...
CuspidalTimesKappa := function(goodword) local mon,ans,i,j,this;
mon := Monomial(goodword,-1);
ans := ZeroWord();
for i in [1..Length(mon!.coeff)] do
this := [];
for j in MvpUnpack(mon!.elm[i][1][1]) do
Add(this,[j]);
od;
ans := ans + mon!.coeff[i] * WordShuffle(this);
od;
return ans*NormalizationScalar(goodword);
end;
# UnscaledCuspidal takes too long. This just works out a particular coefficient which might
# be a tad quicker if you don't actually need the cuspidal character
CuspidalTimesKappaCoefficient := function(goodword,wantedone) local mon,ans,i,j;
mon := Monomial(goodword,-1);
ans := 0*q;
for i in [1..Length(mon!.coeff)] do
ans := ans + mon!.coeff[i] * FullShuffleCoefficient(MvpUnpack(mon!.elm[i][1][1]),wantedone);
od;
return ans*NormalizationScalar(goodword);
end;
## This computes kappa for a good lyndon word
# Its the square root of the coefficient of goodlyndon in dual PBW scaled.
# This is roughly what is written in Leclerc 5.5.2 but I tweaked a few things.
# Unfortunately it gets too slow already for E_7...
GoodKappa := function(goodlyndon) local beta,kappa,i;
Assert(0,IsGoodLyndon(goodlyndon));
for i in [1..Length(kappas)] do
if kappas[i][1] = goodlyndon then return kappas[i][2];fi;
od;
if HomogeneousCharacter(goodlyndon) <> fail then kappa := q^0;
else
kappa := FakeSquareRoot(CuspidalTimesKappaCoefficient(goodlyndon,goodlyndon));
fi;
Add(kappas, [goodlyndon, kappa]);
return kappa;
end;
CuspidalCharacter := function(root) local goodlyndon,i,found,ans,kappa;
goodlyndon := Lyndon(root);
for i in [1..Length(characters)] do
if characters[i][1] = root then return characters[i][2];fi;
od;
if Maximum(d) = 1 then # Might be a homogeneous one!
ans := HomogeneousCharacter(goodlyndon);
if ans <> fail then
Add(characters, [root,ans]);
return ans;
fi;
fi;
ans := CuspidalTimesKappa(goodlyndon);
kappa := FakeSquareRoot(GetCoefficient(ans,goodlyndon));
ans := ans / kappa;
Add(characters, [root,ans]);
found:=false;
for i in [1..Length(kappas)] do
if kappas[i][1] = goodlyndon then Assert(0,kappas[i][2]=kappa);found:=true;fi;
od;
if not found then Add(kappas,[goodlyndon,kappa]);fi;
return ans;
end;
# This computes kappa for a good word using formula (19) from Bernard
# Actually I don't need this scalar every... but it makes
# the PBW basis computable: E_g = 1/kappa_g bar(monomial(g)) or something like that
Kappa := function(good) local cuspidals,kappa,mult,i,beta,deg;
cuspidals := Factorize(good);
kappa := q^0;
mult := 1;
for i in [1..Length(cuspidals)] do
if i < Length(cuspidals) and cuspidals[i] = cuspidals[i+1] then mult := mult + 1;
else
beta := WordToAlpha(cuspidals[i]);
deg := NormSquared(beta)/2;
kappa := kappa * GoodKappa(cuspidals[i])^mult * QuantumInteger(mult,deg); mult := 1;
fi;
od;
return kappa;
end;
#####
# This returns the full character of a standard module with given highest good word
StandardCharacter := function(goodword) local i,cuspidals,substandards,ans,shift,mult;
cuspidals := List(Factorize(goodword),WordToAlpha);
shift := 0;
mult := 1;
for i in [1..Length(cuspidals)] do
if i < Length(cuspidals) and cuspidals[i] = cuspidals[i+1] then mult := mult + 1;
else shift := shift + NormSquared(cuspidals[i]) * mult * (mult-1) / 4; mult := 1;
fi;
od;
substandards := [];
for i in cuspidals do
Add(substandards,CuspidalCharacter(i));
od;
ans := q^shift * Shufffle(substandards);
return ans;
end;
# This by the way is exactly the dual PBW basis in Leclerc...
CostandardCharacter := function(goodword) local i,cuspidals,substandards,ans,shift,mult;
cuspidals := List(Factorize(goodword),WordToAlpha);
shift := 0;
mult := 1;
for i in [1..Length(cuspidals)] do
if i < Length(cuspidals) and cuspidals[i] = cuspidals[i+1] then mult := mult + 1;
else shift := shift + NormSquared(cuspidals[i]) * mult * (mult-1) / 4; mult := 1;
fi;
od;
substandards := [];
for i in cuspidals do
Add(substandards,CuspidalCharacter(i));
od;
ans := q^(-shift) * Shufffle(Reversed(substandards));
return ans;
end;
# Given a character this discards all but the "good" part
Good := function(character) local newcharacter,i,word;
newcharacter := ZeroWord();
for i in [1..Length(character!.elm)] do
word := MvpUnpack(character!.elm[i][1][1]);
if IsGood(word) then newcharacter := newcharacter + character!.coeff[i] * Word(word);fi;
od;
return newcharacter;
end;
####
# This code implements the algorithm to take
# a given bar-invariant polynomial kappa and d in qZ[q] and m bar invariant
# such that d kappa + m is known, it works out d and m.
DM := function(laurent,kappa) local dmv,n,m,r,a,b;
if laurent = 0*q then return [0*q,0*q];fi;
n := -CoefficientsOfLaurentPolynomial(laurent)[2];
a := CoefficientsOfLaurentPolynomial(laurent)[1];
m := -n+Length(a)-1;
if m = 0 and n = 0 then return [0*q,a[1]*q^0];fi;
r := -CoefficientsOfLaurentPolynomial(kappa)[2];
b := CoefficientsOfLaurentPolynomial(kappa)[1][1];
if m > n then
dmv := DM(laurent-a[Length(a)]* q^(m-r)*kappa/b,kappa);
dmv[1] := dmv[1]+a[Length(a)] * q^(m-r) / b;
else
dmv := DM(laurent-a[1]*q^(-n)-a[1]*q^n,kappa);
dmv[2] := dmv[2]+a[1]*q^(-n)+a[1]*q^n;
fi;
return dmv;
end;
####
# Now for the algorithm to compute (a) the good part of the irreducible characters
# and (b) decomposition matrix of standard modules
# This is done as follows. First find the good words in the block in order, smallest to largest.
# Then find the good part of the standard characters stored in a list in the same order
# The bottom one in this list is already irreducible; make the first column of the decomposition
# matrix equal to e_1
# Now go from 2 to the end and work out the remaining columns and characters.
# At k-th step, look at (k-1)th coefficient in standard character.
# work out d and m from above algorithm taking kappa to be the top coefficient in the
# already found irreducible character for k-1.
# The d goes in k-1-th row of k-th row of decomp matrix.
# Then we subtract d*L(k-1) from k-th character.
# repeat with k-2...1
Compute := function(bl) local i,identity,j,dec;
if block = bl then return;fi;
block := 0;
D := [];
IC := [];
SC := [];
goodwords := GoodWords(bl);
identity := [];
for i in [1..Length(goodwords)] do
Add(identity,0*q);
od;
for i in [1..Length(goodwords)] do
Add(D,ShallowCopy(identity));
Add(IC,StandardCharacter(goodwords[i]));
Add(SC,StructuralCopy(IC[Length(IC)]));
Assert(0,IsBarInvariant(GetCoefficient(IC[i],goodwords[i])));
od;
for i in [1..Length(goodwords)] do
D[i][i] := q^0;
for j in Reversed([1..i-1]) do
dec := DM(GetCoefficient(IC[i],goodwords[j]),GetCoefficient(IC[j],goodwords[j]))[1];
D[j][i] := dec;
IC[i] := IC[i]-dec*IC[j];
Assert(0,IsBarInvariant(GetCoefficient(IC[i],goodwords[j])));
od;
od;
block := bl;
end;
#####
# OK so I nearly have everything!
# I would like to write the E(i) in terms of the P(i) for good words i.
# So let's build a matrix whose j-th col is E(j) in terms of P(i)'s
# the ij-entry of this matrix is qdim Hom(E(j),L(i)) = qdim e(j) L(i)
# i.e. the j-coefficient of the i-th entry of IC
# Then the inverse of that matrix has cols giving P(j) in terms of E(i)'s
EtoP := function(block) local m,i,j;
Compute(block);
m := [];
for i in [1..Length(goodwords)] do
Add(m,[]);
for j in [1..Length(goodwords)] do
m[i][j] := GetCoefficient(IC[i],goodwords[j]);
od;
od;
return m;
end;
PtoE := function(block)
return EtoP(block)^(-1);
end;
# Also this is the matrix whose j-th col is E(j) expressed in terms of good words
# Observe it is just EtoP transpose!
LtoW := function(block) local m,i,j;
Compute(block);
m := [];
for i in [1..Length(goodwords)] do
Add(m,[]);
for j in [1..Length(goodwords)] do
m[i][j] := GetCoefficient(IC[j],goodwords[i]);
od;
od;
return m;
end;
StoW := function(block) local m,i,j;
Compute(block);
m := [];
for i in [1..Length(goodwords)] do
Add(m,[]);
for j in [1..Length(goodwords)] do
m[i][j] := GetCoefficient(SC[j],goodwords[i]);
od;
od;
return m;
end;
WtoL := function(block)
return LtoW(block)^(-1);
end;
WtoS := function(block)
return StoW(block)^(-1);
end;
# Now the main new work is to go from E to W
# We want the matrix whose j-th col is E(j) expressed in terms of good words,
# i.e. ij entry is qdim e(i) R e(j)
# This is a matter of finding all w such that e(i) psi_w = psi_w e(j)
# and computing the degree... then its that times prod_{k in i}(1-q^(2d_k))^(-1)
# which I'll omit as its something global
EtoW := function(block) local i,j,m;
Compute(block);