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

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