source: git/Singular/LIB/homolog.lib @ 4d68980

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