source: git/Singular/LIB/homolog.lib @ 0ae4ce

spielwiese
Last change on this file since 0ae4ce was 0ae4ce, checked in by Anne Frühbis-Krüger <anne@…>, 23 years ago
*anne: added category to libraries for "Commutative Algebra" git-svn-id: file:///usr/local/Singular/svn/trunk@4941 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 32.1 KB
Line 
1// $Id: homolog.lib,v 1.11 2000-12-19 14:41:42 anne Exp $
2//(BM/GMG)
3///////////////////////////////////////////////////////////////////////////////
4
5version="$Id: homolog.lib,v 1.11 2000-12-19 14:41:42 anne Exp $";
6category="Commutative Algebra";
7info="
8LIBRARY:  homolog.lib   PROCEDURES FOR HOMOLOGICAL ALGEBRA
9
10AUTHORS:  Gert-Martin Greuel, email: greuel@mathematik.uni-kl.de,
11          Bernd Martin, email: martin@math.tu-cottbus.de
12
13PROCEDURES:
14 cup(M);                cup: Ext^1(M',M') x Ext^1() --> Ext^2()
15 cupproduct(M,N,P,p,q); cup: Ext^p(M',N') x Ext^q(N',P') --> Ext^p+q(M',P')
16 Ext_R(k,M);            Ext^k(M',R),    M module, R basering, M'=coker(M)
17 Ext(k,M,N);            Ext^k(M',N'),   M,N modules, M'=coker(M), N'=coker(N)
18 Hom(M,N);              Hom(M',N'),     M,N modules, M'=coker(M), N'=coker(N)
19 homology(A,B,M,N)      ker(B)/im(A),   homology of complex R^k--A->M'--B->N'
20 kernel(A,M,N);         ker(M'--A->N')  M,N modules, A matrix
21 kohom(A,k);            Hom(R^k,A),     A matrix over basering R
22 kontrahom(A,k);        Hom(A,R^k),     A matrix over basering R
23";
24
25LIB "general.lib";
26LIB "deform.lib";
27LIB "matrix.lib";
28LIB "poly.lib";
29///////////////////////////////////////////////////////////////////////////////
30
31proc cup (module M,list #)
32"USAGE:   cup(M,[,any,any]);  M=module
33COMPUTE: cup-product Ext^1(M',M') x Ext^1(M',M') ---> Ext^2(M',M'),
34         where M':=R^m/M, if M in R^m, R basering (i.e. M':=coker(matrix(M)))
35         in case of a second argument: symmetrized cup-product
36ASSUME:  all Ext's  are finite dimensional
37RETURN:  matrix of the associated linear map,
38         i.e. the columns of <matrix> present the coordinates of b_i & b_j
39         (resp. (1/2)(b_i & b_j + b_j & b_i) in the symmetric version)
40         with respect to a kbase of Ext^2,
41         (where b_1,b_2,... is a kbase of Ext^1 and & denotes cup product)
42         in case of  a third argument return a list:
43               L[1] = matrix see above (and symmetric case)
44               L[2] = matrix of kbase of Ext^1
45               L[3] = matrix of kbase of Ext^2
46NOTE:    printlevel >=1;  shows what is going on
47         printlevel >=2;  shows result in another representation
48         For computing cupproduct of M itself, apply proc to syz(M)!
49EXAMPLE: example cup; shows examples
50"
51{
52//---------- initialization ---------------------------------------------------
53   int    i,j,k,f0,f1,f2,f3,e1,e2;
54   module M1,M2,A,B,C,ker,ima,ext1,ext2,ext10,ext20;
55   matrix cup[1][0];
56   matrix kb1,lift1,kb2,mA,mB,mC;
57   ideal  tes1,tes2,null;
58   int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
59//-----------------------------------------------------------------------------
60//take a resolution of M<--F(0)<--- ...  <---F(3)
61//apply Hom(-,M) and compute the Ext's
62//-----------------------------------------------------------------------------
63   list resM = nres(M,3);
64   M1 = resM[2];
65   M2 = resM[3];
66   f0 = nrows(M);
67   f1 = ncols(M);
68   f2 = ncols(M1);
69   f3 = ncols(M2);
70   tes1 = simplify(ideal(M),10);
71   tes2=simplify(ideal(M1),10);
72   if ((tes1[1]*tes2[1]==0) or (tes1[1]==1) or (tes2[1]==1))
73   {
74      dbprint(p,"// Ext == 0 , hence 'cup' is the zero-map");
75      return(@cup);
76   }
77//------ compute Ext^1 --------------------------------------------------------
78   B     = kohom(M,f2);
79   A     = kontrahom(M1,f0);
80   C     = intersect(A,B);
81   C     = reduce(C,std(null));C = simplify(C,10);
82   ker   = lift(A,C)+syz(A);
83   ima   = kohom(M,f1);
84   ima   = ima + kontrahom(M,f0);
85   ext1  = modulo(ker,ima);
86   ext10 = std(ext1);
87   e1    = vdim(ext10);
88   dbprint(p-1,"// vdim (Ext^1) = "+string(e1));
89   if (e1 < 0)
90   {
91     "// Ext^1 not of finite dimension";
92     return(cup);
93   }
94   kb1 = kbase(ext10);
95   kb1 = matrix(ker)*kb1;
96   dbprint(p-1,"// kbase of Ext^1(M,M)",
97               "//  - the columns present the kbase elements in Hom(F(1),F(0))",
98               "//  - F(*) a free resolution of M",kb1);
99
100//------ compute the liftings of Ext^1 ----------------------------------------
101   mC = matrix(A)*kb1;
102   lift1 =lift(B,mC);
103   dbprint(p-1,"// lift kbase of Ext^1:",
104    "//  - the columns present liftings of kbase elements into Hom(F(2),F(1))",
105    "//  - F(*) a free resolution of M ",lift1);
106
107//------ compute Ext^2  -------------------------------------------------------
108   B    = kohom(M,f3);
109   A    = kontrahom(M2,f0);
110   C    = intersect(A,B);
111   C    = reduce(C,std(null));C = simplify(C,10);
112   ker  = lift(A,C)+syz(A);
113   ima  = kohom(M,f2);
114   ima  = ima + kontrahom(M1,f0);
115   ext2 = modulo(ker,ima);
116   ext20= std(ext2);
117   e2   = vdim(ext20);
118   if (e2<0)
119   {
120     "// Ext^2 not of finite dimension";
121     return(cup);
122   }
123   dbprint(p-1,"// vdim (Ext^2) = "+string(e2));
124   kb2 = kbase(ext20);
125   kb2 = matrix(ker)*kb2;
126   dbprint(p-1,"// kbase of Ext^2(M,M)",
127               "//  - the columns present the kbase elements in Hom(F(2),F(0))",
128               "//  - F(*) is a a free resolution of M ",kb2);
129//-------  compute: cup-products of base-elements -----------------------------
130   for (i=1;i<=e1;i=i+1)
131   {
132     for (j=1;j<=e1;j=j+1)
133     {
134       mA = matrix(ideal(lift1[j]),f1,f2);
135       mB = matrix(ideal(kb1[i]),f0,f1);
136       mC = mB*mA;
137       if (size(#)==0)
138       {                                          //non symmestric
139         mC = matrix(ideal(mC),f0*f2,1);
140         cup= concat(cup,mC);
141       }
142       else                                       //symmetric version
143       {
144         if (j>=i)
145         {
146           if (j>i)
147           {
148             mA = matrix(ideal(lift1[i]),f1,f2);
149             mB = matrix(ideal(kb1[j]),f0,f1);
150             mC = mC+mB*mA;mC=(1/2)*mC;
151           }
152           mC = matrix(ideal(mC),f0*f2,1);
153           cup= concat(cup,mC);
154         }
155       }
156     }
157   }
158   dbprint(p-1,"// matrix of cup-products (in Ext^2)",cup,"////// end level 2 //////");
159//------- comptute: presentation of base-elements -----------------------------
160   cup = lift(ker,cup);
161   cup = lift_kbase(cup,ext20);
162   if( p>2 )
163   {
164     "// the associated matrices of the bilinear mapping 'cup' ";
165     "// corresponding to the kbase elements of Ext^2(M,M) are shown,";
166     "//  i.e. the rows of the final matrix are written as matrix of";
167     "//  a bilinear form on Ext^1 x Ext^1";
168     matrix BL[e1][e1];
169     for (k=1;k<=e2;k=k+1)
170     {
171       "//_____"+string(k)+". component:";
172       for (i=1;i<=e1;i=i+1)
173       {
174         for (j=1;j<=e1;j=j+1)
175         {
176           if (size(#)==0) { BL[i,j]=cup[k,j+e1*(i-1)]; }
177           else
178           {
179             if (i<=j)
180             {
181               BL[i,j]=cup[k,j+e1*(i-1)-binomial(i,2)];
182               BL[j,i]=BL[i,j];
183             }
184           }
185         }
186       }
187       print(BL);
188     }
189     "////// end level 3 //////";
190   }
191   if (size(#)>2) { return(cup,kb1,kb2);}
192   else {return(cup);}
193}
194example
195{"EXAMPLE";  echo=2;
196  int p      = printlevel;
197  ring  rr   = 32003,(x,y,z),(dp,C);
198  ideal  I   = x4+y3+z2;
199  qring  o   = std(I);
200  module M   = [x,y,0,z],[y2,-x3,z,0],[z,0,-y,-x3],[0,z,x,-y2];
201  print(cup(M));
202  print(cup(M,1));
203  // 2nd EXAMPLE  (shows what is going on)
204  printlevel = 3;
205  ring   r   = 0,(x,y),(dp,C);
206  ideal  i   = x2-y3;
207  qring  q   = std(i);
208  module M   = [-x,y],[-y2,x];
209  print(cup(M));
210  printlevel = p;
211}
212///////////////////////////////////////////////////////////////////////////////
213
214proc cupproduct (module M,N,P,int p,q,list #)
215"USAGE:   cupproduct(M,N,P,p,q[,any]);  M,N,P modules, p,q integers
216COMPUTE: cup-product Ext^p(M',N') x Ext^q(N',P') ---> Ext^p+q(M',P')
217         where M':=R^m/M, if M in R^m, R basering (i.e. M':=coker(matrix(M)))
218ASSUME:  all Ext's  are of finite dimension
219RETURN:  matrix of the associated linear map Ext^p(tensor)Ext^q-->Ext^p+q
220         i.e. the columnes of <matrix> present the coordinates of
221         the cup products (b_i & c_j) with respect to a kbase of Ext^p+q
222         (b_i resp. c_j are choosen bases of Ext^p resp. Ext^q)
223         in case of a 6th argument:
224            return a list
225            L[1] = matrix (see above)
226            L[2] = matrix of kbase of Ext^p(M',N')
227            L[3] = matrix of kbase of Ext^q(N',P')
228            L[4] = matrix of kbase of Ext^p+q(N',P')
229NOTE:    printlevel >=1;  shows what is going on
230         printlevel >=2;  shows result in another representation
231         For computing cupproduct of M,N itself, apply proc to syz(M),syz(N)!
232EXAMPLE: example cupproduct; shows examples
233"
234{
235//---------- initialization ---------------------------------------------------
236   int    e1,e2,e3,i,j,k,f0,f1,f2;
237   module M1,M2,N1,N2,P1,P2,A,B,C,ker,ima,extMN,extMN0,extMP,
238          extMP0,extNP,extNP0;
239   matrix cup[1][0];
240   matrix kbMN,kbMP,kbNP,lift1,mA,mB,mC;
241   ideal  test1,test2,null;
242   int pp = printlevel-voice+3;  // pp=printlevel+1 (default: p=1)
243//-----------------------------------------------------------------------------
244//compute resolutions of M and N
245//                     M<--F(0)<--- ...  <---F(p+q+1)
246//                     N<--G(0)<--- ...  <---G(q+1)
247//-----------------------------------------------------------------------------
248   list resM = nres(M,p+q+1);
249   M1 = resM[p];
250   M2 = resM[p+1];
251   list resN = nres(N,q+1);
252   N1 = resN[q];
253   N2 = resN[q+1];
254   P1 = resM[p+q];
255   P2 = resM[p+q+1];
256//-------test: Ext==0?---------------------------------------------------------
257   test1 = simplify(ideal(M1),10);
258   test2 = simplify(ideal(N),10);
259   if (test1[1]==0) { dbprint(pp,"//Ext(M,N)=0");return(cup); }
260   test1 = simplify(ideal(N1),10);
261   test2 = simplify(ideal(P),10);
262   if (test1[1]==0) { dbprint(pp,"//Ext(N,P)=0");return(cup); }
263   test1 = simplify(ideal(P1),10);
264   if (test1[1]==0) { dbprint(pp,"//Ext(M,P)=0");return(cup); }
265 //------ compute kbases of Ext's ---------------------------------------------
266 //------ Ext(M,N)
267   test1 = simplify(ideal(M2),10);
268   if (test1[1]==0) { ker = freemodule(ncols(M1)*nrows(N));}
269   else
270   {
271     A   = kontrahom(M2,nrows(N));
272     B   = kohom(N,ncols(M2));
273     C   = intersect(A,B);
274     C   = reduce(C,std(ideal(0)));C=simplify(C,10);
275     ker = lift(A,C)+syz(A);
276   }
277   ima   = kohom(N,ncols(M1));
278   A     = kontrahom(M1,nrows(N));
279   ima   = ima+A;
280   extMN = modulo(ker,ima);
281   extMN0= std(extMN);
282   e1    = vdim(extMN0);
283   dbprint(pp-1,"// vdim Ext(M,N) = "+string(e1));
284   if (e1 < 0)
285   {
286     "// Ext(M,N) not of finite dimension";
287     return(cup);
288   }
289   kbMN  = kbase(extMN0);
290   kbMN = matrix(ker)*kbMN;
291   dbprint(pp-1,"// kbase of Ext^p(M,N)",
292          "//  - the columns present the kbase elements in Hom(F(p),G(0))",
293          "//  - F(*),G(*) are free resolutions of M and N",kbMN);
294//------- Ext(N,P)
295   test1 = simplify(ideal(N2),10);
296   if (test1[1]==0) {  ker = freemodule(ncols(N1)*nrows(P)); }
297   else
298   {
299     A = kontrahom(N2,nrows(P));
300     B = kohom(P,ncols(N2));
301     C = intersect(A,B);
302     C = reduce(C,std(ideal(0)));C=simplify(C,10);
303     ker = lift(A,C)+syz(A);
304   }
305   ima   = kohom(P,ncols(N1));
306   A     = kontrahom(N1,nrows(P));
307   ima   = ima+A;
308   extNP = modulo(ker,ima);
309   extNP0= std(extNP);
310   e2    = vdim(extNP0);
311   dbprint(pp-1,"// vdim Ext(N,P) = "+string(e2));
312   if (e2 < 0)
313   {
314     "// Ext(N,P) not of finite dimension";
315     return(cup);
316   }
317   kbNP  = kbase(extNP0);
318   kbNP  = matrix(ker)*kbNP;
319   dbprint(pp-1,"// kbase of Ext(N,P):",kbNP,
320          "// kbase of Ext^q(N,P)",
321          "//  - the columns present the kbase elements in Hom(G(q),H(0))",
322          "//  - G(*),H(*) are free resolutions of N and P",kbNP);
323
324//------ Ext(M,P)
325   test1 = simplify(ideal(P2),10);
326   if (test1[1]==0) { ker = freemodule(ncols(P1)*nrows(P)); }
327   else
328   {
329     A = kontrahom(P2,nrows(P));
330     B = kohom(P,ncols(P2));
331     C = intersect(A,B);
332     C = reduce(C,std(ideal(0)));C=simplify(C,10);
333     ker = lift(A,C)+syz(A);
334   }
335   ima   = kohom(P,ncols(P1));
336   A     = kontrahom(P1,nrows(P));
337   ima   = ima+A;
338   extMP = modulo(ker,ima);
339   extMP0= std(extMP);
340   e3    = vdim(extMP0);
341   dbprint(pp-1,"// vdim Ext(M,P) = "+string(e3));
342   if (e3 < 0)
343   {
344     "// Ext(M,P) not of finite dimension";
345     return(cup);
346   }
347   kbMP  = kbase(extMP0);
348   kbMP  = matrix(ker)*kbMP;
349   dbprint(pp-1,"// kbase of Ext^p+q(M,P)",
350          "//  - the columns present the kbase elements in Hom(F(p+q),H(0))",
351          "//  - F(*),H(*) are free resolutions of M and P",kbMP);
352//----- lift kbase of Ext(M,N) ------------------------------------------------
353   lift1 = kbMN;
354   for (i=1;i<=q;i=i+1)
355   {
356     mA = kontrahom(resM[p+i],nrows(resN[i]));
357     mB = kohom(resN[i],ncols(resM[p+i]));
358     lift1 = lift(mB,mA*lift1);
359   }
360   dbprint(pp-1,"// lifting of kbase of Ext^p(M,N)",
361   "//  - the columns present the lifting of kbase elements in Hom(F(p+q),G(q))",lift1);
362//-------  compute: cup-products of base-elements -----------------------------
363   f0 = nrows(P);
364   f1 = ncols(N1);
365   f2 = ncols(resM[p+q]);
366   for (i=1;i<=e1;i=i+1)
367   {
368     for (j=1;j<=e2;j=j+1)
369     {
370       mA = matrix(ideal(lift1[j]),f1,f2);
371       mB = matrix(ideal(kbMP[i]),f0,f1);
372       mC = mB*mA;
373       mC = matrix(ideal(mC),f0*f2,1);
374       cup= concat(cup,mC);
375     }
376   }
377   dbprint(pp-1,"// matrix of cup-products (in Ext^p+q)",cup,"////// end level 2 //////");
378//------- comptute: presentation of base-elements -----------------------------
379   cup = lift(ker,cup);
380   cup = lift_kbase(cup,extMP0);
381//------- special output ------------------------------------------------------
382   if (pp>2)
383   {
384     "// the associated matrices of the bilinear mapping 'cup' ";
385     "// corresponding to the kbase elements of Ext^p+q(M,P) are shown,";
386     "//  i.e. the rows of the final matrix are written as matrix of";
387     "//  a bilinear form on Ext^p x Ext^q";
388     matrix BL[e1][e2];
389     for (k=1;k<=e3;k=k+1)
390     {
391       "//----"+string(k)+". component:";
392       for (i=1;i<=e1;i=i+1)
393       {
394         for (j=1;j<=e2;j=j+1)
395         {
396           BL[i,j]=cup[k,j+e1*(i-1)];
397         }
398        }
399        print(BL);
400      }
401     "////// end level 3 //////";
402   }
403   if (size(#)) { return(cup,kbMN,kbNP,kbMP);}
404   else         { return(cup); }
405}
406example
407{"EXAMPLE";  echo=2;
408  int p      = printlevel;
409  ring  rr   = 32003,(x,y,z),(dp,C);
410  ideal  I   = x4+y3+z2;
411  qring  o   = std(I);
412  module M   = [x,y,0,z],[y2,-x3,z,0],[z,0,-y,-x3],[0,z,x,-y2];
413  print(cupproduct(M,M,M,1,3));
414  printlevel = 3;
415  list l     = (cupproduct(M,M,M,1,3,"any"));
416  show(l[1]);show(l[2]);
417  printlevel = p;
418}
419///////////////////////////////////////////////////////////////////////////////
420
421proc Ext_R (intvec v, module M, list #)
422"USAGE:   Ext_R(v,M[,p]);  v=int/intvec , M=module, p=int
423COMPUTE: A presentation of Ext^k(M',R); for k=v[1],v[2],..., M'=coker(M).
424         Let ...--> F2 --> F1 --M-> F0-->M'-->0 be a free resolution of M'. If
425         0 <-- F0* <-A1-- F1* <-A2-- F2* <-A3--... denotes the dual sequence,
426         Fi*=Hom(Fi,R), then Ext^k = ker(Ak)/im(Ak+1) is presented as in the
427         following exact sequences:
428                 Fk-1* <-Ak-- Fk* <-syz(Ak)-- R^p
429                 Fk*/im(Ak+1) <-syz(Ak)-- R^p <-Ext^k-- R^q
430         Hence Ext^k=modulo(syz(Ak),Ak+1) presents Ext^k(M',R);
431RETURN:  Ext^k, of type module, a presentation of Ext^k(M',R) if v is of type
432         int, resp. a list of Ext^k (k=v[1],v[2],...) if v is of type intvec.
433         In case of a third argument of type int return a list:
434           [1] = module Ext^k/list of Ext^k
435           [2] = SB of Ext^k/list of SB of Ext^k
436           [3] = matrix/list of matrices, each representing kbase of Ext^k
437                 (if finite dimensional)
438DISPLAY: printlevel >=0: degree of Ext^k for each k  (default)
439         printlevel >=1: Ak, Ak+1 and kbase of Ext^k in Fk*
440NOTE:    In order to compute Ext^k(M,R) use the command Ext_R(k,syz(M));
441         or the 2 commands: list L=mres(M,2);  Ext_R(k,L[2]);
442EXAMPLE: example Ext_R; shows examples
443"
444{
445
446// In case M is known to be a SB, set attrib(M,"isSB",1); in order to
447// avoid  unnecessary SB computations
448
449//------------ initialisation -------------------------------------------------
450  module m1,m2,ret,ret0;
451  matrix ker,kb;
452  list L1,L2,L3,L,resl,K;
453  int k,max,ii,t1,t2;
454  int s = size(v);
455  intvec v1 = sort(v)[1];
456  max = v1[s];                 // the maximum integer occuring in intvec v
457  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
458  // --------------- Variante mit sres
459  for( ii=1; ii<=size(#); ii++ )
460  {
461    t2=1; // return a list if t2=1
462    if( typeof(#[ii])=="string" )
463    {
464      if ( #[ii]=="sres" ) { t1=1; t2=0; } // use sres instead of mres if t1=1
465    }
466  }
467//----------------- compute resolution of coker(M) ----------------------------
468  if( max<0 ) { dbprint(p,"// Ext^i=0 for i<0!"); return([1]); }
469  if( t1==1 )
470  {
471    if( attrib(M,"isSB")==0 ) { M=std(M); }
472    resl = sres(M,max+1);
473  }
474  else { resl = mres(M,max+1); }
475  for( ii=1; ii<=s; ii++ )
476  {
477//-----------------  apply Hom(_,R) at k-th place -----------------------------
478    k=v[ii];
479    if( k<0 )                   // Ext^k=0 for negative k
480    {
481      dbprint(p-1,"// Ext^i=0 for i<0!");
482      ret    = gen(1);
483      ret0   = std(ret);
484      L1[ii] = ret;
485      L2[ii] = ret0;
486      L3[ii] = matrix(kbase(ret0));
487      dbprint(p,"// degree of Ext^"+string(k)+":");
488      if( p>=0 ) { degree(ret0);"";}
489    }
490    else
491    {
492      m2 = transpose(resl[k+1]);
493      if( k==0 ) { m1=0*gen(nrows(m2)); }
494      else { m1 = transpose(resl[k]); }
495//----------------- presentation of ker(m2)/im(m1) ----------------------------
496      ker = syz(m2);
497      ret = modulo(ker,m1);
498      dbprint(p-1,"// Computing Ext^"+string(k)+":",
499         "// Let 0<--coker(M)<--F0<--F1<--F2<--... be a resolution of M,",
500         "// then F"+string(k)+"*-->F"+string(k+1)+"* is given by:",m2,
501         "// and F"+string(k-1)+"*-->F"+string(k)+"* is given by:",m1,"");
502      ret0 = std(ret);
503      dbprint(p,"// degree of Ext^"+string(k)+":");
504      if( p>0 ) { degree(ret0);"";}
505      if( t2 )
506      {
507         if( vdim(ret0)>=0 )
508         {
509            kb = kbase(ret0);
510            if ( size(ker)!=0 ) { kb = matrix(ker)*kb; }
511            dbprint(p-1,
512            "// columns of matrix are kbase of Ext^"+string(k)+" in F"+string(k)+"*:",kb,"");
513            L3[ii] = kb;
514         }
515         L2[ii] = ret0;
516      }
517      L1[ii] = ret;
518    }
519  }
520  if( t2 )
521  {
522     if( s>1 ) { L = L1,L2,L3; return(L); }
523     else { L = ret,ret0,kb; return(L); }
524  }
525  else
526  {
527     if( s>1 ) { return(L1); }
528     else { return(ret); }
529  }
530}
531example
532{"EXAMPLE:";     echo=2;
533  int p      = printlevel;
534  printlevel = 1;
535  ring r     = 0,(x,y,z),dp;
536  ideal i    = x2y,y2z,z3x;
537  module E   = Ext_R(1,i);       //computes Ext^1(r/i,r)
538  is_zero(E);
539  module m   = [x],[0,y];
540  list L     = Ext_R(2..3,m);    //computes Ext^i(r^2/m,r), i=2,3
541  show(L);"";
542  qring R    = std(x2+yz);
543  intvec v   = 0,2,4;
544  printlevel = 2;                //shows what is going on
545  ideal i    = x,y,z;            //computes Ext^i(r/(x,y,z),r/(x2+yz)), i=0,2,4
546  list L     = Ext_R(v,i,1);     //over the qring R=r/(x2+yz), std and kbase
547  printlevel = p;
548}
549///////////////////////////////////////////////////////////////////////////////
550
551proc Ext (intvec v, module M, module N, list #)
552"USAGE:   Ext(v,M,N[,any]);  v=int/intvec, M,N=modules
553COMPUTE: A presentation of Ext^k(M',N'); for k=v[1],v[2],... where
554         M'=coker(M) and N'=coker(N). Let
555         0<--M'<-- F0 <-M-- F1 <-- F2 <--...  resp. 0<--N'<-- G0 <--N- G1 be
556         a free resolution of M' resp. a presentations of N'. Consider
557@format
558                      0                  0                  0
559                      |^                 |^                 |^
560               --> Hom(Fk-1,N') -Ak-> Hom(Fk,N') -Ak+1-> Hom(Fk+1,N')
561                      |^                 |^                 |^
562               --> Hom(Fk-1,G0) -Ak-> Hom(Fk,G0) -Ak+1-> Hom(Fk+1,G0)
563                                         |^                 |^
564                                         |C                 |B
565                                      Hom(Fk,G1) -----> Hom(Fk+1,G1)
566@end format
567         (Ak,Ak+1 induced by M and B,C induced by N).
568         Let K=modulo(Ak+1,B), J=module(Ak)+module(C) and Ext=modulo(K,J),
569         then we have exact sequences
570                  R^p  --K-> Hom(Fk,G0) --Ak+1-> Hom(Fk+1,G0)/im(B)
571         R^q -Ext-> R^p --K->Hom(Fk,G0)/im(Ak)+im(C) --Ak+1->Hom(Fk+1,G0)/im(B)
572         Hence Ext presents Ext^k(M',N')
573RETURN: 
574         Ext, of type module, a presentation of Ext^k(M',N') if v is of type
575         int, resp. a list of Ext^k (k=v[1],v[2],...) if v is of type intvec.
576         In case of a third argument of any type return a list:
577           [1] = module Ext/list of Ext^k
578           [2] = SB of Ext/list of SB of Ext^k
579           [3] = matrix/list of matrices, each representing a kbase of Ext^k
580                 (if finite dimensional)
581DISPLAY: printlevel >=0: degree of Ext^k for each k  (default)
582         printlevel >=1: matrices Ak, Ak+1 and kbase of Ext^k in Hom(Fk,G0)
583                            (if finite dimensional)
584NOTE:    In order to compute Ext^k(M,N) use the command Ext(k,syz(M),syz(N));
585         or: list P=mres(M,2); list Q=mres(N,2); Ext(k,P[2],Q[2]);
586EXAMPLE: example Ext;   shows examples
587"
588{
589//---------- initialisation ---------------------------------------------------
590  int k,max,ii,l,row,col;
591  module A,B,C,D,M1,M2,N1,ker,imag,extMN,extMN0;
592  matrix kb;
593  list L1,L2,L3,L,resM,K;
594  ideal  test1;
595  intmat Be;
596  int s = size(v);
597  intvec v1 = sort(v)[1];
598  max = v1[s];                      // the maximum integer occuring in intvec v
599  int p = printlevel-voice+3;       // p=printlevel+1 (default: p=1)
600//---------- test: coker(N)=basering, coker(N)=0 ? ----------------------------
601  if( max<0 ) { dbprint(p,"// Ext^i=0 for i<0!"); return([1]); }
602  N1 = std(N);
603  if( size(N1)==0 )      //coker(N)=basering, in this case proc Ext_R is faster
604  { printlevel=printlevel+1;
605    if( size(#)==0 )
606    { def E = Ext_R(v,M);
607      printlevel=printlevel-1;
608      return(E);
609    }
610    else
611    { def E = Ext_R(v,M,#[1]);
612       printlevel=printlevel-1;
613       return(E);
614     }
615  }
616  if( dim(N1)==-1 )                          //coker(N)=0, all Ext-groups are 0
617  { dbprint(p-1,"2nd module presents 0, hence Ext^k=0, for all k");
618    for( ii=1; ii<=s; ii++ )
619    { k=v[ii];
620      extMN    = gen(1);
621      extMN0   = std(extMN);
622      L1[ii] = extMN;
623      L2[ii] = extMN0;
624      L3[ii] = matrix(kbase(extMN0));
625      if( p>0 ) { "// degree of Ext^"+string(k)+":"; degree(extMN0);""; }
626    }
627  }
628  else
629  {
630    if( size(N1) < size(N) ) { N=N1;}
631    row = nrows(N);
632//---------- resolution of M -------------------------------------------------
633    resM = mres(M,max+1);
634    for( ii=1; ii<=s; ii++ )
635    { k=v[ii];
636      if( k<0  )                                    // Ext^k is 0 for negative k
637      { dbprint(p-1,"// Ext^k=0 for k<0!");
638        extMN    = gen(1);
639        extMN0   = std(extMN);
640        L1[ii] = extMN;
641        L2[ii] = extMN0;
642        L3[ii] = matrix(kbase(extMN0));
643        if( p>0 ) { "// degree of Ext^"+string(k)+":"; degree(extMN0);""; }
644      }
645      else
646      { M2 = resM[k+1];
647        if( k==0 ) { M1=0*gen(nrows(M2)); }
648        else { M1 = resM[k]; }
649        col = ncols(M1);
650        D = kohom(N,col);
651//---------- computing homology ----------------------------------------------
652        imag  = kontrahom(M1,row);
653        A     = kontrahom(M2,row);
654        B     = kohom(N,ncols(M2));
655        ker   = modulo(A,B);
656        imag  = imag,D;
657        extMN = modulo(ker,imag);
658        dbprint(p-1,"// Computing Ext^"+string(k)+" (help Ext; gives an explanation):",
659         "// Let 0<--coker(M)<--F0<--F1<--F2<--... be a resolution of coker(M),",
660         "// and 0<--coker(N)<--G0<--G1 a presentation of coker(N),",
661         "// then Hom(F"+string(k)+",G0)-->Hom(F"+string(k+1)+",G0) is given by:",A,
662         "// and Hom(F"+string(k-1)+",G0) + Hom(F"+string(k)+",G1)-->Hom(F"+string(k)+",G0) is given by:",imag,"");
663        extMN0 = std(extMN);
664        if( p>0 ) { "// degree of Ext^"+string(k)+":"; degree(extMN0);""; }
665//---------- more information -------------------------------------------------
666        if( size(#)>0 )
667        { if( vdim(extMN0) >= 0 )
668          { kb = kbase(extMN0);
669            if ( size(ker)!=0) { kb = matrix(ker)*kb; }
670            dbpri(p-1,"// columns of matrix are kbase of Ext^"+
671                     string(k)+" in Hom(F"+string(k)+",G0)",kb,"");
672            if( p>0 )
673            { for (l=1;l<=ncols(kb);l=l+1)
674              {
675                "// element",l,"of kbase of Ext^"+string(k)+" in Hom(F"+string(k)+",G0)";
676                "// as matrix: F"+string(k)+"-->G0";
677                print(matrix(ideal(kb[l]),row,col));
678              }
679              "";
680            }
681            L3[ii] = matrix(kb);
682          }
683          L2[ii] = extMN0;
684        }
685        L1[ii] = extMN;
686      }
687    }
688  }
689  if( size(#) )
690  {  if( s>1 ) { L = L1,L2,L3; return(L); }
691     else { L = extMN,extMN0,matrix(kb); return(L); }
692  }
693  else
694  {  if( s>1 ) { return(L1); }
695     else { return(extMN); }
696  }
697}
698example
699{"EXAMPLE:";   echo=2;
700  int p      = printlevel;
701  printlevel = 1;
702  ring r     = 0,(x,y),dp;
703  ideal i    = x2-y3;
704  ideal j    = x2-y5;
705  list E     = Ext(0..2,i,j);    // Ext^k(r/i,r/j) for k=0,1,2 over r
706  qring R    = std(i);
707  ideal j    = fetch(r,j);
708  module M   = [-x,y],[-y2,x];
709  printlevel = 2;
710  module E1  = Ext(1,M,j);       // Ext^1(R^2/M,R/j) over R=r/i
711  list l     = Ext(4,M,M,1);     // Ext^4(R^2/M,R^2/M) over R=r/i
712  printlevel = p;
713}
714////////////////////////////////////////////////////////////////////////////////
715
716proc Hom (module M, module N, list #)
717"USAGE:   Hom(M,N,[any]);  M,N=modules
718COMPUTE: A presentation of Hom(M',N'), M'=coker(M), N'=coker(N) as follows:
719         Let ...-->F1 --M-> F0-->M'-->0 and ...-->G1 --N-> G0-->N'-->0  be
720         presentations of M' and N'. Consider
721@format
722                                         0               0
723                                         |^              |^
724              0 --> Hom(M',N') ----> Hom(F0,N') ----> Hom(F1,N')
725                                         |^              |^
726         (A:  induced by M)          Hom(F0,G0) --A-> Hom(F1,G0)
727                                         |^              |^
728         (B,C:induced by N)              |C              |B
729                                     Hom(F0,G1) ----> Hom(F1,G1)
730
731         Let D=modulo(A,B) and Hom=modulo(D,C), then we have exact sequences
732              R^p  --D-> Hom(F0,G0) --A-> Hom(F1,G0)/im(B)
733              R^q -Hom-> R^p --D-> Hom(F0,G0)/im(C) --A-> Hom(F1,G0)/im(B).
734         Hence Hom presents Hom(M',N')
735@end format
736RETURN:  Hom, of type module, presentation of Hom(M',N') or,
737         in case of 3 arguments, a list:
738           [1] = Hom
739           [2] = SB of Hom
740           [3] = kbase of coker(Hom) (if finite dimensional), represented by
741                 elements in Hom(F0,G0) via mapping D
742DISPLAY: printlevel >=0: degree of Hom  (default)
743         printlevel >=1: D and C and kbase of coker(Hom) in Hom(F0,G0)
744         printlevel >=2: elements of kbase of coker(Hom) as matrix :F0-->G0
745NOTE:    DISPLAY is as described only for a direct call of 'Hom'. Calling 'Hom'
746         from another proc has the same effect as decreasing printlevel by 1.
747EXAMPLE: example Hom;  shows examples
748"
749{
750//---------- initialisation ---------------------------------------------------
751  int l,p;
752  matrix kb;
753  module A,B,C,D,homMN,homMN0;
754  list L;
755//---------- computation of Hom -----------------------------------------------
756  B = kohom(N,ncols(M));
757  A = kontrahom(M,nrows(N));
758  C = kohom(N,nrows(M));
759  D = modulo(A,B);
760  homMN = modulo(D,C);
761  homMN0= std(homMN);
762  p = printlevel-voice+3;       // p=printlevel+1 (default: p=1)
763  if( p>=0 ) { "// degree of Hom:"; degree(homMN0); ""; }
764  dbprint(p-1,"// given ...--> F1 --M-> F0 -->M'--> 0 and ...--> G1 --N-> G0 -->N'--> 0,",
765         "// show D=ker(Hom(F0,G0) --> Hom(F1,G0)/im(Hom(F1,G1) --> Hom(F1,G0)))",D,
766         "// show C=im(Hom(F0,G1) --> Hom(F0,G0))",C,"");
767//---------- extra output if size(#)>0 ----------------------------------------
768  if( size(#)>0 )
769  {  if( vdim(homMN0)>0 )
770     {  kb = kbase(homMN0);
771        kb = matrix(D)*kb;
772        if( p>2 )
773        {  for (l=1;l<=ncols(kb);l=l+1)
774           {
775             "// element",l,"of kbase of Hom in Hom(F0,G0) as matrix: F0-->G0:";
776             print(matrix(ideal(kb[l]),nrows(N),nrows(M)));
777           }
778        }
779        else
780       { dbprint(p-1,"// columns of matrix are kbase of Hom in Hom(F0,G0)",kb); }
781        L=homMN,homMN0,kb; return(L);
782     }
783     L=homMN,homMN0; return(L);
784  }
785  return(homMN);
786}
787example
788{"EXAMPLE:";  echo = 2;
789  int p     = printlevel;
790  printlevel= 1;   //in 'example proc' printlevel has to be increased by 1
791  ring r    = 0,(x,y),dp;
792  ideal i   = x2-y3,xy;
793  qring q   = std(i);
794  ideal i   = fetch(r,i);
795  module M  = [-x,y],[-y2,x],[x3];
796  module H  = Hom(M,i);
797  print(H);
798  printlevel= 2;
799  list L    = Hom(M,i,1);"";
800  ring s    = 3,(x,y,z),(c,dp);
801  ideal i   = jacob(ideal(x2+y5+z4));
802  qring rq=std(i);
803  matrix M[2][2]=xy,x3,5y,4z,x2;
804  matrix N[3][2]=x2,x,y3,3xz,x2z,z;
805  print(M);
806  print(N);
807  list l=Hom(M,N,1);
808  printlevel = p;
809}
810////////////////////////////////////////////////////////////////////////////////
811
812proc homology (matrix A,matrix B,module M,module N,list #)
813"USAGE:   homology(A,B,M,N);
814COMPUTE: Let M and N be submodules of R^m and R^n presenting M'=R^m/M, N'=R^n/N
815         (R=basering) and let A,B matrices inducing maps R^k--A-->R^m--B-->R^n.
816         Compute a presentation R^q --H-> R^m of the module
817              ker(B)/im(A) := ker(M'/im(A) --B--> N'/im(BM)+im(BA)).
818         If B induces a map M'--B-->N' (i.e BM=0) and if R^k--A-->M'--B-->N' is
819         a complex (i.e. BA=0) then ker(B)/im(A) is the homology of this complex
820RETURN:  module H, a presentation of ker(B)/im(A)
821NOTE:    homology returns a free module of rank m if ker(B)=im(A)
822EXAMPLE: example homology; shows examples
823"
824{
825  module ker,ima;
826  ker = modulo(B,N);
827  ima = A,M;
828  return(modulo(ker,ima));
829}
830example
831{"EXAMPLE";    echo=2;
832  ring r;
833  ideal id=maxideal(4);
834  qring qr=std(id);
835  module N=maxideal(3)*freemodule(2);
836  module M=maxideal(2)*freemodule(2);
837  module B=[2x,0],[x,y],[z2,y];
838  module A=M;
839  degree(std(homology(A,B,M,N)));"";
840  ring s=0,x,ds;
841  qring qs=std(x4);
842  module A=[x];module B=A;
843  module M=[x3];module N=M;
844  homology(A,B,M,N);
845}
846//////////////////////////////////////////////////////////////////////////////
847
848proc kernel (matrix A,module M,module N)
849"USAGE:   kernel(A,M,N);
850COMPUTE: Let M and N be submodules of R^m and R^n presenting M'=R^m/M, N'=R^n/N
851         (R=basering) and let A:R^m-->R^n a matrix inducing a map A':M'-->N'.
852         Compute a presentation K of ker(A') as in the commutative diagram:
853@format
854                       ker(A') --->  M' --A'--> N'
855                           |^        |^         |^
856                           |         |          |
857                          R^r  ---> R^m --A--> R^n
858                           |^        |^         |^
859                           |K        |M         |N
860                           |         |          |
861                          R^s  ---> R^p -----> R^q
862@end format
863RETURN:  module K, a presentation of ker(A')
864EXAMPLE: example kernel; shows examples
865"
866{
867  module M1 = modulo(A,N);
868  return(modulo(M1,M));
869}
870example
871{"EXAMPLE";    echo=2;
872  ring r;
873  module N=[2x,x],[0,y];
874  module M=maxideal(1)*freemodule(2);
875  matrix A[2][2]=2x,0,x,y,z2,y;
876  module K=kernel(A,M,N);
877  degree(std(K));
878  print(K);
879}
880////////////////////////////////////////////////////////////////////////////////
881
882proc kohom (matrix M, int j)
883"USAGE:   kohom(A,k); A=matrix, k=integer
884RETURN:  matrix Hom(R^k,A) i.e. let A be a matrix defining a map: F1 --> F2 of
885         free R-modules, the matrix of Hom(R^k,F1)-->Hom(R^k,F2) is computed
886EXAMPLE: example kohom; shows an example
887"
888{
889  if (j==1)
890  { return(M);}
891  if (j>1)
892  { return(outer(M,diag(1,j))); }
893  else { return(0);}
894}
895example
896{"EXAMPLE:";   echo=2;
897  ring r;
898  matrix n[2][3]=x,y,5,z,77,33;
899  print(kohom(n,3));
900}
901/////////////////////////////////////////////////////////////////////////////////
902
903proc kontrahom (matrix M, int j)
904"USAGE:   kontrahom(A,k); A=matrix, k=integer
905RETURN:  matrix Hom(A,R^k), i.e. let A be a matrix defining a map: F1 --> F2 of
906         free  R-modules, the matrix of Hom(F2,R^k)-->Hom(F1,R^k) is computed
907EXAMPLE: example kontrahom; shows an example
908"
909{
910if (j==1)
911  { return(transpose(M));}
912  if (j>1)
913  { return(transpose(outer(diag(1,j),M)));}
914  else { return(0);}
915}
916example
917{"EXAMPLE:";  echo=2;
918  ring r;
919  matrix n[2][3]=x,y,5,z,77,33;
920  print(kontrahom(n,3));
921}
922///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.