forked from eloisagrifo/levels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.m2
368 lines (284 loc) · 11.5 KB
/
test2.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
--not a problem
restart
needsPackage "Complexes"
needsPackage "ThickSubcategories";
needsPackage "CompleteIntersectionResolutions";
R = QQ[x,y,z]/ideal"x2,xy,yz,z2"
Y = complex koszul matrix{{x,y,z}}
time supportVariety(R^1)
time supportVariety(Y, FiniteLength => true)
--problem example
uninstallPackage "ThickSubcategories"
restart
path=append(path,"~/Documents/Github/levels");
installPackage "ThickSubcategories"
restart
needsPackage "Complexes"
needsPackage "ThickSubcategories";
needsPackage "CompleteIntersectionResolutions";
R = QQ[x,y]/ideal"x2,y2"
Y = complex koszul matrix{{y}}
time supportVariety(R^1)
time supportVariety(Y)
time ann extKoszul(Y,Y, ResidueField => true)
time supportVariety(Y,FiniteLength => true)
--problem example
restart
needsPackage "Complexes"
needsPackage "ThickSubcategories";
needsPackage "CompleteIntersectionResolutions";
R = QQ[x,y,z]/ideal"x2,xy,z2"
Y = complex koszul matrix{{z}}
time supportVariety(R^1)
time supportVariety(Y)
time supportVariety(Y,FiniteLength => true)
--problem example
restart
needsPackage "Complexes"
needsPackage "ThickSubcategories";
needsPackage "CompleteIntersectionResolutions";
R = QQ[x,y,z,w]/ideal"x2,xy,yz,zw,w2"
X = complex koszul matrix{{x,y,z,w}}
time supportVariety(X)
time ann extKoszul(X,X, ResidueField => true)
time supportVariety(X,FiniteLength => true)
time supportVariety(R^1)
restart
needsPackage "Complexes"
needsPackage "ThickSubcategories";
needsPackage "CompleteIntersectionResolutions";
R = QQ[x]/ideal"x2"
Y = complex koszul matrix{{x}}
time supportVariety(R^1)
time supportVariety(Y)
time supportVariety(Y,FiniteLength => true)
M = Y
N = complex(R^1 / ideal vars R)
B = ring M;
if not(B === ring(N)) then error "expected complexes over the same ring";
if not isCommutative B
then error "'Ext' not implemented yet for noncommutative rings";
if not isHomogeneous B
then error "'Ext' received modules over an inhomogeneous ring";
if ((not isHomogeneous M) or (not isHomogeneous N))
then error "received an inhomogeneous complex";
p = presentation B
A = ring p
I = trim ideal p
n = numgens A
c = numgens I
f = apply(c, i -> I_i)
M' = restrict(M,A) -- homogeneous
assert isHomogeneous M'; -- is this necessary, that is is there a way that the construction could give a non-homogeneous module?
-- Construct ring of cohomological operators (over field)
K = coefficientRing A
X = getSymbol "X"
S = K(monoid[X_1 .. X_c, toSequence gens A,
Degrees => { apply(0 .. c-1, i -> prepend(-2, - degree f_i)),
apply(0 .. n-1, j -> prepend( 0, degree A_j))},
Heft => {-2,1} ])
-- Natural inclusion A -> S
toS = map(S,A,apply(toList(c .. c+n-1), i -> S_i),DegreeMap => prepend_0)
if (M == 0 or N == 0) then return S^0;
C = chainComplex resolution(M')
-- keys: {J,d} where J a list of integers of length c and d the degree of the source in C
homotopies = makeHomotopies(matrix{f},C)
-- Construct Cstar = (S \otimes_A C)^\natural
degreesC = sort select(keys C, i -> class i === ZZ)
-- degreesC := toList(min(C)..max(C));
Cstar = S^(apply(degreesC,i -> toSequence apply(degrees C_i, d -> prepend(i,d))))
-- Construct the (almost) differential Delta: Cstar -> Cstar[-1] that combines the homotopies and multiplication by X_i
-- We omit the sign (-1)^(n+1) which would ordinarily be used, which does not affect the homology.
-- Return X^n = X_0^{n_0} *...* X_(c-1)^{n_{c-1}} for a list of integers n
prodX = o -> product toList(apply(pairs o, i -> S_(i_0)^(i_1)))
-- Create a matrix for each entry of homotopies
r = rank Cstar
ranksC = apply(degreesC, o -> rank(C_o))
matrixfromblocks = (M) -> fold((a,b) -> a || b,apply(M, w -> fold((a,b) -> a | b, w)))
makematrix = (L,M) -> (
-- L a list {gamma,d} where gamma a list of integers of length c and d a degree of C
-- M a matrix
-- Problem if there are undefined degrees between minC and maxC
-- blockmatrix = table( #degreesC,
-- #degreesC,
-- (p,q) -> if (p == L_1 + 2*(sum L_0) - 1 - min C) and (q == L_1 - min C) then M else map(A^(ranksC#p),A^(ranksC#q),0));
-- matrixfromblocks blockmatrix
-- Find position to place M in
topleftrow := sum take(ranksC, L_1 + 2*(sum L_0) - 1 - min C);
topleftcolumn := sum take(ranksC, L_1 - min C);
matrix table(r,r, (p,q) -> (
if (
(p >= topleftrow) and (p < (topleftrow + numRows M)) and
(q >= topleftcolumn) and (q < (topleftcolumn + numColumns M))
) then
M_(p-topleftrow,q-topleftcolumn) else 0
)
)
);
DeltaCmatrix = sum(apply(select(keys homotopies,
i -> homotopies#i != 0), i -> prodX(i_0)*toS(makematrix(i,homotopies#i))))
DeltaC = map( Cstar,
Cstar,
transpose DeltaCmatrix,
Degree => { -1, degreeLength A:0 })
-- Rewrite N as a graded S-module D with a degree -1 map
degreesN = toList((min N) .. (max N))
Ndelta = apply(degreesN, i -> N.dd_i)
Nmods = apply(degreesN, i -> tensor(S,toS,restrict(N_i,A)))
Nmatrix = apply(Ndelta, f -> tensor(S,toS,restrict(f,A)))
Nsize = apply(Nmods,numgens)
Ntable = table(#Nmatrix,#Nmatrix, (p,q) -> if (p == (q-1)) then Nmatrix_(p+1) else map(S^(Nsize_p),S^(Nsize_q),0))
DeltaNmatrix = matrixfromblocks Ntable
Ngraded = fold((a,b) -> a ++ b,Nmods)
DeltaN = map(Ngraded,Ngraded,DeltaNmatrix)
SignIdCstar = diagonalMatrix flatten toList apply(pairs(ranksC), w -> if even(w_0) then apply(toList(1 .. w_1), o -> -1) else apply(toList(1 .. w_1), o -> 1))
SignIdCstar = promote(SignIdCstar, S);
DeltaBar = SignIdCstar ** DeltaN + DeltaC ** id_Ngraded;
H = prune homology(DeltaBar, DeltaBar);
ann H
C.dd
SignIdCstar
homotopies
H
((ker SignIdCstar) / (image SignIdCstar)) == 0
((SignIdCstar)^2)_(7,8)
map(S^(64),S^(64))
((SignIdCstar)^2) == id_(S^(64))
DeltaBar^2
nonzerokeys = select(keys homotopies, o -> homotopies#o != 0)
nonzeroes = apply(select(keys homotopies, o -> homotopies#o != 0), i -> homotopies#i)
#nonzeroes
i = 0
i = i+1
nonzerokeys_i
nonzeroes_i
nonzeroes_0 * nonzeroes_6
nonzeroes_1 * nonzeroes_2
nonzeroes_6
---------------------------------------------------------------
-- Test for problems with extkoszul
---------------------------------------------------------------
uninstallPackage "ThickSubcategories"
restart
installPackage "ThickSubcategories"
needsPackage "Complexes"
needsPackage "CompleteIntersectionResolutions"
needsPackage "ThickSubcategories"
---------------------------------------------------------------
-- check extKoszul
R = QQ[x,y]/ideal(x^2,y^2)
-- M = complex koszul matrix{{y}}
M = complex(R^1/ideal(y))
-- N = complex(R^1/ideal vars R)
N = complex(R^1/ideal(y))
B = R;
p = presentation B;
A = ring p;
I = trim ideal p;
n = numgens A;
c = numgens I;
f = apply(c, i -> I_i);
M' = restrict(M,A);
-- Construct ring of cohomological operators (over field)
K = coefficientRing A;
X = getSymbol "X";
S = K(monoid[X_1 .. X_c, toSequence gens A,
Degrees => { apply(0 .. c-1, i -> prepend(-2, - degree f_i)),
apply(0 .. n-1, j -> prepend( 0, degree A_j))},
Heft => {-2,1} ]);
-- Natural inclusion A -> S
toS = map(S,A,apply(toList(c .. c+n-1), i -> S_i),DegreeMap => prepend_0);
-----------------------------------------------------------
getDeltaC = (C,homotopies) -> (
degreesC = sort select(keys C, i -> class i === ZZ);
-- degreesC = toList(min(C)..max(C));
Cstar = S^(apply(degreesC,i -> toSequence apply(degrees C_i, d -> prepend(i,d))));
prodX = o -> product toList(apply(pairs o, i -> S_(i_0)^(i_1)));
-- Create a matrix for each entry of homotopies
r = rank Cstar;
ranksC = apply(degreesC, o -> rank(C_o));
matrixfromblocks = (M) -> fold((a,b) -> a || b,apply(M, w -> fold((a,b) -> a | b, w)));
makematrix = (L,M) -> (
-- L a list {gamma,d} where gamma a list of integers of length c and d a degree of C
-- M a matrix
-- Find position to place M in
topleftrow = sum take(ranksC, L_1 + 2*(sum L_0) - 1 - min C);
topleftcolumn = sum take(ranksC, L_1 - min C);
matrix table(r,r, (p,q) -> (
if (
(p >= topleftrow) and (p < (topleftrow + numRows M)) and
(q >= topleftcolumn) and (q < (topleftcolumn + numColumns M))
) then
M_(p-topleftrow,q-topleftcolumn) else 0
)
)
);
DeltaCmatrix = sum(apply(select(keys homotopies, i -> homotopies#i != 0), i -> prodX(i_0)*toS(makematrix(i,homotopies#i))));
DeltaC = map( Cstar,
Cstar,
transpose DeltaCmatrix,
Degree => { -1, degreeLength A:0 })
)
getDeltaN = (N) -> (
degreesN = toList((min N) .. (max N));
Ndelta = apply(degreesN, i -> N.dd_i);
Nmods = apply(degreesN, i -> tensor(S,toS,restrict(N_i,A)));
Nmatrix = apply(Ndelta, f -> tensor(S,toS,restrict(f,A)));
Nsize = apply(Nmods,numgens);
Ntable = table(#Nmatrix,#Nmatrix, (p,q) -> if (p == (q-1)) then Nmatrix_(p+1) else map(S^(Nsize_p),S^(Nsize_q),0));
DeltaNmatrix = matrixfromblocks Ntable;
Ngraded = fold((a,b) -> a ++ b,Nmods);
DeltaN = map(Ngraded,Ngraded,DeltaNmatrix)
)
getDeltaBar = (C,N) -> (
homotopies = makeHomotopies(matrix{f},C);
DeltaC = getDeltaC(C,homotopies);
degreesN = toList((min N) .. (max N));
Ndelta = apply(degreesN, i -> N.dd_i);
Nmods = apply(degreesN, i -> tensor(S,toS,restrict(N_i,A)));
Nmatrix = apply(Ndelta, f -> tensor(S,toS,restrict(f,A)));
Nsize = apply(Nmods,numgens);
Ntable = table(#Nmatrix,#Nmatrix, (p,q) -> if (p == (q-1)) then Nmatrix_(p+1) else map(S^(Nsize_p),S^(Nsize_q),0));
DeltaNmatrix = matrixfromblocks Ntable;
Ngraded = fold((a,b) -> a ++ b,Nmods);
DeltaN = map(Ngraded,Ngraded,DeltaNmatrix);
SignIdCstar = diagonalMatrix flatten toList apply(pairs(ranksC), w -> if even(w_0) then apply(toList(1 .. w_1), o -> -1) else apply(toList(1 .. w_1), o -> 1));
SignIdCstar = promote(SignIdCstar, S);
DeltaBar = SignIdCstar ** DeltaN + DeltaC ** id_Ngraded
)
-----------------------------------------------------------
-- Lifted Resolution of M
C1 = chainComplex resolution(M')
homotopies1 = makeHomotopies(matrix{f},C1)
DeltaC1 = getDeltaC(C1,homotopies1)
-- Resolution by hand of M
use A;
del1 = map(A^1,,matrix{{y,x^2,y^2}})
del2 = map(source del1,,matrix{{0,-y^2,-x^2},{-y^2,0,y},{x^2,y,0}})
del3 = map(source del2,,matrix{{y},{-x^2},{y^2}})
C2 = chainComplex complex{del1,del2,del3}
homotopies2 = makeHomotopies(matrix{f},C2)
DeltaC2 = getDeltaC(C2,homotopies2)
-- Against the residue field
N1 = N
DeltaN1 = getDeltaN(N)
-- Against itself
N2 = M
DeltaN2 = getDeltaN(M)
-----------------------------------------------------------
-- lifted resolution against residue field
DeltaBar1 = getDeltaBar(C1,N1)
prune homology(DeltaBar1,DeltaBar1)
radical ann(oo)
-- lifted resolution against M
DeltaBar2 = getDeltaBar(C1,N2)
prune homology(DeltaBar2,DeltaBar2)
radical ann(oo)
-- resolution by hand against residue field
DeltaBar3 = getDeltaBar(C2,N1)
prune homology(DeltaBar3,DeltaBar3)
radical ann(oo)
-- resolution by hand against M
DeltaBar4 = getDeltaBar(C2,N2)
prune homology(DeltaBar4,DeltaBar4)
radical ann(oo)