1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | version="$Id: sheafcoh.lib,v 1.15 2007-10-30 17:17:44 Singular Exp $"; |
---|
3 | category="Commutative Algebra"; |
---|
4 | info=" |
---|
5 | LIBRARY: sheafcoh.lib Procedures for Computing Sheaf Cohomology |
---|
6 | AUTHORS: Wolfram Decker, decker@math.uni-sb.de, |
---|
7 | @* Christoph Lossen, lossen@mathematik.uni-kl.de |
---|
8 | @* Gerhard Pfister, pfister@mathematik.uni-kl.de |
---|
9 | |
---|
10 | PROCEDURES: |
---|
11 | truncate(phi,d); truncation of coker(phi) at d |
---|
12 | CM_regularity(M); Castelnuovo-Mumford regularity of coker(M) |
---|
13 | sheafCohBGG(M,l,h); cohomology of sheaf associated to coker(M) |
---|
14 | sheafCohBGG2(M,l,h); cohomology of sheaf associated to coker(M), experimental version |
---|
15 | sheafCoh(M,l,h); cohomology of sheaf associated to coker(M) |
---|
16 | dimH(i,M,d); compute h^i(F(d)), F sheaf associated to coker(M) |
---|
17 | |
---|
18 | AUXILIARY PROCEDURES: |
---|
19 | displayCohom(B,l,h,n); display intmat as Betti diagram (with zero rows) |
---|
20 | |
---|
21 | KEYWORDS: sheaf cohomology |
---|
22 | "; |
---|
23 | |
---|
24 | /////////////////////////////////////////////////////////////////////////////// |
---|
25 | LIB "matrix.lib"; |
---|
26 | LIB "nctools.lib"; |
---|
27 | LIB "homolog.lib"; |
---|
28 | |
---|
29 | /////////////////////////////////////////////////////////////////////////////// |
---|
30 | static proc jacobM(matrix M) |
---|
31 | { |
---|
32 | int n=nvars(basering); |
---|
33 | matrix B=transpose(diff(M,var(1))); |
---|
34 | int i; |
---|
35 | for(i=2;i<=n;i++) |
---|
36 | { |
---|
37 | B=concat(B,transpose(diff(M,var(i)))); |
---|
38 | } |
---|
39 | return(transpose(B)); |
---|
40 | } |
---|
41 | |
---|
42 | // returns transposed Jacobian of a module M |
---|
43 | static proc tJacobian(module M) |
---|
44 | { |
---|
45 | M = transpose(M); |
---|
46 | |
---|
47 | int N = nvars(basering); |
---|
48 | int k = ncols(M); |
---|
49 | int r = nrows(M); |
---|
50 | |
---|
51 | module Result; |
---|
52 | Result[N*k] = 0; |
---|
53 | |
---|
54 | int i, j; |
---|
55 | int l = 1; |
---|
56 | |
---|
57 | for( j = 1; j <= N; j++ ) // for all variables |
---|
58 | { |
---|
59 | for( i = 1; i <= k; i++ ) // for every v \in transpose(M) |
---|
60 | { |
---|
61 | Result[l] = diff(M[i], var(j)); |
---|
62 | l++; |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | return(Result); |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | /** |
---|
71 | let M = { w_1, ..., w_k }, k = size(M) == ncols(M), n = nvars(currRing). |
---|
72 | assuming that nrows(M) <= m*n; |
---|
73 | computes transpose(M) * transpose( var(1) I_m | ... | var(n) I_m ) :== transpose(module{f_1, ... f_k}), |
---|
74 | where f_i = \sum_{j=1}^{m} (w_i, v_j) gen(j), (w_i, v_j) is a `scalar` multiplication. |
---|
75 | that is, if w_i = (a^1_1, ... a^1_m) | (a^2_1, ..., a^2_m) | ... | (a^n_1, ..., a^n_m) then |
---|
76 | |
---|
77 | (a^1_1, ... a^1_m) | (a^2_1, ..., a^2_m) | ... | (a^n_1, ..., a^n_m) |
---|
78 | * var_1 ... var_1 | var_2 ... var_2 | ... | var_n ... var(n) |
---|
79 | * gen_1 ... gen_m | gen_1 ... gen_m | ... | gen_1 ... gen_m |
---|
80 | + => |
---|
81 | f_i = |
---|
82 | |
---|
83 | a^1_1 * var(1) * gen(1) + ... + a^1_m * var(1) * gen(m) + |
---|
84 | a^2_1 * var(2) * gen(1) + ... + a^2_m * var(2) * gen(m) + |
---|
85 | ... |
---|
86 | a^n_1 * var(n) * gen(1) + ... + a^n_m * var(n) * gen(m); |
---|
87 | |
---|
88 | NOTE: for every f_i we run only ONCE along w_i saving partial sums into a temporary array of polys of size m |
---|
89 | |
---|
90 | */ |
---|
91 | static proc TensorModuleMult(int m, module M) |
---|
92 | { |
---|
93 | int n = nvars(basering); |
---|
94 | int k = ncols(M); |
---|
95 | |
---|
96 | int g, cc, vv; |
---|
97 | |
---|
98 | poly h; |
---|
99 | |
---|
100 | module Temp; // = {f_1, ..., f_k } |
---|
101 | |
---|
102 | intvec exp; |
---|
103 | vector pTempSum, w; |
---|
104 | |
---|
105 | for( int i = k; i > 0; i-- ) // for every w \in M |
---|
106 | { |
---|
107 | pTempSum[m] = 0; |
---|
108 | w = M[i]; |
---|
109 | |
---|
110 | while(w != 0) // for each term of w... |
---|
111 | { |
---|
112 | exp = leadexp(w); |
---|
113 | g = exp[n+1]; // module component! |
---|
114 | h = w[g]; |
---|
115 | |
---|
116 | w = w - h * gen(g); |
---|
117 | |
---|
118 | cc = g % m; |
---|
119 | |
---|
120 | if( cc == 0) |
---|
121 | { |
---|
122 | cc = m; |
---|
123 | } |
---|
124 | |
---|
125 | vv = 1 + (g - cc) / m; |
---|
126 | |
---|
127 | pTempSum = pTempSum + h * var(vv) * gen(cc); |
---|
128 | } |
---|
129 | |
---|
130 | Temp[i] = pTempSum; |
---|
131 | } |
---|
132 | |
---|
133 | Temp = transpose(Temp); |
---|
134 | |
---|
135 | return(Temp); |
---|
136 | } |
---|
137 | |
---|
138 | /////////////////////////////////////////////////////////////////////////////// |
---|
139 | static proc max(int i,int j) |
---|
140 | { |
---|
141 | if(i>j){return(i);} |
---|
142 | return(j); |
---|
143 | } |
---|
144 | |
---|
145 | /////////////////////////////////////////////////////////////////////////////// |
---|
146 | proc truncate(module phi, int d) |
---|
147 | "USAGE: truncate(M,d); M module, d int |
---|
148 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
149 | vector as an attribute |
---|
150 | RETURN: module |
---|
151 | NOTE: Output is a presentation matrix for the truncation of coker(M) |
---|
152 | at d. |
---|
153 | EXAMPLE: example truncate; shows an example |
---|
154 | KEYWORDS: truncated module |
---|
155 | " |
---|
156 | { |
---|
157 | if ( typeof(attrib(phi,"isHomog"))=="string" ) { |
---|
158 | if (size(phi)==0) { |
---|
159 | // assign weights 0 to generators of R^n (n=nrows(phi)) |
---|
160 | intvec v; |
---|
161 | v[nrows(phi)]=0; |
---|
162 | attrib(phi,"isHomog",v); |
---|
163 | } |
---|
164 | else { |
---|
165 | ERROR("No admissible degree vector assigned"); |
---|
166 | } |
---|
167 | } |
---|
168 | else { |
---|
169 | intvec v=attrib(phi,"isHomog"); |
---|
170 | } |
---|
171 | int i,m,dummy; |
---|
172 | int s = nrows(phi); |
---|
173 | module L; |
---|
174 | for (i=1; i<=s; i++) { |
---|
175 | if (d>v[i]) { |
---|
176 | L = L+maxideal(d-v[i])*gen(i); |
---|
177 | } |
---|
178 | else { |
---|
179 | L = L+gen(i); |
---|
180 | } |
---|
181 | } |
---|
182 | L = modulo(L,phi); |
---|
183 | L = minbase(prune(L)); |
---|
184 | if (size(L)==0) {return(L);} |
---|
185 | |
---|
186 | // it only remains to set the degrees for L: |
---|
187 | // ------------------------------------------ |
---|
188 | m = v[1]; |
---|
189 | for(i=2; i<=size(v); i++) { if(v[i]<m) { m = v[i]; } } |
---|
190 | dummy = homog(L); |
---|
191 | intvec vv = attrib(L,"isHomog"); |
---|
192 | if (d>m) { vv = vv+d; } |
---|
193 | else { vv = vv+m; } |
---|
194 | attrib(L,"isHomog",vv); |
---|
195 | return(L); |
---|
196 | } |
---|
197 | example |
---|
198 | {"EXAMPLE:"; |
---|
199 | echo = 2; |
---|
200 | ring R=0,(x,y,z),dp; |
---|
201 | module M=maxideal(3); |
---|
202 | homog(M); |
---|
203 | // compute presentation matrix for truncated module (R/<x,y,z>^3)_(>=2) |
---|
204 | module M2=truncate(M,2); |
---|
205 | print(M2); |
---|
206 | dimGradedPart(M2,1); |
---|
207 | dimGradedPart(M2,2); |
---|
208 | // this should coincide with: |
---|
209 | dimGradedPart(M,2); |
---|
210 | // shift grading by 1: |
---|
211 | intvec v=1; |
---|
212 | attrib(M,"isHomog",v); |
---|
213 | M2=truncate(M,2); |
---|
214 | print(M2); |
---|
215 | dimGradedPart(M2,3); |
---|
216 | } |
---|
217 | |
---|
218 | /////////////////////////////////////////////////////////////////////////////// |
---|
219 | |
---|
220 | proc dimGradedPart(module phi, int d) |
---|
221 | "USAGE: dimGradedPart(M,d); M module, d int |
---|
222 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
223 | vector as an attribute |
---|
224 | RETURN: int |
---|
225 | NOTE: Output is the vector space dimension of the graded part of degree d |
---|
226 | of coker(M). |
---|
227 | EXAMPLE: example dimGradedPart; shows an example |
---|
228 | KEYWORDS: graded module, graded piece |
---|
229 | " |
---|
230 | { |
---|
231 | if ( typeof(attrib(phi,"isHomog"))=="string" ) { |
---|
232 | if (size(phi)==0) { |
---|
233 | // assign weights 0 to generators of R^n (n=nrows(phi)) |
---|
234 | intvec v; |
---|
235 | v[nrows(phi)]=0; |
---|
236 | } |
---|
237 | else { ERROR("No admissible degree vector assigned"); } |
---|
238 | } |
---|
239 | else { |
---|
240 | intvec v=attrib(phi,"isHomog"); |
---|
241 | } |
---|
242 | int s = nrows(phi); |
---|
243 | int i,m,dummy; |
---|
244 | module L,LL; |
---|
245 | for (i=1; i<=s; i++) { |
---|
246 | if (d>v[i]) { |
---|
247 | L = L+maxideal(d-v[i])*gen(i); |
---|
248 | LL = LL+maxideal(d+1-v[i])*gen(i); |
---|
249 | } |
---|
250 | else { |
---|
251 | L = L+gen(i); |
---|
252 | if (d==v[i]) { |
---|
253 | LL = LL+maxideal(1)*gen(i); |
---|
254 | } |
---|
255 | else { |
---|
256 | LL = LL+gen(i); |
---|
257 | } |
---|
258 | } |
---|
259 | } |
---|
260 | LL=LL,phi; |
---|
261 | L = modulo(L,LL); |
---|
262 | L = std(prune(L)); |
---|
263 | if (size(L)==0) {return(0);} |
---|
264 | return(vdim(L)); |
---|
265 | } |
---|
266 | example |
---|
267 | {"EXAMPLE:"; |
---|
268 | echo = 2; |
---|
269 | ring R=0,(x,y,z),dp; |
---|
270 | module M=maxideal(3); |
---|
271 | // assign compatible weight vector (here: 0) |
---|
272 | homog(M); |
---|
273 | // compute dimension of graded pieces of R/<x,y,z>^3 : |
---|
274 | dimGradedPart(M,0); |
---|
275 | dimGradedPart(M,1); |
---|
276 | dimGradedPart(M,2); |
---|
277 | dimGradedPart(M,3); |
---|
278 | // shift grading: |
---|
279 | attrib(M,"isHomog",intvec(2)); |
---|
280 | dimGradedPart(M,2); |
---|
281 | } |
---|
282 | |
---|
283 | /////////////////////////////////////////////////////////////////////////////// |
---|
284 | |
---|
285 | proc CM_regularity (module M) |
---|
286 | "USAGE: CM_regularity(M); M module |
---|
287 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
288 | vector as an attribute |
---|
289 | RETURN: integer, the Castelnuovo-Mumford regularity of coker(M) |
---|
290 | NOTE: procedure calls mres |
---|
291 | EXAMPLE: example CM_regularity; shows an example |
---|
292 | KEYWORDS: Castelnuovo-Mumford regularity |
---|
293 | " |
---|
294 | { |
---|
295 | if ( typeof(attrib(M,"isHomog"))=="string" ) { |
---|
296 | if (size(M)==0) { |
---|
297 | // assign weights 0 to generators of R^n (n=nrows(M)) |
---|
298 | intvec v; |
---|
299 | v[nrows(M)]=0; |
---|
300 | attrib(M,"isHomog",v); |
---|
301 | } |
---|
302 | else { |
---|
303 | ERROR("No admissible degree vector assigned"); |
---|
304 | } |
---|
305 | } |
---|
306 | def L = mres(M,0); |
---|
307 | intmat BeL = betti(L); |
---|
308 | int r = nrows(module(matrix(BeL))); // last non-zero row |
---|
309 | if (typeof(attrib(BeL,"rowShift"))!="string") { |
---|
310 | int shift = attrib(BeL,"rowShift"); |
---|
311 | } |
---|
312 | return(r+shift-1); |
---|
313 | } |
---|
314 | example |
---|
315 | {"EXAMPLE:"; |
---|
316 | echo = 2; |
---|
317 | ring R=0,(x,y,z,u),dp; |
---|
318 | resolution T1=mres(maxideal(1),0); |
---|
319 | module M=T1[3]; |
---|
320 | intvec v=2,2,2,2,2,2; |
---|
321 | attrib(M,"isHomog",v); |
---|
322 | CM_regularity(M); |
---|
323 | } |
---|
324 | |
---|
325 | /////////////////////////////////////////////////////////////////////////////// |
---|
326 | proc sheafCohBGG(module M,int l,int h) |
---|
327 | "USAGE: sheafCohBGG(M,l,h); M module, l,h int |
---|
328 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
329 | vector as an attribute, @code{h>=l}, and the basering has @code{n+1} |
---|
330 | variables. |
---|
331 | RETURN: intmat, cohomology of twists of the coherent sheaf F on P^n |
---|
332 | associated to coker(M). The range of twists is determined by @code{l}, |
---|
333 | @code{h}. |
---|
334 | DISPLAY: The intmat is displayed in a diagram of the following form: @* |
---|
335 | @format |
---|
336 | l l+1 h |
---|
337 | ---------------------------------------------------------- |
---|
338 | n: h^n(F(l)) h^n(F(l+1)) ...... h^n(F(h)) |
---|
339 | ............................................... |
---|
340 | 1: h^1(F(l)) h^1(F(l+1)) ...... h^1(F(h)) |
---|
341 | 0: h^0(F(l)) h^0(F(l+1)) ...... h^0(F(h)) |
---|
342 | ---------------------------------------------------------- |
---|
343 | chi: chi(F(l)) chi(F(l+1)) ...... chi(F(h)) |
---|
344 | @end format |
---|
345 | A @code{'-'} in the diagram refers to a zero entry; a @code{'*'} |
---|
346 | refers to a negative entry (= dimension not yet determined). |
---|
347 | refers to a not computed dimension. @* |
---|
348 | NOTE: This procedure is based on the Bernstein-Gel'fand-Gel'fand |
---|
349 | correspondence and on Tate resolution ( see [Eisenbud, Floystad, |
---|
350 | Schreyer: Sheaf cohomology and free resolutions over exterior |
---|
351 | algebras, Trans AMS 355 (2003)] ).@* |
---|
352 | @code{sheafCohBGG(M,l,h)} does not compute all values in the above |
---|
353 | table. To determine all values of @code{h^i(F(d))}, @code{d=l..h}, |
---|
354 | use @code{sheafCohBGG(M,l-n,h+n)}. |
---|
355 | SEE ALSO: sheafCoh, dimH |
---|
356 | EXAMPLE: example sheafCohBGG; shows an example |
---|
357 | " |
---|
358 | { |
---|
359 | int i,j,k,row,col; |
---|
360 | if( typeof(attrib(M,"isHomog"))!="intvec" ) |
---|
361 | { |
---|
362 | if (size(M)==0) { attrib(M,"isHomog",0); } |
---|
363 | else { ERROR("No admissible degree vector assigned"); } |
---|
364 | } |
---|
365 | int n=nvars(basering)-1; |
---|
366 | int ell=l+n; |
---|
367 | def R=basering; |
---|
368 | int reg = CM_regularity(M); |
---|
369 | int bound=max(reg+1,h-1); |
---|
370 | module MT=truncate(M,bound); |
---|
371 | int m=nrows(MT); |
---|
372 | MT=transpose(jacobM(MT)); |
---|
373 | MT=syz(MT); |
---|
374 | matrix ML[n+1][1]=maxideal(1); |
---|
375 | matrix S=transpose(outer(ML,unitmat(m))); |
---|
376 | matrix SS=transpose(S*MT); |
---|
377 | //--- to the exterior algebra |
---|
378 | def AR = Exterior(); |
---|
379 | setring AR; |
---|
380 | option(redSB); |
---|
381 | option(redTail); |
---|
382 | module EM=imap(R,SS); |
---|
383 | intvec w; |
---|
384 | //--- here we are with our matrix |
---|
385 | int bound1=max(1,bound-ell+1); |
---|
386 | for (i=1; i<=nrows(EM); i++) |
---|
387 | { |
---|
388 | w[i]=-bound-1; |
---|
389 | } |
---|
390 | attrib(EM,"isHomog",w); |
---|
391 | resolution RE=mres(EM,bound1); |
---|
392 | intmat Betti=betti(RE); |
---|
393 | k=ncols(Betti); |
---|
394 | row=nrows(Betti); |
---|
395 | int shift=attrib(Betti,"rowShift")+(k+ell-1); |
---|
396 | intmat newBetti[n+1][h-l+1]; |
---|
397 | for (j=1; j<=row; j++) |
---|
398 | { |
---|
399 | for (i=l; i<=h; i++) |
---|
400 | { |
---|
401 | if ((k+1-j-i+ell-shift>0) and (j+i-ell+shift>=1)) |
---|
402 | { |
---|
403 | newBetti[n+2-shift-j,i-l+1]=Betti[j,k+1-j-i+ell-shift]; |
---|
404 | } |
---|
405 | else { newBetti[n+2-shift-j,i-l+1]=-1; } |
---|
406 | } |
---|
407 | } |
---|
408 | for (j=2; j<=n+1; j++) |
---|
409 | { |
---|
410 | for (i=1; i<j; i++) |
---|
411 | { |
---|
412 | newBetti[j,i]=-1; |
---|
413 | } |
---|
414 | } |
---|
415 | int d=k-h+ell-1; |
---|
416 | for (j=1; j<=n; j++) |
---|
417 | { |
---|
418 | for (i=h-l+1; i>=k+j; i--) |
---|
419 | { |
---|
420 | newBetti[j,i]=-1; |
---|
421 | } |
---|
422 | } |
---|
423 | displayCohom(newBetti,l,h,n); |
---|
424 | setring R; |
---|
425 | return(newBetti); |
---|
426 | option(noredSB); |
---|
427 | option(noredTail); |
---|
428 | } |
---|
429 | example |
---|
430 | {"EXAMPLE:"; |
---|
431 | echo = 2; |
---|
432 | // cohomology of structure sheaf on P^4: |
---|
433 | //------------------------------------------- |
---|
434 | ring r=0,x(1..5),dp; |
---|
435 | module M=0; |
---|
436 | def A=sheafCohBGG(0,-9,4); |
---|
437 | // cohomology of cotangential bundle on P^3: |
---|
438 | //------------------------------------------- |
---|
439 | ring R=0,(x,y,z,u),dp; |
---|
440 | resolution T1=mres(maxideal(1),0); |
---|
441 | module M=T1[3]; |
---|
442 | intvec v=2,2,2,2,2,2; |
---|
443 | attrib(M,"isHomog",v); |
---|
444 | def B=sheafCohBGG(M,-8,4); |
---|
445 | } |
---|
446 | |
---|
447 | /////////////////////////////////////////////////////////////////////////////// |
---|
448 | proc sheafCohBGG2(module M,int l,int h) |
---|
449 | "USAGE: sheafCohBGG2(M,l,h); M module, l,h int |
---|
450 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
451 | vector as an attribute, @code{h>=l}, and the basering has @code{n+1} |
---|
452 | variables. |
---|
453 | RETURN: intmat, cohomology of twists of the coherent sheaf F on P^n |
---|
454 | associated to coker(M). The range of twists is determined by @code{l}, |
---|
455 | @code{h}. |
---|
456 | DISPLAY: The intmat is displayed in a diagram of the following form: @* |
---|
457 | @format |
---|
458 | l l+1 h |
---|
459 | ---------------------------------------------------------- |
---|
460 | n: h^n(F(l)) h^n(F(l+1)) ...... h^n(F(h)) |
---|
461 | ............................................... |
---|
462 | 1: h^1(F(l)) h^1(F(l+1)) ...... h^1(F(h)) |
---|
463 | 0: h^0(F(l)) h^0(F(l+1)) ...... h^0(F(h)) |
---|
464 | ---------------------------------------------------------- |
---|
465 | chi: chi(F(l)) chi(F(l+1)) ...... chi(F(h)) |
---|
466 | @end format |
---|
467 | A @code{'-'} in the diagram refers to a zero entry; a @code{'*'} |
---|
468 | refers to a negative entry (= dimension not yet determined). |
---|
469 | refers to a not computed dimension. @* |
---|
470 | NOTE: This procedure is based on the Bernstein-Gel'fand-Gel'fand |
---|
471 | correspondence and on Tate resolution ( see [Eisenbud, Floystad, |
---|
472 | Schreyer: Sheaf cohomology and free resolutions over exterior |
---|
473 | algebras, Trans AMS 355 (2003)] ).@* |
---|
474 | @code{sheafCohBGG(M,l,h)} does not compute all values in the above |
---|
475 | table. To determine all values of @code{h^i(F(d))}, @code{d=l..h}, |
---|
476 | use @code{sheafCohBGG(M,l-n,h+n)}. |
---|
477 | Experimental version. Should require less memory. |
---|
478 | SEE ALSO: sheafCohBGG |
---|
479 | EXAMPLE: example sheafCohBGG2; shows an example |
---|
480 | " |
---|
481 | { |
---|
482 | int i,j,k,row,col; |
---|
483 | if( typeof(attrib(M,"isHomog"))!="intvec" ) { |
---|
484 | if (size(M)==0) { attrib(M,"isHomog",0); } |
---|
485 | else { ERROR("No admissible degree vector assigned"); } |
---|
486 | } |
---|
487 | intvec ivOptionsSave = option(get); |
---|
488 | option(redSB); option(redTail); |
---|
489 | |
---|
490 | int n=nvars(basering)-1; |
---|
491 | int ell=l+n; |
---|
492 | def R=basering; |
---|
493 | int reg = CM_regularity(M); |
---|
494 | int bound=max(reg+1,h-1); |
---|
495 | module MT=truncate(M,bound); |
---|
496 | int m=nrows(MT); |
---|
497 | MT = tJacobian(MT); // transpose(jacobM(MT)); |
---|
498 | MT=syz(MT); |
---|
499 | |
---|
500 | module SS = TensorModuleMult(m, MT); |
---|
501 | |
---|
502 | //--- to the exterior algebra |
---|
503 | def AR = Exterior(); setring AR; |
---|
504 | |
---|
505 | module EM=imap(R,SS); |
---|
506 | intvec w; |
---|
507 | //--- here we are with our matrix |
---|
508 | int bound1=max(1,bound-ell+1); |
---|
509 | for (i=1; i<=nrows(EM); i++) |
---|
510 | { |
---|
511 | w[i]=-bound-1; |
---|
512 | } |
---|
513 | attrib(EM,"isHomog",w); |
---|
514 | resolution RE = minres(nres(EM,bound1)); |
---|
515 | intmat Betti=betti(RE); |
---|
516 | k=ncols(Betti); |
---|
517 | row=nrows(Betti); |
---|
518 | int shift=attrib(Betti,"rowShift")+(k+ell-1); |
---|
519 | intmat newBetti[n+1][h-l+1]; |
---|
520 | for (j=1; j<=row; j++) { |
---|
521 | for (i=l; i<=h; i++) { |
---|
522 | if ((k+1-j-i+ell-shift>0) and (j+i-ell+shift>=1)) { |
---|
523 | newBetti[n+2-shift-j,i-l+1]=Betti[j,k+1-j-i+ell-shift]; |
---|
524 | } |
---|
525 | else { newBetti[n+2-shift-j,i-l+1]=-1; } |
---|
526 | } |
---|
527 | } |
---|
528 | for (j=2; j<=n+1; j++) { |
---|
529 | for (i=1; i<j; i++) { |
---|
530 | newBetti[j,i]=-1; |
---|
531 | } |
---|
532 | } |
---|
533 | int d=k-h+ell-1; |
---|
534 | for (j=1; j<=n; j++) { |
---|
535 | for (i=h-l+1; i>=k+j; i--) { |
---|
536 | newBetti[j,i]=-1; |
---|
537 | } |
---|
538 | } |
---|
539 | displayCohom(newBetti,l,h,n); |
---|
540 | |
---|
541 | setring R; |
---|
542 | option(set, ivOptionsSave); |
---|
543 | |
---|
544 | return(newBetti); |
---|
545 | } |
---|
546 | example |
---|
547 | {"EXAMPLE:"; |
---|
548 | echo = 2; |
---|
549 | // cohomology of structure sheaf on P^4: |
---|
550 | //------------------------------------------- |
---|
551 | ring r=0,x(1..5),dp; |
---|
552 | module M=0; |
---|
553 | def A=sheafCohBGG2(0,-9,4); |
---|
554 | // cohomology of cotangential bundle on P^3: |
---|
555 | //------------------------------------------- |
---|
556 | ring R=0,(x,y,z,u),dp; |
---|
557 | resolution T1=mres(maxideal(1),0); |
---|
558 | module M=T1[3]; |
---|
559 | intvec v=2,2,2,2,2,2; |
---|
560 | attrib(M,"isHomog",v); |
---|
561 | def B=sheafCohBGG2(M,-8,4); |
---|
562 | } |
---|
563 | |
---|
564 | |
---|
565 | /////////////////////////////////////////////////////////////////////////////// |
---|
566 | |
---|
567 | proc dimH(int i,module M,int d) |
---|
568 | "USAGE: dimH(i,M,d); M module, i,d int |
---|
569 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
570 | vector as an attribute, @code{h>=l}, and the basering @code{S} has |
---|
571 | @code{n+1} variables. |
---|
572 | RETURN: int, vector space dimension of @math{H^i(F(d))} for F the coherent |
---|
573 | sheaf on P^n associated to coker(M). |
---|
574 | NOTE: The procedure is based on local duality as described in [Eisenbud: |
---|
575 | Computing cohomology. In Vasconcelos: Computational methods in |
---|
576 | commutative algebra and algebraic geometry. Springer (1998)]. |
---|
577 | SEE ALSO: sheafCoh, sheafCohBGG |
---|
578 | EXAMPLE: example dimH; shows an example |
---|
579 | " |
---|
580 | { |
---|
581 | if( typeof(attrib(M,"isHomog"))=="string" ) { |
---|
582 | if (size(M)==0) { |
---|
583 | // assign weights 0 to generators of R^n (n=nrows(M)) |
---|
584 | intvec v; |
---|
585 | v[nrows(M)]=0; |
---|
586 | attrib(M,"isHomog",v); |
---|
587 | } |
---|
588 | else { |
---|
589 | ERROR("No admissible degree vector assigned"); |
---|
590 | } |
---|
591 | } |
---|
592 | int Result; |
---|
593 | int n=nvars(basering)-1; |
---|
594 | if ((i>0) and (i<=n)) { |
---|
595 | list L=Ext_R(n-i,M,1)[2]; |
---|
596 | def N=L[1]; |
---|
597 | return(dimGradedPart(N,-n-1-d)); |
---|
598 | } |
---|
599 | else { |
---|
600 | if (i==0) { |
---|
601 | list L=Ext_R(intvec(n+1,n+2),M,1)[2]; |
---|
602 | def N0=L[2]; |
---|
603 | def N1=L[1]; |
---|
604 | Result=dimGradedPart(M,d) - dimGradedPart(N0,-n-1-d) |
---|
605 | - dimGradedPart(N1,-n-1-d); |
---|
606 | return(Result); |
---|
607 | } |
---|
608 | else { |
---|
609 | return(0); |
---|
610 | } |
---|
611 | } |
---|
612 | } |
---|
613 | example |
---|
614 | {"EXAMPLE:"; |
---|
615 | echo = 2; |
---|
616 | ring R=0,(x,y,z,u),dp; |
---|
617 | resolution T1=mres(maxideal(1),0); |
---|
618 | module M=T1[3]; |
---|
619 | intvec v=2,2,2,2,2,2; |
---|
620 | attrib(M,"isHomog",v); |
---|
621 | dimH(0,M,2); |
---|
622 | dimH(1,M,0); |
---|
623 | dimH(2,M,1); |
---|
624 | dimH(3,M,-5); |
---|
625 | } |
---|
626 | |
---|
627 | |
---|
628 | /////////////////////////////////////////////////////////////////////////////// |
---|
629 | |
---|
630 | proc sheafCoh(module M,int l,int h,list #) |
---|
631 | "USAGE: sheafCoh(M,l,h); M module, l,h int |
---|
632 | ASSUME: @code{M} is graded, and it comes assigned with an admissible degree |
---|
633 | vector as an attribute, @code{h>=l}. The basering @code{S} has |
---|
634 | @code{n+1} variables. |
---|
635 | RETURN: intmat, cohomology of twists of the coherent sheaf F on P^n |
---|
636 | associated to coker(M). The range of twists is determined by @code{l}, |
---|
637 | @code{h}. |
---|
638 | DISPLAY: The intmat is displayed in a diagram of the following form: @* |
---|
639 | @format |
---|
640 | l l+1 h |
---|
641 | ---------------------------------------------------------- |
---|
642 | n: h^n(F(l)) h^n(F(l+1)) ...... h^n(F(h)) |
---|
643 | ............................................... |
---|
644 | 1: h^1(F(l)) h^1(F(l+1)) ...... h^1(F(h)) |
---|
645 | 0: h^0(F(l)) h^0(F(l+1)) ...... h^0(F(h)) |
---|
646 | ---------------------------------------------------------- |
---|
647 | chi: chi(F(l)) chi(F(l+1)) ...... chi(F(h)) |
---|
648 | @end format |
---|
649 | A @code{'-'} in the diagram refers to a zero entry. |
---|
650 | NOTE: The procedure is based on local duality as described in [Eisenbud: |
---|
651 | Computing cohomology. In Vasconcelos: Computational methods in |
---|
652 | commutative algebra and algebraic geometry. Springer (1998)].@* |
---|
653 | By default, the procedure uses @code{mres} to compute the Ext |
---|
654 | modules. If called with the additional parameter @code{\"sres\"}, |
---|
655 | the @code{sres} command is used instead. |
---|
656 | SEE ALSO: dimH, sheafCohBGG |
---|
657 | EXAMPLE: example sheafCoh; shows an example |
---|
658 | " |
---|
659 | { |
---|
660 | int use_sres; |
---|
661 | if( typeof(attrib(M,"isHomog"))!="intvec" ) { |
---|
662 | if (size(M)==0) { attrib(M,"isHomog",0); } |
---|
663 | else { ERROR("No admissible degree vector assigned"); } |
---|
664 | } |
---|
665 | if (size(#)>0) { |
---|
666 | if (#[1]=="sres") { use_sres=1; } |
---|
667 | } |
---|
668 | int i,j; |
---|
669 | module N,N0,N1; |
---|
670 | int n=nvars(basering)-1; |
---|
671 | intvec v=0..n+1; |
---|
672 | int col=h-l+1; |
---|
673 | intmat newBetti[n+1][col]; |
---|
674 | if (use_sres) { list L=Ext_R(v,M,1,"sres")[2]; } |
---|
675 | else { list L=Ext_R(v,M,1)[2]; } |
---|
676 | for (i=l; i<=h; i++) { |
---|
677 | N0=L[n+2]; |
---|
678 | N1=L[n+1]; |
---|
679 | newBetti[n+1,i-l+1]=dimGradedPart(M,i) - dimGradedPart(N0,-n-1-i) |
---|
680 | - dimGradedPart(N0,-n-1-i); |
---|
681 | } |
---|
682 | for (j=1; j<=n; j++) { |
---|
683 | N=L[j]; |
---|
684 | attrib(N,"isSB",1); |
---|
685 | if (dim(N)>=0) { |
---|
686 | for (i=l; i<=h; i++) { |
---|
687 | newBetti[j,i-l+1]=dimGradedPart(N,-n-1-i); |
---|
688 | } |
---|
689 | } |
---|
690 | } |
---|
691 | displayCohom(newBetti,l,h,n); |
---|
692 | return(newBetti); |
---|
693 | } |
---|
694 | example |
---|
695 | {"EXAMPLE:"; |
---|
696 | echo = 2; |
---|
697 | // |
---|
698 | // cohomology of structure sheaf on P^4: |
---|
699 | //------------------------------------------- |
---|
700 | ring r=0,x(1..5),dp; |
---|
701 | module M=0; |
---|
702 | def A=sheafCoh(0,-7,2); |
---|
703 | // |
---|
704 | // cohomology of cotangential bundle on P^3: |
---|
705 | //------------------------------------------- |
---|
706 | ring R=0,(x,y,z,u),dp; |
---|
707 | resolution T1=mres(maxideal(1),0); |
---|
708 | module M=T1[3]; |
---|
709 | intvec v=2,2,2,2,2,2; |
---|
710 | attrib(M,"isHomog",v); |
---|
711 | def B=sheafCoh(M,-6,2); |
---|
712 | } |
---|
713 | |
---|
714 | /////////////////////////////////////////////////////////////////////////////// |
---|
715 | proc displayCohom (intmat data, int l, int h, int n) |
---|
716 | "USAGE: displayCohom(data,l,h,n); data intmat, l,h,n int |
---|
717 | ASSUME: @code{h>=l}, @code{data} is the return value of |
---|
718 | @code{sheafCoh(M,l,h)} or of @code{sheafCohBGG(M,l,h)}, and the |
---|
719 | basering has @code{n+1} variables. |
---|
720 | RETURN: none |
---|
721 | NOTE: The intmat is displayed in a diagram of the following form: @* |
---|
722 | @format |
---|
723 | l l+1 h |
---|
724 | ---------------------------------------------------------- |
---|
725 | n: h^n(F(l)) h^n(F(l+1)) ...... h^n(F(h)) |
---|
726 | ............................................... |
---|
727 | 1: h^1(F(l)) h^1(F(l+1)) ...... h^1(F(h)) |
---|
728 | 0: h^0(F(l)) h^0(F(l+1)) ...... h^0(F(h)) |
---|
729 | ---------------------------------------------------------- |
---|
730 | chi: chi(F(l)) chi(F(l+1)) ...... chi(F(h)) |
---|
731 | @end format |
---|
732 | where @code{F} refers to the associated sheaf of @code{M} on P^n.@* |
---|
733 | A @code{'-'} in the diagram refers to a zero entry, a @code{'*'} |
---|
734 | refers to a negative entry (= dimension not yet determined). |
---|
735 | " |
---|
736 | { |
---|
737 | int i,j,k,dat,maxL; |
---|
738 | intvec notSumCol; |
---|
739 | notSumCol[h-l+1]=0; |
---|
740 | string s; |
---|
741 | maxL=4; |
---|
742 | for (i=1;i<=nrows(data);i++) { |
---|
743 | for (j=1;j<=ncols(data);j++) { |
---|
744 | if (size(string(data[i,j]))>=maxL-1) { |
---|
745 | maxL=size(string(data[i,j]))+2; |
---|
746 | } |
---|
747 | } |
---|
748 | } |
---|
749 | string Row=" "; |
---|
750 | string Row1="----"; |
---|
751 | for (i=l; i<=h; i++) { |
---|
752 | for (j=1; j<=maxL-size(string(i)); j++) { |
---|
753 | Row=Row+" "; |
---|
754 | } |
---|
755 | Row=Row+string(i); |
---|
756 | for (j=1; j<=maxL; j++) { Row1 = Row1+"-"; } |
---|
757 | } |
---|
758 | print(Row); |
---|
759 | print(Row1); |
---|
760 | for (j=1; j<=n+1; j++) { |
---|
761 | s = string(n+1-j); |
---|
762 | Row = ""; |
---|
763 | for(k=1; k<4-size(s); k++) { Row = Row+" "; } |
---|
764 | Row = Row + s+":"; |
---|
765 | for (i=0; i<=h-l; i++) { |
---|
766 | dat = data[j,i+1]; |
---|
767 | if (dat>0) { s = string(dat); } |
---|
768 | else { |
---|
769 | if (dat==0) { s="-"; } |
---|
770 | else { s="*"; notSumCol[i+1]=1; } |
---|
771 | } |
---|
772 | for(k=1; k<=maxL-size(s); k++) { Row = Row+" "; } |
---|
773 | Row = Row + s; |
---|
774 | } |
---|
775 | print(Row); |
---|
776 | } |
---|
777 | print(Row1); |
---|
778 | Row="chi:"; |
---|
779 | for (i=0; i<=h-l; i++) { |
---|
780 | dat = 0; |
---|
781 | if (notSumCol[i+1]==0) { |
---|
782 | for (j=0; j<=n; j++) { dat = dat + (-1)^j * data[n+1-j,i+1]; } |
---|
783 | s = string(dat); |
---|
784 | } |
---|
785 | else { s="*"; } |
---|
786 | for (k=1; k<=maxL-size(s); k++) { Row = Row+" "; } |
---|
787 | Row = Row + s; |
---|
788 | } |
---|
789 | print(Row); |
---|
790 | } |
---|
791 | /////////////////////////////////////////////////////////////////////////////// |
---|
792 | |
---|
793 | |
---|
794 | /* |
---|
795 | Examples: |
---|
796 | --------- |
---|
797 | LIB "sheafcoh.lib"; |
---|
798 | |
---|
799 | ring S = 32003, x(0..4), dp; |
---|
800 | module MI=maxideal(1); |
---|
801 | attrib(MI,"isHomog",intvec(-1)); |
---|
802 | resolution kos = nres(MI,0); |
---|
803 | print(betti(kos),"betti"); |
---|
804 | LIB "random.lib"; |
---|
805 | matrix alpha0 = random(32002,10,3); |
---|
806 | module pres = module(alpha0)+kos[3]; |
---|
807 | attrib(pres,"isHomog",intvec(1,1,1,1,1,1,1,1,1,1)); |
---|
808 | resolution fcokernel = mres(pres,0); |
---|
809 | print(betti(fcokernel),"betti"); |
---|
810 | module dir = transpose(pres); |
---|
811 | attrib(dir,"isHomog",intvec(-1,-1,-1,-2,-2,-2, |
---|
812 | -2,-2,-2,-2,-2,-2,-2)); |
---|
813 | resolution fdir = mres(dir,2); |
---|
814 | print(betti(fdir),"betti"); |
---|
815 | ideal I = groebner(flatten(fdir[2])); |
---|
816 | resolution FI = mres(I,0); |
---|
817 | print(betti(FI),"betti"); |
---|
818 | module F=FI[2]; |
---|
819 | int t=timer; |
---|
820 | def A1=sheafCoh(F,-8,8); |
---|
821 | timer-t; |
---|
822 | t=timer; |
---|
823 | def A2=sheafCohBGG(F,-8,8); |
---|
824 | timer-t; |
---|
825 | |
---|
826 | LIB "sheafcoh.lib"; |
---|
827 | LIB "random.lib"; |
---|
828 | ring S = 32003, x(0..4), dp; |
---|
829 | resolution kos = nres(maxideal(1),0); |
---|
830 | betti(kos); |
---|
831 | matrix kos5 = kos[5]; |
---|
832 | matrix tphi = transpose(dsum(kos5,kos5)); |
---|
833 | matrix kos3 = kos[3]; |
---|
834 | matrix psi = dsum(kos3,kos3); |
---|
835 | matrix beta1 = random(32002,20,2); |
---|
836 | matrix tbeta1tilde = transpose(psi*beta1); |
---|
837 | matrix tbeta0 = lift(tphi,tbeta1tilde); |
---|
838 | matrix kos4 = kos[4]; |
---|
839 | matrix tkos4pluskos4 = transpose(dsum(kos4,kos4)); |
---|
840 | matrix tgammamin1 = random(32002,20,1); |
---|
841 | matrix tgamma0 = tkos4pluskos4*tgammamin1; |
---|
842 | matrix talpha0 = concat(tbeta0,tgamma0); |
---|
843 | matrix zero[20][1]; |
---|
844 | matrix tpsi = transpose(psi); |
---|
845 | matrix tpresg = concat(tpsi,zero); |
---|
846 | matrix pres = module(transpose(talpha0)) |
---|
847 | + module(transpose(tpresg)); |
---|
848 | module dir = transpose(pres); |
---|
849 | dir = prune(dir); |
---|
850 | homog(dir); |
---|
851 | intvec deg_dir = attrib(dir,"isHomog"); |
---|
852 | attrib(dir,"isHomog",deg_dir-2); // set degrees |
---|
853 | resolution fdir = mres(prune(dir),2); |
---|
854 | print(betti(fdir),"betti"); |
---|
855 | ideal I = groebner(flatten(fdir[2])); |
---|
856 | resolution FI = mres(I,0); |
---|
857 | |
---|
858 | module F=FI[2]; |
---|
859 | def A1=sheafCoh(F,-5,7); |
---|
860 | def A2=sheafCohBGG(F,-5,7); |
---|
861 | |
---|
862 | */ |
---|