Changeset 5a8318 in git for Singular/LIB/freegb.lib


Ignore:
Timestamp:
Apr 6, 2011, 6:38:35 PM (13 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
830ef89e5dc0be692aac1a170b5523278b45caba
Parents:
57ec06794c88c0f906a9f4532c10eb7c02b302e4
Message:
*levandov: lpNF computes Normal Form with shift invariant presentation plus some docfixes

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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/freegb.lib

    r57ec06 r5a8318  
    33category="Noncommutative";
    44info="
    5 LIBRARY: freegb.lib   Compute two-sided Groebner bases in free algebras via letterplace
    6 AUTHOR: Viktor Levandovskyy,     levandov@math.rwth-aachen.de
    7 
    8 OVERVIEW: For the theory, see chapter 'Letterplace' in the @sc{Singular} Manual.
     5LIBRARY: freegb.lib   Compute two-sided Groebner bases in free algebras via
     6@*                    letterplace
     7AUTHORS: Viktor Levandovskyy,     viktor.levandovskyy@math.rwth-aachen.de
     8@*       Grischa Studzinski,      grischa.studzinski@math.rwth-aachen.de
     9
     10OVERVIEW: For the theory, see chapter 'Letterplace' in the @sc{Singular} Manual
    911
    1012PROCEDURES:
    11 makeLetterplaceRing(d);    creates a ring with d blocks of shifted original variables
    12 letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I up to a degree bound
    13 freeGBasis(L, n);  computes two-sided Groebner basis of an ideal, encoded via list L, up to degree n
    14 setLetterplaceAttributes(R,d,b);  supplies ring R with the letterplace structure
    15 
    16 
    17 lpMult(f,g);        letterplace multiplication of letterplace polynomials
    18 shiftPoly(p,i);    compute the i-th shift of letterplace polynomial p
    19 lpPower(f,n);     natural power of a letterplace polynomial
     13makeLetterplaceRing(d);    creates a ring with d blocks of shifted original
     14@*                         variables
     15letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I
     16@*                 up to a degree bound
     17lpNF(f,I);      normal form of f with respect to ideal I
     18freeGBasis(L, n);  computes two-sided Groebner basis of an ideal, encoded via
     19@*                 list L, up to degree n
     20setLetterplaceAttributes(R,d,b); supplies ring R with the letterplace structure
     21
     22
     23lpMult(f,g);    letterplace multiplication of letterplace polynomials
     24shiftPoly(p,i); compute the i-th shift of letterplace polynomial p
     25lpPower(f,n);   natural power of a letterplace polynomial
    2026lp2lstr(K, s);      convert letter-place ideal to a list of modules
    21 lst2str(L[, n]);     convert a list (of modules) into polynomials in free algebra
     27lst2str(L[, n]);   convert a list (of modules) into polynomials in free algebra
    2228mod2str(M[, n]); convert a module into a polynomial in free algebra
    2329vct2str(M[, n]);   convert a vector into a word in free algebra
    24 lieBracket(a,b[, N]);    compute Lie bracket ab-ba of two letterplace polynomials
    25 serreRelations(A,z);   compute the homogeneous part of Serre's relations associated to a generalized Cartan matrix A
    26 fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations associated to a generalized Cartan matrix A
     30lieBracket(a,b[, N]);  compute Lie bracket ab-ba of two letterplace polynomials
     31serreRelations(A,z);   compute the homogeneous part of Serre's relations
     32@*                     associated to a generalized Cartan matrix A
     33fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations
     34@*                             associated to a generalized Cartan matrix A
    2735isVar(p);                   check whether p is a power of a single variable
    2836ademRelations(i,j);    compute the ideal of Adem relations for i<2j in char 0
     
    467475"USAGE: letplaceGBasis(I);  I an ideal
    468476RETURN: ideal
    469 ASSUME: basering is a Letterplace ring, an ideal consists of Letterplace polynomials
    470 PURPOSE: compute the two-sided Groebner basis of an ideal I via Letterplace algorithm
    471 NOTE: the degree bound for this computation is read off the letterplace structure of basering
     477ASSUME: basering is a Letterplace ring, an ideal consists of Letterplace
     478@*      polynomials
     479PURPOSE: compute the two-sided Groebner basis of an ideal I via Letterplace
     480@*       algorithm
     481NOTE: the degree bound for this computation is read off the letterplace
     482@*    structure of basering
    472483EXAMPLE: example letplaceGBasis; shows examples
    473484"
     
    527538ASSUME: L has a special form. Namely, it is a list of modules, where
    528539
    529  - each generator of every module stands for a monomial times coefficient in free algebra,
    530 
    531  - in such a vector generator, the 1st entry is a nonzero coefficient from the ground field
     540 - each generator of every module stands for a monomial times coefficient in
     541@* free algebra,
     542
     543 - in such a vector generator, the 1st entry is a nonzero coefficient from the
     544@* ground field
    532545
    533546 - and each next entry hosts a variable from the basering.
    534547PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L
    535548@* in the free associative algebra, up to degree d
    536 NOTE: Apply @code{lst2str} to the output in order to obtain a better readable presentation
     549NOTE: Apply @code{lst2str} to the output in order to obtain a better readable
     550@*    presentation
    537551EXAMPLE: example freeGBasis; shows examples
    538552"
     
    954968RETURN:  ring
    955969PURPOSE: creates a ring with the ordering, used in letterplace computations
    956 NOTE: if h is given and nonzero, the pure homogeneous letterplace block ordering will be used.
     970NOTE: if h is given and nonzero, the pure homogeneous letterplace block
     971@*    ordering will be used.
    957972EXAMPLE: example makeLetterplaceRing; shows examples
    958973"
     
    23562371RETURN:  poly
    23572372ASSUME: basering has a letterplace ring structure
    2358 PURPOSE: compute the Lie bracket [a,b] = ab - ba between letterplace polynomials
    2359 NOTE: if N>1 is specified, then the left normed bracket [a,[...[a,b]]]] is computed.
     2373PURPOSE:compute the Lie bracket [a,b] = ab - ba between letterplace polynomials
     2374NOTE: if N>1 is specified, then the left normed bracket [a,[...[a,b]]]] is
     2375@*    computed.
    23602376EXAMPLE: example lieBracket; shows examples
    23612377"
     
    25472563"USAGE:  fullSerreRelations(A,N,C,P,d); A an intmat, N,C,P ideals, d an int
    25482564RETURN:  ring (and ideal)
    2549 PURPOSE: compute the inhomogeneous Serre's relations associated to A in given variable names
    2550 ASSUME: three ideals in the input are of the same sizes and contain merely variables
    2551 @* which are interpreted as follows: N resp. P stand for negative resp. positive roots,
    2552 @* C stand for Cartan elements. d is the degree bound for letterplace ring, which will be returned.
     2565PURPOSE: compute the inhomogeneous Serre's relations associated to A in given
     2566@*       variable names
     2567ASSUME: three ideals in the input are of the same sizes and contain merely
     2568@* variables which are interpreted as follows: N resp. P stand for negative
     2569@* resp. positive roots, C stand for Cartan elements. d is the degree bound for
     2570@* letterplace ring, which will be returned.
    25532571@* The matrix A is a generalized Cartan matrix with integer entries
    25542572@* The result is the ideal called 'fsRel' in the returned ring.
     
    31453163}
    31463164
     3165// new: lp normal from by using shift-invariant data by Grischa Studzinski
     3166
     3167/////////////////////////////////////////////////////////
     3168//   ASSUMPTIONS: every polynomial is an element of V',
     3169//@* else there wouldn't be an dvec representation
     3170
     3171//Mainprocedure for the user
     3172
     3173proc lpNF(poly p, ideal G)
     3174"USAGE: lpNF(p,G); f letterplace polynomial, ideal I
     3175RETURN: poly
     3176PURPOSE: computation of the normalform of p with respect to G
     3177ASSUME: p is a Letterplace polynomial, G is a set Letterplace polynomials,
     3178being a Letterplace Groebner basis (no check for this will be done)
     3179NOTE: Strategy: take the smallest monomial wrt ordering for reduction
     3180@*     For homogenous ideals the shift does not matter
     3181@*     For non-homogenous ideals the first shift will be the smallest monomial
     3182EXAMPLE: example lpNF; shows examples
     3183"
     3184{if ((p==0) || (size(G) == 0)){return(p);}
     3185 checkAssumptions(p,G);
     3186 G = sort(G)[1];
     3187 list L = makeDVecI(G);
     3188 return(normalize(lpNormalForm1(p,G,L)));
     3189}
     3190example
     3191{
     3192  "EXAMPLE:"; echo = 2;
     3193ring r = 0,(x,y,z),dp;
     3194int d =5; // degree
     3195def R = makeLetterplaceRing(d);
     3196setring R;
     3197ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3), z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) + z(1)*z(2)*z(3) + x(1)*y(2)*z(3);
     3198ideal J = letplaceGBasis(I); // compute a Letterplace Groebner basis
     3199poly p = y(1)*x(2)*y(3)*z(4)*y(5) - y(1)*z(2)*z(3)*y(4) + z(1)*y(2)*z(3);
     3200poly q = z(1)*x(2)*z(3)*y(4)*z(5) - y(1)*z(2)*x(3)*y(4)*z(5);
     3201lpNF(p,J);
     3202lpNF(q,J);
     3203}
     3204
     3205//procedures to convert monomials into the DVec representation, all static
     3206////////////////////////////////////////////////////////
     3207
     3208
     3209static proc getExpVecs(ideal G)
     3210"USUAGE: getExpVecs(G);
     3211RETURN: list of intvecs
     3212PURPOSE: convert G into a list of intvecs, corresponding to the exponent vector
     3213@* of the leading monomials of G
     3214"
     3215{int i; list L;
     3216 for (i = 1; i <= size(G); i++) {L[i] = leadexp(G[i]); }
     3217 return(L);
     3218}
     3219
     3220
     3221static proc delSupZero(intvec I)
     3222"USUAGE:delSupZero(I);
     3223RETURN: intvec
     3224PURPOSE: Deletes superfluous zero blocks of an exponent vector
     3225ASSUME: Intvec is an exponent vector of a letterplace monomial contained in V'
     3226"
     3227{if (I==intvec(0)) {return(intvec(0));}
     3228 int j,k,l;
     3229 int n = attrib(basering,"lV"); int d = attrib(basering,"uptodeg");
     3230 intvec w; j = 1;
     3231 while (j <= d)
     3232 {w = I[1..n];
     3233  if (w<>intvec(0)){break;}
     3234   else {I = I[(n+1)..(n*d)]; d = d-1; j++;}
     3235 }
     3236 for (j = 1; j <= d; j++)
     3237  {l=(j-1)*n+1; k= j*n;
     3238   w = I[l..k];
     3239   if (w==intvec(0)){w = I[1..(l-1)]; return(w);}//if a zero block is found there are only zero blocks left,
     3240                                                 //otherwise there would be a hole in the monomial
     3241                                                 // shrink should take care that this will not happen
     3242  }
     3243 return(I);
     3244}
     3245
     3246
     3247static proc delSupZeroList(list L)
     3248"USUAGE:delSupZeroList(L); L a list, containing intvecs
     3249RETURN: list, containing intvecs
     3250PURPOSE: Deletes all superfluous zero blocks for a list of exponent vectors
     3251ASSUME: All intvecs are exponent vectors of letterplace monomials contained in V'
     3252"
     3253{int i;
     3254 for (i = size(L); 0 < i; i--){L[i] = delSupZero(L[i]);}
     3255 return(L);
     3256}
     3257
     3258
     3259static proc makeDVec(intvec V)
     3260"USUAGE:makeDVec(V);
     3261RETURN: intvec
     3262PURPOSE: Converts an modified exponent vector into an Dvec
     3263NOTE: Superfluos zero blocks must have been deleted befor using this procedure
     3264"
     3265{int i,j,k,r1,r2; intvec D;
     3266 int n = attrib(basering,"lV");
     3267 k = size(V)/n; r1 = 0; r2 = 0;
     3268 for (i=1; i<= k; i++)
     3269  {for (j=(1+((i-1)*n)); j <= (i*n); j++)
     3270   {if (V[j]>0){r2 = j - ((i-1)*n); j = (j mod n); break;}
     3271   }
     3272   D[size(D)+1] = r1+r2;
     3273   if (j == 0) {r1 = 0;} else{r1= n-j;}
     3274  }
     3275 D = D[2..size(D)];
     3276 return(D);
     3277}
     3278
     3279static proc makeDVecL(list L)
     3280"USUAGE:makeDVecL(L); L, a list containing intvecs
     3281RETURN: list, containing intvecs
     3282ASSUME:
     3283"
     3284{int i; list R;
     3285 for (i=1; i <= size(L); i++) {R[i] = makeDVec(L[i]);}
     3286 return(R);
     3287}
     3288
     3289static proc makeDVecI(ideal G)
     3290"USUAGE:makeDVecI(G);
     3291RETURN:list, containing intvecs
     3292PURPOSE:computing the DVec representation for lead(G)
     3293ASSUME:
     3294"
     3295{list L = delSupZeroList(getExpVecs(G));
     3296 return(makeDVecL(L));
     3297}
     3298
     3299
     3300//procedures, which are dealing with the DVec representation, all static
     3301
     3302static proc dShiftDiv(intvec V, intvec W)
     3303"USUAGE: dShiftDiv(V,W);
     3304RETURN: a list,containing integers, or -1, if no shift of W divides V
     3305PURPOSE: find all possible shifts s, such that s.W|V
     3306ASSUME: V,W are DVecs of monomials contained in V'
     3307"
     3308{if(size(V)<size(W)){return(list(-1));}
     3309
     3310 int i,j,r; intvec T; list R;
     3311 int n = attrib(basering,"lV");
     3312 int k = size(V) - size(W) + 1;
     3313 if (intvec(V[1..size(W)])-W == 0){R[1]=0;}
     3314 for (i =2; i <=k; i++)
     3315 {r = 0; kill T; intvec T;
     3316  for (j =1; j <= i; j++) {r = r + V[j];}
     3317  //if (i==1) {T[1] = r-(i-1)*n;} else
     3318  T[1] = r-(i-1)*n; if (size(W)>1) {T[2..size(W)] = V[(i+1)..(size(W)+i-1)];}
     3319  if (T-W == 0) {R[size(R)+1] = i-1;}
     3320 }
     3321 if (size(R)>0) {return(R);}
     3322 else {return(list(-1));}
     3323}
     3324
     3325
     3326
     3327//the actual normalform procedure, if a user want not to presort the ideal, just make it not static
     3328
     3329
     3330static proc lpNormalForm1(poly p, ideal G, list L)
     3331"USUAGE:lpNormalForm1(p,G);
     3332RETURN:poly
     3333PURPOSE:computation of the normalform of p w.r.t. G
     3334ASSUME: p is a Letterplace polynomial, G is a set of Letterplace polynomials
     3335NOTE: Taking the first possible reduction
     3336"
     3337{
     3338 if (deg(p) <1) {return(p);}
     3339 else
     3340  {
     3341  int i; int s;
     3342  intvec V = makeDVec(delSupZero(leadexp(p)));
     3343  for (i = 1; i <= size(L); i++)
     3344  {s = dShiftDiv(V, L[i])[1];
     3345   if (s <> -1)
     3346   {p = lpReduce(p,G[i],s);
     3347    p = lpNormalForm1(p,G,L);
     3348    break;
     3349   }
     3350  }
     3351  p = p[1] + lpNormalForm1(p-p[1],G,L);
     3352  return(p);
     3353 }
     3354}
     3355
     3356
     3357
     3358
     3359//secundary procedures, all static
     3360
     3361static proc getlpCoeffs(poly q, poly p)
     3362"
     3363"
     3364{list R; poly m; intvec cq,t,lv,rv,bla;
     3365 int n = attrib(basering,"lV"); int d = attrib(basering,"uptodeg");
     3366 int i;
     3367 m = p/q;
     3368 cq = leadexp(m);
     3369 for (i = 1; i<= d; i++)
     3370 {bla = cq[((i-1)*n+1)..(i*n)];
     3371  if (bla == 0) {lv = cq[1..i*n]; cq = cq[(i*n+1)..(d*n)]; break;}
     3372 }
     3373 
     3374 d = size(cq)/n;
     3375 for (i = 1; i<= d; i++)
     3376 {bla = cq[((i-1)*n+1)..(i*n)];
     3377  if (bla <> 0){rv = cq[((i-1)*n+1)..(d*n)]; break;}
     3378 }
     3379 return(list(monomial(lv),monomial(rv)));
     3380}
     3381
     3382static proc lpReduce(poly p, poly g, int s)
     3383"NOTE: shift can not exceed the degree bound, because s*g | p
     3384"
     3385{poly l,r,qt; int i;
     3386 g = shiftPoly(g,s);
     3387 list K = getlpCoeffs(lead(g),lead(p));
     3388 l = K[1]; r = K[2];
     3389 kill K;
     3390 for (i = 1; i <= size(g); i++)
     3391 {qt = qt + lpMult(lpMult(l,g[i]),r);
     3392 }
     3393 return((leadcoef(qt)*p - leadcoef(p)*qt));
     3394}
     3395
     3396
     3397static proc lpShrink(poly p)
     3398"
     3399"
     3400{int n;
     3401 if (typeof(attrib(basering,"isLetterplaceRing"))=="int")
     3402 {n = attrib(basering,"lV");
     3403  return(system("shrinktest",p,n));
     3404 }
     3405 else {ERROR("Basering is not a Letterplace ring!");}
     3406}
     3407
     3408static proc checkAssumptions(poly p, ideal G)
     3409"
     3410"
     3411{checkLPRing();
     3412 checkAssumptionPoly(p);
     3413 checkAssumptionIdeal(G);
     3414 return();
     3415}
     3416
     3417static proc checkLPRing();
     3418"
     3419"
     3420{if (typeof(attrib(basering,"isLetterplaceRing"))=="string") {ERROR("Basering is not a Letterplace ring!");}
     3421 return();
     3422}
     3423
     3424static proc checkAssumptionIdeal(ideal G)
     3425"PURPOSE:Check if all elements of ideal are elements of V'
     3426"
     3427{ideal L = lead(normalize(G));
     3428 int i;
     3429 for (i = 1; i <= ncols(G); i++) {if (!isContainedInVp(G[i])) {ERROR("Ideal containes elements not contained in V'");}}
     3430 return();
     3431}
     3432
     3433static proc checkAssumptionPoly(poly p)
     3434"PURPOSE:Check if p is an element of V'
     3435"
     3436{poly l = lead(normalize(p));
     3437 if (!isContainedInVp(l)) {ERROR("Polynomial is not contained in V'");}
     3438 return();
     3439}
     3440
     3441static proc isContainedInVp(poly p)
     3442"PURPOSE: Check monomial for holes in the places
     3443"
     3444{int r = 0; intvec w;
     3445 intvec l = leadexp(p);
     3446 int n = attrib(basering,"lV"); int d = attrib(basering,"uptodeg");
     3447 int i,j,c,c1;
     3448 while (1 <= d)
     3449 {w = l[1..n];
     3450  if (w<>intvec(0)){break;}
     3451   else {l = l[(n+1)..(n*d)]; d = d-1;}
     3452 }
     3453 
     3454 while (1 <= d)
     3455  {for (j = 1; j <= n; j++)
     3456   {if (l[j]<>0)
     3457    {if (c1<>0){return(0);}
     3458     if (c<>0){return(0);}
     3459     if (l[j]<>1){return(0);}
     3460     c=1;
     3461    }
     3462   }
     3463   if (c == 0){c1=1;if (1 < d){l = l[(n+1)..(n*d)]; d = d-1;} else {d = d -1;}}
     3464    else {c = 0; if (1 < d){l = l[(n+1)..(n*d)]; d = d-1;} else {d = d -1;}}
     3465  }
     3466 return(1);
     3467}
     3468
    31473469// under development for Roberto
    31483470static proc extractLinearPart(module M)
Note: See TracChangeset for help on using the changeset viewer.