/
GradedLieAlgebras.m2
4137 lines (3547 loc) · 122 KB
/
GradedLieAlgebras.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
--------------------------------------------------------------------------------
-- Copyright 2020 Clas L\"ofwall and Samuel Lundqvist
--
-- You may redistribute this program under the terms of the GNU General Public
-- License as published by the Free Software Foundation, either version 2 of the
-- License, or any later version.
--------------------------------------------------------------------------------
newPackage(
"GradedLieAlgebras",
Version => "3.0",
Date => "June 2020",
Authors => {
{Name => "Clas Löfwall", Email => "clas.lofwall@gmail.com"},
{Name => "Samuel Lundqvist", Email => "samuel@math.su.se"}},
AuxiliaryFiles => true,
DebuggingMode => false,
Headline => "computations in graded Lie algebras"
)
export {
"boundaries",
"center",
"computedDegree",
"cycles",
"differential",
"differentialLieAlgebra",
"dims",
"extAlgebra",
"ExtAlgebra",
"ExtElement",
"Field",
"firstDegree",
"FGLieIdeal",
"FGLieSubAlgebra",
"holonomy",
"holonomyLocal",
"indexForm",
"innerDerivation",
"koszulDual",
"LastWeightHomological",
"LieAlgebra",
"lieAlgebra",
"LieAlgebraMap",
"lieDerivation",
"LieDerivation",
"LieElement",
"lieHomology",
"LieIdeal",
"lieIdeal",
"lieRing",
"LieSubSpace",
"lieSubSpace",
"LieSubAlgebra",
"lieSubAlgebra",
"listMultiply",
"mbRing",
"minimalModel",
"normalForm",
"sign",
"Signs",
"weight",
"VectorSpace",
"zeroDerivation",
"zeroIdeal",
"zeroMap"
}
-- the following built-in functions has a special meaning
-- in this package:
-- basis, dim, degree, degreeLength, baseName, standardForm, isWellDefined,
-- coefficients, monomials, use, random, describe, generators,
-- ideal, image, quotient, isSurjective, map, inverse, sum, intersect,
-- Ext, numgens, member, kernel, annihilator, Weights,
-- diff, max, gb, ambient, source, target, minimalPresentation,
-- isIsomorphism, trace
-- Also, the following symbols are used
-- /, \,\\, SPACE, +, -, @, ++, *
-- LIE ALGEBRA CONSTRUCTIONS
-- A free Lie algebra without differential is constructed by lieAlgebra(x) where x is a list
-- of names of the generators. Options for weights, signs,
-- field may be given and also the option
-- LastWeightHomological may be set to true if the last weight is considered to be the
-- homological degree. A differential Lie algebra
-- may be constructed using D=differentialLieAlgebra(x)
-- where x is a list of homogeneous elememnts in a free Lie algebra L.
-- The elements in x must obey some
-- rules for weight and sign, which is checked by the program.
-- The square of the differential might
-- not be zero. New relations are added to get the
-- square of the differential equal to zero.
-- The relations are given by D#ideal and may be seen by the user (but not change),
-- using describe under the key ideal. The relations may also be obtained as ideal(D).
-- The ambient Lie algebra
-- of D is L, the free underlying Lie algebra, it is obtained as ambient(D) or
-- D#cache.ambient.
-- A quotient Lie algebra Q of L may be formed in two ways,
-- 1. as L/x, where x is a list of homogeneous elements in L or
-- 2. as L/I, where I is an ideal of L.
-- In case 1, x may not be invariant under the differential.
-- As in the construction of differential
-- Lie algebras, the extra relations are added to (L/x)#ideal
-- and they may be seen as above by the user using describe.
-- In case 2, if I#?ideal then I is generated by the list I#gens,
-- so L/I is defined as L/I#gens.
-- If not I#?ideal, then there are two cases, either
-- 2a. L#ideal is a list or
-- 2b L#ideal is an ideal J of class LieIdeal.
-- In case 2a,
-- the ambient of L/I is defined to be L and (L/I)#ideal=I.
-- In case 2b, L=M/J and then L/I
-- is defined as M/inverse(h,I) where h is the natural map M -> L. Also, ambient(L/I)=M.
-- It remains to consider case 1.
-- Again there are two cases, either
-- 1a. L#ideal is a list or
-- 1b L#ideal is an ideal J of class LieIdeal.
-- In case 1a,
-- L=M/y as non-differential Lie algebra where M is free and the ambient of L.
-- Now L/x is defined as
-- M/z where z is the union of y and imap(x,M) where imap(x,M) is a section of the map M->L.
-- Also, ambient(L/x)=M. If L has a differential, then x is extended to get invariance under
-- the differential.
-- In case 1b,
-- then L=M/J, where M#ideal is a list. Now first N is defined as M/imap(x,M).
-- Then finally L/x is defined as
-- N/image(h,J), where h: M -> N. Also ambient(L/x)=N.
--
-- The ambient of Q, which is a quotient of a differential Lie algebra D by a
-- list is F, the free non-differential underlying Lie algebra.
-- The elements of Q#ideal belong to ambient(Q)=F.
-- Also, the elements of Q#diff belong to ambient(Q)=F.
-- The ambient of Q=L/I where class I=LieIdeal is L, The elements of Q#diff belong to ambient(Q)=L.
-- The ideal Q#ideal=I is an ideal of L.
recursionLimit=10000;
----------------------------------------
--
--TYPES AND CONSTRUCTORS
--
----------------------------------------
LieAlgebra = new Type of HashTable;
LieElement = new Type of BasicList;
ExtAlgebra = new Type of MutableHashTable;
ExtElement = new Type of BasicList;
LieAlgebraMap = new Type of HashTable;
LieDerivation = new Type of HashTable;
VectorSpace = new Type of HashTable;
LieSubSpace = new Type of VectorSpace;
LieSubAlgebra = new Type of LieSubSpace;
LieIdeal = new Type of LieSubAlgebra;
FGLieSubAlgebra = new Type of LieSubAlgebra;
FGLieIdeal = new Type of LieIdeal;
debug Core;
net LieAlgebra:=L->(
if hasAnAttribute L then
return toString getAttribute(L,ReverseDictionary);
horizontalJoin ( net class L, if #L > 0 then
("{...", toString(#L), "...}") else "{}" )
);
debug Core;
net LieIdeal:=I->(
if hasAnAttribute I then
return toString getAttribute(I,ReverseDictionary);
"ideal of"|" "|net(I#lieAlgebra)
);
debug Core;
net FGLieIdeal:=I->(
if hasAnAttribute I then
return toString getAttribute(I,ReverseDictionary);
"finitely generated ideal of"|" "|net(I#lieAlgebra)
);
debug Core;
net LieAlgebraMap:=f->(
L:=source f; M:=target f; G:=gens(L);
if all(G,z->f#z===0_M) then "0" else (
if L===M and all(G,z->f#z===z) then "id_"|net(M) else (
if hasAnAttribute f then
return toString getAttribute(f,ReverseDictionary);
"homomorphism from "|net(source f)|" to "|net(target f)
)
)
);
debug Core;
net LieDerivation:=d->(
L:=source d; M:=target d; G:=gens(L);
if all(G,z->d#z===0_M) then "0" else (
if hasAnAttribute d then
return toString getAttribute(d,ReverseDictionary);
"derivation from "|net(L)|" to "|net(M)
)
);
debug Core;
net LieSubSpace:=I->(
if hasAnAttribute I then
return toString getAttribute(I,ReverseDictionary);
"subspace of"|" "|net(I#lieAlgebra)
);
debug Core;
net VectorSpace:=V->(
if hasAnAttribute V then
return toString getAttribute(V,ReverseDictionary);
"homology of "|net(V#lieAlgebra)
);
debug Core;
net FGLieSubAlgebra:=I->(
if hasAnAttribute I then
return toString getAttribute(I,ReverseDictionary);
"finitely generated subalgebra of"|" "|
net(I#lieAlgebra)
);
debug Core;
net LieSubAlgebra:=I->(
if hasAnAttribute I then
return toString getAttribute(I,ReverseDictionary);
"subalgebra of"|" "|net(I#lieAlgebra)
);
----------------------------------------
-- SYMBOLS
----------------------------------------
aR=getSymbol("aR");
mb0=getSymbol("mb0");
mb=getSymbol("mb");
opL=getSymbol("opL");
genslie=getSymbol("genslie");
localone=getSymbol("localone");
localtwo=getSymbol("localtwo");
ko=getSymbol("ko");
pr=getSymbol("pr");
fr=getSymbol("fr");
subAlgebra=getSymbol("subAlgebra");
subIdeal=getSymbol("subIdeal");
subSpace=getSymbol("subSpace");
homdefs=getSymbol("homdefs");
ext=getSymbol("ext");
welldef=getSymbol("welldef");
globalAssignment LieAlgebra
globalAssignment ExtAlgebra
globalAssignment LieIdeal
globalAssignment LieAlgebraMap
globalAssignment LieDerivation
globalAssignment LieSubAlgebra
globalAssignment LieSubSpace
globalAssignment FGLieSubAlgebra
globalAssignment FGLieIdeal
globalAssignment VectorSpace
lieIdeal=method()
lieIdeal(List):=(x)->(
if x=={} then
error "input may not be the empty set";
L:=class x_0;
dL:=differential L;
if not all(x,y->class y===L) then (
error "the generators do not belong to the same Lie algebra";
);
J:=new HashTable from {
cache => new CacheTable,
gens => skipzz(join(x,dL\\x),L),
ideal => true,
lieAlgebra => L};
new FGLieIdeal from J
);
lieIdeal(LieSubSpace):=(A)->(
L:=A#lieAlgebra;
J:=new HashTable from {
cache => new CacheTable,
subIdeal => true,
gens => A,
lieAlgebra => L};
if instance(A,LieIdeal) then A else if
A#?gens then
if A#gens==={} then
lieIdeal{0_L} else lieIdeal(A#gens)
else
new LieIdeal from J
);
lieSubAlgebra=method()
lieSubAlgebra(List):=(x)->(
if x=={} then
error "input may not be the empty set";
L:=class x_0;
if not all(x,y->class y===L) then (
error "the generators do not belong to the same Lie algebra";
);
dL:= differential L;
J:=new HashTable from {
cache => new CacheTable,
subAlgebra => true,
gens => skipzz(join(x,dL\\x),L),
lieAlgebra => L};
new FGLieSubAlgebra from J
);
lieSubSpace=method()
lieSubSpace(List):=(x)->(
if x=={} then
error "input may not be the empty set";
L:=class x_0;
if not all(x,y->class y===L) then (
error "the generators do not belong to the same Lie algebra";
);
J:=new HashTable from {
cache => new CacheTable,
subSpace => true,
gens => skipzz(x,L),
lieAlgebra => L};
new LieSubSpace from J
);
image(LieAlgebraMap,LieSubSpace):=(f,A)->(
L:=target f;
if not source f===A#lieAlgebra then
error "the map is not defined on the subspace";
J:= new HashTable from {
cache => new CacheTable,
image => {f,A},
lieAlgebra => L};
if class A===FGLieSubAlgebra then
new FGLieSubAlgebra from
new HashTable from {
cache => new CacheTable,
subAlgebra => true,
gens => skipzz(f\A#gens,L),
lieAlgebra => L} else
if instance(A,LieSubAlgebra) then
new LieSubAlgebra from J else
new LieSubSpace from J
);
image(LieDerivation,LieSubSpace):=(d,S)->(
L:=target d;
if not source d===S#lieAlgebra then
error "the derivation is not defined on the subspace";
del:=differential L;
J:=new HashTable from {
cache => new CacheTable,
image => {d,S},
lieAlgebra => L};
if (source d===L and d#map===id_L
and all(d\d\L#cache.gens,x->x===0_L) and d del===zeroDerivation(L) and
instance(S,LieIdeal)) then new LieSubAlgebra from J else
new LieSubSpace from J
);
inverse(LieAlgebraMap,LieSubSpace):=(f,S)->(
L:=target f;
if not L===S#lieAlgebra then
error "the map has not values in the subspace";
J:=new HashTable from {
cache => new CacheTable,
inverse => {f,S},
lieAlgebra => source f};
if instance(S,LieIdeal) then
new LieIdeal from J else
if instance(S,LieSubAlgebra) then
new LieSubAlgebra from J else
new LieSubSpace from J
);
inverse(LieDerivation,LieSubSpace):=(d,S)->(
Ls:=source d;
Lt:=target d;
if not Lt===S#lieAlgebra then
error "the derivation does not have values in the subspace";
J:=new HashTable from {
cache => new CacheTable,
inverse => {d,S},
lieAlgebra => Ls};
ds:=differential Ls;
dt:=differential Lt;
if instance(S,LieIdeal) and
unique apply(gens Ls,
x->d(ds(x))-(-1)^(sign d) dt(d(x)))==={0_Lt} then
new LieSubAlgebra from J else
new LieSubSpace from J
);
quotient(LieIdeal,FGLieSubAlgebra):=opts->(I,J)->(
L:=I#lieAlgebra;
if not L===J#lieAlgebra then
error "the Lie algebras must be the same";
S:=new HashTable from {
cache => new CacheTable,
quotient => {I,J},
lieAlgebra => L};
new LieSubAlgebra from S
);
LieSubSpace+LieSubSpace:=(I,J)->(
L:=I#lieAlgebra;
if not L===J#lieAlgebra then
error "the Lie algebras must be the same";
if I#?ideal and J#?ideal then
new FGLieIdeal from new HashTable from {
cache => new CacheTable,
ideal => true,
gens => join(I#gens,J#gens),
lieAlgebra => L} else (
U:=new HashTable from {
cache => new CacheTable,
sum => {I,J},
lieAlgebra => L};
if instance(I,LieIdeal) and instance(J,LieIdeal) then
new LieIdeal from U else
if instance(I,LieIdeal) and instance(J,LieSubAlgebra) or
instance(J,LieIdeal) and instance(I,LieSubAlgebra) then
new LieSubAlgebra from U else
new LieSubSpace from U
)
);
LieSubSpace@LieSubSpace:=(S,T)->(
L:=S#lieAlgebra;
if not L===T#lieAlgebra then
error "the Lie algebras must be the same";
U:=new HashTable from {
cache => new CacheTable,
intersect => {S,T},
lieAlgebra => L};
if instance(S,LieIdeal) and instance(T,LieIdeal) then
new LieIdeal from U else
if instance(S,LieSubAlgebra) and instance(T,LieSubAlgebra) then
new LieSubAlgebra from U else
new LieSubSpace from U
);
zeroIdeal=method()
zeroIdeal(LieAlgebra):=L->(
J:=new HashTable from {
cache => new CacheTable,
ideal => true,
gens => {},
lieAlgebra => L};
new FGLieIdeal from J
);
fullLieIdeal=method()
fullLieIdeal(LieAlgebra):=L->(
J:=new HashTable from {
cache => new CacheTable,
ideal => true,
gens => L#cache.gens,
lieAlgebra => L};
new FGLieIdeal from J
);
fullLieSubAlgebra=method()
fullLieSubAlgebra(LieAlgebra):=L->(
J:=new HashTable from {
cache => new CacheTable,
subAlgebra => true,
gens => L#cache.gens,
lieAlgebra => L};
new FGLieSubAlgebra from J
);
boundaries=method()
boundaries(LieAlgebra):=L->(
J:=new HashTable from {
cache => new CacheTable,
homology => true,
boundaries => true,
lieAlgebra => L};
new LieSubAlgebra from J
);
cycles=method()
cycles(LieAlgebra):=L->(
J:=new HashTable from {
cache => new CacheTable,
homology => true,
cycles => true,
lieAlgebra => L};
new LieSubAlgebra from J
);
lieHomology=method()
lieHomology(LieAlgebra):=L->(
J:=new HashTable from {
cache => new CacheTable,
homology => true,
lieAlgebra => L};
new VectorSpace from J
);
extAlgebra = method()
extAlgebra(ZZ,LieAlgebra):=(n,L)->(
if L#cache.?Ext and L#cache.Ext#degree>=n then L#cache.Ext else (
M:=minimalModel(n,L);
J:=new HashTable of ExtElement from new HashTable from {
cache => new CacheTable,
homology => true,
Ext => true,
numgens => M#numgens,
degree => n,
lieAlgebra => L};
E:=new ExtAlgebra from J;
E#cache.gens=apply(M#numgens,i->new E from
new BasicList from {new BasicList from {1_(L#Field)},
new BasicList from {i}});
net E:= x->(
if all(x#0,y->y==0) then out:=toString 0 else
out=outputext x;
if substring(out,0,1)=== "+" then substring(out,2) else
if substring(out,0,2)=== " +" then substring(out,3) else out
);
setgen(E);
L#cache.Ext=E;
E
)
);
member(LieElement,LieSubSpace):=(x,S)->(
n:=ideglie x;
if n==0 then true else (
B:=basis(n,S);
L:=class x;
M:=S#lieAlgebra;
L===M and length isubSpace(n,append(ifed\B,ifed x),L)==length B
)
);
kernel(LieAlgebraMap):=kernel(LieDerivation):=opts->f->inverse(f,zeroIdeal target f);
image(LieAlgebraMap):=f->image(f,fullLieSubAlgebra source f);
image(LieDerivation):= f->image(f,fullLieIdeal source f);
annihilator(FGLieSubAlgebra):=opts->(S)->(
L:=S#lieAlgebra;
quotient(zeroIdeal L,S)
);
center=method()
center(LieAlgebra):=L->(
c:=annihilator(fullLieSubAlgebra L);
new LieIdeal from c
);
basis(ZZ,VectorSpace):=List=>opts->(n,S)->
if S#?homology then flatten for j to n-1 list basis(n,j,S) else (
L:=S#lieAlgebra;
computeLie(n,L);
dL:=differential L;
if S#?ideal then
if S#cache#?n then out:=S#cache#n else (
y:=select(S#gens,x->ideglie x<=n);
yy:=ifed\y;
out=apply(iideal(n,yy,S),x->idef(x,L));
S#cache#n=out;
);
if S#?subIdeal then
if S#cache#?n then out=S#cache#n else (
A:=S#gens;
out=apply(iideal(n,A,S),x->idef(x,L));
S#cache#n=out;
);
if S#?subAlgebra then
if S#cache#?n then out=S#cache#n else (
y=select(S#gens,x->ideglie x<=n);
yy=ifed\y;
out=apply(isubalg(n,yy,S),x->idef(x,L));
S#cache#n=out;
);
if S#?subSpace then
if S#cache#?n then out=S#cache#n else (
xn:=select(S#gens,y->ideglie y==n);
out=apply(isubSpace(n,skipz(ifed\xn),L),y->idef(y,L));
S#cache#n=out;
);
if S#?image then (
if S#cache#?n then out=S#cache#n else (
f:=(S#image)_0;
A=(S#image)_1;
if class f===LieAlgebraMap then (
arg:=basis(n,A);
imf:=f\arg;
out=apply(isubSpace(n,ifed\imf,L),y->idef(y,L))
) else (
arg=basis(n-(f#weight)_0,A);
idi:= skipz(ifed\f\\arg);
out=apply(isubSpace(n,idi,L),y->idef(y,L))
);
S#cache#n=out;
)
);
if S#?inverse then (
if S#cache#?n then out=S#cache#n else (
f=(S#inverse)_0;
A=(S#inverse)_1;
T:=target f;
M:=source f;
if class f===LieAlgebraMap then
if basis(n,T)=={} then out=S#cache#n=basis(n,M) else (
b:=f\basis(n,M);
An:=ifed\basis(n,A);
if An=={} then An={0_(T#cache.lieRing)};
if b=={} then out={} else (
mat:=invimage(
basToMat(n,ifed\b,T),
basToMat(n,An,T));
out=apply(matToBas(n,mat,M),x->idef(x,M)));
S#cache#n=out;
) else (
nn:=n+(f#weight)_0;
if basis(nn,T)=={} then out=S#cache#n=basis(n,M) else (
b=f\basis(n,M);
An=ifed\basis(nn,A);
if An=={} then An={0_(T#cache.lieRing)};
if b=={} then out={} else (
mat=invimage(
basToMat(nn,ifed\b,T),
basToMat(nn,An,T));
out=apply(matToBas(n,mat,M),x->idef(x,M)));
S#cache#n=out;
)
)
)
);
if S#?quotient then (
if S#cache#?n then out=S#cache#n else (
I:=(S#quotient)_0;
J:=(S#quotient)_1;
if L#cache.basis#n=={} then S#cache#n=out={} else (
p:=J#gens;
matlist:=apply(p,y->(
d:=ideglie y;
computeLie(n+d,L);
m:=ifed\basis(n+d,I);
if m==={} then m={0_(L#cache.lieRing)};
if L#cache.basis#(n+d)=={} then
matrix table(1,L#cache.dim#n,x->0_(L#Field)) else (
B:=transpose basToMat(n+d,m,L);
kerB:=transpose generators kernel(B);
kerB*basToMat(n+d,apply(ibasis(n,L),x->imult(ifed y,x,L)),L)
)
)
);
out=apply(matToBas(n,generators kernel joinvert matlist,L),x->idef(x,L));
S#cache#n=out;
)
)
);
if S#?sum then (
if S#cache#?n then out=S#cache#n else (
I=(S#sum)_0;
J=(S#sum)_1;
In:=basis(n,I);
Jn:=basis(n,J);
out=S#cache#n=apply(isubSpace(n,ifed\join(In,Jn),L),x->idef(x,L))
)
);
if S#?intersect then (
if S#cache#?n then out=S#cache#n else (
I=(S#intersect)_0;
J=(S#intersect)_1;
In=basis(n,I);
Jn=basis(n,J);
if In=={} or Jn=={} then out={} else (
Imat:=transpose basToMat(n,ifed\In,L);
Jmat:=transpose basToMat(n,ifed\Jn,L);
out=S#cache#n=apply(matToBas(n,
generators kernel transpose(
generators kernel Imat|generators kernel Jmat),L),
x->idef(x,L))
)
)
);
out
);
basis(ZZ,ZZ,VectorSpace):=List=>opts->(n,j,S)-> (
if n<0 or j<0 or j>n then {} else
(
L:=S#lieAlgebra;
computeLie(n,L);
dL:=differential L;
if S#?homology then (
if S#?boundaries then (
if S#cache#?(n,j) then S#cache#(n,j) else (
if j==n-1 then idi:={} else
idi=ifed\skipzz(dL\basis(n,j+1,L),L);
if idi==={} then S#cache#(n,j)={} else
S#cache#(n,j)=apply(flatten entries gens gb(
ideal idi,DegreeLimit=>
prepend(n,flatten table(1,length((L#Weights)_0)-1,x->0))),
x->idef(x,L))
)
) else
if S#?cycles then (
if S#cache#?(n,j) then S#cache#(n,j) else (
if j==0 then S#cache#(n,0)=basis(n,0,L) else (
ba:=basToMat(n,j-1,ifed\dL\basis(n,j,L),L);
if ba==0 then S#cache#(n,j)=basis(n,j,L) else
S#cache#(n,j)=apply(
skipz matToBas(n,j,matrix gens kernel ba,L),x->idef(x,L))
)
)
) else (
if S#cache#?(n,j) then S#cache#(n,j) else (
B:=boundaries(L);
Z:=cycles(L);
Bnj:=ifed\basis(n,j,B);
Znj:=ifed\basis(n,j,Z);
if Bnj=={} then prel:=Znj else (
I:=ideal Bnj;
prel=skipz apply(Znj,x->x%I)
);
if prel=={} then {} else
S#cache#(n,j)=apply(
flatten entries gens gb(ideal prel,DegreeLimit=>
prepend(n,flatten table(1,L#degreeLength-1,x->1))),x->idef(x,L))
)
)
) else select(basis(n,S),x->(iweight x)_(-1)==j)
)
);
basis(List,VectorSpace):=List=>opts->(x,S)->
if S#?homology then select(basis(x_0,x_(-1),S),y->iweight(y)==x) else
select(basis(x_0,S),y->iweight(y)==x);
basis(ZZ,LieAlgebra):=List=>opts->(n,L)->(
if n<=0 then {} else (
computeLie(n,L);
apply(ibasis(n,L),x->idef(x,L))
)
);
basis(ZZ,ZZ,LieAlgebra):=List=>opts->(n,d,L)->(
if n<=0 then {} else (
computeLie(n,L);
apply(ibasis(n,d,L),x->idef(x,L))
)
);
basis(List,LieAlgebra):=List=>opts->(x,L)->
select(basis(x_0,x_(-1),L),y->iweight(y)==x);
basis(ZZ,ExtAlgebra):=List=>opts->(n,E)->
flatten for j to n list basis(n,j,E);
basis(ZZ,ZZ,ExtAlgebra):=List=>opts->(n,j,E)->(
if E#cache#?(n,j) then E#cache#(n,j) else
E#cache#(n,j)=select(E#cache.gens,x->first(weight x)==n and last(weight x)==j)
);
basis(List,ExtAlgebra):=List=>opts->(x,E)->
select(basis(x_0,x_(-1),E),y->weight y==x);
dim(ZZ,VectorSpace):=(n,S)-> length basis(n,S);
dim(ZZ,LieAlgebra):=(n,L)->length basis(n,L);
dim(ZZ,ExtAlgebra):=(n,E)->length basis(n,E);
dim(ZZ,ZZ,VectorSpace):=(d,n,S)-> length basis(d,n,S);
dim(ZZ,ZZ,LieAlgebra):=(d,n,L)->length basis(d,n,L);
dim(ZZ,ZZ,ExtAlgebra):=(d,n,E)->length basis(d,n,E);
dim(List,VectorSpace):=(x,S)-> length basis(x,S);
dim(List,LieAlgebra):=(x,L)->length basis(x,L);
dim(List,ExtAlgebra):=(x,E)->length basis(x,E);
----------------------------------------
--eulers, euler
----------------------------------------
-- computes the list of eulercharacteristics of
-- first degree 1 to n. It is
-- assumed that the homological degree is less
-- than the first degree.
-- Also euler(L) is the Euler derivation on L
eulers(ZZ,LieAlgebra):=List=>(n,L)->(
computeLie(n,L);
for i from 1 to n list sum apply(i,j->(-1)^j*dim(i,j,L))
);
euler(LieAlgebra) := LieDerivation=>L->
lieDer(apply(gens L,x->(firstDegree x) x),L);
-------------------------------
-- baseName
-------------------------------
-- this is the extension of the built-in function
-- baseName to cover the case LieElement, ExtElement, the output
-- is the symbol name of a generator.
baseName(LieElement):=x->(
L:=class x;
i:=((x#1)#0)#0;
(L#genslie)_i);
baseName(ExtElement):=x->(
E:=class x;
i:=(x#1)#0;
toString(ext_i)
);
---------------------------------------
-- empty, the empty BasicList
--------------------------------------
empty=new BasicList from {};
----------------------------------------------------
-- CONSTRUCTIONS OF LIE ALGEBRAS
----------------------------------------------------
----------------------------------
-- LIEALGEBRA
----------------------------------
-- construction of a free non-differential Lie algebra
lieAlgebra = method(TypicalValue => LieAlgebra,Options =>
{Weights => 1, Signs => 0, Field => QQ, LastWeightHomological=> false} )
lieAlgebra(List) := opts->(generators)->(
weights:=opts.Weights;
signs:=opts.Signs;
numg:=length generators;
diffl:=opts.LastWeightHomological;
field:=opts.Field;
if generators==={} then L:=zeroLieAlgebra(field) else (
if signs===0 then signs=flatten table(1,numg,x->0);
if signs===1 then signs=flatten table(1,numg,x->1);
if weights===1 then weights=flatten table(1,numg,x->1);
if not numg==length weights then
error "the number of weights must be equal to the number of generators";
if class weights_0===ZZ and diffl then (
error "there is no homological degree defined";
);
if class (weights)_0===List and not diffl then (
weights=apply(weights,x->append(x,0));
);
if class (weights)_0===ZZ and not diffl then (
weights=apply(weights,x->{x,0});
);
if min(apply(weights,x->x_0))<1 then (
error "the (first) degree of a generator must be at least one";
);
if length unique (length\weights)>1 then (
error "all weights must have the same length";
);
if not numg==length signs then (
error "the number of signs must be equal to the number of generators";
);
if not all(signs,x->x===0 or x===1) then (
error "all signs must be 0 or 1";
);
if diffl and any(weights,x->x_0<=x_(-1)) then (
error "the homological (last) degree must be less than the (first) degree";
);
if diffl and any(weights,x->x_(-1)<0) then (
error "the homological (last) degree must be non-negative";
);
deglen:=length (weights)_0;
L = new MutableHashTable of LieElement from new HashTable from {
genslie=>apply(generators,baseName),
Weights=>weights,
Signs=>signs,
Field=>field,
cache=>new CacheTable,
ideal=>{},
diff=>{},
numgens=>numg,
degreeLength=>deglen
};
L#cache.degree=0;
L#cache.max=5;
L#cache.mbRing=field[];
L#cache.dim=new MutableHashTable;
L#cache.opL=new MutableHashTable;
L#cache.basis=new MutableHashTable;
L#cache.gb=new MutableHashTable;
L#cache.degrees=new MutableHashTable;
L#cache.lieRing=lieR(L);
L#cache.basis#0={mb0};
L#cache.dim#0=1;
net L:= x->(
if x#0===empty then out:=toString 0 else (
if x#0#0==1 and #x#1==1 then
out=outmon(x#1#0,L) else out=outputrec x;
);
if substring(out,0,1)=== "+" then substring(out,2) else
if substring(out,0,2)=== " +" then substring(out,3) else out
);
M:=new LieAlgebra from L;
M#cache.ambient=M;
M#cache.gens=apply(M#numgens,i->new M from (
new BasicList from {new BasicList from {1_(M#Field)},
new BasicList from {new BasicList from {i}}}));
for i from 0 to M#numgens-1 do (M#genslie)_i<-(M#cache.gens)_i;
M
));
-------------------------------------
-- the internal version of lieAlgebra with relations and differential
-- this version does not set the generators
-------------------------------------
ilieAlgebra = method(TypicalValue => LieAlgebra,Options =>
{Weights => 1, Signs => 0, Field => QQ})
ilieAlgebra(List,List,List) := opts->(g,r,d)->(
weights:=opts.Weights;
signs:=opts.Signs;
field:=opts.Field;
numg:=length g;
deglen:=if weights=={} then 0 else length (weights)_0;
L := new MutableHashTable of LieElement from new HashTable from {
genslie=>apply(g,baseName),
Weights=>weights,
Signs=>signs,
Field=>field,
cache=>new CacheTable,
ideal=>r,
diff=>d,
numgens=>numg,
degreeLength=>deglen};
L#cache.degree=0;
L#cache.max=5;
L#cache.mbRing=field[];
L#cache.dim=new MutableHashTable;
L#cache.opL=new MutableHashTable;
L#cache.basis=new MutableHashTable;
L#cache.gb=new MutableHashTable;
L#cache.degrees=new MutableHashTable;
L#cache.lieRing=lieR(L);
L#cache.basis#0={mb0};
L#cache.dim#0=1;
net L:= x->(
if x#0===empty then out:=toString 0 else (
if x#0#0==1 and #x#1==1 then
out=outmon(x#1#0,L) else out=outputrec x;
);
if substring(out,0,1)=== "+" then substring(out,2) else
if substring(out,0,2)=== " +" then substring(out,3) else out
);
M:=new LieAlgebra from L;
M#cache.ambient=if r==={} and d==={} then M else if not d==={} then
class(d_0) else class(r_0);
M#cache.gens=apply(M#numgens,i->new M from (
new BasicList from {new BasicList from {1_(M#Field)},
new BasicList from {new BasicList from {i}}}));
M
);
-------------------------------------
-- the internal version of a lieAlgebra modulo an ideal,
-- this version does not set the generators