source: git/Singular/LIB/ncalg.lib @ a09c2a0

spielwiese
Last change on this file since a09c2a0 was 91c978, checked in by Viktor Levandovskyy <levandov@…>, 19 years ago
*levandov: makeup things for the documentation together with minor fixes in code and English git-svn-id: file:///usr/local/Singular/svn/trunk@7758 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 14.9 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: ncalg.lib,v 1.11 2005-02-23 18:10:46 levandov Exp $";
3category="Noncommutative";
4info="
5LIBRARY:  ncalg.lib      Definitions of important GR-algebras
6AUTHORS:  Viktor Levandovskyy,     levandov@mathematik.uni-kl.de,
7          Oleksandr Motsak,        motsak@mathematik.uni-kl.de.
8
9PROCEDURES:
10sl(n[,p]);   returns U(sl_n) in char p, if an integer p is given,
11sl2([p]);    returns U(sl_2) in the (e,f,h) presentation; in char p, if an integer p is given,
12g2([p]);     returns U(g_2) in the (x(i),y(i),Ha,Hb) presentation; in char p, if an integer p is given,
13gl(n,[p]);    returns U(gl_n) in the (e_ij (1<i,j<n)) presentation; in char p, if an integer p is given,
14Qso3([n]);   returns U_q(so_3) in the presentation of Klimyk, if integer n is given, the quantum parameter will be specialized at the (2n)-th root of unity,
15Qso3Casimir(n [,m]); returns a list with the (optionally normalized) Casimir elements of U_q(so_3) for the quantum parameter specialized at the n-th root of unity,
16Qsl2([n]); returns ring, corresponding to the V_q(sl_2) and the ideal Qideal in it, such that U_q(sl_2) = V_q(sl_2) / Qideal; if n is specified, the quantum parameter q will be specialized at the n-th root of unity
17Qsl3([n]); returns ring, corresponding to the V_q(sl_3) and the ideal Qideal in it, such that U_q(sl_3) = V_q(sl_3) / Qideal; if n is specified, the quantum parameter q will be specialized at the n-th root of unity
18GKZsystem(A, sord, alg [,v]);  returns a ring and an ideal, describing
19Gelfand-Kapranov-Zelevinsky system of differential equations
20";
21
22LIB "nctools.lib";
23LIB "general.lib";
24LIB "toric.lib"; // needed for GKZsystem
25
26///////////////////////////////////////////////////////////////////////////////
27static proc defInt ( list # )
28// return 0 or int(#)
29{
30  int @p = 0;
31  if ( size(#) > 0 )
32  {
33    if ( typeof( #[1] ) == "int" )
34    {
35      @p = #[1];
36    };
37  };
38  return (@p);
39};
40
41///////////////////////////////////////////////////////////////////////////////
42proc sl2(list #)
43"USAGE:   sl2([p]), p an optional integer (field characteristic)
44PURPOSE: set up the U(sl_2) in the (e,f,h) presentation over the field of char p
45RETURN:  ring
46NOTE:    you have to activate this ring with the 'setring' command
47SEE ALSO: sl, g2, gl
48EXAMPLE: example sl2; shows examples
49"{
50   int @p = defInt(#);
51   ring @@@rrr=@p,(e,f,h),dp;
52   matrix D[3][3]=0;
53   D[1,2]=-h;
54   D[1,3]=2*e;
55   D[2,3]=-2*f;
56   ncalgebra(1,D);
57   return(@@@rrr);
58}
59example
60{ "EXAMPLE:"; echo = 2;
61   def a=sl2();
62   setring a;
63   a;
64}
65
66///////////////////////////////////////////////////////////////////////////////
67proc sl(int n, list #)
68"USAGE:   sl(n,[p]); n an integer, n>1; p an optional integer (field characteristic)
69PURPOSE: set up the U(sl_n) in x(i),y(i),h(i) presentation over the field of char p
70RETURN:  ring, describing
71NOTE:    You have to activate this ring with the 'setring' command.
72@*       The presentation of U(sl_n) is derived from the standard presentation of sl_n,
73@*       where positive resp. negative roots are denoted by x(i) resp. y(i) and
74@*       Cartan elements are denoted by h(i).
75SEE ALSO: sl2, g2, gl, Qsl3, Qso3
76EXAMPLE: example sl; shows examples
77"{
78  if (n<2)
79  {
80    Print("Incorrect input");
81    return(0);
82  }
83  if (n==2)
84  {
85    def @@@a=sl2(#);
86    setring @@@a;
87    return(@@@a);
88  }
89 
90  int @p = defInt(#);
91  ring @@@rr=@p,(x(1..n*(n-1)/2),y(1..n*(n-1)/2),h(1..n-1)),dp;
92  intmat CNT[n][n]=0;
93  matrix TMP[n][n]=0;
94  int k,l=1,1;
95  int buf=0; 
96  list X,Y,H;
97  for(k=1; k<=n; k++)
98  {
99    for(l=k+1; l<=n; l++)
100    {
101      buf = (l-k-1)*(2*n-l+k)/2 + k;
102      CNT[k,l] = buf;
103      TMP[k,l] = 1;
104      X[buf] = TMP;
105      TMP = 0;
106      CNT[l,k] = buf;
107      TMP[l,k] = 1;
108      Y[buf] = TMP;
109      TMP=0;   
110    }
111  }
112  for(k=1; k<=n-1; k++)
113  {
114    TMP[k,k]=1;
115    TMP[k+1,k+1]=-1;
116    H[k]=TMP;
117    TMP=0;
118  } 
119  int i,j=1,1;
120  number p,q=0,0;
121  list V=X+Y+H;
122  int v=size(V);
123  matrix D[v][v]=0; 
124  for(k=1; k<=v; k++)
125  {
126    for(l=k+1; l<=v; l++)
127    {
128      TMP=V[l]*V[k]-V[k]*V[l];
129      for(i=1; i<=n; i++)
130      {
131        for(j=i+1; j<=n; j++)
132        {
133          buf=(j-i-1)*(2*n-j+i)/2+i;
134          if (TMP[i,j]!=0)
135          {
136            D[k,l]=D[k,l]+leadcoef(TMP[i,j])*x(buf);
137          }
138          if (TMP[j,i]!=0)
139          {         
140            D[k,l]=D[k,l]+leadcoef(TMP[j,i])*y(buf);
141          }
142        }
143      }
144      i=1;
145      while ( (TMP[i,i]==0) && (i<n) ) { i++; }
146      for(j=i; j<=n-1; j++)
147      {
148        p=leadcoef(TMP[j,j]);
149        q=leadcoef(TMP[j+1,j+1]);
150        D[k,l]=D[k,l]+p*h(j);
151        //        if ((j!=n-1)&&((p+q)!=0)) {D[k,l]=D[k,l]+(p+q)*h(j+1);}
152        TMP[j+1,j+1]=TMP[j+1,j+1]+p;
153      }
154    }
155  }
156  ncalgebra(1,D);
157  return(@@@rr);
158}
159example
160{ "EXAMPLE:"; echo = 2;
161   def a=sl(3);
162   setring a;
163   a;
164}
165
166///////////////////////////////////////////////////////////////////////////////
167proc g2(list #)
168"USAGE:  g2([p]), p an optional integer (field characteristic)
169PURPOSE: set up the U(g_2) in (x(i),y(i),Ha,Hb) presentation over the field of char p
170RETURN:  ring
171NOTE:    you have to activate this ring with the 'setring' command
172SEE ALSO: sl, gl
173EXAMPLE: example g2; shows examples
174"{
175  int @p = defInt(#);
176  ring @@@rrr=@p,(x(1..6),y(1..6),Ha,Hb),dp;
177  setring @@@rrr;
178  matrix D[14][14];
179  D[1,2]=-x(3);
180  D[1,3]=-2*x(4);
181  D[1,4]=3*x(5);
182  D[1,7]=-Ha;
183  D[1,9]=3*y(2);
184  D[1,10]=2*y(3);
185  D[1,11]=-y(4);
186  D[1,13]=2*x(1);
187  D[1,14]=-x(1);
188  D[2,5]=x(6);
189  D[2,8]=-Hb;
190  D[2,9]=-y(1);
191  D[2,12]=-y(5);
192  D[2,13]=-3*x(2);
193  D[2,14]=2*x(2);
194  D[3,4]=3*x(6);
195  D[3,7]=3*x(2);
196  D[3,8]=-x(1);
197  D[3,9]=-Ha-3*Hb;
198  D[3,10]=-2*y(1);
199  D[3,12]=-y(4);
200  D[3,13]=-x(3);
201  D[3,14]=x(3);
202  D[4,7]=2*x(3);
203  D[4,9]=-2*x(1);
204  D[4,10]=-2*Ha-3*Hb;
205  D[4,11]=y(1);
206  D[4,12]=y(3);
207  D[4,13]=x(4);
208  D[5,7]=-x(4);
209  D[5,10]=x(1);
210  D[5,11]=-Ha-Hb;
211  D[5,12]=y(2);
212  D[5,13]=3*x(5);
213  D[5,14]=-x(5);
214  D[6,8]=-x(5);
215  D[6,9]=-x(4);
216  D[6,10]=x(3);
217  D[6,11]=x(2);
218  D[6,12]=-Ha-2*Hb;
219  D[6,14]=x(6);
220  D[7,8]=y(3);
221  D[7,9]=2*y(4);
222  D[7,10]=-3*y(5);
223  D[7,13]=-2*y(1);
224  D[7,14]=y(1);
225  D[8,11]=-y(6);
226  D[8,13]=3*y(2);
227  D[8,14]=-2*y(2);
228  D[9,10]=-3*y(6);
229  D[9,13]=y(3);
230  D[9,14]=-y(3);
231  D[10,13]=-y(4);
232  D[11,13]=-3*y(5);
233  D[11,14]=y(5);
234  D[12,14]=-y(6);
235  ncalgebra(1,D);
236  return(@@@rrr);
237}
238example
239{ "EXAMPLE:"; echo = 2;
240   def a = g2();
241   setring a;  a;
242}
243
244///////////////////////////////////////////////////////////////////////////////
245proc gl(int n, list #)
246"
247USAGE:   gl(n,[p]); n an integer, n>1;  p an optional integer (field characteristic)
248PURPOSE: set up the U(gl_n) in the (e_ij (1<i,j<n)) presentation over the field of char p
249RETURN:  ring
250NOTE:    You have to activate this ring with the 'setring' command.
251SEE ALSO: sl, g2
252EXAMPLE: example gl; shows examples
253"{
254  if (n<2)
255  {
256    print("Incorrect input");
257    return(0);
258  };
259  int @p = defInt(#);
260  int i, j;
261  string vs = "";
262  for ( i = 1; i<= n ; i++ )
263  {
264        for ( j = 1; j<= n ; j++ )
265        {
266            if ( vs != "" )
267            {
268                vs = vs + ", ";
269            };
270            vs = vs + "e_" + string(i) + "_" + string(j);   
271        }; 
272  };
273  string strRING = "ring RING_GL=(" + string (@p) + "), (" + vs + "),dp;";
274  execute( strRING );
275  int N = nvars( RING_GL ); // n*n
276  matrix D[N][N]=0;
277  int k, l;
278  int ik,il,jk,jl;
279  poly p ;
280  for( k=1; k<=N; k++)
281  {
282    ik = 1 + ((k-1)/n);
283    jk = k -  n*(ik-1);
284   
285    for( l=k+1; l<=N; l++)
286    {
287        il = 1 + ((l-1)/n);
288        jl = l -  n*(il-1);
289        p = 0;   
290        if( jl == ik )
291        {
292            p = p + var ( (il-1)*n + jk );
293        };
294        if( jk == il )
295        {
296            p = p - var ( (ik-1)*n + jl );
297        };
298        D[k,l]=p;
299    };
300  };
301  ncalgebra(1,D);
302  return(RING_GL);
303}
304example
305{ "EXAMPLE:"; echo = 2;
306   def a=gl(3);
307   setring a; a;
308};
309
310///////////////////////////////////////////////////////////////////////////////
311proc Qso3(list #)
312"USAGE:   Qso3([n]), n an optional integers
313PURPOSE: set up the U_q(so_3) in the presentation of Klimyk; if n is specified, the quantum parameter Q will be specialized at the (2*n)-th root of unity
314RETURN:  ring
315NOTE:    you have to activate this ring with the 'setring' command
316SEE ALSO: sl, g2, gl, Qsl2, Qsl3, Qso3Casimir
317EXAMPLE: example Qso3; shows examples
318"{
319  int @p = 2*defInt(#);
320  ring @@@r=(0,Q),(x,y,z),dp;
321  minpoly = RootOfUnity(@p);
322  matrix C[3][3];
323  C[1,2]=Q2;
324  C[1,3]=1/Q2;
325  C[2,3]=Q2;
326  matrix D[3][3];
327  D[1,2]=-Q*z;
328  D[1,3]=1/Q*y;
329  D[2,3]=-Q*x;
330  ncalgebra(C,D);
331  return(@@@r);
332}
333example
334{ "EXAMPLE:"; echo = 2;
335   def K = Qso3(3);
336   setring K;
337   K;
338}
339
340///////////////////////////////////////////////////////////////////////////////
341proc Qso3Casimir(int n, list #)
342"USAGE:   Qso3Casimir(n [,m]), n an integer, m an optional integer
343PURPOSE: compute the Casimir elements of U_q(so_3) for the quantum parameter specialized at the n-th root of unity; if m!=0 is given, polynomials will be normalized
344RETURN:  list (of polynomials)
345NOTE:    the result of the procedure makes sense only when the basering is U_q(so_3)
346SEE ALSO: Qso3
347EXAMPLE: example Qso3Casimir; shows examples
348"{
349  if ( npars(basering) !=1 )
350  {
351    "Error: wrong algebra. U_q(so3) has only one parameter";
352    return(0);
353  }
354  if (n<1) { return(0); }
355  number Q = par(1);
356  int N=(n-1)/2;
357  int NV=nvars(basering);
358  number k1,k2;
359  poly p,rs,hlp;
360  list cp;
361  int j;
362  p=var(1);
363  for(j=0; j<=N; j++)
364  {
365    k1 = binomial(n-j,j,0);
366    k1=k1/(n-j);
367    k1=k1*((-1)^j);
368    k2=((Q^2)/(Q^4-1))^(2*j);
369    k2=k2*k1;
370    hlp=k2*(p)^(n-(2*j));
371    rs=rs+hlp;
372    hlp=0; k2=0; k1=0;
373  }
374  if (size(#)>0)
375  {
376    int m = int(#[1]);
377    if (m!=0)
378    {
379       rs = cleardenom(rs);
380    }
381  }
382  cp[1] = rs;
383  for(j=2; j<=NV; j++)
384  {
385    cp[j] = subst(rs,var(1),var(j));
386  }
387  return(cp);
388}
389example
390{ "EXAMPLE:"; echo = 2;
391   def R = Qso3(5);
392   setring R;
393   list C = Qso3Casimir(5);
394   C;
395   list Cnorm = Qso3Casimir(5,1);
396   Cnorm;
397}
398
399///////////////////////////////////////////////////////////////////////////////
400proc Qsl2(list #)
401"USAGE:   Qsl2([n]), n an optional integer
402PURPOSE: set up the U_q(sl_2) = V_q(sl_2) / Qideal via the ring V_q(sl_2) and the ideal 'Qideal' in it;
403@*       if n is specified, the quantum parameter q will be specialized at the n-th root of unity
404RETURN:  ring (V_q(sl_2))
405NOTE:    you have to activate this ring with the 'setring' command.
406@*       In order to create the U_q(sl_2) from the output, you have to call the command like 'qring Usl2q = Qideal;'
407SEE ALSO: sl, Qsl3, Qso3
408EXAMPLE: example Qsl2; shows examples
409"
410{
411  ring r=(0,q),(E,F,Ke,Kf),dp;
412  int @p = defInt(#);
413  if (@p >1)
414  {
415    minpoly = RootOfUnity(@p);
416  }
417  matrix C = UpOneMatrix(4);;
418  matrix D[4][4];
419  C[1,3]=q^2;
420  C[2,3]=1/(q^2);
421  C[1,4]=1/(q^2);
422  C[2,4]=q^2;
423  D[1,2]=(1/(q-(1/q)))*(-Ke+Kf);
424  ncalgebra(C,D);
425  ideal Qideal = Ke*Kf-1;
426  Qideal = twostd(Qideal);
427  export Qideal;
428  return(r);
429}
430example
431{ "EXAMPLE:"; echo = 2;
432   def A = Qsl2(3);
433   setring A;
434   Qideal;
435   qring Usl2q = Qideal;
436   Usl2q;
437}       
438
439///////////////////////////////////////////////////////////////////////////////
440proc Qsl3(list #)
441"USAGE:   Qsl3([n]), n an optional integer
442PURPOSE: set up the U_q(sl_3) = V_q(sl_3) / Qideal via the ring V_q(sl_3) and the ideal 'Qideal' in it;
443@*       if n is specified, the quantum parameter q will be specialized at the n-th root of unity
444RETURN:  ring (V_q(sl_3))
445NOTE:    you have to activate this ring with the 'setring' command.
446@*       In order to create the U_q(sl_3) from the output, you have to call the command like 'qring Usl3q = Qideal;'
447SEE ALSO: sl, Qsl2, Qso3
448EXAMPLE: example Qsl3; shows examples
449"{
450  int @p = defInt(#);
451  ring @@@rrr=(0, q), (f12, f13, f23, k1, k2, l1, l2, e12, e13, e23), wp(2, 3, 2, 1, 1, 1, 1, 2, 3, 2);
452  if (@p >1)
453  {
454    minpoly = RootOfUnity(@p);
455  }
456  int @n = nvars(@@@rrr);
457  matrix C = UpOneMatrix(@n);
458  matrix D[@n][@n];
459  // some constants
460  number q1 =    1/q;
461  number Q  = (q )^2;
462  number Q1 = (q1)^2;
463  //   number QQ = Q - Q1; // q2 - 1/(q2)
464  number QQ1= 1 / (Q - Q1); 
465  // relations:
466  C[1,2] = Q1;
467  C[2,3] = C[1,2];
468  C[8,9] = C[1,2];
469  C[9,10]= C[1,2];
470  C[1,3] = Q;
471  C[8,10]= C[1,3];
472 
473  D[1,3] = -q*(f13);
474  D[8,10]= -q*(e13);
475  // V_q(sl_3)
476  D[1,8] = QQ1 * ( (k1) ^ 2 - (l1) ^ 2 );
477  D[3,10]= QQ1 * ( (k2) ^ 2 - (l2) ^ 2 );
478  D[2,9] = -QQ1 * ( ((k1)^2)*((k2)^2) - ((l1)^2)*((l2)^2) );
479  D[2, 8] =   q * (f23) * ((k1)^2);
480  D[3, 9] =   q * ((k2)^2) * (e12);
481  D[1, 9] = -q1 * ((l1)^2) * (e23);
482  D[2, 10]= -q1 * (f12) * ((l2)^2);
483  // k1
484  C[ 4, 8 ]= Q1;
485  C[ 4, 9 ]= q1;
486  C[ 4, 10]= q;
487  // l1
488  C[ 6, 8 ]= Q;
489  C[ 6, 9 ]= q;
490  C[ 6, 10]= q1;
491  // k2
492  C[ 5, 8 ]= q;
493  C[ 5, 9 ]= q1;
494  C[ 5, 10]= Q1;
495  // l2
496  C[ 7, 8 ]= q1;
497  C[ 7, 9 ]= q;
498  C[ 7, 10]= Q;
499  // k1
500  C[ 1, 4 ]= Q1;
501  C[ 2, 4 ]= q1;
502  C[ 3, 4 ]= q;
503  // l1
504  C[ 1, 6 ]= Q;
505  C[ 2, 6 ]= q;
506  C[ 3, 6 ]= q1;
507  // k2
508  C[ 1, 5 ]= q;
509  C[ 2, 5 ]= q1;
510  C[ 3, 5 ]= Q1;
511  // l2
512  C[ 1, 7 ]= q1;
513  C[ 2, 7 ]= q;
514  C[ 3, 7 ]= Q;
515  ncalgebra(C,D); // the V_q(sl3) is done
516  ideal Qideal = k1*l1-1,  k2*l2-1;
517  Qideal = twostd(Qideal);
518  export Qideal;
519  return(@@@rrr);
520}
521example
522{ "EXAMPLE:"; echo = 2;
523   def B = Qsl3(5);
524   setring B;
525   qring Usl3q = Qideal;
526   Usl3q;
527}
528
529proc GKZsystem(intmat A, string sord, string alg, list #)
530"USAGE:   GKZsystem(A, sord, alg, [,v]), where
531@*        A    is an intmat, defining the system,
532@*        sord is a string with desired term ordering,
533@*        alg  is a string, saying which algorithm to use (exactly like in toric_lib),
534@*        v    is an optional intvec.
535PURPOSE: compute the ring and the GKZ system of equations in it
536RETURN:  ring (moreover, the ideal GKZid with equations is exported in it)
537NOTE:    you have to activate the ring with the 'setring' command;
538the procedure is elaborated by Oleksandr Yena
539OVERVIEW: this procedure uses toric_lib and therefore inherits its input requirements:
540@*        possible values for input variable 'alg' are: \"ect\",\"pt\",\"blr\", \"hs\", \"du\".
541@*        As for the term ordering, it should be a string in Singular format like \"lp\",\"dp\", etc. @*        Please consult with the toric_lib for allowed orderings and more details.
542SEE ALSO: toric_lib
543EXAMPLE: example GKZsystem; shows examples
544"{
545  int d = nrows(A);
546  int n = ncols(A);
547  execute("ring r1=0,(d(1..n)),"+sord+";");
548  ideal I0;
549  if (size(#)==0)
550  {
551    I0 = toric_ideal(A, alg);
552  }
553  else
554  {
555    if ( typeof(#[1]) == "intvec" )
556    {
557      intvec V = intvec(#[1]);
558      I0 = toric_ideal(A, alg, V);
559    }
560    else
561    {
562      "Wrong type of the optional argument. Intvec expected.";
563      return();
564    }
565  };
566  execute("ring GR = (0,b(1..d)),(x(1..n),d(1..n)),"+sord+";");
567  Weyl();
568  int i,j;
569  poly p;
570  ideal I;
571  for (i=1; i<=d; i++)
572  {
573    p = -b(i);
574    for (j=1; j<=n; j++)
575    {
576      p = p+ A[i,j]*x(j)*d(j);
577    }
578  I = I, p;
579  }
580  I = I, imap(r1,I0);
581  I = simplify(I,2);
582  ideal GKZid = I;
583  export GKZid;
584  return(GR);
585}
586example
587{"EXAMPLE:"; echo = 2;
588  intmat A[2][4]=3,2,1,0,0,1,2,3;
589  print(A);
590  def D1 = GKZsystem(A,"lp","ect");
591  setring D1;
592  D1;
593  print(GKZid);
594  intvec v=1,1,1,1;
595  def D2 = GKZsystem(A,"lp","blr",v);
596  setring D2;
597  print(GKZid);
598}
599
600///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.