source: git/Singular/LIB/nchomolog.lib @ 05a2f6

spielwiese
Last change on this file since 05a2f6 was 05a2f6, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: add file magic git-svn-id: file:///usr/local/Singular/svn/trunk@12086 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 15.8 KB
Line 
1//
2version="$Id: nchomolog.lib,v 1.12 2009-08-21 14:14:05 Singular Exp $";
3category="Noncommutative";
4info="
5LIBRARY:  nchomolog.lib   Procedures for Noncommutative Homological Algebra
6AUTHORS:  Viktor Levandovskyy  levandov@math.rwth-aachen.de,
7@*             Gerhard Pfister, pfister@mathematik.uni-kl.de
8
9PROCEDURES:
10 ncExt_R(k,M);            Ext^k(M',R),    M module, R basering, M'=coker(M)
11 ncHom(M,N);              Hom(M',N'),     M,N modules, M'=coker(M), N'=coker(N)
12 coHom(A,k);            Hom(R^k,A),     A matrix over basering R
13 contraHom(A,k);        Hom(A,R^k),     A matrix over basering R
14 dmodoublext(M, l);  computes Ext_D^i(Ext_D^i(M,D),D), where D is a basering
15";
16
17LIB "dmod.lib";
18LIB "gkdim.lib";
19LIB "involut.lib";
20LIB "nctools.lib";
21
22//  ncExt(k,M,N);            Ext^k(M',N'),   M,N modules, M'=coker(M), N'=coker(N)
23//  ncTensorMod(M,N);        Tensor product of modules M'=coker(M), N'=coker(N)
24//  ncTor(k,M,N);            Tor_k(M',N'),   M,N modules, M'=coker(M), N'=coker(N)
25//  tensorMaps(M,N);       tensor product of  matrices
26
27proc contraHom(matrix M, int s)
28{
29   int n,m=ncols(M),nrows(M);
30   int a,b,c;
31   matrix R[s*n][s*m];
32   for(b=1; b<=m; b++)
33   {
34      for(a=1; a<=s; a++)
35      {
36         for(c=1; c<=n; c++)
37         {
38            R[(a-1)*n+c,(a-1)*m+b] = M[b,c];
39         }
40      }
41   }
42   return(R);
43}
44example
45{ "EXAMPLE:"; echo = 2;
46  ring A=0,(x,y,z),dp;
47  matrix M[3][3]=1,2,3,
48               4,5,6,
49               7,8,9;
50  module cM = contraHom(M,2);
51  print(cM);
52}
53
54proc coHom(matrix M, int s)
55{
56   int n,m=ncols(M),nrows(M);
57   int a,b,c;
58   matrix R[s*m][s*n];
59   for(b=1; b<=s; b++)
60   {
61      for(a=1; a<=m; a++)
62      {
63         for(c=1; c<=n; c++)
64         {
65            R[(a-1)*s+b,(c-1)*s+b] = M[a,c];
66         }
67      }
68   }
69   return(R);
70}
71example
72{ "EXAMPLE:"; echo = 2;
73  ring A=0,(x,y,z),dp;
74  matrix M[3][3]=1,2,3,
75                 4,5,6,
76                 7,8,9;
77  module cM = coHom(M,2);
78  print(cM);
79}
80
81proc ncHom(matrix M, matrix N)
82"USAGE:   ncHom(M,N);  M,N modules
83COMPUTE: A presentation of Hom(M',N'), M'=coker(M), N'=coker(N)
84ASSUME: M' is a left module, N' is a centralizing bimodule
85NOTE: ncHom(M,N) is a right module, hence a right presentation matrix
86is returned
87EXAMPLE: example ncHom;  shows examples
88"
89{
90  // assume: M is left module
91  // assume: N is centralizing bimodule
92  // returns a right presentation matrix
93  // for a right module
94  matrix F  = contraHom(M,nrows(N));
95  matrix B  = coHom(N,ncols(M));
96  matrix C  = coHom(N,nrows(M));
97  def Rbase = basering;
98  def Rop   = opposite(Rbase);
99  setring Rop;
100  matrix Bop = oppose(Rbase, B);
101  matrix Cop = oppose(Rbase, C);
102  matrix Fop = oppose(Rbase, F);
103  matrix Dop = modulo(Fop, Bop);
104  matrix Eop = modulo(Dop, Cop);
105  setring Rbase;
106  matrix E   = oppose(Rop, Eop);
107  kill Rop;
108  return(E);
109}
110example
111{ "EXAMPLE:"; echo = 2;
112  ring A=0,(x,y,z),dp;
113  matrix M[3][3]=1,2,3,
114                 4,5,6,
115                 7,8,9;
116  matrix N[2][2]=x,y,
117                 z,0;
118  module H = ncHom(M,N);
119  print(H);
120}
121
122proc ncHom_alt(matrix M, matrix N)
123{
124  // shorter but potentially slower
125  matrix F = contraHom(M,nrows(N)); // \varphi^*
126  matrix B = coHom(N,ncols(M));     // i
127  matrix C = coHom(N,nrows(M));     // j
128  matrix D = rightModulo(F,B);      // D
129  matrix E = rightModulo(D,C);      // Hom(M,N)
130  return(E);
131}
132example
133{ "EXAMPLE:"; echo = 2;
134  ring A=0,(x,y,z),dp;
135  matrix M[3][3]=1,2,3,
136                 4,5,6,
137                 7,8,9;
138  matrix N[2][2]=x,y,
139                 z,0;
140  module H = ncHom_alt(M,N);
141  print(H);
142}
143
144proc ncHom_R(matrix M)
145"USAGE:   ncHom_R(M);  M a module
146COMPUTE: A presentation of Hom_R(M',R), M'=coker(M)
147ASSUME: M' is a left module
148NOTE: ncHom_R(M) is a right module, hence a right presentation matrix is returned
149EXAMPLE: example ncHom_R;  shows examples
150"
151{
152  // assume: M is left module
153  // returns a right presentation matrix
154  // for a right module
155  matrix F  = transpose(M);
156  def Rbase = basering;
157  def Rop   = opposite(Rbase);
158  setring Rop;
159  matrix Fop = oppose(Rbase, F);
160  matrix Dop = modulo(Fop, std(0)); //ker Hom(A^n,A) -> Hom(A^m,A)
161  matrix Eop = modulo(Dop, std(0)); // its presentation
162  setring Rbase;
163  matrix E   = oppose(Rop, Eop);
164  kill Rop;
165  return(E);
166}
167example
168{ "EXAMPLE:"; echo = 2;
169  ring A=0,(x,t,dx,dt),dp;
170  def W = Weyl(); setring W;
171  matrix M[2][2] =
172    dt,  dx,
173    t*dx,x*dt;
174  module H = ncHom_R(M);
175  print(H);
176  matrix N[2][1] = x,dx;
177  H = ncHom_R(N);
178  print(H);
179}
180
181
182proc ncExt(int i, matrix Ps, matrix Ph)
183"USAGE:   Ext(i,M,N);  i int, M,N modules
184COMPUTE: A presentation of Ext^i(M',N');  for M'=coker(M) and N'=coker(N).
185NOTE: ncExt(M,N) is a right module, hence a right presentation matrix
186is returned
187EXAMPLE: example ncExt;  shows examples
188"
189{
190  if(i==0) { return(module(ncHom(Ps,Ph))); }
191  list Phi   = mres(Ps,i+1);
192  module Im  = coHom(Ph,ncols(Phi[i+1]));
193  module f   = contraHom(matrix(Phi[i+1]),nrows(Ph));
194  module Im1 = coHom(Ph,ncols(Phi[i]));
195  module Im2 = contraHom(matrix(Phi[i]),nrows(Ph));
196  def Rbase = basering;
197  def Rop   = opposite(Rbase);
198  setring Rop;
199  module fop    = oppose(Rbase,f);
200  module Imop   = oppose(Rbase,Im);
201  module Im1op  = oppose(Rbase,Im1);
202  module Im2op  = oppose(Rbase,Im2);
203  module ker_op = modulo(fop,Imop);
204  module ext_op = modulo(ker_op,Im1op+Im2op);
205  //  ext        = prune(ext);
206 // to be discussed and done prune_from_the_left
207  setring Rbase;
208  module ext = oppose(Rop,ext_op);
209  kill Rop;
210  return(ext);
211}
212example
213{ "EXAMPLE:"; echo = 2;
214  ring R     = 0,(x,y),dp;
215  ideal I    = x2-y3;
216  qring S    = std(I);
217  module M   = [-x,y],[-y2,x];
218  module E1  = ncExt(1,M,M);
219  E1;
220}
221
222proc ncExt_R(int i, matrix Ps)
223"USAGE:   ncExt_R(i, M);  i int, M module
224COMPUTE:  a presentation of Ext^i(M',R); for M'=coker(M).
225RETURN:   right module Ext, a presentation of Ext^i(M',R)
226EXAMPLE: example ncExt_R; shows an example
227"{
228  if (i==0)
229  {
230    return(ncHom_R(Ps)); // the rest is not needed
231  }
232  list Phi   = nres(Ps,i+1); // left resolution
233  module f   = transpose(matrix(Phi[i+1])); // transp. because of Hom_R
234  module Im2 = transpose(matrix(Phi[i]));
235  def Rbase = basering;
236  def Rop   = opposite(Rbase);
237  setring Rop;
238  module fop    = oppose(Rbase,f);
239  module Im2op  = oppose(Rbase,Im2);
240  module ker_op = modulo(fop,std(0));
241  module ext_op = modulo(ker_op,Im2op);
242  //  ext        = prune(ext);
243  // to be discussed and done prune_from_the_left
244  // necessary: compute SB!
245  // "Computing SB of Ext";
246//   option(redSB);
247//   option(redTail);
248//   ext_op = std(ext_op);
249//   int dimop = GKdim(ext_op);
250//   printf("Ext has dimension %s",dimop);
251//   if (dimop==0)
252//   {
253//       printf("of K-dimension %s",vdim(ext_op));
254//   }
255  setring Rbase;
256  module ext = oppose(Rop,ext_op); // a right module!
257  kill Rop;
258  return(ext);
259}
260example
261{ "EXAMPLE:"; echo = 2;
262  ring R     = 0,(x,y),dp;
263  poly F    = x2-y2;
264  def A = annfs(F);
265  setring A;
266  matrix M[1][size(LD)] = LD;
267  print(ncExt_R(1,M)); // hence the Ext^1 is zero
268  module E  = ncExt_R(2,M); // right module
269  print(E);
270  def Aop = opposite(A);
271  setring Aop;
272  module Eop = oppose(A,E);
273  module T1  = ncExt_R(2,Eop);
274  setring A;
275  module T1 = oppose(Aop,T1);
276  print(T1); // this is a left module Ext^2(Ext^2(M,A),A)
277}
278
279proc nctors(matrix M)
280{
281  // ext^1_A(adj(M),A)
282  def save = basering;
283  matrix MM = M;  // left
284  def sop = opposite(save);
285  setring sop;
286  matrix MM  = oppose(save,MM); // right
287  MM = transpose(MM); // transposed
288  list Phi = nres(MM,2); // i=1
289  module f   = transpose(matrix(Phi[2])); // transp. because of Hom_R
290  module Im2 = transpose(matrix(Phi[1]));
291  setring save;
292  module fop    = oppose(sop,f);
293  module Im2op  = oppose(sop,Im2);
294  module ker_op = modulo(fop,std(0));
295  module ext_op = modulo(ker_op,Im2op);
296  //  matrix E = ncExt_R(1,MM);
297  //  setring save;
298  //  matrix E = oppose(sop,E);
299  return(ext_op);
300}
301
302proc altExt_R(int i, matrix Ps, map Invo)
303  // TODO!!!!!!!!
304  // matrix Ph
305  // work thru Involutions;
306{
307  if(i==0)
308  { // return the formal adjoint
309    matrix Ret   = transpose(Ps);
310    matrix Retop = involution(Ret, Invo);
311    //    "Computing prune of Hom";
312    //    Retop = prune(Retop);
313    //    Retop = std(Retop);
314    return(Retop);
315  }
316  list Phi   = mres(Ps,i+1);
317  //  module Im  = coHom(Ph,ncols(Phi[i+1]));
318  module f   = transpose(matrix(Phi[i+1]));
319  f = involution(f, Invo);
320  //= contraHom(matrix(Phi[i+1]),nrows(Ph));
321  //  module Im1 = coHom(Ph,ncols(Phi[i]));
322  module Im2 = transpose(matrix(Phi[i]));
323  Im2 = involution(Im2, Invo);
324  //contraHom(matrix(Phi[i]),nrows(Ph));
325  module ker_op = modulo(f,std(0));
326  module ext_op = modulo(ker_op,Im2);
327  //  ext        = prune(ext);
328 // to be discussed and done prune_from_the_left
329  // optionally: compute SB!
330  //  "Computing prune of Ext";
331  ext_op = std(ext_op);
332  int dimop = GKdim(ext_op);
333  printf("Ext has dimension %s",dimop);
334  if (dimop==0)
335  {
336      printf("of K-dimension %s",vdim(ext_op));
337  }
338  module ext = involution(ext_op, Invo); // what about transpose?
339  return(ext);
340}
341example
342{ "EXAMPLE:"; echo = 2;
343  ring R     = 0,(x,y),dp;
344  ideal I    = x2-y3;
345  qring S    = std(I);
346  module M   = [-x,y],[-y2,x];
347  module E1  = ncExt(2,M,M);
348  E1;
349}
350
351proc tensorMaps(matrix M, matrix N)
352{
353   int r = ncols(M);
354   int s = nrows(M);
355   int p = ncols(N);
356   int q = nrows(N);
357   int a,b,c,d;
358   matrix R[s*q][r*p];
359   for(b=1;b<=p;b++)
360   {
361      for(d=1;d<=q;d++)
362      {
363         for(a=1;a<=r;a++)
364         {
365            for(c=1;c<=s;c++)
366            {
367               R[(c-1)*q+d,(a-1)*p+b]=M[c,a]*N[d,b];
368            }
369         }
370      }
371   }
372   return(R);
373}
374
375proc ncTensorMod(matrix Phi, matrix Psi)
376{
377   int s=nrows(Phi);
378   int q=nrows(Psi);
379   matrix A=tensorMaps(unitmat(s),Psi);  //I_s tensor Psi
380   matrix B=tensorMaps(Phi,unitmat(q));  //Phi tensor I_q
381   matrix R=concat(A,B);                 //sum of A and B
382   return(R);
383}
384
385
386proc ncTor(int i, matrix Ps, matrix Ph)
387{
388  if(i==0) { return(module(ncTensorMod(Ps,Ph))); }
389                               // the tensor product
390  list Phi   = mres(Ph,i+1);     // a resolution of Ph
391  module Im  = tensorMaps(unitmat(nrows(Phi[i])),Ps);
392  module f   = tensorMaps(matrix(Phi[i]),unitmat(nrows(Ps)));
393  module Im1 = tensorMaps(unitmat(ncols(Phi[i])),Ps);
394  module Im2 = tensorMaps(matrix(Phi[i+1]),unitmat(nrows(Ps)));
395  module ker = modulo(f,Im);
396  module tor = modulo(ker,Im1+Im2);
397  //  tor        = prune(tor);
398  return(tor);
399}
400
401
402static proc Hochschild()
403{
404  ring A    = 0,(x,y),dp;
405  ideal I   = x2-y3;
406  qring B   = std(I);
407  module M  = [-x,y],[-y2,x];
408  ring C    = 0,(x,y,z,w),dp; // x->z, y->w
409  ideal I   = x2-y3,z3-w2;
410  qring Be  = std(I);   //the enveloping algebra
411  matrix AA[1][2]  = x-z,y-w;  //the presentation of the algebra B as Be-module
412  module MM = imap(B,M);
413  module E = ncExt(1,AA,MM);
414  print(E);  //the presentation of the H^1(A,M)
415
416ring A          = 0,(x,y),dp;
417ideal I         = x2-y3;
418qring B         = std(I);
419ring C          = 0,(x,y,z,w),dp;
420ideal I         = x2-y3,z3-w2;
421qring Be        = std(I);   //the enveloping algebra
422matrix AA[1][2] = x-z,y-w;  //the presentation of B as Be-module
423matrix AAA[1][2] = z,w; // equivalent? pres. of B
424print(ncExt(1,AA,AA));  //the presentation of the H^1(A,A)
425print(ncExt(1,AAA,AAA));
426}
427
428static proc Lie()
429{
430// consider U(sl2)* U(sl2)^opp;
431LIB "ncalg.lib";
432ring A = 0,(e,f,h,H,F,E),Dp; // any degree ordering
433int N = 6; // nvars(A);
434matrix @D[N][N];
435@D[1,2] = -h;
436@D[1,3] = 2*e;
437@D[2,3] = -2*f;
438@D[4,5] = 2*F;
439@D[4,6] = -2*E;
440@D[5,6] = H;
441 def AA = nc_algebra(1,@D); setring AA;
442ideal Q = E,F,H;
443poly Z = 4*e*f+h^2-2*h; // center
444poly Zo = 4*F*E+H^2+2*H;  // center opposed
445ideal Qe = Z,Zo;
446//qring B = twostd(Qe);
447//ideal T = e-E,f-F,h-H;
448//ideal T2 = e-H,f-F,h-E;
449//Q = twostd(Q); // U is U(sl2) as left U(sl2)* U(sl2)^opp -- module
450matrix M[1][3] = E,F,H;
451module X0 = ncExt(0,M,M);
452print(X0);
453
454module X1 = ncExt(1,M,M);
455print(X1);
456module X2 = ncExt(2,M,M); // equal to Tor^Z_1(K,K)
457print(X2);
458
459// compute  Tor^Z_1(K,K)
460ring r = 0,(z),dp;
461ideal i = z;
462matrix I[1][1]=z;
463Tor(1,I,I);
464}
465
466
467proc AllExts(module N, list #)
468  // computes and shows everything
469  // assumes we are in the opposite
470  // and N is dual of some M
471  // if # is given, map Invo and Ext_Invo are used
472{
473  int UseInvo = 0;
474  int sl = size(#);
475  if (sl >0)
476  {
477    ideal I = ideal(#[1]);
478    map Invo = basering, I;
479    UseInvo  = 1;
480    "Using the involution";
481  }
482  int nv = nvars(basering);
483  int i,d;
484  module E;
485  list EE;
486  print("--- module:"); print(matrix(N));
487  for (i=1; i<=nv; i++)
488  {
489    if (UseInvo)
490    {
491      E = altExt_R(i,N,Invo);
492    }
493    else
494    {
495      E = ncExt_R(i,N);
496    }
497    printf("--- Ext %s",i);
498    print(matrix(E));
499    EE[i] = E;
500  }
501  return(E);
502}
503
504static proc dmod_exts(module M)
505{
506  // return all Ext_R for a D-module M
507}
508
509proc dmodualtest(module M, int n)
510{
511  // computes the "dual" of the "dual" of a d-mod M
512  // where n is the half-number of vars of Weyl algebra
513  // assumed to be basering
514  // returns the difference between M and Ext^n_D(Ext^n_D(M,D),D)
515  def save = basering;
516  setring save;
517  module Md = ncExt_R(n,M); // right module
518  // would be nice to use "prune"!
519  // NO! prune performs left sided operations!!!
520  //  Md = prune(Md);
521  //  print(Md);
522  def saveop = opposite(save);
523  setring saveop;
524  module Mdop = oppose(save,Md); // left module
525  // here we're eligible to use prune
526  Mdop = prune(Mdop);
527  module Mopd = ncExt_R(n,Mdop); // right module
528  setring save;
529  module M2 = oppose(saveop,Mopd);  // left module
530  M2 = prune(M2); // eligible since M2 is a left mod
531  M2 = groebner(M2);
532  ideal tst = M2 - M;
533  tst = groebner(tst);
534  return(tst);
535}
536example
537{ "EXAMPLE:"; echo = 2;
538  ring R   = 0,(x,y),dp;
539  poly F   = x3-y2;
540  def A    = annfs(F);
541  setring A;
542  dmodualtest(LD,2);
543}
544
545
546proc dmodoublext(module M, list #)
547"USAGE:   dmodoublext(M [,i]);  M module, i optional int
548COMPUTE:  a presentation of Ext^i(Ext^i(M,D),D); for basering D
549RETURN:   left module
550NOTE: by default, i is set to the integer part of the half of number of variables of D
551@* for holonomic modules over Weyl algebra, the double ext is known to be holonomic
552EXAMPLE: example dmodoublext; shows an example
553"
554{
555  // assume: basering is a Weyl algebra?
556  def save = basering;
557  setring save;
558  // if a list is nonempty and contains an integer N, n = N; otherwise n = nvars/2
559  int n;
560  if (size(#) > 0)
561  {
562    //    if (typeof(#) == "int")
563    //    {
564      n = int(#[1]);
565      //    }
566//     else
567//     {
568//       ERROR("the optional argument expected to have type int");
569//     }
570  }
571  else
572  {
573    n = nvars(save); n = n div 2;
574  }
575  // returns Ext^i_D(Ext^i_D(M,D),D), that is
576  // computes the "dual" of the "dual" of a d-mod M (for n = nvars/2)
577  module Md = ncExt_R(n,M); // right module
578  // no prune yet!
579  def saveop = opposite(save);
580  setring saveop;
581  module Mdop = oppose(save,Md); // left module
582  // here we're eligible to use prune
583  Mdop = prune(Mdop);
584  module Mopd = ncExt_R(n,Mdop); // right module
585  setring save;
586  module M2 = oppose(saveop,Mopd);  // left module
587  kill saveop;
588  M2 = prune(M2); // eligible since M2 is a left mod
589  def M3;
590  if (nrows(M2)==1)
591  {
592    M3 = ideal(M2);
593  }
594  else
595  {
596    M3 = M2;
597  }
598  M3 = groebner(M3);
599  return(M3);
600}
601example
602{ "EXAMPLE:"; echo = 2;
603  ring R   = 0,(x,y),dp;
604  poly F   = x3-y2;
605  def A    = annfs(F);
606  setring A;
607  dmodoublext(LD);
608  LD;
609  // fancier example:
610  setring A;
611  ideal I = Dx*(x2-y3),Dy*(x2-y3);
612  I = groebner(I);
613  print(dmodoublext(I,1));
614  print(dmodoublext(I,2));
615}
616
617static proc part_Ext_R(matrix M)
618{
619  // if i==0
620    matrix Ret = transpose(Ps);
621    def Rbase = basering;
622    def Rop   = opposite(Rbase);
623    setring Rop;
624    module Retop = oppose(Rbase,Ret);
625    module Hm = modulo(Retop,std(0)); // right kernel of transposed
626    //    "Computing prune of Hom";
627    //    Retop = prune(Retop);
628    //    Retop = std(Retop);
629    setring Rbase;
630    Ret = oppose(Rop, Hm);
631    kill Rop;
632    return(Ret);
633// some checkz:
634//  setring Rbase;
635  // ker_op is the right Kernel of f^t:
636  //  module ker = oppose(Rop,ker_op);
637  //  print(f*ker);
638//  module ext = oppose(Rop,ext_op);
639}
Note: See TracBrowser for help on using the repository browser.