Changeset fda6986 in git


Ignore:
Timestamp:
Mar 6, 2009, 9:54:45 PM (14 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
cad5075007d013d435407e43d47c2810e6f19bec
Parents:
dfb2c646c61802722d29569f2e01d9a2fe1af023
Message:
*levandov: freegb lib reworked, new functions, many things renamed


git-svn-id: file:///usr/local/Singular/svn/trunk@11522 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/freegb.lib

    rdfb2c6 rfda6986  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: freegb.lib,v 1.17 2009-02-24 12:11:25 Singular Exp $";
     2version="$Id: freegb.lib,v 1.18 2009-03-06 20:54:45 levandov Exp $";
    33category="Noncommutative";
    44info="
     
    99
    1010PROCEDURES:
    11 freegbRing(d);    creates a ring with d blocks of shifted original variables
    12 freegbasis(L, int n);   compute two-sided Groebner basis of ideal, encoded via L, up to degree n
     11makeLetterplaceRing(d);    creates a ring with d blocks of shifted original variables
     12freeGBasis(L, n);   compute two-sided Groebner basis of ideal, encoded via L, up to degree n
     13setLetterplaceAttributes(R,d,b);  supplies ring R with the letterplace structure
    1314
    1415AUXILIARY PROCEDURES:
     
    1920mod2str(M[, n]); convert a module into a polynomial in free algebra
    2021vct2str(M[, n]);   convert a vector into a word in free algebra
    21 Liebr(a,b[, N]);    compute Lie bracket ab-ba of two letterplace polynomials
    22 Serre(A,z);          compute the ideal of Serre's relations associated to a generalized Cartan matrix A
     22lieBracket(a,b[, N]);    compute Lie bracket ab-ba of two letterplace polynomials
     23serreRelations(A,z);          compute the ideal of Serre's relations associated to a generalized Cartan matrix A
    2324isVar(p);             check whether p is a power of a single variable
    2425adem(i,j);            compute the ideal of Adem relations for i<2j in char 0
     
    3940proc testfreegblib()
    4041{
    41   example freegbRing;
    42   example freegbasis;
     42  example makeLetterplaceRing;
     43  example freeGBasis;
     44  example setLetterplaceAttributes;
    4345    "AUXILIARY PROCEDURES: ";
     46  example shiftPoly;
    4447  example lpMult;
    4548  example lp2lstr;
     
    4750  example mod2str;
    4851  example vct2str;
    49   example Liebr;
    50   example Serre;
     52  example lieBracket;
     53  example serreRelations;
    5154  example isVar;
     55}
     56
     57
     58proc setLetterplaceAttributes(def R, int uptodeg, int lV)
     59"USAGE: setLetterplaceAttributes(R, d, b); R a ring, b,d integers
     60RETURN: ring with special attributes set
     61PURPOSE: sets attributes for a letterplace ring:
     62@*      'isLetterplaceRing' = true, 'uptodeg' = d, 'lV' = b, where
     63@*      'uptodeg' stands for the degree bound,
     64@*      'lV' for the number of variables in the block 0.
     65"
     66{
     67  if (uptodeg*lV != nvars(R))
     68  {
     69    ERROR("uptodeg and lV do not agree on the basering!");
     70  }
     71 
     72    // Set letterplace-specific attributes for the output ring!
     73  attrib(R, "uptodeg", uptodeg);
     74  attrib(R, "lV", lV); 
     75  attrib(R, "isLetterplaceRing", 1); 
     76  return (R);
     77}
     78example
     79{
     80  "EXAMPLE:"; echo = 2;
     81  ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp;
     82  def R = setLetterplaceAttributes(r, 4, 2); setring R;
     83  attrib(R,"isLetterplaceRing");
     84  lieBracket(x(1),y(1),2);
    5285}
    5386
     
    421454// 6. return the result
    422455
    423 proc freegbasis(list LM, int d)
    424 "USAGE:  freegbasis(L, d);  L a list of modules, d an integer
     456proc freeGBasis(list LM, int d)
     457"USAGE:  freeGBasis(L, d);  L a list of modules, d an integer
    425458RETURN:  ring
    426459PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in
    427460the free associative algebra, up to degree d
    428 EXAMPLE: example freegbasis; shows examples
     461EXAMPLE: example freeGBasis; shows examples
    429462"
    430463{
     
    671704  list L; L[1] = M; L[2] = N;
    672705  lst2str(L);
    673   def U = freegbasis(L,5);
     706  def U = freeGBasis(L,5);
    674707  lst2str(U);
    675708}
     
    840873}
    841874
    842 proc freegbRing(int d)
    843 "USAGE:  freegbRing(d); d an integer
     875//proc freegbRing(int d)
     876proc makeLetterplaceRing(int d)
     877"USAGE:  makeLetterplaceRing(d); d an integer
    844878RETURN:  ring
    845879PURPOSE: creates a ring with d blocks of shifted original variables
    846 EXAMPLE: example freegbRing; shows examples
     880EXAMPLE: example makeLetterplaceRing; shows examples
    847881"
    848882{
    849883  // d = up to degree, will be shifted to d+1
    850884  if (d<1) {"bad d"; return(0);}
     885
     886  int uptodeg = d; int lV = nvars(basering);
    851887
    852888  int ppl = printlevel-voice+2;
     
    907943  def @R = ring(L);
    908944  //  setring @R;
    909   return (@R);
     945  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     946  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     947  return (@@R);
    910948}
    911949example
     
    913951  "EXAMPLE:"; echo = 2;
    914952  ring r = 0,(x,y,z),(dp(1),dp(2));
    915   def A = freegbRing(2);
     953  def A = makeLetterplaceRing(2);
    916954  setring A;
    917955  A;
     956  attrib(A,"isLetterplaceRing");
     957  attrib(A,"uptodeg");  // degree bound
     958  attrib(A,"lV"); // number of variables in the main block
    918959}
    919960
     
    946987  ring r =0,(x,y,z),dp;
    947988  int d = 5;
    948   def R = freegbRing(d);
     989  def R = makeLetterplaceRing(d);
    949990  setring R;
    950991  poly p1 = x(1)*y(2)*z(3);
     
    10291070  M = [1,y,h],[-1,h,y]; // yh - hy
    10301071  L[3] = M;
    1031   def U = freegbasis(L,3);
     1072  def U = freeGBasis(L,3);
    10321073  lst2str(U);
    10331074  // strange answer CHECK
     
    13391380}
    13401381
     1382/* begin older procs and tests
     1383
    13411384static proc sgb(ideal I, int d)
    13421385{
     
    13471390  //int d =7;// degree
    13481391  int nv = nvars(save);
    1349   def R = freegbRing(d);
     1392  def R = makeLetterplaceRing(d);
    13501393  setring R;
    13511394  int i;
     
    13651408{
    13661409  ring r = 0,(x,y),Dp;
    1367   def A = freegbRing(4);
     1410  def A = makeLetterplaceRing(4);
    13681411  setring A;
    13691412  A;
     
    14161459  ring r = 0,(x,y),Dp;
    14171460  int d = 10; // degree
    1418   def R = freegbRing(d);
     1461  def R = makeLetterplaceRing(d);
    14191462  setring R;
    14201463  ideal I = x(1)*x(2) - y(1)*y(2);
     
    14301473  ring r = 0,(x,y),Dp;
    14311474  int d = 10; // degree
    1432   def R = freegbRing(d);
     1475  def R = makeLetterplaceRing(d);
    14331476  setring R;
    14341477  ideal I = x(1)*x(2) - x(1)*y(2);
     
    14441487  ring r = 0,(x,y,z),dp;
    14451488  int d =5; // degree
    1446   def R = freegbRing(d);
     1489  def R = makeLetterplaceRing(d);
    14471490  setring R;
    14481491  ideal I = x(1)*y(2), y(1)*x(2)+z(1)*z(2);
     
    14611504}
    14621505
     1506end older procs and tests */
     1507
    14631508proc adem(int i, int j)
    14641509"USAGE:  adem(i,j); i,j int
    1465 RETURN:  ring and exports ideal
     1510RETURN:  ring (and exports ideal)
    14661511ASSUME: there are at least i+j variables in the basering
    14671512PURPOSE: compute the ideal of Adem relations for i<2j in characteristic 0
     
    19672012}
    19682013
    1969 proc Liebr(poly a, poly b, list #)
    1970 "USAGE:  Liebr(a,b[,N]); a,b letterplace polynomials, N an optional integer
     2014proc lieBracket(poly a, poly b, list #)
     2015"USAGE:  lieBracket(a,b[,N]); a,b letterplace polynomials, N an optional integer
    19712016RETURN:  poly
    1972 ASSUME: basering has a letterplace ring structure, like the one returned by freegbRing
    1973 @*   Moreover, the variables 'uptodeg' (degree bound of the letterplace ring) and 'lV' (number of
    1974 blocks of variables of the letterplace ring ) must be defined
     2017ASSUME: basering has a letterplace ring structure
    19752018PURPOSE: compute the Lie bracket [a,b] = ab - ba between letterplace polynomials
    19762019NOTE: if N>1 is specified, then the left normed bracket [a,[...[a,b]]]] is computed.
    1977 EXAMPLE: example Liebr; shows examples
     2020EXAMPLE: example lieBracket; shows examples
    19782021"
    19792022{
    1980 
    19812023  if (lpAssumeViolation())
    19822024  {
    1983     ERROR("Either 'uptodeg' or 'lV' global variables are not set!");
     2025    //    ERROR("Either 'uptodeg' or 'lV' global variables are not set!");
     2026    ERROR("Incomplete Letterplace structure on the basering!");
    19842027  }
    19852028  // alias ppLiebr;
     
    20052048    for(i=1; i<=N; i++)
    20062049    {
    2007       q = Liebr(a,q);
     2050      q = lieBracket(a,q);
    20082051    }
    20092052  }
     
    20142057  "EXAMPLE:"; echo = 2;
    20152058  ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp;
     2059  def R = setLetterplaceAttributes(r,4,2); // supply R with letterplace structure
     2060  setring R;
    20162061  poly a = x(1)*y(2); poly b = y(1);
    2017   int uptodeg=4; int lV=2;
    2018   export uptodeg; export lV;
    2019   Liebr(a,b);
    2020   Liebr(x(1),y(1),2);
    2021   kill uptodeg, lV;
     2062  lieBracket(a,b);
     2063  lieBracket(x(1),y(1),2);
    20222064}
    20232065
     
    20342076}
    20352077
    2036 //proc pshift(poly a, int i, int uptodeg, int lV)
    2037 static proc pshift(poly a, int i)
     2078proc shiftPoly(poly a, int i)
     2079"USAGE:  shiftPoly(p,i); p letterplace poly, i int
     2080RETURN: poly
     2081ASSUME: basering has letterplace ring structure
     2082PURPOSE: compute the i-th shift of letterplace polynomial p
     2083EXAMPLE: example shiftPoly; shows examples
     2084"
    20382085{
    20392086  // shifts a monomial a by i
    20402087  // calls pLPshift(p,sh,uptodeg,lVblock);
     2088  if (lpAssumeViolation())
     2089  {
     2090    ERROR("Incomplete Letterplace structure on the basering!");
     2091  }
     2092  int uptodeg = attrib(basering,"uptodeg");
     2093  int lV = attrib(basering,"lV");
    20412094  if (deg(a) + i > uptodeg)
    20422095  {
     
    20452098  return(system("stest",a,i,uptodeg,lV));
    20462099}
     2100example
     2101{
     2102  "EXAMPLE:"; echo = 2;
     2103  ring r = 0,(x,y,z),dp;
     2104  int uptodeg = 5; int lV = 3;
     2105  def R = makeLetterplaceRing(uptodeg);
     2106  setring R;
     2107  poly f = x(1)*z(2)*y(3) - 2*z(1)*y(2) + 3*x(1);
     2108  shiftPoly(f,1);
     2109  shiftPoly(f,2);
     2110}
     2111
    20472112
    20482113static proc mmLiebr(poly a, poly b)
     
    20532118  int sa = deg(a);
    20542119  int sb = deg(b);
    2055   poly v = a*pshift(b,sa) - b*pshift(a,sb);
     2120  poly v = a*shiftPoly(b,sa) - b*shiftPoly(a,sb);
    20562121  return(v);
    20572122}
     
    20622127  ring r = 0,(a,b),dp;
    20632128  int d =5;
    2064   def R = freegbRing(d);
     2129  def R = makeLetterplaceRing(d);
    20652130  setring R;
    2066   int uptodeg = d; export uptodeg;
    2067   int lV = 2; export lV;
     2131  int uptodeg = d;
     2132  int lV = 2;
     2133  def R = setLetterplaceAttributes(r,uptodeg,2); // supply R with letterplace structure
     2134  setring R;
    20682135  poly p = mmLiebr(a(1),b(1));
    2069   poly p = Liebr(a(1),b(1));
    2070   kill uptodeg, lV;
    2071 }
    2072 
    2073 proc Serre(intmat A, int zu)
    2074 "USAGE:  Serre(A,z); A an intmat, z an int
     2136  poly p = lieBracket(a(1),b(1));
     2137}
     2138
     2139proc serreRelations(intmat A, int zu)
     2140"USAGE:  serreRelations(A,z); A an intmat, z an int
    20752141RETURN:  ideal
    20762142ASSUME: basering has a letterplace ring structure and
    2077 @*    A is a generalized Cartan matrix with integer entries
     2143@*          A is a generalized Cartan matrix with integer entries
    20782144PURPOSE: compute the ideal of Serre's relations associated to A
    2079 EXAMPLE: example Serre; shows examples
     2145EXAMPLE: example serreRelations; shows examples
    20802146"
    20812147{
     
    21002166      if ((i!=j) && (el >0))
    21012167      {
    2102         q = Liebr(var(j),var(i));
     2168        q = lieBracket(var(j),var(i));
    21032169        dbprint(ppl,"first bracket: ",q);
    21042170        //        if (l >=2)
     
    21062172          for (k=1; k<=el-1; k++)
    21072173          {
    2108             q = Liebr(var(j),q);
     2174            q = lieBracket(var(j),q);
    21092175            dbprint(ppl,"further bracket:",q);
    21102176          }
     
    21252191    0, -1, 2; // G^1_2 Cartan matrix
    21262192  ring r = 0,(f1,f2,f3),dp;
    2127   int uptodeg = 5; int lV = 3;
    2128   export uptodeg; export lV;
    2129   def R = freegbRing(uptodeg);
     2193  int uptodeg = 5;
     2194  def R = makeLetterplaceRing(uptodeg);
    21302195  setring R;
    2131   ideal I = Serre(A,1); I = simplify(I,1+2+8);
     2196  ideal I = serreRelations(A,1); I = simplify(I,1+2+8);
    21322197  I;
    2133   kill uptodeg, lV;
    21342198}
    21352199
     
    21422206proc lp2lstr(ideal K, def save)
    21432207"USAGE:  lp2lstr(K,s); K an ideal, s a ring
    2144 RETURN:  nothing (exports object LN into s)
     2208RETURN:  nothing (exports object @LN into s)
    21452209ASSUME: basering has a letterplace ring structure
    21462210PURPOSE: converts letterplace ideal to list of modules
     
    22422306  }
    22432307  setring save;
    2244   export LN;
     2308  list @LN = LN;
     2309  export @LN;
    22452310  //  return(LN);
    22462311}
     
    22502315  intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2
    22512316  ring r = 0,(f1,f2),dp;
    2252   int uptodeg = 3; int lV = 2;
    2253   export uptodeg; export lV;
    2254   def R = freegbRing(uptodeg);
     2317  def R = makeLetterplaceRing(3);
    22552318  setring R;
    2256   ideal I = Serre(A,1);
     2319  ideal I = serreRelations(A,1);
    22572320  lp2lstr(I,r);
    22582321  setring r;
    2259   lst2str(LN,1);
    2260   kill uptodeg; kill lV;
     2322  lst2str(@LN,1);
    22612323}
    22622324
     
    22922354  "EXAMPLE:"; echo = 2;
    22932355  ring r =0,(x,y,z,t),Dp;
    2294   def A = freegbRing(4);
     2356  def A = makeLetterplaceRing(4);
    22952357  setring A;
    22962358  string t = "-2*y*z*y*z + y*t*z*z - z*x*x*y  + 2*z*y*z*y";
     
    23522414  "EXAMPLE:"; echo = 2;
    23532415  ring r =0,(x,y,z,t),dp;
    2354   def A = freegbRing(4);
     2416  def A = makeLetterplaceRing(4);
    23552417  setring A;
    23562418  string fn = "myfile";
     
    23702432  ring r =0,(x,y,z,t),dp;
    23712433  int d = 10;
    2372   def A = freegbRing(d);
     2434  def A = makeLetterplaceRing(d);
    23732435  setring A;
    23742436  ideal I = file2lplace("./ls3nilp.bg");
     
    23762438  lp2lstr(I,r);
    23772439  setring r;
    2378   lst2str(LN,1); // agree!
     2440  lst2str(@LN,1); // agree!
    23792441}
    23802442
     
    23842446  ring r = 0,(x,y,z),dp;
    23852447  int d =4; // degree bound
    2386   def R = freegbRing(d);
     2448  def R = makeLetterplaceRing(d);
    23872449  setring R;
    23882450  ideal I = x(1)*y(2) + y(1)*z(2), x(1)*x(2) + x(1)*y(2) - y(1)*x(2) - y(1)*y(2);
     
    23912453  J;
    23922454  // visualization:
    2393   lp2lstr(J,r); // export an object called LN to the ring r
     2455  lp2lstr(J,r); // export an object called @LN to the ring r
    23942456  setring r;  // change to the ring r
    2395   lst2str(LN,1); // output the strings
     2457  lst2str(@LN,1); // output the strings
    23962458}
    23972459
     
    24052467"USAGE:  lpMult(f,g); f,g letterplace polynomials
    24062468RETURN:  poly
    2407 ASSUME: basering has a letterplace ring structure, like the one returned by freegbRing
    2408 @*   Moreover, the variables 'uptodeg' (degree bound of the letterplace ring) and 'lV' (number of
    2409 blocks of variables of the letterplace ring ) must be defined
     2469ASSUME: basering has a letterplace ring structure
    24102470PURPOSE: compute the letterplace form of f*g
    24112471EXAMPLE: example lpMult; shows examples
     
    24142474  if (lpAssumeViolation())
    24152475  {
    2416     ERROR("Either 'uptodeg' or 'lV' global variables are not set!");
     2476    ERROR("Incomplete Letterplace structure on the basering!");
    24172477  }
    24182478  int sf = deg(f);
    24192479  int sg = deg(g);
     2480  int uptodeg = attrib(basering, "uptodeg");
    24202481  if (sf+sg > uptodeg)
    24212482  {
     
    24232484  }
    24242485  //  if (sf>1) { sf = sf -1; }
    2425   poly v = f*pshift(g,sf);
     2486  poly v = f*shiftPoly(g,sf);
    24262487  return(v);
    24272488}
     
    24322493  ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp;
    24332494  poly a = x(1)*y(2); poly b = y(1);
    2434   int uptodeg=4; int lV=2;
    2435   export uptodeg; export lV;
     2495  def R = setLetterplaceAttributes(r,4,2); // supply R with letterplace structure
     2496  setring R;
    24362497  lpMult(b,a);
    24372498  lpMult(a,b);
    2438   kill uptodeg, lV;
    24392499}
    24402500
     
    24442504  // uptodeg and lV are defined
    24452505  // returns Boolean : yes/no [for assume violation]
    2446   int i = ( defined(uptodeg) && (defined(lV)) );
    2447   return ( !i );
    2448 }
     2506  def lpring = attrib(basering,"isLetterplaceRing");
     2507  if ( typeof(lpring)!="int" )
     2508  {
     2509    //  if ( typeof(lpring)=="string" ) ??
     2510    // basering is NOT lp Ring
     2511
     2512    return(1);
     2513  }
     2514  def uptodeg = attrib(basering,"uptodeg");
     2515  if ( typeof(uptodeg)!="int" )
     2516  {
     2517    return(1);
     2518  }
     2519  def lV = attrib(basering,"lV");
     2520  if ( typeof(lV)!="int" )
     2521  {
     2522    return(1);
     2523  }
     2524  //  int i = ( defined(uptodeg) && (defined(lV)) );
     2525  //  return ( !i );
     2526  return(0);
     2527}
Note: See TracChangeset for help on using the changeset viewer.