/
OIModules.m2
1434 lines (1265 loc) · 37.5 KB
/
OIModules.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 -*-
newPackage( "OIModules",
Version => "0.1.0",
Date => "July 22, 2019",
Authors => {
{Name => "Nathan Fieldsteel",
Email => "nathan.fieldsteel@uky.edu"},
{Name => "Tom Grubb",
Email => "tgrubb@ucsd.edu"},
{Name => "Robert Krone",
Email => "rckrone@ucdavis.edu"},
{Name => "Erica Musgrave",
Email => "erica.musgrave@huskers.unl.edu"},
{Name => "Jonathan Niño",
Email => "ninojonathan4@gmail.com"},
{Name => "Steven Sam",
Email => "ssam@ucsd.edu"}
},
HomePage => "https://nathanfieldsteel.github.io",
Headline => "A package for computations with OI-algebras and modules over OI-algebras",
AuxiliaryFiles => false)
export {
"oiObject",
"OIObject",
"oiMorphism",
"OIMorphism",
"oiAlgebra",
"OIAlgebra",
"oiModule",
"OIModule",
"oiModuleMap",
"OIModuleMap",
"oiHom",
"getOIBasis",
"getWidthList",
"idOI",
"Generators",
"Relations",
"gensMap",
"oiMonomialsToHilbert",
"OIInitial",
"OIGCD",
"repToHilb",
"OILCM",
"OIGroebner",
"OIElement",
"OIMonomials",
"OIMontoHilbert",
"Hilb",
"isOIMonomial",
"oihs",
"oigb"
}
protect \ {widthList,OIAlg,OIBasis,imageGensList,isFree}
---------------
-- New types --
---------------
OIObject = new Type of VisibleList
OIMorphism = new Type of HashTable
OIModule = new Type of HashTable
OIModuleElement = new Type of HashTable
OIModuleMap = new Type of HashTable
OIAlgebra = new Type of MutableHashTable
OIAlgebra.synonym = "constant OI-Algebra"
OIAlgebra.GlobalAssignHook = globalAssignFunction
OIAlgebra.GlobalReleaseHook = globalReleaseFunction
-----------------------
-- Type constructors --
-----------------------
-- constructor for OIElements
OIElement = method()
OIElement HashTable := OIModuleElement => H ->( --CONSTRUCTOR FUNCTION FOR OIELEMENT
new OIModuleElement from H)
OICleaner = m ->( --Given an OI element, drops any value whose hash (coefficient) is zero
templist :={};
for i in keys m do(
if m#i !=0 then templist = append(templist,{i,m#i}));
return OIElement(hashTable(templist)))
OIModuleElement == OIModuleElement := (a,b) ->( --Equality tester for OIElements
tempbool:=true;
if keys a != keys b then tempbool = false
else for i in keys a when tempbool == true do(
if a#i != b#i then tempbool = false);
return tempbool)
OIMonomials = method()
OIMonomials OIModuleElement := List => H -> keys H --Returns a list of the OIMorphisms appearing in OIElement
OIMorphism*OIModuleElement := (a,b) ->( --Applies OIMorphism to OIElement
temp:={};
for i in keys b do(
temp = append(temp,{a i,b#i}));
return OIElement(hashTable(temp)))
OIModuleElement + OIModuleElement := (a,b) ->( --Addition of OIElements
temp := {};
for i in OIMonomials a do(
if b#?i then temp = append(temp, {i,a#i+b#i})
else temp = append(temp,{i,a#i}));
for j in OIMonomials b do(
if not a#?j then temp = append(temp,{j,b#j}));
temphash := new HashTable from temp;
return OICleaner(OIElement temphash))
--Scaling an OIElement by ZZ, QQ, and RingElement
ZZ*OIModuleElement := (a,b) -> (OIElement(hashTable(for i in keys b list {i,a*b#i})))
QQ*OIModuleElement := (a,b) -> (OIElement(hashTable(for i in keys b list {i,a*b#i})))
RingElement*OIModuleElement := (a,b) -> (OIElement(hashTable(for i in keys b list {i,a*b#i})))
--Subtraction is just inverse addition
OIModuleElement - OIModuleElement := (a,b) -> a+((-1)*b)
--Tests if an OIMorphism a divides an OIMorphism b by computing their associated polynomial monomials and
--testing divisibility there
OIDivides = (a,b) ->(
if #(source a)!= #(source b) then(
return false)
else if b(1) < a(1) then(
return false)
else(
tempbool:=true;
for i from 1 to (#(source b)-1) do(
if b(i+1)-b(i) < a(i+1)-a(i) then(
tempbool = false));
if #(target b) - b(#source b) < #(target a) - a(#source a) then tempbool = false;
return tempbool))
--Given a morphism a which divides a morphism b, provides the lex smallest f for which f a = b
OIDivider = (a,b) ->(
assert(OIDivides(a,b));
btarget := toList(1..#(target b));
asource := toList(1..#(source a));
atarget := toList(1..#(target a));
templist := {};
tempbig:={};
for i from 1 to #(source a) do(
templist = append(templist,{a(i),b(i)});
btarget = delete(b(i),btarget);
atarget = delete(a(i),atarget));
temphash:= hashTable(templist);
for i in atarget do(
if i==1 then templist = append(templist,{i,btarget_0})
else(
tempbig={};
for j in btarget when tempbig=={} do(
if j>temphash#(i-1) then tempbig = append(tempbig,j));
templist = append(templist,{i,tempbig_0}));
temphash = hashTable templist);
tempmorph := for i in sort(keys temphash) list temphash#i;
f:= oiMorphism(tempmorph,#(target b));
assert((f a) ==b);
return f)
--Given a list of OIElements, returns a list of their initial terms
oiInitialTerms = L->(
temp:={};
for i in L do(
temp = append(temp,OIElement(hashTable{{OIInitial i,1}})));
return temp)
--Given OIElements, putatively returns the Hilbert series of the rep they generate
repToHilb = L->oiMonomialsToHilbert(oiInitialTerms(OIGroebner(L)))
--Given a list of OIMorphisms, returns the max (in lex order)
MaxOIMon = L ->(
temp :=L_0;
for i in L do if i>temp then temp = i;
return temp)
--Given OIElement, returns initial OIMorphism appearing in the element
OIInitial = m -> MaxOIMon OIMonomials m
--Given two OIMorphisms a,b returns a list of all morphisms c for which c a = b.
OIDivideList = (a,b) ->(
temp:={};
for i in oiHom(target a, target b) do(
if (i a) ==b then temp = append(temp, i));
return temp)
--Given an OIElement and a list L of dividers, returns (a) remainder upon dividing m by L.
OIDivisionAlgorithm = (m,L) ->(
tempbool := false;
init:=0;
dummy:=m;
divider :=0;
remain := 0;
templist:={};
initialL := for i in L list {i,OIInitial i};
for i in initialL when (not tempbool) do(
for k in (keys m) when (not tempbool) do(
if OIDivides(i_1,k) then tempbool = true));
while tempbool == true and #(keys dummy)>0 do(
templist={};
for k in keys dummy do(
for i in initialL do(
if OIDivides(i_1,k) then templist=append(templist,k)));
init=MaxOIMon templist;
for i in initialL do(
if OIDivides(i_1,init) then(
divider = i_0;
break));
initdivider := OIInitial divider;
dummy = dummy - (dummy#init/divider#(initdivider))*((OIDivider(initdivider,init))*divider);
tempbool = false;
for i in initialL when (not tempbool) do(
for k in (keys dummy) when (not tempbool) do(
if OIDivides(i_1,k) then tempbool = true));
);
return dummy)
OIGCD = (a,b) ->(
tempa:={a(1)-1};
tempb:={b(1)-1};
temp:={};
tempreturn:={};
for i from 1 to (#(source a)-1) do(
tempa = append(tempa,a(i+1)-a(i)-1);
tempb = append(tempb,b(i+1)-b(1)-1));
tempa = append(tempa,#target(a) - a(#(source a)));
tempb = append(tempb,#target(b) - b(#(source b)));
for i from 0 to (#tempa-1) do temp = append(temp,min(tempa_i,tempb_i));
tempreturn = {temp_0+1};
for i from 1 to (#temp-2) do(
tempreturn = append(tempreturn,temp_i+tempreturn_(i-1)+1));
return oiMorphism(tempreturn,temp_(#temp-1)+tempreturn_(#tempreturn-1)))
OILCM = (a,b) ->(
tempa:={a(1)-1};
tempb:={b(1)-1};
temp:={};
tempreturn:={};
for i from 1 to (#(source a)-1) do(
tempa = append(tempa,a(i+1)-a(i)-1);
tempb = append(tempb,b(i+1)-b(1)-1));
tempa = append(tempa,#target(a) - a(#(source a)));
tempb = append(tempb,#target(b) - b(#(source b)));
for i from 0 to (#tempa-1) do temp = append(temp,max(tempa_i,tempb_i));
tempreturn = {temp_0+1};
for i from 1 to (#temp-2) do(
tempreturn = append(tempreturn,temp_i+tempreturn_(i-1)+1));
return oiMorphism(tempreturn,temp_(#temp-1)+tempreturn_(#tempreturn-1)))
oiSyzZero = (a,b) -> ( --EVENTUALLY SHOULD REMOVE DUPLICATES I.E. SYZ0 SHOULDNT HAVE (f,g) and (g,f)
mona := (keys a)_0;
monb := (keys b)_0;
temp:={};
temppair :={};
tempreverse:={};
newtemp := {};
finalreturn :={};
tempbool := false;
targetstart := max(#(target mona),#(target monb));
maxtarget := #(target mona)+#(target monb)-#(source mona);
for i from targetstart to maxtarget do(
for h in oiHom(#(target mona),i) do(
for h' in oiHom(#(target monb), i) do(
if h*a == h'*b then temp = append(temp, (h,h')))));
for k from 1 to #temp-1 do(
tempbool = false;
h := temp_(-k)_0;
for l from 0 to #temp-k-1 do(
f:=temp_l_0;
for morph in oiHom(target f,target h) do(
if (morph temp_l_0,morph temp_l_1)==temp_(-k) then tempbool = true);
if not tempbool then newtemp = append(newtemp,temp_(-k))));
newtemp = unique newtemp;
newtemp = append(newtemp,temp_0);
--print newtemp;
--print newtemp;
for i from 0 to #newtemp-2 do(
temppair = newtemp_i;
--print temppair;
--print("I am printing hopefully a thing",(temppair_1,temppair_0));
tempreverse = {(temppair_1,temppair_0)}_0;
--print temppair;
--print("tempreverse",tempreverse);
if not member(tempreverse,newtemp_{i+1,#newtemp-1}) then finalreturn = append(finalreturn,temppair));
finalreturn = prepend(newtemp_(-1),finalreturn);
return finalreturn)
OISPairs = (a,b)->(
temp :={};
inita:=OIInitial a;
initb:=OIInitial b;
tempsyz:=oiSyzZero(OIElement(hashTable{{inita,1}}),OIElement(hashTable{{initb,1}}));
for i in tempsyz do(
temppair := (b#initb)*(i_0*a) - (a#inita)*(i_1*b);
if #(keys temppair)>0 then temp = append(temp,(b#initb)*(i_0*a) - (a#inita)*(i_1*b)));
return toList(set(temp)))
OIGroebner = L ->(
Grob:= L;
tempGrob:={};
SPolys:= {};
calculated:={};
while Grob != tempGrob do(
--print(Grob,tempGrob);
SPolys = {};
tempGrob = Grob;
tempbool := true;
-- print(target((keys(Grob_(-1)))_0));
print(Grob);
-- for i in Grob do print(i,target (keys i)_0);
--print(calculated);
for i in tempGrob do(
for j in tempGrob do(
if not member({i,j},calculated) and not member({j,i},calculated) then(
calculated = append(calculated,{i,j});
for k in OISPairs(i,j) do(
SPolys = append(SPolys,k)))));
-- print("NUMBER OF",#SPolys);
for i in SPolys do(
tempbool = true;
-- print("BEFORE DIVISION",i,Grob);
Lemon := OIDivisionAlgorithm(i,Grob);
-- print("AFTER DIVISION");
-- print Lemon;
if keys(Lemon) !={} and not member(OIInitial Lemon,Grob/OIInitial) then(
for Apple in Grob do(
if OIDivides(OIInitial Apple,OIInitial Lemon) then tempbool = false);
if tempbool == true then Grob = append(Grob,(1/Lemon#(OIInitial Lemon))*Lemon)));
Grob = oiGrobPrune(Grob));
return(Grob))
oiGrobPrune = L ->(
tempbool := false;
tempa :=L;
tempb :={};
while tempa != tempb do(
tempb = tempa;
for i in tempa do(
tempbool = false;
for j in tempa do(
if i!=j and OIDivides(OIInitial j,OIInitial i) then tempbool = true);
if tempbool == true then tempa = delete(i,tempa)));
return tempa)
oiMonomialsToHilbert = L ->(
basecase:= L_0;
basemorphism := (keys basecase)_0;
n := #source basemorphism;
R := QQ; --TO BE REPLACED BY ARBITRARY RING
x := getSymbol "x";
S := R[x_0..x_n];
temp := {};
for mon in L do(
tempmonomial :=1;
t := (keys mon)_0;
m := #(target t);
tempmonomial = tempmonomial*(S_0)^(t(1)-1)*(S_n)^(m-t(n));
for i from 1 to n-1 do tempmonomial = tempmonomial*(S_i)^(t(i+1)-t(i)-1);
temp = append(temp,tempmonomial);
);
I := ideal(temp);
temphilb:=reduceHilbert(hilbertSeries(I));
return ((gens class numerator temphilb)_0^n*numerator(temphilb)/denominator(temphilb)))
-*OrderPreservingInjectiveFunction == OrderPreservingInjectiveFunction := (a,b) ->(
if #(source a) != #(source b) then return false
else if #(target a)!= #(target b) then return false
else(
tempbool := true;
for i from 1 to #(source a) do(
if a(i) != b(i) then tempbool = false);
return tempbool)) *-
-- constructor for OIObject objects
oiObject = method()
oiObject ZZ := OIObject => n -> (
if n < 0 then error "can't make OIObject from negative integer";
new OIObject from toList(1..n)
)
oiObject OIObject := OIObject => obj -> obj
net OIObject := (obj) -> (
"[" | (toString length obj) |"]"
)
toString OIObject := (obj) -> (
toString net obj
)
oiMorphism = method()
oiMorphism List := OIMorphism => (l) -> (
new OIMorphism from {
symbol source => oiObject length l,
symbol target => oiObject max l,
symbol values => l
}
)
oiMorphism (List,ZZ) := OIMorphism => (l,n) -> (
new OIMorphism from {
symbol source => oiObject length l,
symbol target => oiObject n,
symbol values => l
}
)
net OIMorphism := (epsilon) -> (
vals := epsilon#(symbol values);
if (length vals == 0) then (
net 0
) else (
if (length vals == 1) then (
net vals_0
)
else (
(fold(vals, (x,y) -> (toString x) | (toString y)))
)
)
)
-- get source object
source OIMorphism := OIObject => (epsilon) -> (
epsilon#(symbol source)
)
-- get target object
target OIMorphism := OIObject => (epsilon) -> (
epsilon#(symbol target)
)
-- apply function to integers
OIMorphism ZZ := ZZ => (ep, n) -> (
ep#(symbol values)_(n-1)
)
-- function composition
OIMorphism OIMorphism := OIMorphism => (epsilon, tau) -> (
composedVals := (toList source tau) / (i -> tau i) / (j -> epsilon j);
new OIMorphism from {
symbol source => source tau,
symbol target => target epsilon,
symbol values => composedVals
}
)
-- compare morphisms in OI
OIMorphism ? OIMorphism := (ep, tau) -> (
if source ep != source tau then (
symbol incomparable
)
else (
if (target ep != target tau) then (
length target ep ? length target tau
)
else (
ep#(symbol values) ? tau#(symbol values)
)
)
)
OIMorphism == OIMorphism := Boolean => (ep, tau) -> (
if (source ep == source tau and target ep == target tau and ep#(symbol values) == tau#(symbol values)) then (
true
) else (
false
)
)
oiHom = method()
oiHom (OIObject, OIObject) := List => (ob1, ob2) -> (
subsets(toList ob2, length ob1) / (l -> oiMorphism(l,length ob2))
)
oiHom (ZZ,ZZ) := List => (m,n) -> (
oiHom(oiObject m, oiObject n)
)
oiAlgebra = method()
oiAlgebra Ring := OIAlgebra => (K) -> (
new OIAlgebra from {symbol ring => K}
)
ring OIAlgebra := (A) -> A#(symbol ring)
OIAlgebra OIObject := Ring => (A,n) -> ring A
oiModule = method(Options=>{Generators=>null,Relations=>null})
oiModule(OIAlgebra,List) := OIModule => o -> (A,l) -> (
new OIModule from {
cache => new MutableHashTable from {},
numgens => length l,
widthList => l,
OIAlg => A,
generators => o.Generators,
relations => o.Relations,
isFree => (o.Generators === null and o.Relations === null)
}
)
net OIModule := M -> (
if M.isFree then "Free OI-module on "|net(M.widthList)
else "OI-module generated by "|net(M#generators)
)
gensMap = method()
gensMap OIModule := M -> (
if M#generators =!= null then M#generators else idOI(M)
)
OIAlgebra ^ List := OIModule => (A,l) -> oiModule(A,l)
getWidthList = method()
getWidthList OIModule := List => (M) -> M.widthList
oiAlgebra OIModule := OIAlgebra => (M) -> M.OIAlg
OIModule ++ OIModule := OIModule => (M,N) -> (
A := oiAlgebra M;
if (ring A =!= ring oiAlgebra N) then
error "expected OIModules over the same OIAlgebra";
oiModule(A, getWidthList M | getWidthList N)
)
retrieveModule = method()
retrieveModule (OIModule, OIObject) := Module => (M,n) -> (
phi := M#generators;
psi := M#relations;
R := ring oiAlgebra M;
naturalBasis := flatten (M.widthList / (w -> sort oiHom(oiObject w,n)));
nthModule := R^(length naturalBasis);
relsmat := if psi =!= null then (psi n) else map(nthModule,R^0,0);
relsmat = map(nthModule,target relsmat,id_(target relsmat))*relsmat;
if phi =!= null then (
gensmat := (phi n);
gensmat = map(nthModule,target gensmat,id_(target gensmat))*gensmat;
nthModule = subquotient(nthModule,gensmat,relsmat);
) else
nthModule = nthModule/image relsmat;
nthModule.cache#(symbol OIBasis) = naturalBasis;
M.cache#n = nthModule;
nthModule
)
OIModule OIObject := Module => (M,n) -> (
((cacheValue n) (a -> retrieveModule(a,n))) M
)
OIModule ZZ := Module => (M,n) -> M (oiObject n)
generators OIModule := List => o -> M -> (
if M#generators =!= null then gens M#generators
else gens idOI M
)
retrieveMorphism = method()
retrieveMorphism (OIModule, OIMorphism) := Matrix => (M,ep) -> (
sourceModule := M source ep;
targetModule := M target ep;
summandMatrices := M#widthList / (w -> inducedMorphism(ep,w));
integerMatrix := fold(summandMatrices, (a,b) -> a++b);
ringMatrix := sub(integerMatrix, ring oiAlgebra M);
map(targetModule, sourceModule, ringMatrix)
)
OIModule OIMorphism := Matrix => (M,ep) -> (
((cacheValue ep) (a -> retrieveMorphism(a,ep))) M
)
inducedMorphism = method()
-- given a principle projective P_n and an OImorphism ep, the matrix for the induced map
-- P_n(b) <- P_n(a) (here, ep is a morphisms from [a] to [b])
inducedMorphism (OIMorphism,ZZ) := Matrix => (ep,n) -> (
sourceBasis := sort oiHom(oiObject n, source ep);
targetBasis := sort oiHom(oiObject n, target ep);
matrixEntriesFunction := (i,j) -> (
if (ep sourceBasis_j == targetBasis_i) then (
1
) else (
0
)
);
map(ZZ^(length targetBasis), ZZ^(length sourceBasis), matrixEntriesFunction)
)
getOIBasis = method()
getOIBasis Module := List => (M) -> (
if (M.cache #? (symbol OIBasis)) then (
M.cache# (symbol OIBasis)
)
else (
error "Module does not have a cached OIBasis"
)
)
--Add a check that the imageGensList is the same length as the
--number of generators of M
oiModuleMap = method()
oiModuleMap (OIModule, OIModule, List) := OIModuleMap => (M,N,l) -> (
new OIModuleMap from {
cache => new MutableHashTable from {},
source => N,
target => M,
imageGensList => l
}
)
idOI = method()
idOI(OIModule) := OIModuleMap => (M) -> (
R := ring oiAlgebra M;
l := for i from 0 to #M.widthList-1 list flatten for j from 0 to #M.widthList-1 list (
k := #oiHom(oiObject M.widthList#j, oiObject M.widthList#i);
toList (k: if i==j then 1_R else 0_R)
);
l = apply(l, L -> transpose matrix{L});
oiModuleMap(M,M,l)
)
generators OIModuleMap := List => o -> phi -> phi.imageGensList
source OIModuleMap := phi -> phi#source
target OIModuleMap := phi -> phi#target
retrieveMorphism (OIModuleMap, OIObject) := matrix => (phi, obj) -> (
n := length obj;
M := target phi;
N := source phi;
R := ring oiAlgebra M;
if (M n) == 0 then return map(M n, N n, 0);
if (N n) == 0 then return map(M n, N n, 0);
vectors := {};
widths := getWidthList N;
imageGens := gens phi;
for i from 0 to ((length widths)-1) when widths_i < n+1 do (
maps := sort oiHom(widths_i, n);
for j from 0 to ((length maps)-1) do (
ep := maps_j;
imageEpMatrix := M ep;
m := map(source imageEpMatrix, target imageGens_i, id_(target imageGens_i));
imageGenMatrix := imageEpMatrix*m*matrix(imageGens_i);
vectors = append(vectors, flatten(entries(imageGenMatrix)));
)
);
transpose matrix(ring oiAlgebra M, vectors)
)
OIModuleMap OIObject := matrix => (phi, obj) -> (
((cacheValue obj) (f -> retrieveMorphism(f,obj))) phi
)
OIModuleMap ZZ := matrix => (phi, n) -> phi (oiObject n)
image OIModuleMap := OIModule => (phi) -> (
M := target phi;
oiModule(oiAlgebra M, getWidthList M, Generators => phi, Relations => M#relations)
)
coker OIModuleMap := OIModule => (phi) -> (
M := target phi;
A := oiAlgebra M;
rels := if M#relations =!= null then (
oiModuleMap(M,(source rels)++(source phi),(gens rels)|(gens phi))
) else phi;
oiModule(oiAlgebra M, getWidthList M, Generators => M#generators, Relations => rels)
)
oigb = method()
oigb(OIModule) := M -> (
A := oiAlgebra M;
R := ring A;
Mgens := gensMap M;
G := gens Mgens; -- partial GB
widths := getWidthList source Mgens;
k := min widths;
lastnewk := k;
while k < 2*lastnewk do (
Mkgb := gens gb (Mgens k); -- gb of M k
inMk := leadComponent Mkgb; -- initial term positions of M k
Gmap := oiModuleMap(target Mgens, A^widths, G);
inGk := leadComponent Gmap k; -- what inG generates in width k
-- check if each initial term of M k is in inGk. if not, it's added to G.
for i from 0 to #inMk-1 do (
if not member(inMk#i, inGk) then (
G = append(G,Mkgb_{i});
widths = append(widths,k);
lastnewk = k;
);
);
k = k+1;
);
oiModuleMap(target Mgens, A^widths, G)
)
kernel OIModuleMap := o -> (phi) -> (
M := source phi;
N := target phi;
A := oiAlgebra M;
idGens := gens(idOI M);
phiGens := gens(phi);
graphGens := apply(#phiGens, i->(idGens#i)||(phiGens#i));
graphMap := oiModuleMap(M++N, M, graphGens);
G := oigb image graphMap;
Gwidths := getWidthList (source G);
Ggens := gens G;
GelimIndices := select(#Ggens, i -> (
first leadComponent Ggens#i < numgens(M (Gwidths#i))
));
Gelimwidths := apply(GelimIndices, i->Gwidths#i);
Gelim := apply(GelimIndices, i -> (
matrix take(entries Ggens#i, numgens(M (Gwidths#i)))
));
image oiModuleMap(M, A^Gelimwidths, Gelim)
)
--composition of oiModuleMaps
OIModuleMap*OIModuleMap := OIModuleMap => (psi, phi) -> (
vectors := gens phi;
M := source phi;
widthsSource := getWidthList M;
newVectors := {};
for i from 0 to ((length vectors)-1) do (
newVectors = append(newVectors, (psi widthsSource_i)*vectors_i)
);
oiModuleMap(target psi, M, newVectors)
)
gapList := m -> (
k := 0;
L := for i in source m list (
gap := m i - k - 1;
k = m i;
gap
);
append(L,(last target m) - k)
)
cleanhs = (I,U) -> (
H := hilbertSeries I;
sub(value numerator H,matrix{{U_0}})/sub(value denominator H,matrix{{U_0}})
)
-- hilbert series of P/M
-- assumes that M is generated by a Groebner basis
oihs = method()
oihs OIModule := M -> (
gensInit := apply(gens M, g -> first leadComponent g);
gensWidths := getWidthList (source gensMap M);
Mwidths := getWidthList M;
Mparts := new MutableHashTable;
for i from 0 to #gensWidths-1 do (
k := 0;
prt := -1;
while k <= gensInit#i do (
prt = prt+1;
k = k + binomial(gensWidths#i, Mwidths#prt);
);
oimorph := (getOIBasis(M gensWidths#i))#(gensInit#i);
if not Mparts#?prt then Mparts#prt = {};
Mparts#prt = append(Mparts#prt, oimorph);
);
U := ZZ[local T];
sum for prt in keys Mparts list (
x := local x;
R := ZZ[x_0..x_(Mwidths#prt)];
mons := apply(Mparts#prt, m -> R_(gapList(m)));
--h := cleanhs(ideal{0_R},U) - cleanhs(ideal mons,U);
h := cleanhs(ideal mons,U);
(U_0)^(Mwidths#prt)*h
)
)
beginDocumentation()
multidoc ///
-- front page of documentation
Node
Key
OIModules
Headline
A Package computations with OIModules
Description
Text
Big-picture description of package goes here.
Node
Key
OIObject
(net,OIObject)
(toString,OIObject)
Headline
the class ordered finite sets
Description
Text
A finite ordered set, represented by the integers from 1 to n.
These are the objects of the category OI. Therefore an OIModule
maps OIObjects to modules. An OIModuleMap maps OIObjects to
module maps.
Example
A = oiAlgebra QQ
M = A^{1,2}
obj = oiObject 3
M obj
Node
Key
oiObject
(oiObject,ZZ)
(oiObject,OIObject)
Headline
constructor for OIObject
Usage
obj = oiObject(n)
Inputs
n:ZZ
Outputs
obj:OIObject
Description
Text
Creates an OIObject representing an ordered set with n elements.
Node
Key
OIMorphism
(source,OIMorphism)
(target,OIMorphism)
(net,OIMorphism)
(symbol SPACE,OIMorphism,ZZ)
(symbol SPACE,OIMorphism,OIMorphism)
(symbol ==,OIMorphism,OIMorphism)
(symbol ?,OIMorphism,OIMorphism)
Headline
the class of injective order-preserving maps
Description
Text
A map between two finite ordered sets that is injective and order-preserving.
These are the morphisms of the category OI. Therefore OIModule maps
OIMorphisms to module maps.
Text
One can ask for the source or target of @ofClass OIMorphism@. Morphisms can be
composed if their sources and targets are compatible, and they can be applied
to @ofClass ZZ@ in their domain.
Example
epsilon = oiMorphism({1,4,5}, 7)
tau = oiMorphism({1,3,4,5,7,8,9})
target epsilon
source tau
tau epsilon
epsilon 2
Text
The collection of all OIMorphisms between two OIObjects can be found using oiHom
Example
sourceObj = oiObject 2;
targetObj = oiObject 4;
oiHom (sourceObj, targetObj)
Text
The net used to represent @ofClass OIMorphism@ is the strings representing the
images of the function, concatenated in order. This can lead to notational
ambiguities where distinct morphism are printed with identical strings.
Example
epsilon1 = oiMorphism {1,2,3,4}
epsilon2 = oiMorphism ({1,2,3,4},5)
epsilon3 = oiMorphism {12,34}
epsilon4 = oiMorphism {1,234}
Text
Such concise notation was chosen because these objects are typically used as
indices for @ofClass IndexedVariable@, where their primary purpose is bookkeeping
for OI-algebras.
Node
Key
oiMorphism
(oiMorphism,List)
(oiMorphism,List,ZZ)
Headline
constructor for OIMorphism
Usage
epsilon = oiMorphism(images)
epsilon = oiMorphism(images, n)
Inputs
images:List
A list, specifying the images of the elements in the source.
n:ZZ
A non-negative integer specifying the target of the morphism if the one
inferred from the list of images is not correct.
Outputs
epsilon:OIMorphism
Description
Text
A morphism $\epsilon: [n] \rightarrow [m]$ in the category OI is determined
by the list of values $\{\epsilon(1), \epsilon(2), \ldots, \epsilon(n)\}$ as
well as the target $[m]$. The constructor takes inputs specifying
these data and produces @ofClass OIMorphism@. If a target is not specified,
the minimal target is inferred from the list of images.
Example
epsilon = oiMorphism({1,4,5}, 7)
tau = oiMorphism({1,3,4,5,7,8,9})
Node
Key
oiHom
(oiHom,OIObject,OIObject)
(oiHom,ZZ,ZZ)
Headline
Hom set for OI
Usage
L = oiHom(S,T)
Inputs
S:OIObject
T:OIObject
Outputs
L:List
of OIMorphisms
Description
Text
Returns a list of all morphisms between two objects in OI.
Example
S = oiObject 2
T = oiObject 4
oiHom(S,T)
oiHom(T,S)
Node
Key
OIAlgebra
(ring,OIAlgebra)
(symbol SPACE,OIAlgebra,OIObject)
Headline
the class of OI-algebras
Description
Text
An OIAlgebra is a functor from OI to algebras.
Currently only constant OI-algebras are supported. This means every
finite ordered set maps to the same algebra. OI-algerbas can have
modules defined over them
Example
R = QQ[x,y]
A = oiAlgebra R
M = A^{2}
M 3
Node
Key
oiAlgebra
(oiAlgebra,Ring)
(oiAlgebra,OIModule)
Headline
constructor for OIAlgebra
Usage
A = oiAlgebra(R)
Inputs
R:Ring
Outputs
A:OIAlgebra
a constant OI-algebra
Description
Text
Produces the constant OI-algebra that maps every OIObject to algebra R.
Example
R = QQ[x,y]
A = oiAlgebra R
obj = oiObject 3
A obj
Node
Key
OIModule
(net,OIModule)
(symbol SPACE,OIModule,OIObject)
(symbol SPACE,OIModule,ZZ)
(symbol SPACE,OIModule,OIMorphism)
(symbol ++,OIModule,OIModule)
Headline