source: git/Singular/LIB/sheafcoh.lib @ 83a3e7

spielwiese
Last change on this file since 83a3e7 was 83a3e7, checked in by Hans Schönemann <hannes@…>, 19 years ago
*lossen:... git-svn-id: file:///usr/local/Singular/svn/trunk@8216 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 14.8 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2category="Commutative Algebra";
3info="
4LIBRARY:  sheafcoh.lib   Procedures for Computing Sheaf Cohomology
5AUTHORS:  Wolfram Decker, decker@math.uni-sb.de,
6@*        Christoph Lossen,  lossen@mathematik.uni-kl.de
7@*        Gerhrd Pfister,  pfister@mathematik.uni-kl.de
8
9PROCEDURES:
10 truncate(phi,d);        truncation of coker(phi) at d
11 CM_regularity(M);       Castelnuovo-Mumford regularity of coker(M)
12 sheafCohBGG(M,l,h);     cohomology of sheaf associated to coker(M)
13 sheafCohE(M,l,h);       cohomology of sheaf associated to coker(M)
14
15AUXILIARY PROCEDURES:
16 displayCohom(B,l,h,n);  display intmat as Betti diagram (with zero rows)
17
18KEYWORDS: sheaf cohomology
19";
20
21///////////////////////////////////////////////////////////////////////////////
22LIB "matrix.lib";
23LIB "nctools.lib";
24LIB "homolog.lib";
25
26///////////////////////////////////////////////////////////////////////////////
27static proc jacobM(matrix M)
28{
29   int n=nvars(basering);
30   int a=nrows(M);
31   int b=ncols(M);
32   matrix B=transpose(diff(M,var(1)));
33   int i,j;
34   for(i=2;i<=n;i++)
35   {
36     B=concat(B,transpose(diff(M,var(i))));
37   }
38   return(transpose(B));
39}
40///////////////////////////////////////////////////////////////////////////////
41static proc max(int i,int j)
42{
43  if(i>j){return(i);}
44  return(j);
45}
46
47///////////////////////////////////////////////////////////////////////////////
48proc truncate(module phi, int d)
49"USAGE:   truncate(M,d);  M module, d int
50ASSUME:  M comes assigned with an admissible degree vector as an attribute
51RETURN:  module
52NOTE:    Output is a presentation matrix for the truncation of coker(M)
53         at d.
54EXAMPLE: example truncate; shows an example
55KEYWORDS: truncated module
56"
57{
58  if ( typeof(attrib(phi,"isHomog"))=="string" ) { 
59    ERROR("No admissible degree vector assigned");
60  }
61  else {
62   intvec v=attrib(phi,"isHomog");
63  }
64  int s = nrows(phi);
65  int i,m,dummy;
66  module L;
67  for (i=1; i<=s; i++) {
68    if (d>v[i]) {
69      L = L+maxideal(d-v[i])*gen(i);
70    }
71    else {
72      L = L+gen(i);
73    }
74  }
75  L = modulo(L,phi);
76  L = minbase(prune(L));
77  if (size(L)==0) {return(L);}
78
79  // it only remains to set the degrees for L:
80  // ------------------------------------------
81  m = v[1];
82  for(i=2; i<=size(v); i++) {  if(v[i]<m) { m = v[i]; } }
83  dummy = homog(L);
84  intvec vv = attrib(L,"isHomog");
85  if (d>m) { vv = vv+d; }
86  else     { vv = vv+m; }
87  attrib(L,"isHomog",vv);
88  return(L);
89}
90example
91{"EXAMPLE:";
92   echo = 2;
93   ring R=0,(x,y,z),dp;
94   module M=maxideal(3);
95   homog(M);
96   // compute presentation matrix for truncated module (R/<x,y,z>^3)_(>=2)
97   module M2=truncate(M,2);
98   print(M2);
99   dimGradedPart(M2,1);
100   dimGradedPart(M2,2);
101   // this should coincide with:
102   dimGradedPart(M,2);
103   // shift grading by 1:
104   intvec v=1;
105   attrib(M,"isHomog",v);
106   M2=truncate(M,2);
107   print(M2);
108   dimGradedPart(M2,3);
109
110}
111
112///////////////////////////////////////////////////////////////////////////////
113
114proc dimGradedPart(module phi, int d)
115"USAGE:   dimGradedPart(M,d);  M module, d int
116ASSUME:  M comes assigned with an admissible degree vector as an attribute
117RETURN:  int
118NOTE:    Output is the vector space dimension of the graded part of degree d
119         of coker(M).
120EXAMPLE: example dimGradedPart; shows an example
121KEYWORDS: graded module, graded piece
122"
123{
124  if ( typeof(attrib(phi,"isHomog"))=="string" ) { 
125    ERROR("No admissible degree vector assigned");
126  }
127  else {
128    intvec v=attrib(phi,"isHomog");
129  }
130  int s = nrows(phi);
131  int i,m,dummy;
132  module L,LL;
133  for (i=1; i<=s; i++) {
134    if (d>v[i]) {
135      L = L+maxideal(d-v[i])*gen(i);
136      LL = LL+maxideal(d+1-v[i])*gen(i);
137    }
138    else {
139      L = L+gen(i);
140      if (d==v[i]) {
141        LL = LL+maxideal(1)*gen(i);
142      }
143      else {
144        LL = LL+gen(i);
145      }
146    }
147  }
148  LL=LL,phi;
149  L = modulo(L,LL);
150  L = std(prune(L));
151  if (size(L)==0) {return(0);}
152  return(vdim(L));
153}
154example
155{"EXAMPLE:";
156   echo = 2;
157   ring R=0,(x,y,z),dp;
158   module M=maxideal(3);
159   // assign compatible weight vector (here: 0)
160   homog(M);
161   // compute dimension of graded pieces of R/<x,y,z>^3 :
162   dimGradedPart(M,0);
163   dimGradedPart(M,1);
164   dimGradedPart(M,2);
165   dimGradedPart(M,3);
166   // shift grading:
167   attrib(M,"isHomog",intvec(2));
168   dimGradedPart(M,2);
169}
170
171///////////////////////////////////////////////////////////////////////////////
172
173proc CM_regularity (module M)
174"USAGE:   CM_regularity(M);    M module
175ASSUME:  @code{M} comes assigned with an admissible degree vector as an
176         attribute.
177RETURN:  integer, the Castelnuovo-Mumford regularity of coker(M)
178NOTE:    procedure calls mres
179EXAMPLE: example CM_regularity; shows an example
180KEYWORDS: Castelnuovo-Mumford regularity
181"
182{
183  if ( typeof(attrib(phi,"isHomog"))=="string" ) { 
184    ERROR("No admissible degree vector assigned");
185  } 
186  def L = mres(M,0);
187  intmat BeL = betti(L);
188  int r = nrows(module(matrix(BeL)));  // last non-zero row
189  if (typeof(attrib(BeL,"rowShift"))!="string") {
190    int shift = attrib(BeL,"rowShift");
191  }
192  return(r+shift-1);
193}
194example
195{"EXAMPLE:";
196   echo = 2;
197   ring R=0,(x,y,z,u),dp;
198   resolution T1=mres(maxideal(1),0);
199   module M=T1[3];
200   intvec v=2,2,2,2,2,2;
201   attrib(M,"isHomog",v);
202   CM_regularity(M);
203}
204
205///////////////////////////////////////////////////////////////////////////////
206
207proc sheafCohBGG(module M,int l,int h)
208"USAGE:   sheafCohBGG(M,l,h);    M module, l,h int
209ASSUME:  @code{M} comes assigned with an admissible degree vector as an
210         attribute, @code{h>=l}, and the basering has @code{n+1} variables.
211RETURN:  intmat, cohomology of the associated sheaf F of coker(M) on P^n.
212DISPLAY: The intmat is displayed in a Betti-like diagram: @*
213  @format
214                0             1                     h-l
215  ----------------------------------------------------------
216     -h:     h^0(F(h))    h^0(F(h-1))   ......    h^0(F(l))
217   -h+1:   h^1(F(h-1))    h^1(F(h-2))   ......  h^1(F(l-1))
218           .........................................
219   -h+n:   h^n(F(h-n))  h^n(F(h-n-1))   ......  h^n(F(l-n))
220  ----------------------------------------------------------
221  total:         .................................
222  @end format
223         A @code{'-'} in the diagram refers to a zero entry, a @code{'*'}
224         refers to a negative entry (= dimension not yet determined). 
225NOTE:    procedure is based on the Bernstein-Gel'fand-Gel'fand correspondence
226         and on Tate resolution ( see [Eisenbud, Floystad, Schreyer: Sheaf
227         cohomology and free resolutions over exterior algebras, Trans AMS
228         355 (2003)] ).
229EXAMPLE: example sheafCohBGG; shows an example
230"
231{
232  int i,j,k,row,row1,col;
233  if( typeof(attrib(M,"isHomog"))!="intvec" )
234  {
235     ERROR("The module has no weights");
236  }
237  def R=basering;
238  int reg = CM_regularity(M);
239  int bound=max(reg+1,h-1);
240  module MT=truncate(M,bound);
241  int m=nrows(MT);
242  MT=transpose(jacobM(MT));
243  MT=syz(MT);
244  int n=nvars(basering);
245  matrix ML[n][1]=maxideal(1);
246  matrix S=transpose(outer(ML,unitmat(m)));
247  matrix SS=transpose(S*MT);
248  //--- to the exterior algebra
249  def AR = Exterior();
250  setring AR;
251  option(redSB);
252  option(redTail);
253  module EM=imap(R,SS);
254  intvec w;
255  //--- here we are with our matrix
256  int bound1=max(1,bound-l+1);
257  for (i=1; i<=nrows(EM); i++)
258  {
259     w[i]=-bound-1;
260  }
261  attrib(EM,"isHomog",w);
262  resolution RE=mres(EM,bound1);
263  intmat Betti=betti(RE);
264  k=ncols(Betti);
265  int d=k-h+l-1;
266  if (d>0)
267  {
268   // select relevant k-d columns from Betti diagram:
269   row=nrows(Betti);
270   intmat newBetti[row][k-d]=Betti[1..row,d+1..k];
271   int shift=attrib(Betti,"rowShift");
272   attrib(newBetti,"rowShift",shift+d);
273   Betti=newBetti;
274  }
275
276  row1=attrib(Betti,"rowShift");
277  row=nrows(Betti);
278  col=ncols(Betti);
279  if ((row<n) or (row1>-h) ) {
280   // insert top and bottom zero lines (diagram is n x (h-l+1))
281   intmat newBetti1[n][col];
282   for (i=1; i<=row; i++) {
283     for (j=1; j<=col; j++) {
284        newBetti1[i+row1+h,j]=Betti[i,j];
285     }
286   }
287   attrib(newBetti1,"rowShift",-h);
288   Betti=newBetti1;
289  }
290  displayCohom(Betti,l,h,n-1);
291  setring R;
292  return(Betti);
293  option(noredSB);
294  option(noredTail);
295}
296example
297{"EXAMPLE:";
298   echo = 2;
299   ring R=0,(x,y,z,u),dp;
300   resolution T1=mres(maxideal(1),0);
301   module M=T1[3];
302   intvec v=2,2,2,2,2,2;
303   attrib(M,"isHomog",v);
304   def B=sheafCohBGG(M,-6,2);
305}
306
307///////////////////////////////////////////////////////////////////////////////
308
309proc sheafCohE(module M,int l,int h)
310"USAGE:   sheafCohE(M,l,h);    M module, l,h int
311ASSUME:  @code{M} comes assigned with an admissible degree vector as an
312         attribute, @code{h>=l}, and the basering @code{S} has @code{n+1}
313         variables.
314RETURN:  intmat, cohomology of the associated sheaf F of coker(M) on P^n.
315DISPLAY: The intmat is displayed in a Betti-like diagram: @*
316  @format
317                0             1                     h-l
318  ----------------------------------------------------------
319     -h:     h^0(F(h))    h^0(F(h-1))   ......    h^0(F(l))
320   -h+1:   h^1(F(h-1))    h^1(F(h-2))   ......  h^1(F(l-1))
321           .........................................
322   -h+n:   h^n(F(h-n))  h^n(F(h-n-1))   ......  h^n(F(l-n))
323  ----------------------------------------------------------
324  total:         .................................
325  @end format
326         A @code{'-'} in the diagram refers to a zero entry, a @code{'*'}
327         refers to a negative entry (= dimension not yet determined). 
328NOTE:    procedure is based on the local duality as described in [Eisenbud:
329         Computing cohomology. In Vasconcelos: Computational methods in
330         commutative algebra and algebraic geometry. Springer (1998)]:
331   @format
332           h^i(F(j)) = dim_K Ext_S^(n-i) (M,S)_(-j-n-1).
333   @end format
334EXAMPLE: example sheafCohE; shows an example
335"
336{
337  int i,j;
338  module N;
339  int n=nvars(basering)-1;
340  intvec v=0..n-1;
341  int col=h-l+1;
342  intmat newBetti[n+1][col];
343  list L=Ext_R(v,M,1)[2];     // list of GB for Ext_R
344  for (i=1; i<=col; i++) {
345    newBetti[1,i]=-1;
346  }
347  for (j=1; j<=n; j++) {
348     N=L[n+1-j];
349     attrib(N,"isSB",1);
350     if (dim(N)>=0) {
351       for (i=1; i<=col; i++) {
352         newBetti[j+1,i]=dimGradedPart(N,-h-n-2+j+i);
353       }
354     }
355  }
356  displayCohom(newBetti,l,h,n);
357  return(newBetti);
358}
359example
360{"EXAMPLE:";
361   echo = 2;
362   ring R=0,(x,y,z,u),dp;
363   resolution T1=mres(maxideal(1),0);
364   module M=T1[3];
365   intvec v=2,2,2,2,2,2;
366   attrib(M,"isHomog",v);
367   def B=sheafCohE(M,-6,2);
368}
369
370/*
371   To compute dim_K Ext_S^(n-j) ( M, S(-n-1) )_i
372                 = dim_K Ext_S^(n-j) ( M, S )_i-n-1
373   we just need the following input lines:
374       
375       module N = Ext_R(n-j,phi);
376       homog(N);   // Hier muss man momentan noch von Hand eingreifen...
377                   // (siehe unten)
378       dimGradedPart( N, i-n-1);
379*/
380
381///////////////////////////////////////////////////////////////////////////////
382proc displayCohom (intmat data, int l, int h, int n)
383"USAGE:   displayCohom(data,l,h,n);  data intmat, l,h,n int
384ASSUME:  @code{h>=l}, @code{data} is the return value of
385         @code{sheafCohE(M,l,h)} or of @code{sheafCohBGG(M,l,h)}, and the
386         basering has @code{n+1} variables.
387RETURN:  none
388NOTE:    The intmat is displayed in a Betti-like diagram: @*
389  @format
390                0             1                     h-l
391  ----------------------------------------------------------
392     -h:     h^0(F(h))    h^0(F(h-1))   ......    h^0(F(l))
393   -h+1:   h^1(F(h-1))    h^1(F(h-2))   ......  h^1(F(l-1))
394           .........................................
395   -h+n:   h^n(F(h-n))  h^n(F(h-n-1))   ......  h^n(F(l-n))
396  ----------------------------------------------------------
397  total:         .................................
398  @end format
399         where @code{F} refers to the associated sheaf of @code{M} on P^n.@*
400         A @code{'-'} in the diagram refers to a zero entry, a @code{'*'}
401         refers to a negative entry (= dimension not yet determined). 
402EXAMPLE: example truncate; shows an example
403"
404{
405  int i,j,k,dat;
406  intvec notSumCol;
407  notSumCol[h-l+1]=0;
408  string s;
409  string Row="      ";
410  string Row1="------";
411  for (i=0; i<=h-l; i++) {
412    if (i<10) { Row=Row+"     "+string(i); }
413    else      { Row=Row+"    "+string(i); }
414    Row1 = Row1+"------";
415  }
416  print(Row);
417  print(Row1);
418  for (j=1; j<=n+1; j++) {
419    s = string(j-h-1);
420    Row = "";
421    for(k=1; k<6-size(s); k++) { Row = Row+" "; }
422    Row = Row + s+":";
423    for (i=0; i<=h-l; i++) {
424      dat = data[j,i+1];
425      if (dat>0) { s = string(dat); }
426      else {
427        if (dat==0) { s="-"; }
428        else        { s="*"; notSumCol[i+1]=1; }
429      }
430      for(k=1; k<=6-size(s); k++) { Row = Row+" "; }
431      Row = Row + s;
432    }
433    print(Row);
434  }
435  print(Row1);
436  Row="total:";
437  for (i=0; i<=h-l; i++) {
438    dat = 0;
439    if (notSumCol[i+1]==0) {
440      for (j=1; j<=n+1; j++) { dat = dat + data[j,i+1]; }
441      if (dat>0) { s = string(dat); }
442    }
443    else { s="*"; }
444    for (k=1; k<=6-size(s); k++) { Row = Row+" "; }
445    Row = Row + s;
446  }
447  print(Row);
448}
449///////////////////////////////////////////////////////////////////////////////
450
451
452/*
453Examples:
454---------
455 LIB "sheafcoh.lib";
456
457 ring S = 32003, x(0..4), dp;
458 module MI=maxideal(1);
459 attrib(MI,"isHomog",intvec(-1)); 
460 resolution kos = nres(MI,0);
461 print(betti(kos),"betti");
462 LIB "random.lib";
463 matrix alpha0 = random(32002,10,3);
464 module pres = module(alpha0)+kos[3];
465 attrib(pres,"isHomog",intvec(1,1,1,1,1,1,1,1,1,1));
466 resolution fcokernel = mres(pres,0);
467 print(betti(fcokernel),"betti");
468 module dir = transpose(pres);
469 attrib(dir,"isHomog",intvec(-1,-1,-1,-2,-2,-2,
470                             -2,-2,-2,-2,-2,-2,-2));
471 resolution fdir = mres(dir,2);
472 print(betti(fdir),"betti");
473 ideal I = groebner(flatten(fdir[2]));
474 resolution FI = mres(I,0);
475 print(betti(FI),"betti");
476 module F=FI[2];
477 def A1=sheafCohE(F,-2,6);
478 def A2=sheafCohBGG(F,-2,6);
479
480 LIB "sheafcoh.lib";
481 LIB "random.lib";
482 ring S = 32003, x(0..4), dp;
483 resolution kos = nres(maxideal(1),0);
484 betti(kos);
485 matrix kos5 = kos[5];
486 matrix tphi = transpose(dsum(kos5,kos5));
487 matrix kos3 = kos[3];
488 matrix psi = dsum(kos3,kos3);
489 matrix beta1 = random(32002,20,2);
490 matrix tbeta1tilde = transpose(psi*beta1);
491 matrix tbeta0 = lift(tphi,tbeta1tilde);
492 matrix kos4 = kos[4];
493 matrix tkos4pluskos4 = transpose(dsum(kos4,kos4));
494 matrix tgammamin1 = random(32002,20,1);
495 matrix tgamma0 = tkos4pluskos4*tgammamin1;
496 matrix talpha0 = concat(tbeta0,tgamma0);
497 matrix zero[20][1];
498 matrix tpsi = transpose(psi);
499 matrix tpresg = concat(tpsi,zero);
500 matrix pres = module(transpose(talpha0))
501                    + module(transpose(tpresg));
502 module dir = transpose(pres);
503 dir = prune(dir);
504 homog(dir); 
505 intvec deg_dir = attrib(dir,"isHomog");
506 attrib(dir,"isHomog",deg_dir-2);        // set degrees
507 resolution fdir = mres(prune(dir),2);
508 print(betti(fdir),"betti");
509 ideal I = groebner(flatten(fdir[2]));
510 resolution FI = mres(I,0);
511
512 module F=FI[2];
513 def A1=sheafCohE(F,0,8);
514 def A2=sheafCohBGG(F,0,8);
515
516*/
Note: See TracBrowser for help on using the repository browser.