# Ticket #54: freegb.lib.diff3

File freegb.lib.diff3, 20.2 KB (added by Oleksandr , 14 years ago)

Inspecting changes 1: initial version, 2: my changes/sugestions 3: latest author's version

Line
1====3
21:2c
32:2c
4  version="\$Id: freegb.lib,v 1.12 2008/10/06 17:04:27 Singular Exp \$";
53:2c
6  version="\$Id: freegb.lib,v 1.16 2009/02/13 21:37:20 levandov Exp \$";
7====3
81:5c
92:5c
10  LIBRARY: freegb.lib   Twosided Noncommutative Groebner bases in Free Algebras
113:5c
12  LIBRARY: freegb.lib   Twosided Noncommutative Groebner bases in Free Algebras via Letterplace
13====
141:8,10c
15  PROCEDURES:
16  freegbRing(int d);    creates a ring with d blocks of shifted original variables
17  freegbasis(list L, int n);   compute two-sided Groebner basis of ideal, encoded via L, up to degree n
182:8,20c
19  BACKGROUND:
20  TODO: WRITE DOWN SOME THEORY BEHIND (DIVISIBILITY, ORDERING ON FREE ASSOC. ALG., GB)
22  TODO: EXPLAIN YOUR ASSUMPTIONS/IMPLICITE AGREEMENTS/INPUT, OUTPUT FORMATS ETC.
23  TODO: BAD NAMES, SEE 3.9.1 Procedures in a library, 5^th rule. PLEASE RENAME!
24
25
26  MAIN PROCEDURES:
27
28  freegbRing(int d);    creates a ring with d blocks of shifted original variables
29  freegbasis(list L, int n); computes two-sided GB of an ideal up to degree n
30
31  AUXILIARY PROCEDURES:
323:8,14c
33  THEORY: See chapter 'Letterplace' in the Singular Manual.
34
35  PROCEDURES:
36  freegbRing(d);    creates a ring with d blocks of shifted original variables
37  freegbasis(L, int n);   compute two-sided Groebner basis of ideal, encoded via L, up to degree n
38
39  AUXILIARY PROCEDURES:
40====
411:12c
42  CONVERSION ROUTINES:
432:22,30c
44  lp2lstr(ideal K, def save); converts letter-place ideal to a list of modules
45  lst2str(list L[,int n]);    converts a list of modules into polys in free alg.
46  mod2str(module M[,int n]);  converts a module into a polynomial in free algebra
47  vct2str(module M[,int n]);  converts a vector into a word in free algebra
48  "
49
50  // TODO: LOTS OF GLOBAL UNLISTED PROCS WITHOUT HELP/EXAMPLES... ->
51  // -> MAKE THEM STATIC OR DOCUMENT THEM!
52  // TODO: AT LEAST SOME (E.G. Serre MUST BE LISTED IN THE HEADER)
533:16,24c
54  lpMult(f,g);        letterplace multiplication of letterplace polynomials
55  lp2lstr(K, s);      convert letter-place ideal to a list of modules
56  lst2str(L[, n]);     convert a list (of modules) into polynomials in free algebra
57  mod2str(M[, n]); convert a module into a polynomial in free algebra
58  vct2str(M[, n]);   convert a vector into a word in free algebra
59  Liebr(a,b[, N]);    compute Lie bracket ab-ba of two letterplace polynomials
60  Serre(A,z);          compute the ideal of Serre's relations associated to a generalized Cartan matrix A
61  isVar(p);             check whether p is a power of a single variable
62  adem(i,j);            compute the ideal of Adem relations for i<2j in char 0
63====
641:14,18c
65  lp2lstr(ideal K, def save): converts letter-place ideal to a list of modules
66  lst2str(list L[,int n]);            convert a list (of modules) into polynomials in free algebra
67  mod2str(module M[,int n]);  convert a module into a polynomial in free algebra
68  vct2str(module M[,int n]);  convert a vector into a word in free algebra
69  "
702:32c
71  // TODO: MOVE THE FOLLOWING TO THE ABOVE BACKGROUND...
723:26,27c
74  "
75====2
761:26a
773:35a
782:41,44c
79
80
81
82
83====3
841:29a
852:47a
863:39,53c
87  proc testfreegblib()
88  {
89    example freegbRing;
90    example freegbasis;
91      "AUXILIARY PROCEDURES: ";
92    example lpMult;
93    example lp2lstr;
94    example lst2str;
95    example mod2str;
96    example vct2str;
97    example Liebr;
98    example Serre;
99    example isVar;
100  }
101
102====3
1031:33c
1042:51c
105  proc lshift(module M, int s, string varing, def lpring)
1063:57c
107  static proc lshift(module M, int s, string varing, def lpring)
108====3
1091:78c
1102:96c
111  proc skip0(vector v)
1123:102c
113  static proc skip0(vector v)
114====2
1151:100a
1163:124a
1172:119,122c
118
119  // TODO: ANY ASSUMPTIONS ON THE BASERING?
120  // TODO: EXPLAIN WHICH FREE ALGEBRA IS MEANT?
121
122====2
1231:103,104c
1243:127,128c
125  RETURN:  list (of strings)
126  PURPOSE: convert a list (of modules) into polynomials in free algebra
1272:125,127c
128  RETURN:  list of strings
129  PURPOSE: converts a list of modules into a list of strings representing
130           corresponding module as an element in the free algebra
131====2
1321:106c
1333:130c
134  NOTE: if an optional integer is not 0, stars signs are used in multiplication
1352:129c
136  NOTE:    if an optional integer is not 0, stars signs are used in multiplication
137====2
1381:115c
1393:139c
140      if (#[1])
1412:138c
142      if (typeof(#[1]) == "int")
143====2
1441:121c
1453:145c
146    int s    = size(L);
1472:144c
148    int s = size(L);
149====2
1501:131,132c
1513:155,156c
152        "module or matrix expected in the list";
153        return(N);
1542:154,156c
155        ERROR("module or matrix expected in the list");
156        brake;
157  //      return(N);
158====2
1591:148a
1603:172a
1612:173,175c
162  // TODO: ANY ASSUMPTIONS ON THE BASERING/INPUT!?
163  // TODO: EXPLAIN WHICH FREE ALGEBRA IS MEANT?
164
165====2
1661:152c
1673:176c
168  PURPOSE: convert a module into a polynomial in free algebra
1692:179,180c
170  PURPOSE: Converts the module M into a string representing M
171           as an element in the free algebra
172====2
1731:163c
1743:187c
175      if (#[1])
1762:191c
177      if (typeof(#[1]) == "int")
178====2
1791:196a
1803:220a
1812:225,231c
182    // TODO: WHAT ABOUT ZERO?
183    M = 0;
184    mod2str(M); // TODO: FIX BUG: MUST BE JUST A ZERO!
185    M = [0], [0], [1], [0, x];
186    mod2str(M); // TODO: FIX THIS BUGS!
187    M = [1, x, y, z], [0, x], [2, y], [0];
188    mod2str(M);
189====2
1901:198a
1913:222a
1922:234,236c
193  // TODO: ANY ASSUMPTIONS ON THE BASERING/INPUT!?
194  // TODO: EXPLAIN WHICH FREE ALGEBRA IS MEANT?
195
196====2
1971:202c
1983:226c
199  PURPOSE: convert a vector into a word in free algebra
2002:240c
201  PURPOSE: Converts a vector into a string representing a word in the free alg.
202====2
2031:211c
2043:235c
205      if (#[1])
2062:249c
207      if (typeof(#[1]) == "int")
208====3
2091:226c
2102:264c
211      p     = IsVar(v[i+1]);
2123:250c
213      p     = isVar(v[i+1]);
214====2
2151:287a
2163:311a
2172:326,337c
218    // TODO: WHAT ABOUT ZERO?
219    vector M = 0;
220    vct2str(M);
221    M = [0];
222    vct2str(M);
223    M = [0, x, y3, z(1)];
224    vct2str(M,1); // TODO: FIX BUG: MUST BE ZERO!
225    M = [1, x, 0, z(1)];
226    vct2str(M,1);
227    M = [1, 0, z(1), 0, 0, x*y3, 0, 666];
228    vct2str(M,1); // TODO: FIX BUG: WHAT IS THIS???
229
230====3
2311:290c
2322:340c
233  proc IsVar(poly p)
2343:314,320c
235  proc isVar(poly p)
236  "USAGE:  isVar(p);  poly p
237  RETURN:  int
238  PURPOSE: checks whether p is a power of a single variable from the basering.
239  @* Returns the exponent or 0 is p is not a power of  a single variable.
240  EXAMPLE: example isVar; shows examples
241  "
242====3
2431:319c
2442:369c
245    IsVar(f);
2463:349c
247    isVar(f);
248====3
2491:321c
2502:371c
251    IsVar(g);
2523:351c
253    isVar(g);
254====3
2551:323c
2562:373c
257    IsVar(h);
2583:353c
259    isVar(h);
260====3
2611:325c
2622:375c
263    IsVar(i);
2643:355c
265    isVar(i);
266====3
2671:330c
2682:380c
269  proc id2words(ideal I, int d)
2703:360c
271  static proc id2words(ideal I, int d)
272====3
2731:373c
2742:423c
275  proc mono2word(poly p, int d)
2763:403c
277  static proc mono2word(poly p, int d)
278====2
2791:392a
2803:422a
2812:443,447c
282
283  // TODO: BAD NAME -> RENAME!
284  // TODO: NO ASSUMPTIONS? WHAT ABOUT NON-COMM. INPUT RING? NON-HOMOG. INPUT?
286
287====2
2881:395,397c
2893:425,427c
290  RETURN:  ring
291  PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in
292  the free associative algebra, up to degree d
2932:450,461c
294  RETURN:  ring,
295    TODO: EXPLAIN OUTPUT FORMAT
296  PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L
297           (TODO: EXPLAIN FORMAT OF L)
298           in the free associative algebra,
299           (TODO: WHICH free associative algebra? SYMBOLS? GROUND FIELD?)
300           up to degree d
301  BACKGROUND:
302    TODO: EXPLAIN ALGORITHM, GIVE REFERENCES!
304  DISPLAY:
305    TODO: EXPLAIN!
306====2
3071:424a
3083:454a
3092:489,493c
310
311    // TODO: THE FOLLOWING SEEMS TO BE THE CONTENT OF 'freegbRing'!
312    // AND THUS IS OVERSIMPLIFIED: WHAT IF VARIABLES/PARAMETERS HAVE BRACKETS?
313    // SEE EXAMPLE FOR 'freegbRing'!
314
315====2
3161:477,478c
3173:507,508c
318    def @R = ring(L);
319    setring @R;
3202:546,553c
321    def @R = ring(L);
322
323    // HERE END 'freegbRing'! ;-)
324
325
326    // TODO: THE FOLLOWING CONVERSION DESERVES TO BE AN AUXILIARY PROCEDURE!
327
328    setring @R; // !
329====2
3301:484c
3313:514c
332    setring save;
3332:559c
334    setring save; // !!
335====2
3361:492c
3373:522c
338    setring @R;
3392:567c
340    setring @R; // !!!
341====2
3421:494c
3433:524c
344    setring save;
3452:569c
346    setring save; // !!!!
347====2
3481:513c
3493:543c
350        setring @R;
3512:588c
352        setring @R; // !!!!!
353====2
3541:515c
3553:545c
356        setring save;
3572:590c
358        setring save; // !!!!! !
359====2
3601:517c
3613:547c
362      setring @R;
3632:592c
364      setring @R; // !!!!! !!
365====2
3661:521c
3673:551c
368      setring save;
3692:596c
370      setring save; // !!!!! !!!
371====2
3721:525c
3733:555c
374    setring @R;
3752:600,607c
376    setring @R; // !!!!! !!!!
377
378    // TODO: UNBELIEVABLE PLENITUDE OF SETRING ABOVE!
379    // YOU CAN DO BETTER AS FOLLOWS:
380    //  1. GENERATE ONLY 1 (ONE!!!!) STRING sp FOR THE WHOLE(!!!) L
381    //              BEFORE(!!!!) SWITCHING TO @R
382    //  2. EXECUTE IT IN @R
383
384====2
3851:533a
3863:563a
3872:616,618c
388
389    // TODO: THE FOLLOWING DESERVES TO BE AN AUXILIARY PROCEDURE AS WELL! IS IT lp2lstr?
390
391====2
3921:540a
3933:570a
3942:626,628c
395
396    // YOU HAVE A LOT OF SETRINGS BELOW, ARE YOU SURE THAT YOU CANNOT ELIMINATE SOME...?
397
398====2
3991:547c
4003:577c
401    setring save;
4022:635c
403    setring save; // !
404====2
4051:553c
4063:583c
407    setring @R;
4082:641c
409    setring @R; // !!
410====2
4111:580a
4123:610a
4132:669c
414
415====2
4161:585c
4173:615c
418      setring @R;
4192:674c
420      setring @R; // !!!
421====2
4221:595c
4233:625c
424        setring save;
4252:684c
426        setring save; // !!!!
427====2
4281:624c
4293:654c
430        setring @R;
4312:713c
432        setring @R; // !!!!!
433====2
4341:628c
4353:658c
436      setring save;
4372:717c
438      setring save; // !!!!! !
439====2
4401:632c
4413:662c
442    setring save;
4432:721c
444    setring save; // !!!!! !!
445====2
4461:644a
4473:674a
4482:734,762c
449    kill U;
450    setring r; // non-homog. input:
451    M = [-1,x,y],[-7,y,y,z],[3,x,x,x,z,z];
452    N = [1,x,y,z,x],[-1,y,x,y];
453    L[1] = M; L[2] = N;
454    lst2str(L);
455    def U = freegbasis(L,5);
456    lst2str(U); // OK
457    kill U,r;
458    ring r = 0,(x,y,z),(dp(1),dp(2));
459    def R = nc_algebra(1,0); setring R; // should be the same as 1st!
460    module M = [-1,x,y],[-7,y,y],[3,x,x];
461    module N = [1,x,y,x],[-1,y,x,y];
462    list L; L[1] = M; L[2] = N;
463    lst2str(L);
464    def U = freegbasis(L,5);
465    lst2str(U); // OK
466    kill U, R;
467    setring r;
468    def R = nc_algebra(-1,1); setring R; // some non-commutativity
469    R;
470    module M = [-1,x,y],[-7,y,y],[3,x,x];
471    module N = [1,x,y,x],[-1,y,x,y];
472    list L; L[1] = M; L[2] = N;
473    lst2str(L);
474    def U = freegbasis(L,5);
475    lst2str(U);
476
477
478====3
4791:647c
4802:765c
481  proc crs(list LM, int d)
4823:677c
483  static proc crs(list LM, int d)
484====3
4851:796c
4862:914c
487  proc polylen(ideal I)
4883:826c
489  static proc polylen(ideal I)
490====2
4911:811a
4923:841a
4932:930,938c
494
495  // TODO: ASSUMPTIONS?
496  // TODO: PROC FORGETS ABOUT NON-COMM. RELATIONS IN THE
497  //// BASERING! DOCUMENT IT OR FIX...
498  // TODO: WRITE DOWN WHAT IS THE ORDERING IN THE OUTPUT RING?
499  // TODO: OVERSIMPLIFIED: WHAT IF PARAMETERS HAVE BRACKETS
500  //// AND COINCIDE WITH GENERATED VARIABLES? SEE EXAMPLE
501
502
503====2
5041:822c
5053:852c
506    int ppl = printlevel-voice+2;
5072:949c
508    int ppl = printlevel-voice+2;
509====2
5101:885,886c
5113:915,916c
512    def A = freegbRing(2);
513    setring A;
5142:1012,1013c
515    r;
516    def A = freegbRing(2); setring A;
517====2
5181:887a
5193:917a
5202:1015,1032c
521    kill A, r;
522    ring r = 0,(x(1..3)),(dp(1),lp(2));
523    r;
524    def A = freegbRing(2); setring A;
525    A; // OK
526    kill A, r;
527    ring r = (0,a(1),b(1)),(a, b),(lp(1),dp(1));
528    r;
529    def A = freegbRing(2); setring A;
530    A; // BUG: parameter should not be named as a variable and vice verse!
531    a(1); typeof(a(1));
532    kill A, r;
533    ring r = 0,(x,y,z),dp;
534    def R = nc_algebra(-1, 1); setring R;
535    R;
536    def A = freegbRing(2); setring A;
537    A; // NOTE: the putput is a purely commutative ring!
538    kill A, R, r;
539====3
5401:890c
5412:1035c
542  proc ex_shift()
5433:920,922c
544  /* EXAMPLES:
545
546  //static proc ex_shift()
547====3
5481:911c
5492:1056c
550  proc test_shrink()
5513:943c
552  //static proc test_shrink()
553====3
5541:938c
5552:1083c
556  proc ex2()
5573:970c
558  //static proc ex2()
559====3
5601:948c
5612:1093c
562  proc ex_nonhomog()
5633:980c
564  //static proc ex_nonhomog()
565====3
5661:966c
5672:1111c
568  proc ex_nonhomog_comm()
5693:998c
570  //static proc ex_nonhomog_comm()
571====3
5721:976c
5732:1121c
574  proc ex_nonhomog_h()
5753:1008c
576  //static proc ex_nonhomog_h()
577====3
5781:986c
5792:1131c
580  proc ex_nonhomog_h2()
5813:1018c
582  //static proc ex_nonhomog_h2()
583====3
5841:1005c
5852:1150c
586  proc ex_nonhomog_3()
5873:1037c
588  //static proc ex_nonhomog_3()
589====3
5901:1024c
5912:1169c
592  proc ex_densep_2()
5933:1056c
594  //static proc ex_densep_2()
595====3
5961:1039a
5972:1184a
5983:1072,1074c
599  // END COMMENTED EXAMPLES
600
601  */
602====3
6031:1048c
6042:1193c
605  proc freegbold(list LM, int d)
6063:1083c
607  static proc freegbold(list LM, int d)
608====3
6091:1306c
6102:1451c
611  proc sgb(ideal I, int d)
6123:1341c
613  static proc sgb(ideal I, int d)
614====3
6151:1329,1330c
6162:1474,1475c
617
618
6193:1363a
620====3
6211:1344,1345c
6222:1489,1490c
623
624  proc exHom1()
6253:1377c
626  static proc exHom1()
627====3
6281:1422c
6292:1567c
630  proc schur2-3()
6313:1454c
632  static proc schur2-3()
633====3
6341:1431a
6352:1576a
6363:1464,1470c
638  RETURN:  ring and exports ideal
639  ASSUME: there are at least i+j variables in the basering
640  PURPOSE: compute the ideal of Adem relations for i<2j in characteristic 0
641  @*  the ideal is exported under the name AdemRel in the output ring
642  EXAMPLE: example adem; shows examples
643  "
644====3
6451:1447c
6462:1592c
647    printf("k=0, term=%s",q);
6483:1486c
649    //  printf("k=0, term=%s",q);
650====3
6511:1453c
6522:1598c
653      printf("k=%s, term=%s",k,q);
6543:1492c
655      //    printf("k=%s, term=%s",k,q);
656====3
6571:1498,1501c
6582:1643,1646c
660  {
661    // Adem rels modulo 2
662  }
6633:1537c
664    // Adem rels modulo 2 are interesting
665====3
6661:1503c
6672:1648c
668  proc stringpoly2lplace(string s)
6693:1539c
670  static proc stringpoly2lplace(string s)
671====3
6721:1649c
6732:1794c
6753:1685c
677====3
6781:1677c
6792:1822c
680  proc sent2lplace(string s)
6813:1713c
682  static proc sent2lplace(string s)
683====3
6841:1696c
6852:1841c
686  proc testnumber(string s)
6873:1732c
688  static proc testnumber(string s)
689====3
6901:1746c
6912:1891c
692  proc str2lplace(string s)
6933:1782c
694  static proc str2lplace(string s)
695====3
6961:1823c
6972:1968c
698  proc strpower2rep(string s)
6993:1859c
700  static proc strpower2rep(string s)
701====3
7021:1933a
7032:2078a
7043:1970,1978c
705  "USAGE:  Liebr(a,b[,N]); a,b letterplace polynomials, N an optional integer
706  RETURN:  poly
707  ASSUME: basering has a letterplace ring structure, like the one returned by freegbRing
708  @*   Moreover, the variables 'uptodeg' (degree bound of the letterplace ring) and 'lV' (number of
709  blocks of variables of the letterplace ring ) must be defined
710  PURPOSE: compute the Lie bracket [a,b] = ab - ba between letterplace polynomials
711  NOTE: if N>1 is specified, then the left normed bracket [a,[...[a,b]]]] is computed.
712  EXAMPLE: example Liebr; shows examples
713  "
714====3
7151:1934a
7162:2079a
7173:1980,1984c
718
719    if (lpAssumeViolation())
720    {
721      ERROR("Either 'uptodeg' or 'lV' global variables are not set!");
722    }
723====3
7241:1970a
7252:2115a
7263:2021c
727    kill uptodeg, lV;
728====3
7291:1973c
7302:2118c
731  proc pmLiebr(poly a, poly b)
7323:2024c
733  static proc pmLiebr(poly a, poly b)
734====3
7351:1986c
7362:2131c
737  proc pshift(poly a, int i)
7383:2037c
739  static proc pshift(poly a, int i)
740====3
7411:1989a
7422:2134a
7433:2041,2044c
744    if (deg(a) + i > uptodeg)
745    {
746      ERROR("degree bound violated by the shift!");
747    }
748====3
7491:1993c
7502:2138c
751  proc mmLiebr(poly a, poly b)
7523:2048c
753  static proc mmLiebr(poly a, poly b)
754====3
7551:2014a
7562:2159a
7573:2070c
758    kill uptodeg, lV;
759====3
7601:2017a
7612:2162a
7623:2074,2080c
763  "USAGE:  Serre(A,z); A an intmat, z an int
764  RETURN:  ideal
765  ASSUME: basering has a letterplace ring structure and
766  @*    A is a generalized Cartan matrix with integer entries
767  PURPOSE: compute the ideal of Serre's relations associated to A
768  EXAMPLE: example Serre; shows examples
769  "
770====3
7711:2025c
7722:2170c
773    int i,j,k,l;
7743:2088c
775    int i,j,k,el;
776====3
7771:2032c
7782:2177c
779        l = 1 - A[i,j];
7803:2095c
781        el = 1 - A[i,j];
782====3
7831:2034c
7842:2179c
785        dbprint(ppl,"i, j, l: ",i,j,l);
7863:2097c
787        dbprint(ppl,"i, j, l: ",i,j,el);
788====3
7891:2037c
7902:2182c
791        if ((i!=j) && (l >0))
7923:2100c
793        if ((i!=j) && (el >0))
794====3
7951:2040c
7962:2185c
797          //        printf("first bracket: %s",q);
7983:2102a
799====3
8001:2044c
8012:2189c
802            for (k=1; k<=l-1; k++)
8033:2106c
804            for (k=1; k<=el-1; k++)
805====3
8061:2047c
8072:2192c
808              //            printf("further bracket: %s",q);
8093:2108a
810====
8111:2061,2063c
812    intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2
813    ring r = 0,(f1,f2),dp;
814    int uptodeg = 3; int lV = 2;
8152:2206,2209c
816    intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2
817    ring r = 0,(f1,f2),dp;
818    int uptodeg = 3;
819    int lV = 2;
8203:2122,2127c
821    intmat A[3][3] =
822      2, -1, 0,
823      -1, 2, -3,
824      0, -1, 2; // G^1_2 Cartan matrix
825    ring r = 0,(f1,f2,f3),dp;
826    int uptodeg = 5; int lV = 3;
827====3
8281:2067c
8292:2213c
830    ideal I = Serre(A,1);
8313:2131c
832    ideal I = Serre(A,1); I = simplify(I,1+2+8);
833====3
8341:2069c
8352:2215c
836    Serre(A,0);
8373:2133c
838    kill uptodeg, lV;
839====
8401:2071a
8412:2218,2221c
842  // TODO: EXPLAIN CONVERTION RULE, ENCODING OF 'LN'!
843  // THIS SEEMS TO BE THE LAST PART OF FREEGBASIS?
844  // TODO: ASSUMPTIONS! WHY NO SQUARES IN ELEMENTS FROM K?
845
8463:2136,2141c
847  /* setup for older example:
848    intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2
849    ring r = 0,(f1,f2),dp;
850    int uptodeg = 5; int lV = 2;
851  */
852
853====3
8541:2073,2075c
8552:2223,2225c
856  "USAGE:  lp2lstr(K,save); K an ideal, save a ring
857  RETURN:  nothing (exports object LN into save)
858  PURPOSE: converts letter-place ideal to list of modules
8593:2143,2147c
860  "USAGE:  lp2lstr(K,s); K an ideal, s a ring
861  RETURN:  nothing (exports object LN into s)
862  ASSUME: basering has a letterplace ring structure
863  PURPOSE: converts letterplace ideal to list of modules
864  NOTE: useful as preprocessing to 'lst2str'
865====2
8661:2097a
8673:2169a
8682:2248,2250c
869
870    // TODO: YOU CAN FOLD TWO FOLLOWING LOOPS TOGETHER!
871    // THE FOLLOWING CHECK/PREPROCESSING MIGHT BE EXPENSIVE!
872====2
8731:2180,2181c
8743:2252,2253c
875    int uptodeg = 3; int lV = 2;
876    export uptodeg; export lV;
8772:2333c
878    int uptodeg = 3;
879====2
8801:2184c
8813:2256c
882    ideal I = Serre(A,1);
8832:2336,2341c
884    ideal I = Serre(A,1); // TODO: BUG: WHY IS THIS FAILED??? HIDING ARGUMENTS IS A BAD STYLE!!!
885
886    int lV = 2; // NOT CLEAR WHERE DO YOU NEED THIS?
887    export uptodeg; export lV; // TODO: BUG: THEY WHERE NOR DEFINED BEFORE IN CODE!!!
888    I = Serre(A,1);
889
890====2
8911:2188c
8923:2260c
893    kill uptodeg; kill lV;
8942:2345,2348c
895
896
897    kill uptodeg;
898    kill lV;
899====3
9001:2191c
9012:2351c
902  proc strList2poly(list L)
9033:2263c
904  static proc strList2poly(list L)
905====3
9061:2231c
9072:2391c
908  proc file2lplace(string fname)
9093:2303,2308c
910  static proc file2lplace(string fname)
911  "USAGE:  file2lplace(fnm);  fnm a string
912  RETURN:  ideal
913  PURPOSE: convert the contents of the file fnm into ideal of polynomials in free algebra
914  EXAMPLE: example file2lplace; shows examples
915  "
916====3
9171:2289c
9182:2449c
919  static proc get_ls3nilp()
9203:2366,2367c
921  /* EXAMPLES AGAIN:
922  //static proc get_ls3nilp()
923====3
9241:2303c
9252:2463c
926  static proc doc_example
9273:2381c
928  //static proc doc_example()
929====3
9301:2320c
9312:2480c
932
9333:2398c
934  */
935====3
9361:2325a
9372:2485a
9383:2404,2448c
939  proc lpMult(poly f, poly g)
940  "USAGE:  lpMult(f,g); f,g letterplace polynomials
941  RETURN:  poly
942  ASSUME: basering has a letterplace ring structure, like the one returned by freegbRing
943  @*   Moreover, the variables 'uptodeg' (degree bound of the letterplace ring) and 'lV' (number of
944  blocks of variables of the letterplace ring ) must be defined
945  PURPOSE: compute the letterplace form of f*g
946  EXAMPLE: example lpMult; shows examples
947  "
948  {
949    if (lpAssumeViolation())
950    {
951      ERROR("Either 'uptodeg' or 'lV' global variables are not set!");
952    }
953    int sf = deg(f);
954    int sg = deg(g);
955    if (sf+sg > uptodeg)
956    {
957      ERROR("degree bound violated by the product!");
958    }
959    //  if (sf>1) { sf = sf -1; }
960    poly v = f*pshift(g,sf);
961    return(v);
962  }
963  example
964  {
965    "EXAMPLE:"; echo = 2;
966    // define a ring in letterplace form as follows:
967    ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp;
968    poly a = x(1)*y(2); poly b = y(1);
969    int uptodeg=4; int lV=2;
970    export uptodeg; export lV;
971    lpMult(b,a);
972    lpMult(a,b);
973    kill uptodeg, lV;
974  }
975
976  static proc lpAssumeViolation()
977  {
978    // checks whether the global vars
979    // uptodeg and lV are defined
980    // returns Boolean : yes/no [for assume violation]
981    int i = ( defined(uptodeg) && (defined(lV)) );
982    return ( !i );
983  }