source: git/Singular/LIB/homolog.lib @ c702d2

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