Changeset fda6986 in git
- Timestamp:
- Mar 6, 2009, 9:54:45 PM (14 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- cad5075007d013d435407e43d47c2810e6f19bec
- Parents:
- dfb2c646c61802722d29569f2e01d9a2fe1af023
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/freegb.lib
rdfb2c6 rfda6986 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: freegb.lib,v 1.1 7 2009-02-24 12:11:25 SingularExp $";2 version="$Id: freegb.lib,v 1.18 2009-03-06 20:54:45 levandov Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 9 9 10 10 PROCEDURES: 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 11 makeLetterplaceRing(d); creates a ring with d blocks of shifted original variables 12 freeGBasis(L, n); compute two-sided Groebner basis of ideal, encoded via L, up to degree n 13 setLetterplaceAttributes(R,d,b); supplies ring R with the letterplace structure 13 14 14 15 AUXILIARY PROCEDURES: … … 19 20 mod2str(M[, n]); convert a module into a polynomial in free algebra 20 21 vct2str(M[, n]); convert a vector into a word in free algebra 21 Liebr(a,b[, N]); compute Lie bracket ab-ba of two letterplace polynomials22 Serre(A,z); compute the ideal of Serre's relations associated to a generalized Cartan matrix A22 lieBracket(a,b[, N]); compute Lie bracket ab-ba of two letterplace polynomials 23 serreRelations(A,z); compute the ideal of Serre's relations associated to a generalized Cartan matrix A 23 24 isVar(p); check whether p is a power of a single variable 24 25 adem(i,j); compute the ideal of Adem relations for i<2j in char 0 … … 39 40 proc testfreegblib() 40 41 { 41 example freegbRing; 42 example freegbasis; 42 example makeLetterplaceRing; 43 example freeGBasis; 44 example setLetterplaceAttributes; 43 45 "AUXILIARY PROCEDURES: "; 46 example shiftPoly; 44 47 example lpMult; 45 48 example lp2lstr; … … 47 50 example mod2str; 48 51 example vct2str; 49 example Liebr;50 example Serre;52 example lieBracket; 53 example serreRelations; 51 54 example isVar; 55 } 56 57 58 proc setLetterplaceAttributes(def R, int uptodeg, int lV) 59 "USAGE: setLetterplaceAttributes(R, d, b); R a ring, b,d integers 60 RETURN: ring with special attributes set 61 PURPOSE: 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 } 78 example 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); 52 85 } 53 86 … … 421 454 // 6. return the result 422 455 423 proc free gbasis(list LM, int d)424 "USAGE: free gbasis(L, d); L a list of modules, d an integer456 proc freeGBasis(list LM, int d) 457 "USAGE: freeGBasis(L, d); L a list of modules, d an integer 425 458 RETURN: ring 426 459 PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in 427 460 the free associative algebra, up to degree d 428 EXAMPLE: example free gbasis; shows examples461 EXAMPLE: example freeGBasis; shows examples 429 462 " 430 463 { … … 671 704 list L; L[1] = M; L[2] = N; 672 705 lst2str(L); 673 def U = free gbasis(L,5);706 def U = freeGBasis(L,5); 674 707 lst2str(U); 675 708 } … … 840 873 } 841 874 842 proc freegbRing(int d) 843 "USAGE: freegbRing(d); d an integer 875 //proc freegbRing(int d) 876 proc makeLetterplaceRing(int d) 877 "USAGE: makeLetterplaceRing(d); d an integer 844 878 RETURN: ring 845 879 PURPOSE: creates a ring with d blocks of shifted original variables 846 EXAMPLE: example freegbRing; shows examples880 EXAMPLE: example makeLetterplaceRing; shows examples 847 881 " 848 882 { 849 883 // d = up to degree, will be shifted to d+1 850 884 if (d<1) {"bad d"; return(0);} 885 886 int uptodeg = d; int lV = nvars(basering); 851 887 852 888 int ppl = printlevel-voice+2; … … 907 943 def @R = ring(L); 908 944 // 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); 910 948 } 911 949 example … … 913 951 "EXAMPLE:"; echo = 2; 914 952 ring r = 0,(x,y,z),(dp(1),dp(2)); 915 def A = freegbRing(2);953 def A = makeLetterplaceRing(2); 916 954 setring A; 917 955 A; 956 attrib(A,"isLetterplaceRing"); 957 attrib(A,"uptodeg"); // degree bound 958 attrib(A,"lV"); // number of variables in the main block 918 959 } 919 960 … … 946 987 ring r =0,(x,y,z),dp; 947 988 int d = 5; 948 def R = freegbRing(d);989 def R = makeLetterplaceRing(d); 949 990 setring R; 950 991 poly p1 = x(1)*y(2)*z(3); … … 1029 1070 M = [1,y,h],[-1,h,y]; // yh - hy 1030 1071 L[3] = M; 1031 def U = free gbasis(L,3);1072 def U = freeGBasis(L,3); 1032 1073 lst2str(U); 1033 1074 // strange answer CHECK … … 1339 1380 } 1340 1381 1382 /* begin older procs and tests 1383 1341 1384 static proc sgb(ideal I, int d) 1342 1385 { … … 1347 1390 //int d =7;// degree 1348 1391 int nv = nvars(save); 1349 def R = freegbRing(d);1392 def R = makeLetterplaceRing(d); 1350 1393 setring R; 1351 1394 int i; … … 1365 1408 { 1366 1409 ring r = 0,(x,y),Dp; 1367 def A = freegbRing(4);1410 def A = makeLetterplaceRing(4); 1368 1411 setring A; 1369 1412 A; … … 1416 1459 ring r = 0,(x,y),Dp; 1417 1460 int d = 10; // degree 1418 def R = freegbRing(d);1461 def R = makeLetterplaceRing(d); 1419 1462 setring R; 1420 1463 ideal I = x(1)*x(2) - y(1)*y(2); … … 1430 1473 ring r = 0,(x,y),Dp; 1431 1474 int d = 10; // degree 1432 def R = freegbRing(d);1475 def R = makeLetterplaceRing(d); 1433 1476 setring R; 1434 1477 ideal I = x(1)*x(2) - x(1)*y(2); … … 1444 1487 ring r = 0,(x,y,z),dp; 1445 1488 int d =5; // degree 1446 def R = freegbRing(d);1489 def R = makeLetterplaceRing(d); 1447 1490 setring R; 1448 1491 ideal I = x(1)*y(2), y(1)*x(2)+z(1)*z(2); … … 1461 1504 } 1462 1505 1506 end older procs and tests */ 1507 1463 1508 proc adem(int i, int j) 1464 1509 "USAGE: adem(i,j); i,j int 1465 RETURN: ring and exports ideal1510 RETURN: ring (and exports ideal) 1466 1511 ASSUME: there are at least i+j variables in the basering 1467 1512 PURPOSE: compute the ideal of Adem relations for i<2j in characteristic 0 … … 1967 2012 } 1968 2013 1969 proc Liebr(poly a, poly b, list #)1970 "USAGE: Liebr(a,b[,N]); a,b letterplace polynomials, N an optional integer2014 proc lieBracket(poly a, poly b, list #) 2015 "USAGE: lieBracket(a,b[,N]); a,b letterplace polynomials, N an optional integer 1971 2016 RETURN: 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 2017 ASSUME: basering has a letterplace ring structure 1975 2018 PURPOSE: compute the Lie bracket [a,b] = ab - ba between letterplace polynomials 1976 2019 NOTE: if N>1 is specified, then the left normed bracket [a,[...[a,b]]]] is computed. 1977 EXAMPLE: example Liebr; shows examples2020 EXAMPLE: example lieBracket; shows examples 1978 2021 " 1979 2022 { 1980 1981 2023 if (lpAssumeViolation()) 1982 2024 { 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!"); 1984 2027 } 1985 2028 // alias ppLiebr; … … 2005 2048 for(i=1; i<=N; i++) 2006 2049 { 2007 q = Liebr(a,q);2050 q = lieBracket(a,q); 2008 2051 } 2009 2052 } … … 2014 2057 "EXAMPLE:"; echo = 2; 2015 2058 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; 2016 2061 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); 2022 2064 } 2023 2065 … … 2034 2076 } 2035 2077 2036 //proc pshift(poly a, int i, int uptodeg, int lV) 2037 static proc pshift(poly a, int i) 2078 proc shiftPoly(poly a, int i) 2079 "USAGE: shiftPoly(p,i); p letterplace poly, i int 2080 RETURN: poly 2081 ASSUME: basering has letterplace ring structure 2082 PURPOSE: compute the i-th shift of letterplace polynomial p 2083 EXAMPLE: example shiftPoly; shows examples 2084 " 2038 2085 { 2039 2086 // shifts a monomial a by i 2040 2087 // 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"); 2041 2094 if (deg(a) + i > uptodeg) 2042 2095 { … … 2045 2098 return(system("stest",a,i,uptodeg,lV)); 2046 2099 } 2100 example 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 2047 2112 2048 2113 static proc mmLiebr(poly a, poly b) … … 2053 2118 int sa = deg(a); 2054 2119 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); 2056 2121 return(v); 2057 2122 } … … 2062 2127 ring r = 0,(a,b),dp; 2063 2128 int d =5; 2064 def R = freegbRing(d);2129 def R = makeLetterplaceRing(d); 2065 2130 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; 2068 2135 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 2139 proc serreRelations(intmat A, int zu) 2140 "USAGE: serreRelations(A,z); A an intmat, z an int 2075 2141 RETURN: ideal 2076 2142 ASSUME: basering has a letterplace ring structure and 2077 @* A is a generalized Cartan matrix with integer entries2143 @* A is a generalized Cartan matrix with integer entries 2078 2144 PURPOSE: compute the ideal of Serre's relations associated to A 2079 EXAMPLE: example Serre; shows examples2145 EXAMPLE: example serreRelations; shows examples 2080 2146 " 2081 2147 { … … 2100 2166 if ((i!=j) && (el >0)) 2101 2167 { 2102 q = Liebr(var(j),var(i));2168 q = lieBracket(var(j),var(i)); 2103 2169 dbprint(ppl,"first bracket: ",q); 2104 2170 // if (l >=2) … … 2106 2172 for (k=1; k<=el-1; k++) 2107 2173 { 2108 q = Liebr(var(j),q);2174 q = lieBracket(var(j),q); 2109 2175 dbprint(ppl,"further bracket:",q); 2110 2176 } … … 2125 2191 0, -1, 2; // G^1_2 Cartan matrix 2126 2192 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); 2130 2195 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); 2132 2197 I; 2133 kill uptodeg, lV;2134 2198 } 2135 2199 … … 2142 2206 proc lp2lstr(ideal K, def save) 2143 2207 "USAGE: lp2lstr(K,s); K an ideal, s a ring 2144 RETURN: nothing (exports object LN into s)2208 RETURN: nothing (exports object @LN into s) 2145 2209 ASSUME: basering has a letterplace ring structure 2146 2210 PURPOSE: converts letterplace ideal to list of modules … … 2242 2306 } 2243 2307 setring save; 2244 export LN; 2308 list @LN = LN; 2309 export @LN; 2245 2310 // return(LN); 2246 2311 } … … 2250 2315 intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2 2251 2316 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); 2255 2318 setring R; 2256 ideal I = Serre(A,1);2319 ideal I = serreRelations(A,1); 2257 2320 lp2lstr(I,r); 2258 2321 setring r; 2259 lst2str(LN,1); 2260 kill uptodeg; kill lV; 2322 lst2str(@LN,1); 2261 2323 } 2262 2324 … … 2292 2354 "EXAMPLE:"; echo = 2; 2293 2355 ring r =0,(x,y,z,t),Dp; 2294 def A = freegbRing(4);2356 def A = makeLetterplaceRing(4); 2295 2357 setring A; 2296 2358 string t = "-2*y*z*y*z + y*t*z*z - z*x*x*y + 2*z*y*z*y"; … … 2352 2414 "EXAMPLE:"; echo = 2; 2353 2415 ring r =0,(x,y,z,t),dp; 2354 def A = freegbRing(4);2416 def A = makeLetterplaceRing(4); 2355 2417 setring A; 2356 2418 string fn = "myfile"; … … 2370 2432 ring r =0,(x,y,z,t),dp; 2371 2433 int d = 10; 2372 def A = freegbRing(d);2434 def A = makeLetterplaceRing(d); 2373 2435 setring A; 2374 2436 ideal I = file2lplace("./ls3nilp.bg"); … … 2376 2438 lp2lstr(I,r); 2377 2439 setring r; 2378 lst2str( LN,1); // agree!2440 lst2str(@LN,1); // agree! 2379 2441 } 2380 2442 … … 2384 2446 ring r = 0,(x,y,z),dp; 2385 2447 int d =4; // degree bound 2386 def R = freegbRing(d);2448 def R = makeLetterplaceRing(d); 2387 2449 setring R; 2388 2450 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); … … 2391 2453 J; 2392 2454 // visualization: 2393 lp2lstr(J,r); // export an object called LN to the ring r2455 lp2lstr(J,r); // export an object called @LN to the ring r 2394 2456 setring r; // change to the ring r 2395 lst2str( LN,1); // output the strings2457 lst2str(@LN,1); // output the strings 2396 2458 } 2397 2459 … … 2405 2467 "USAGE: lpMult(f,g); f,g letterplace polynomials 2406 2468 RETURN: 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 2469 ASSUME: basering has a letterplace ring structure 2410 2470 PURPOSE: compute the letterplace form of f*g 2411 2471 EXAMPLE: example lpMult; shows examples … … 2414 2474 if (lpAssumeViolation()) 2415 2475 { 2416 ERROR(" Either 'uptodeg' or 'lV' global variables are not set!");2476 ERROR("Incomplete Letterplace structure on the basering!"); 2417 2477 } 2418 2478 int sf = deg(f); 2419 2479 int sg = deg(g); 2480 int uptodeg = attrib(basering, "uptodeg"); 2420 2481 if (sf+sg > uptodeg) 2421 2482 { … … 2423 2484 } 2424 2485 // if (sf>1) { sf = sf -1; } 2425 poly v = f* pshift(g,sf);2486 poly v = f*shiftPoly(g,sf); 2426 2487 return(v); 2427 2488 } … … 2432 2493 ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp; 2433 2494 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; 2436 2497 lpMult(b,a); 2437 2498 lpMult(a,b); 2438 kill uptodeg, lV;2439 2499 } 2440 2500 … … 2444 2504 // uptodeg and lV are defined 2445 2505 // 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.