Annotation of OpenXM/src/k097/lib/minimal/minimal.k, Revision 1.18
1.18 ! takayama 1: /* $OpenXM: OpenXM/src/k097/lib/minimal/minimal.k,v 1.17 2000/07/26 12:56:36 takayama Exp $ */
1.1 takayama 2: #define DEBUG 1
3: /* #define ORDINARY 1 */
1.4 takayama 4: /* If you run this program on openxm version 1.1.2 (FreeBSD),
5: make a symbolic link by the command
6: ln -s /usr/bin/cpp /lib/cpp
7: */
1.6 takayama 8: #define OFFSET 0
9: /* #define OFFSET 20*/
1.1 takayama 10: /* Test sequences.
11: Use load["minimal.k"];;
12:
13: a=Sminimal(v);
14: b=a[0];
15: b[1]*b[0]:
16: b[2]*b[1]:
17:
18: a = test0();
19: b = a[0];
20: b[1]*b[0]:
21: b[2]*b[1]:
22: a = Sminimal(b[0]);
23:
24: a = test1();
25: b=a[0];
26: b[1]*b[0]:
27: b[2]*b[1]:
28:
29: */
30:
31:
32: load("cohom.k");
33: def load_tower() {
34: if (Boundp("k0-tower.sm1.loaded")) {
35: }else{
36: sm1(" [(parse) (k0-tower.sm1) pushfile ] extension ");
37: sm1(" /k0-tower.sm1.loaded 1 def ");
38: }
1.7 takayama 39: sm1(" oxNoX ");
1.1 takayama 40: }
41: load_tower();
42: SonAutoReduce = true;
43: def Factor(f) {
44: sm1(f, " fctr /FunctionValue set");
45: }
46: def Reverse(f) {
47: sm1(f," reverse /FunctionValue set");
48: }
49: def Sgroebner(f) {
50: sm1(" [f] groebner /FunctionValue set");
51: }
52: def test0() {
53: local f;
54: Sweyl("x,y,z");
55: f = [x^2+y^2+z^2, x*y+x*z+y*z, x*z^2+y*z^2, y^3-x^2*z - x*y*z+y*z^2,
56: -y^2*z^2 + x*z^3 + y*z^3, -z^4];
57: frame=SresolutionFrame(f);
58: Println(frame);
59: /* return(frame); */
60: return(SlaScala(f));
61: }
62: def test1() {
63: local f;
64: Sweyl("x,y,z");
65: f = [x^2+y^2+z^2, x*y+x*z+y*z, x*z^2+y*z^2, y^3-x^2*z - x*y*z+y*z^2,
66: -y^2*z^2 + x*z^3 + y*z^3, -z^4];
67: return(Sminimal(f));
68: }
69:
70:
71:
72: def Sweyl(v,w) {
73: /* extern WeightOfSweyl ; */
74: local ww,i,n;
75: if(Length(Arglist) == 1) {
76: sm1(" [v s_ring_of_differential_operators 0 [(schreyer) 1]] define_ring ");
77: sm1(" define_ring_variables ");
78:
79: sm1(" [ v to_records pop ] /ww set ");
80: n = Length(ww);
81: WeightOfSweyl = NewArray(n*4);
82: for (i=0; i< n; i++) {
83: WeightOfSweyl[2*i] = ww[i];
84: WeightOfSweyl[2*i+1] = 1;
85: }
86: for (i=0; i< n; i++) {
87: WeightOfSweyl[2*n+2*i] = AddString(["D",ww[i]]);
88: WeightOfSweyl[2*n+2*i+1] = 1;
89: }
90:
91: }else{
92: sm1(" [v s_ring_of_differential_operators w s_weight_vector 0 [(schreyer) 1]] define_ring ");
93: sm1(" define_ring_variables ");
94: WeightOfSweyl = w[0];
95: }
96: }
97:
98:
99: def Spoly(f) {
100: sm1(f, " toString tparse /FunctionValue set ");
101: }
102:
103: def SreplaceZeroByZeroPoly(f) {
104: if (IsArray(f)) {
105: return(Map(f,"SreplaceZeroByZeroPoly"));
106: }else{
107: if (IsInteger(f)) {
108: return(Poly(ToString(f)));
109: }else{
110: return(f);
111: }
112: }
113: }
114: def Shomogenize(f) {
115: f = SreplaceZeroByZeroPoly(f);
116: if (IsArray(f)) {
117: sm1(f," sHomogenize2 /FunctionValue set ");
118: /* sm1(f," {sHomogenize2} map /FunctionValue set "); */
119: /* Is it correct? Double check.*/
120: }else{
121: sm1(f, " sHomogenize /FunctionValue set ");
122: }
123: }
124:
125: def StoTower() {
126: sm1(" [(AvoidTheSameRing)] pushEnv [ [(AvoidTheSameRing) 0] system_variable (mmLarger) (tower) switch_function ] pop popEnv ");
127: }
128:
129: def SsetTower(tower) {
130: sm1(" [(AvoidTheSameRing)] pushEnv
131: [ [(AvoidTheSameRing) 0] system_variable
132: [(gbListTower) tower (list) dc] system_variable
133: ] pop popEnv ");
1.14 takayama 134: /* sm1("(hoge) message show_ring "); */
1.1 takayama 135: }
136:
137: def SresolutionFrameWithTower(g,opt) {
138: local gbTower, ans, ff, count, startingGB, opts, skelton,withSkel, autof,
1.15 takayama 139: gbasis, nohomog;
140: nohomog = false;
141: count = -1;
1.1 takayama 142: if (Length(Arglist) >= 2) {
1.15 takayama 143: if (IsInteger(opt)) {
144: count = opt;
145: }else if (IsString(opt)) {
146: if (opt == "homogenized") {
147: nohomog = true;
148: }else{
149: Println("Warning: unknown option");
150: Println(opt);
151: }
152: }
1.1 takayama 153: }else{
154: count = -1;
155: }
156:
157: sm1(" setupEnvForResolution ");
158: /* If I do not put this macro, homogenization
159: make a strange behavior. For example,
160: [(2*x*Dx + 3*y*Dy+6) (0)] homogenize returns
161: [(2*x*Dx*h + 3*y*Dy*h+6*h^3) (0)].
162: 4/19, 2000.
163: */
164:
165: sm1(" (mmLarger) (matrix) switch_function ");
1.15 takayama 166: if (! nohomog) {
167: Println("Automatic homogenization.");
168: g = Map(g,"Shomogenize");
169: }else{
170: Println("No automatic homogenization.");
171: }
1.1 takayama 172: if (SonAutoReduce) {
173: sm1("[ (AutoReduce) ] system_variable /autof set ");
174: sm1("[ (AutoReduce) 1 ] system_variable ");
175: }
176: gbasis = Sgroebner(g);
177: g = gbasis[0];
178: if (SonAutoReduce) {
179: sm1("[ (AutoReduce) autof] system_variable ");
180: }
181:
182: g = Init(g);
183:
184: /* sm1(" setupEnvForResolution-sugar "); */
185: /* -sugar is fine? */
186: sm1(" setupEnvForResolution ");
187:
188: Println(g);
189: startingGB = g;
190: /* ans = [ SzeroMap(g) ]; It has not been implemented. see resol1.withZeroMap */
191: ans = [ ];
192: gbTower = [ ];
193: skelton = [ ];
194: while (true) {
195: /* sm1(g," res0Frame /ff set "); */
196: withSkel = Sres0FrameWithSkelton(g);
197: ff = withSkel[0];
198: ans = Append(ans, ff[0]);
199: gbTower = Join([ ff[1] ], gbTower);
200: skelton = Join([ withSkel[1] ], skelton);
201: g = ff[0];
202: if (Length(g) == 0) break;
203: SsetTower( gbTower );
204: if (count == 0) break;
205: count = count - 1;
206: }
207: return([ans,Reverse(gbTower),Join([ [ ] ], Reverse(skelton)),gbasis]);
208: }
209: HelpAdd(["SresolutionFrameWithTower",
210: ["It returs [resolution of the initial, gbTower, skelton, gbasis]",
1.15 takayama 211: "option: \"homogenized\" (no automatic homogenization) ",
1.1 takayama 212: "Example: Sweyl(\"x,y\");",
213: " a=SresolutionFrameWithTower([x^3,x*y,y^3-1]);"]]);
214:
215: def SresolutionFrame(f,opt) {
216: local ans;
1.15 takayama 217: ans = SresolutionFrameWithTower(f,opt);
1.1 takayama 218: return(ans[0]);
219: }
220: /* ---------------------------- */
221: def ToGradedPolySet(g) {
222: sm1(g," (gradedPolySet) dc /FunctionValue set ");
223: }
224:
225: def NewPolynomialVector(size) {
226: sm1(size," (integer) dc newPolyVector /FunctionValue set ");
227: }
228:
229: def SturnOffHomogenization() {
230: sm1("
231: [(Homogenize)] system_variable 1 eq
232: { (Warning: Homogenization and ReduceLowerTerms options are automatically turned off.) message
233: [(Homogenize) 0] system_variable
234: [(ReduceLowerTerms) 0] system_variable
235: } { } ifelse
236: ");
237: }
238: def SturnOnHomogenization() {
239: sm1("
240: [(Homogenize)] system_variable 0 eq
241: { (Warning: Homogenization and ReduceLowerTerms options are automatically turned ON.) message
242: [(Homogenize) 1] system_variable
243: [(ReduceLowerTerms) 1] system_variable
244: } { } ifelse
245: ");
246: }
247:
248: def SschreyerSkelton(g) {
249: sm1(" [(schreyerSkelton) g] gbext /FunctionValue set ");
250: }
251: def Stoes(g) {
252: if (IsArray(g)) {
253: sm1(g," {toes} map /FunctionValue set ");
254: }else{
255: sm1(g," toes /FunctionValue set ");
256: }
257: }
258: def Stoes_vec(g) {
259: sm1(g," toes /FunctionValue set ");
260: }
261:
262: def Sres0Frame(g) {
263: local ans;
264: ans = Sres0FrameWithSkelton(g);
265: return(ans[0]);
266: }
267: def Sres0FrameWithSkelton(g) {
268: local t_syz, nexttower, m, t_gb, skel, betti,
269: gg, k, i, j, pair, tmp, si, sj, grG, syzAll, gLength;
270:
271: SturnOffHomogenization();
272:
273: g = Stoes(g);
274: skel = SschreyerSkelton(g);
275: /* Print("Skelton is ");
276: sm1_pmat(skel); */
277: betti = Length(skel);
278:
279: gLength = Length(g);
280: grG = ToGradedPolySet(g);
281: syzAll = NewPolynomialVector(betti);
282: for (k=0; k<betti; k++) {
283: pair = skel[k];
284: i = pair[0,0];
285: j = pair[0,1];
286: si = pair[1,0];
287: sj = pair[1,1];
288: /* si g[i] + sj g[j] + \sum tmp[2][k] g[k] = 0 in res0 */
289: Print(".");
290:
291: t_syz = NewPolynomialVector(gLength);
292: t_syz[i] = si;
293: t_syz[j] = sj;
294: syzAll[k] = t_syz;
295: }
296: t_syz = syzAll;
297: Print("Done. betti="); Println(betti);
298: /* Println(g); g is in a format such as
299: [e_*x^2 , e_*x*y , 2*x*Dx*h , ...]
300: [e_*x^2 , e_*x*y , 2*x*Dx*h , ...]
301: [y-es*x , 3*es^4*y*Dy-es^5*x , 3*es^5*y*Dy-es^6*x , ...]
302: [3*es^3*y*Dy-es^5*x ]
303: */
304: nexttower = Init(g);
305: SturnOnHomogenization();
306: return([[t_syz, nexttower],skel]);
307: }
308:
309:
310: def StotalDegree(f) {
1.14 takayama 311: local d0;
312: sm1(" [(grade) f] gbext (universalNumber) dc /d0 set ");
313: /* Print("degree of "); Print(f); Print(" is "); Println(d0); */
314: return(d0);
1.1 takayama 315: }
316:
317: /* Sord_w(x^2*Dx*Dy,[x,-1,Dx,1]); */
318: def Sord_w(f,w) {
319: local neww,i,n;
320: n = Length(w);
321: neww = NewArray(n);
322: for (i=0; i<n; i=i+2) {
323: neww[i] = ToString(w[i]);
324: }
325: for (i=1; i<n; i=i+2) {
326: neww[i] = IntegerToSm1Integer(w[i]);
327: }
328: sm1(" f neww ord_w (universalNumber) dc /FunctionValue set ");
329: }
330:
331:
332: /* This is not satisfactory. */
333: def SinitOfArray(f) {
334: local p,pos,top;
335: if (IsArray(f)) {
336: sm1(f," toes init /p set ");
337: sm1(p," (es). degree (universalNumber) dc /pos set ");
338: return([Init(f[pos]),pos]);
339: } else {
340: return(Init(f));
341: }
342: }
343:
344: def test_SinitOfArray() {
345: local f, frame,p,tower,i,j,k;
346: Sweyl("x,y,z");
347: f = [x^2+y^2+z^2, x*y+x*z+y*z, x*z^2+y*z^2, y^3-x^2*z - x*y*z+y*z^2,
348: -y^2*z^2 + x*z^3 + y*z^3, -z^4];
349: p=SresolutionFrameWithTower(f);
350: sm1_pmat(p);
351: sm1_pmat(SgenerateTable(p[1]));
352: return(p);
353: frame = p[0];
354: sm1_pmat(p[1]);
355: sm1_pmat(frame);
356: sm1_pmat(Map(frame[0],"SinitOfArray"));
357: sm1_pmat(Map(frame[1],"SinitOfArray"));
358: return(p);
359: }
360:
361: /* f is assumed to be a monomial with toes. */
362: def Sdegree(f,tower,level) {
1.6 takayama 363: local i,ww, wd;
364: /* extern WeightOfSweyl; */
365: ww = WeightOfSweyl;
1.5 takayama 366: f = Init(f);
1.1 takayama 367: if (level <= 1) return(StotalDegree(f));
368: i = Degree(f,es);
1.6 takayama 369: return(StotalDegree(f)+Sdegree(tower[level-2,i],tower,level-1));
370:
1.1 takayama 371: }
372:
373: def SgenerateTable(tower) {
374: local height, n,i,j, ans, ans_at_each_floor;
1.16 takayama 375:
376: /*
377: Print("SgenerateTable: tower=");Println(tower);
378: sm1(" print_switch_status "); */
1.1 takayama 379: height = Length(tower);
380: ans = NewArray(height);
381: for (i=0; i<height; i++) {
382: n = Length(tower[i]);
383: ans_at_each_floor=NewArray(n);
384: for (j=0; j<n; j++) {
1.6 takayama 385: ans_at_each_floor[j] = Sdegree(tower[i,j],tower,i+1)-(i+1)
386: + OFFSET;
1.1 takayama 387: /* Println([i,j,ans_at_each_floor[j]]); */
388: }
389: ans[i] = ans_at_each_floor;
390: }
391: return(ans);
392: }
393: Sweyl("x,y,z");
394: v=[[2*x*Dx + 3*y*Dy+6, 0],
395: [3*x^2*Dy + 2*y*Dx, 0],
396: [0, x^2+y^2],
397: [0, x*y]];
398: /* SresolutionFrameWithTower(v); */
399:
400: def SnewArrayOfFormat(p) {
401: if (IsArray(p)) {
402: return(Map(p,"SnewArrayOfFormat"));
403: }else{
404: return(null);
405: }
406: }
1.4 takayama 407: def ScopyArray(a) {
408: local n, i,ans;
409: n = Length(a);
410: ans = NewArray(n);
411: for (i=0; i<n; i++) {
412: ans[i] = a[i];
413: }
414: return(ans);
415: }
1.1 takayama 416: def SminOfStrategy(a) {
417: local n,i,ans,tt;
418: ans = 100000; /* very big number */
419: if (IsArray(a)) {
420: n = Length(a);
421: for (i=0; i<n; i++) {
422: if (IsArray(a[i])) {
423: tt = SminOfStrategy(a[i]);
424: if (tt < ans) ans = tt;
425: }else{
426: if (a[i] < ans) ans = a[i];
427: }
428: }
429: }else{
430: if (a < ans) ans = a;
431: }
432: return(ans);
433: }
434: def SmaxOfStrategy(a) {
435: local n,i,ans,tt;
436: ans = -100000; /* very small number */
437: if (IsArray(a)) {
438: n = Length(a);
439: for (i=0; i<n; i++) {
440: if (IsArray(a[i])) {
441: tt = SmaxOfStrategy(a[i]);
442: if (tt > ans) ans = tt;
443: }else{
444: if (a[i] > ans) ans = a[i];
445: }
446: }
447: }else{
448: if (a > ans) ans = a;
449: }
450: return(ans);
451: }
452:
453:
1.15 takayama 454: def SlaScala(g,opt) {
1.1 takayama 455: local rf, tower, reductionTable, skel, redundantTable, bases,
456: strategy, maxOfStrategy, height, level, n, i,
457: freeRes,place, f, reducer,pos, redundant_seq,bettiTable,freeResV,ww,
1.4 takayama 458: redundantTable_ordinary, redundant_seq_ordinary,
459: reductionTable_tmp;
1.1 takayama 460: /* extern WeightOfSweyl; */
461: ww = WeightOfSweyl;
1.6 takayama 462: Print("WeightOfSweyl="); Println(WeightOfSweyl);
1.15 takayama 463: rf = SresolutionFrameWithTower(g,opt);
1.14 takayama 464: Print("rf="); sm1_pmat(rf);
1.1 takayama 465: redundant_seq = 1; redundant_seq_ordinary = 1;
466: tower = rf[1];
1.16 takayama 467:
468: Println("Generating reduction table which gives an order of reduction.");
469: Print("WeghtOfSweyl="); Println(WeightOfSweyl);
470: Print("tower"); Println(tower);
1.1 takayama 471: reductionTable = SgenerateTable(tower);
1.16 takayama 472: Print("reductionTable="); sm1_pmat(reductionTable);
473:
1.1 takayama 474: skel = rf[2];
475: redundantTable = SnewArrayOfFormat(rf[1]);
476: redundantTable_ordinary = SnewArrayOfFormat(rf[1]);
477: reducer = SnewArrayOfFormat(rf[1]);
478: freeRes = SnewArrayOfFormat(rf[1]);
479: bettiTable = SsetBettiTable(rf[1],g);
480:
481: strategy = SminOfStrategy( reductionTable );
482: maxOfStrategy = SmaxOfStrategy( reductionTable );
483: height = Length(reductionTable);
484: while (strategy <= maxOfStrategy) {
485: for (level = 0; level < height; level++) {
486: n = Length(reductionTable[level]);
1.4 takayama 487: reductionTable_tmp = ScopyArray(reductionTable[level]);
488: while (SthereIs(reductionTable_tmp,strategy)) {
489: i = SnextI(reductionTable_tmp,strategy,redundantTable,
490: skel,level,freeRes);
491: Println([level,i]);
492: reductionTable_tmp[i] = -200000;
1.1 takayama 493: if (reductionTable[level,i] == strategy) {
1.16 takayama 494: Print("Processing [level,i]= "); Print([level,i]);
1.1 takayama 495: Print(" Strategy = "); Println(strategy);
496: if (level == 0) {
497: if (IsNull(redundantTable[level,i])) {
498: bases = freeRes[level];
499: /* Println(["At floor : GB=",i,bases,tower[0,i]]); */
500: pos = SwhereInGB(tower[0,i],rf[3,0]);
501: bases[i] = rf[3,0,pos];
502: redundantTable[level,i] = 0;
503: redundantTable_ordinary[level,i] = 0;
504: freeRes[level] = bases;
505: /* Println(["GB=",i,bases,tower[0,i]]); */
506: }
507: }else{ /* level >= 1 */
508: if (IsNull(redundantTable[level,i])) {
509: bases = freeRes[level];
510: f = SpairAndReduction(skel,level,i,freeRes,tower,ww);
511: if (f[0] != Poly("0")) {
512: place = f[3];
513: /* (level-1, place) is the place for f[0],
514: which is a newly obtained GB. */
515: #ifdef ORDINARY
516: redundantTable[level-1,place] = redundant_seq;
517: redundant_seq++;
518: #else
519: if (f[4] > f[5]) {
520: /* Zero in the gr-module */
521: Print("v-degree of [org,remainder] = ");
522: Println([f[4],f[5]]);
523: Print("[level,i] = "); Println([level,i]);
524: redundantTable[level-1,place] = 0;
525: }else{
526: redundantTable[level-1,place] = redundant_seq;
527: redundant_seq++;
528: }
529: #endif
530: redundantTable_ordinary[level-1,place]
531: =redundant_seq_ordinary;
532: redundant_seq_ordinary++;
533: bases[i] = SunitOfFormat(place,f[1])-f[1]; /* syzygy */
534: redundantTable[level,i] = 0;
535: redundantTable_ordinary[level,i] = 0;
536: /* i must be equal to f[2], I think. Double check. */
537: freeRes[level] = bases;
538: bases = freeRes[level-1];
539: bases[place] = f[0];
540: freeRes[level-1] = bases;
541: reducer[level-1,place] = f[1];
542: }else{
543: redundantTable[level,i] = 0;
544: bases = freeRes[level];
545: bases[i] = f[1]; /* Put the syzygy. */
546: freeRes[level] = bases;
547: }
548: }
549: } /* end of level >= 1 */
550: }
551: }
552: }
553: strategy++;
554: }
555: n = Length(freeRes);
556: freeResV = SnewArrayOfFormat(freeRes);
557: for (i=0; i<n; i++) {
558: bases = freeRes[i];
559: bases = Sbases_to_vec(bases,bettiTable[i]);
560: freeResV[i] = bases;
561: }
1.17 takayama 562: return([freeResV, redundantTable,reducer,bettiTable,redundantTable_ordinary,rf]);
1.1 takayama 563: }
1.4 takayama 564:
565: def SthereIs(reductionTable_tmp,strategy) {
566: local n,i;
567: n = Length(reductionTable_tmp);
568: for (i=0; i<n; i++) {
569: if (reductionTable_tmp[i] == strategy) {
570: return(true);
571: }
572: }
573: return(false);
574: }
575:
576: def SnextI(reductionTable_tmp,strategy,redundantTable,
577: skel,level,freeRes)
578: {
579: local ii,n,p,myindex,i,j,bases;
580: n = Length(reductionTable_tmp);
581: if (level == 0) {
582: for (ii=0; ii<n; ii++) {
583: if (reductionTable_tmp[ii] == strategy) {
584: return(ii);
585: }
586: }
587: }else{
588: for (ii=0; ii<n; ii++) {
589: if (reductionTable_tmp[ii] == strategy) {
590: p = skel[level,ii];
591: myindex = p[0];
592: i = myindex[0]; j = myindex[1];
593: bases = freeRes[level-1];
594: if (IsNull(bases[i]) || IsNull(bases[j])) {
595:
596: }else{
597: return(ii);
598: }
599: }
600: }
601: }
1.5 takayama 602: Print("reductionTable_tmp=");
1.4 takayama 603: Println(reductionTable_tmp);
1.5 takayama 604: Println("See also reductionTable, strategy, level,i");
1.4 takayama 605: Error("SnextI: bases[i] or bases[j] is null for all combinations.");
606: }
607:
608:
1.1 takayama 609:
610: def SsetBettiTable(freeRes,g) {
611: local level,i, n,bases,ans;
612: ans = NewArray(Length(freeRes)+1);
613: n = Length(freeRes);
614: if (IsArray(g[0])) {
615: ans[0] = Length(g[0]);
616: }else{
617: ans[0] = 1;
618: }
619: for (level=0; level<n; level++) {
620: bases = freeRes[level];
621: if (IsArray(bases)) {
622: ans[level+1] = Length(bases);
623: }else{
624: ans[level+1] = 1;
625: }
626: }
627: return(ans);
628: }
629:
630: def SwhereInGB(f,tower) {
631: local i,n,p,q;
632: n = Length(tower);
633: for (i=0; i<n; i++) {
634: p = MonomialPart(tower[i]);
635: q = MonomialPart(f);
636: if (p == q) return(i);
637: }
638: Println([f,tower]);
639: Error("whereInGB : [f,myset]: f could not be found in the myset.");
640: }
641: def SunitOfFormat(pos,forms) {
642: local ans,i,n;
643: n = Length(forms);
644: ans = NewArray(n);
645: for (i=0; i<n; i++) {
646: if (i != pos) {
647: ans[i] = Poly("0");
648: }else{
649: ans[i] = Poly("1");
650: }
651: }
652: return(ans);
653: }
654:
655: def Error(s) {
656: sm1(" s error ");
657: }
658:
659: def IsNull(s) {
660: if (Stag(s) == 0) return(true);
661: else return(false);
662: }
663:
664: def StowerOf(tower,level) {
665: local ans,i;
666: ans = [ ];
667: if (level == 0) return([[]]);
668: for (i=0; i<level; i++) {
669: ans = Append(ans,tower[i]);
670: }
671: return(Reverse(ans));
672: }
673:
674: def Sspolynomial(f,g) {
675: if (IsArray(f)) {
676: f = Stoes_vec(f);
677: }
678: if (IsArray(g)) {
679: g = Stoes_vec(g);
680: }
681: sm1("f g spol /FunctionValue set");
682: }
683:
684: def MonomialPart(f) {
685: sm1(" [(lmonom) f] gbext /FunctionValue set ");
686: }
687:
1.14 takayama 688: /* WARNING:
689: When you use SwhereInTower, you have to change gbList
690: as below. Ofcourse, you should restrore the gbList
691: SsetTower(StowerOf(tower,level));
692: pos = SwhereInTower(syzHead,tower[level]);
693: */
1.1 takayama 694: def SwhereInTower(f,tower) {
695: local i,n,p,q;
696: if (f == Poly("0")) return(-1);
697: n = Length(tower);
698: for (i=0; i<n; i++) {
699: p = MonomialPart(tower[i]);
700: q = MonomialPart(f);
701: if (p == q) return(i);
702: }
703: Println([f,tower]);
704: Error("[f,tower]: f could not be found in the tower.");
705: }
706:
707: def Stag(f) {
708: sm1(f," tag (universalNumber) dc /FunctionValue set");
709: }
710:
711: def SpairAndReduction(skel,level,ii,freeRes,tower,ww) {
712: local i, j, myindex, p, bases, tower2, gi, gj,
713: si, sj, tmp, t_syz, pos, ans, ssp, syzHead,pos2,
714: vdeg,vdeg_reduced;
715: Println("SpairAndReduction:");
716:
717: if (level < 1) Error("level should be >= 1 in SpairAndReduction.");
718: p = skel[level,ii];
719: myindex = p[0];
720: i = myindex[0]; j = myindex[1];
721: bases = freeRes[level-1];
722: Println(["p and bases ",p,bases]);
723: if (IsNull(bases[i]) || IsNull(bases[j])) {
724: Println([level,i,j,bases[i],bases[j]]);
725: Error("level, i, j : bases[i], bases[j] must not be NULL.");
726: }
727:
728: tower2 = StowerOf(tower,level-1);
729: SsetTower(tower2);
1.14 takayama 730: Println(["level=",level]);
731: Println(["tower2=",tower2]);
1.1 takayama 732: /** sm1(" show_ring "); */
733:
734: gi = Stoes_vec(bases[i]);
735: gj = Stoes_vec(bases[j]);
736:
737: ssp = Sspolynomial(gi,gj);
738: si = ssp[0,0];
739: sj = ssp[0,1];
740: syzHead = si*es^i;
741: /* This will be the head term, I think. But, double check. */
742: Println([si*es^i,sj*es^j]);
743:
744: Print("[gi, gj] = "); Println([gi,gj]);
745: sm1(" [(Homogenize)] system_variable message ");
746: Print("Reduce the element "); Println(si*gi+sj*gj);
747: Print("by "); Println(bases);
748:
749: tmp = Sreduction(si*gi+sj*gj, bases);
750:
751: Print("result is "); Println(tmp);
752:
1.3 takayama 753: /* This is essential part for V-minimal resolution. */
754: /* vdeg = SvDegree(si*gi+sj*gj,tower,level-1,ww); */
755: vdeg = SvDegree(si*gi,tower,level-1,ww);
1.1 takayama 756: vdeg_reduced = SvDegree(tmp[0],tower,level-1,ww);
757: Print("vdegree of the original = "); Println(vdeg);
758: Print("vdegree of the remainder = "); Println(vdeg_reduced);
759:
760: t_syz = tmp[2];
761: si = si*tmp[1]+t_syz[i];
762: sj = sj*tmp[1]+t_syz[j];
763: t_syz[i] = si;
764: t_syz[j] = sj;
1.14 takayama 765:
766: SsetTower(StowerOf(tower,level));
1.1 takayama 767: pos = SwhereInTower(syzHead,tower[level]);
1.14 takayama 768:
769: SsetTower(StowerOf(tower,level-1));
1.1 takayama 770: pos2 = SwhereInTower(tmp[0],tower[level-1]);
771: ans = [tmp[0],t_syz,pos,pos2,vdeg,vdeg_reduced];
772: /* pos is the place to put syzygy at level. */
773: /* pos2 is the place to put a new GB at level-1. */
774: Println(ans);
775: return(ans);
776: }
777:
778: def Sreduction(f,myset) {
779: local n, indexTable, set2, i, j, tmp, t_syz;
780: n = Length(myset);
781: indexTable = NewArray(n);
782: set2 = [ ];
783: j = 0;
784: for (i=0; i<n; i++) {
785: if (IsNull(myset[i])) {
786: indexTable[i] = -1;
787: /* }else if (myset[i] == Poly("0")) {
788: indexTable[i] = -1; */
789: }else{
790: set2 = Append(set2,Stoes_vec(myset[i]));
791: indexTable[i] = j;
792: j++;
793: }
794: }
795: sm1(" f toes set2 (gradedPolySet) dc reduction /tmp set ");
796: t_syz = NewArray(n);
797: for (i=0; i<n; i++) {
798: if (indexTable[i] != -1) {
799: t_syz[i] = tmp[2, indexTable[i]];
800: }else{
801: t_syz[i] = Poly("0");
802: }
803: }
804: return([tmp[0],tmp[1],t_syz]);
805: }
806:
807: def Warning(s) {
808: Print("Warning: ");
809: Println(s);
810: }
811: def RingOf(f) {
812: local r;
813: if (IsPolynomial(f)) {
814: if (f != Poly("0")) {
815: sm1(f," (ring) dc /r set ");
816: }else{
817: sm1(" [(CurrentRingp)] system_variable /r set ");
818: }
819: }else{
820: Warning("RingOf(f): the argument f must be a polynomial. Return the current ring.");
821: sm1(" [(CurrentRingp)] system_variable /r set ");
822: }
823: return(r);
824: }
825:
826: def Sfrom_es(f,size) {
827: local c,ans, i, d, myes, myee, j,n,r,ans2;
828: if (Length(Arglist) < 2) size = -1;
829: if (IsArray(f)) return(f);
830: r = RingOf(f);
831: myes = PolyR("es",r);
832: myee = PolyR("e_",r);
833: if (Degree(f,myee) > 0 && size == -1) {
834: if (size == -1) {
835: sm1(f," (array) dc /ans set");
836: return(ans);
837: }
838: }
839:
840: /*
841: Coefficients(x^2-1,x):
842: [ [ 2 , 0 ] , [ 1 , -1 ] ]
843: */
844: if (Degree(f,myee) > 0) {
845: c = Coefficients(f,myee);
846: }else{
847: c = Coefficients(f,myes);
848: }
849: if (size < 0) {
850: size = c[0,0]+1;
851: }
852: ans = NewArray(size);
853: for (i=0; i<size; i++) {ans[i] = 0;}
854: n = Length(c[0]);
855: for (j=0; j<n; j++) {
856: d = c[0,j];
857: ans[d] = c[1,j];
858: }
859: return(ans);
860: }
861:
862: def Sbases_to_vec(bases,size) {
863: local n, giveSize, newbases,i;
864: /* bases = [1+es*x, [1,2,3*x]] */
865: if (Length(Arglist) > 1) {
866: giveSize = true;
867: }else{
868: giveSize = false;
869: }
870: n = Length(bases);
871: newbases = NewArray(n);
872: for (i=0; i<n; i++) {
873: if (giveSize) {
874: newbases[i] = Sfrom_es(bases[i], size);
875: }else{
876: newbases[i] = Sfrom_es(bases[i]);
877: }
878: }
879: return(newbases);
880: }
881:
1.14 takayama 882: HelpAdd(["Sminimal",
1.18 ! takayama 883: ["It constructs the V-minimal free resolution by LaScala's algorithm",
1.15 takayama 884: "option: \"homogenized\" (no automatic homogenization ",
1.14 takayama 885: "Example: Sweyl(\"x,y\",[[\"x\",-1,\"y\",-1,\"Dx\",1,\"Dy\",1]]);",
886: " v=[[2*x*Dx + 3*y*Dy+6, 0],",
887: " [3*x^2*Dy + 2*y*Dx, 0],",
888: " [0, x^2+y^2],",
889: " [0, x*y]];",
890: " a=Sminimal(v);",
891: " Sweyl(\"x,y\",[[\"x\",-1,\"y\",-1,\"Dx\",1,\"Dy\",1]]);",
892: " b = ReParse(a[0]); sm1_pmat(b); ",
893: " IsExact_h(b,[x,y]):",
894: "Note: a[0] is the V-minimal resolution. a[3] is the Schreyer resolution."]]);
895:
1.15 takayama 896: def Sminimal(g,opt) {
1.1 takayama 897: local r, freeRes, redundantTable, reducer, maxLevel,
898: minRes, seq, maxSeq, level, betti, q, bases, dr,
1.14 takayama 899: betti_levelplus, newbases, i, j,qq, tminRes;
1.16 takayama 900: if (Length(Arglist) < 2) {
901: opt = null;
902: }
903: ScheckIfSchreyer("Sminimal:0");
1.15 takayama 904: r = SlaScala(g,opt);
1.1 takayama 905: /* Should I turn off the tower?? */
1.16 takayama 906: ScheckIfSchreyer("Sminimal:1");
1.1 takayama 907: freeRes = r[0];
908: redundantTable = r[1];
909: reducer = r[2];
910: minRes = SnewArrayOfFormat(freeRes);
911: seq = 0;
912: maxSeq = SgetMaxSeq(redundantTable);
913: maxLevel = Length(freeRes);
914: for (level = 0; level < maxLevel; level++) {
915: minRes[level] = freeRes[level];
916: }
917: seq=maxSeq+1;
918: while (seq > 1) {
919: seq--;
920: for (level = 0; level < maxLevel; level++) {
921: betti = Length(freeRes[level]);
922: for (q = 0; q<betti; q++) {
923: if (redundantTable[level,q] == seq) {
924: Print("[seq,level,q]="); Println([seq,level,q]);
925: if (level < maxLevel-1) {
926: bases = freeRes[level+1];
927: dr = reducer[level,q];
928: dr[q] = -1;
929: newbases = SnewArrayOfFormat(bases);
930: betti_levelplus = Length(bases);
931: /*
932: bases[i,j] ---> bases[i,j]+bases[i,q]*dr[j]
933: */
934: for (i=0; i<betti_levelplus; i++) {
935: newbases[i] = bases[i] + bases[i,q]*dr;
936: }
937: Println(["level, q =", level,q]);
938: Println("bases="); sm1_pmat(bases);
939: Println("dr="); sm1_pmat(dr);
940: Println("newbases="); sm1_pmat(newbases);
941: minRes[level+1] = newbases;
942: freeRes = minRes;
943: #ifdef DEBUG
944: for (qq=0; qq<betti; qq++) {
945: if ((redundantTable[level,qq] >= seq) &&
946: (redundantTable[level,qq] <= maxSeq)) {
947: for (i=0; i<betti_levelplus; i++) {
948: if (!IsZero(newbases[i,qq])) {
949: Println(["[i,qq]=",[i,qq]," is not zero in newbases."]);
950: Print("redundantTable ="); sm1_pmat(redundantTable[level]);
951: Error("Stop in Sminimal for debugging.");
952: }
953: }
954: }
955: }
956: #endif
957: }
958: }
959: }
960: }
961: }
1.14 takayama 962: tminRes = Stetris(minRes,redundantTable);
963: return([SpruneZeroRow(tminRes), tminRes,
1.17 takayama 964: [ minRes, redundantTable, reducer,r[3],r[4]],r[0],r[5]]);
1.1 takayama 965: /* r[4] is the redundantTable_ordinary */
1.3 takayama 966: /* r[0] is the freeResolution */
1.17 takayama 967: /* r[5] is the skelton */
1.1 takayama 968: }
969:
970:
971: def IsZero(f) {
972: if (IsPolynomial(f)) {
973: return( f == Poly("0"));
974: }else if (IsInteger(f)) {
975: return( f == 0);
976: }else if (IsSm1Integer(f)) {
977: return( f == true );
978: }else if (IsDouble(f)) {
979: return( f == 0.0 );
980: }else if (IsRational(f)) {
981: return(IsZero(Denominator(f)));
982: }else{
983: Error("IsZero: cannot deal with this data type.");
984: }
985: }
986: def SgetMaxSeq(redundantTable) {
987: local level,i,n,ans, levelMax,bases;
988: levelMax = Length( redundantTable );
989: ans = 0;
990: for (level = 0; level < levelMax; level++) {
991: bases = redundantTable[level];
992: n = Length(bases);
993: for (i=0; i<n; i++) {
994: if (IsInteger( bases[i] )) {
995: if (bases[i] > ans) {
996: ans = bases[i];
997: }
998: }
999: }
1000: }
1001: return(ans);
1002: }
1003:
1004: def Stetris(freeRes,redundantTable) {
1005: local level, i, j, resLength, minRes,
1006: bases, newbases, newbases2;
1007: minRes = SnewArrayOfFormat(freeRes);
1008: resLength = Length( freeRes );
1009: for (level=0; level<resLength; level++) {
1010: bases = freeRes[level];
1011: newbases = SnewArrayOfFormat(bases);
1012: betti = Length(bases); j = 0;
1013: /* Delete rows */
1014: for (i=0; i<betti; i++) {
1015: if (redundantTable[level,i] < 1) {
1016: newbases[j] = bases[i];
1017: j++;
1018: }
1019: }
1020: bases = SfirstN(newbases,j);
1021: if (level > 0) {
1022: /* Delete columns */
1023: newbases = Transpose(bases);
1024: betti = Length(newbases); j = 0;
1025: newbases2 = SnewArrayOfFormat(newbases);
1026: for (i=0; i<betti; i++) {
1027: if (redundantTable[level-1,i] < 1) {
1028: newbases2[j] = newbases[i];
1029: j++;
1030: }
1031: }
1032: newbases = Transpose(SfirstN(newbases2,j));
1033: }else{
1034: newbases = bases;
1035: }
1036: Println(["level=", level]);
1037: sm1_pmat(bases);
1038: sm1_pmat(newbases);
1039:
1040: minRes[level] = newbases;
1041: }
1042: return(minRes);
1043: }
1044:
1045: def SfirstN(bases,k) {
1046: local ans,i;
1047: ans = NewArray(k);
1048: for (i=0; i<k; i++) {
1049: ans[i] = bases[i];
1050: }
1051: return(ans);
1052: }
1053:
1054:
1055: /* usage: tt is tower. ww is weight.
1056: a = SresolutionFrameWithTower(v);
1057: tt = a[1];
1058: ww = [x,1,y,1,Dx,1,Dy,1];
1059: SvDegree(x*es,tt,1,ww):
1060:
1061: In(17)=tt:
1062: [[2*x*Dx , e_*x^2 , e_*x*y , 3*x^2*Dy , e_*y^3 , 9*x*y*Dy^2 , 27*y^2*Dy^3 ] ,
1063: [es*y , 3*es^3*y*Dy , 3*es^5*y*Dy , 3*x*Dy , es^2*y^2 , 9*y*Dy^2 ] ,
1064: [3*es^3*y*Dy ] ]
1065: In(18)=SvDegree(x*es,tt,1,ww):
1066: 3
1067: In(19)=SvDegree(x*es^3,tt,1,ww):
1068: 4
1069: In(20)=SvDegree(x,tt,2,ww):
1070: 4
1071:
1072: */
1073: def SvDegree(f,tower,level,w) {
1074: local i,ans;
1075: if (IsZero(f)) return(null);
1.3 takayama 1076: f = Init(f);
1.1 takayama 1077: if (level <= 0) {
1078: return(Sord_w(f,w));
1079: }
1080: i = Degree(f,es);
1081: ans = Sord_w(f,w) +
1082: SvDegree(tower[level-1,i],tower,level-1,w);
1083: return(ans);
1084: }
1085:
1.2 takayama 1086: def Sannfs(f,v) {
1087: local f2;
1088: f2 = ToString(f);
1089: if (IsArray(v)) {
1090: v = Map(v,"ToString");
1091: }
1092: sm1(" [f2 v] annfs /FunctionValue set ");
1093: }
1094:
1095: /* Sannfs2("x^3-y^2"); */
1096: def Sannfs2(f) {
1097: local p,pp;
1098: p = Sannfs(f,"x,y");
1.6 takayama 1099: sm1(" p 0 get { [(x) (y) (Dx) (Dy)] laplace0 } map /p set ");
1100: Sweyl("x,y",[["x",-1,"y",-1,"Dx",1,"Dy",1]]);
1101: pp = Map(p,"Spoly");
1.18 ! takayama 1102: return(Sminimal(pp));
1.6 takayama 1103: }
1104:
1.10 takayama 1105: HelpAdd(["Sannfs2",
1106: ["Sannfs2(f) constructs the V-minimal free resolution for the weight (-1,1)",
1107: "of the Laplace transform of the annihilating ideal of the polynomial f in x,y.",
1.18 ! takayama 1108: "See also Sminimal, Sannfs3.",
1.10 takayama 1109: "Example: a=Sannfs2(\"x^3-y^2\");",
1110: " b=a[0]; sm1_pmat(b);",
1111: " b[1]*b[0]:",
1112: "Example: a=Sannfs2(\"x*y*(x-y)*(x+y)\");",
1113: " b=a[0]; sm1_pmat(b);",
1114: " b[1]*b[0]:"
1115: ]]);
1.18 ! takayama 1116: /* Some samples.
! 1117: The betti numbers of most examples are 2,1. (0-th and 1-th).
! 1118: a=Sannfs2("x*y*(x+y-1)"); ==> The betti numbers are 3, 2.
! 1119: a=Sannfs2("x^3-y^2-x");
! 1120: a=Sannfs2("x*y*(x-y)");
! 1121: */
1.10 takayama 1122:
1.11 takayama 1123:
1.3 takayama 1124: def Sannfs3(f) {
1125: local p,pp;
1126: p = Sannfs(f,"x,y,z");
1.6 takayama 1127: sm1(" p 0 get { [(x) (y) (z) (Dx) (Dy) (Dz)] laplace0 } map /p set ");
1.3 takayama 1128: Sweyl("x,y,z",[["x",-1,"y",-1,"z",-1,"Dx",1,"Dy",1,"Dz",1]]);
1.6 takayama 1129: pp = Map(p,"Spoly");
1.18 ! takayama 1130: return(Sminimal(pp));
1.3 takayama 1131: }
1132:
1.10 takayama 1133: HelpAdd(["Sannfs3",
1134: ["Sannfs3(f) constructs the V-minimal free resolution for the weight (-1,1)",
1135: "of the Laplace transform of the annihilating ideal of the polynomial f in x,y,z.",
1.18 ! takayama 1136: "See also Sminimal, Sannfs2.",
1.10 takayama 1137: "Example: a=Sannfs3(\"x^3-y^2*z^2\");",
1138: " b=a[0]; sm1_pmat(b);",
1139: " b[1]*b[0]: b[2]*b[1]:"]]);
1140:
1.2 takayama 1141:
1.6 takayama 1142:
1143: /* Sannfs2("x*y*(x-y)*(x+y)"); is a test problem */
1.10 takayama 1144: /* x y (x+y-1)(x-2), x^3-y^2, x^3 - y^2 z^2,
1145: x y z (x+y+z-1) seems to be interesting, because the first syzygy
1146: contains 1.
1147: */
1148:
1149: def CopyArray(m) {
1150: local ans,i,n;
1151: if (IsArray(m)) {
1152: n = Length(m);
1153: ans = NewArray(n);
1154: for (i=0; i<n; i++) {
1155: ans[i] = CopyArray(m[i]);
1156: }
1157: return(ans);
1158: }else{
1159: return(m);
1160: }
1161: }
1162: HelpAdd(["CopyArray",
1163: ["It duplicates the argument array recursively.",
1164: "Example: m=[1,[2,3]];",
1165: " a=CopyArray(m); a[1] = \"Hello\";",
1166: " Println(m); Println(a);"]]);
1167:
1168: def IsZeroVector(m) {
1169: local n,i;
1170: n = Length(m);
1171: for (i=0; i<n; i++) {
1172: if (!IsZero(m[i])) {
1173: return(false);
1174: }
1175: }
1176: return(true);
1177: }
1178:
1179: def SpruneZeroRow(res) {
1180: local minRes, n,i,j,m, base,base2,newbase,newbase2, newMinRes;
1181:
1182: minRes = CopyArray(res);
1183: n = Length(minRes);
1184: for (i=0; i<n; i++) {
1185: base = minRes[i];
1186: m = Length(base);
1187: if (i != n-1) {
1188: base2 = minRes[i+1];
1189: base2 = Transpose(base2);
1190: }
1191: newbase = [ ];
1192: newbase2 = [ ];
1193: for (j=0; j<m; j++) {
1194: if (!IsZeroVector(base[j])) {
1195: newbase = Append(newbase,base[j]);
1196: if (i != n-1) {
1197: newbase2 = Append(newbase2,base2[j]);
1198: }
1199: }
1200: }
1201: minRes[i] = newbase;
1202: if (i != n-1) {
1203: if (newbase2 == [ ]) {
1204: minRes[i+1] = [ ];
1205: }else{
1206: minRes[i+1] = Transpose(newbase2);
1207: }
1208: }
1209: }
1210:
1211: newMinRes = [ ];
1212: n = Length(minRes);
1213: i = 0;
1214: while (i < n ) {
1215: base = minRes[i];
1216: if (base == [ ]) {
1217: i = n; /* break; */
1218: }else{
1219: newMinRes = Append(newMinRes,base);
1220: }
1221: i++;
1222: }
1223: return(newMinRes);
1224: }
1225:
1226: def testAnnfs2(f) {
1227: local a,i,n;
1228: a = Sannfs2(f);
1229: b=a[0];
1230: n = Length(b);
1231: Println("------ V-minimal free resolution -----");
1232: sm1_pmat(b);
1233: Println("----- Is it complex? ---------------");
1234: for (i=0; i<n-1; i++) {
1235: Println(b[i+1]*b[i]);
1236: }
1237: return(a);
1238: }
1239: def testAnnfs3(f) {
1240: local a,i,n;
1241: a = Sannfs3(f);
1242: b=a[0];
1243: n = Length(b);
1244: Println("------ V-minimal free resolution -----");
1245: sm1_pmat(b);
1246: Println("----- Is it complex? ---------------");
1247: for (i=0; i<n-1; i++) {
1248: Println(b[i+1]*b[i]);
1249: }
1.11 takayama 1250: return(a);
1251: }
1252:
1253: def ToString_array(p) {
1254: local ans;
1255: if (IsArray(p)) {
1256: ans = Map(p,"ToString_array");
1257: }else{
1258: ans = ToString(p);
1259: }
1260: return(ans);
1261: }
1262:
1263: /* sm1_res_div([[x],[y]],[[x^2],[x*y],[y^2]],[x,y]): */
1264:
1265: def sm1_res_div(I,J,V) {
1266: I = ToString_array(I);
1267: J = ToString_array(J);
1268: V = ToString_array(V);
1269: sm1(" [[ I J] V ] res*div /FunctionValue set ");
1270: }
1271:
1272: /* It has not yet been working */
1273: def sm1_res_kernel_image(m,n,v) {
1274: m = ToString_array(m);
1275: n = ToString_array(n);
1276: v = ToString_array(v);
1277: sm1(" [m n v] res-kernel-image /FunctionValue set ");
1278: }
1279: def Skernel(m,v) {
1280: m = ToString_array(m);
1281: v = ToString_array(v);
1282: sm1(" [ m v ] syz /FunctionValue set ");
1283: }
1284:
1285:
1286: def sm1_gb(f,v) {
1287: f =ToString_array(f);
1288: v = ToString_array(v);
1289: sm1(" [f v] gb /FunctionValue set ");
1.13 takayama 1290: }
1291:
1.11 takayama 1292:
1.12 takayama 1293: def SisComplex(a) {
1294: local n,i,j,k,b,p,q;
1295: n = Length(a);
1296: for (i=0; i<n-1; i++) {
1297: if (Length(a[i+1]) != 0) {
1298: b = a[i+1]*a[i];
1299: p = Length(b); q = Length(b[0]);
1300: for (j=0; j<p; j++) {
1301: for (k=0; k<q; k++) {
1302: if (!IsZero(b[j,k])) {
1303: Print("Is is not complex at ");
1304: Println([i,j,k]);
1305: return(false);
1306: }
1307: }
1308: }
1309: }
1310: }
1311: return(true);
1.14 takayama 1312: }
1313:
1314: def IsExact_h(c,v) {
1315: local a;
1316: v = ToString_array(v);
1317: a = [c,v];
1318: sm1(a," isExact_h /FunctionValue set ");
1319: }
1320: HelpAdd(["IsExact_h",
1321: ["IsExact_h(complex,var): bool",
1322: "It checks the given complex is exact or not in D<h> (homogenized Weyl algebra)",
1323: "cf. ReParse"
1324: ]]);
1325:
1326: def ReParse(a) {
1327: local c;
1328: if (IsArray(a)) {
1329: c = Map(a,"ReParse");
1330: }else{
1331: sm1(a," toString . /c set");
1332: }
1333: return(c);
1334: }
1335: HelpAdd(["ReParse",
1336: ["Reparse(obj): obj",
1337: "It parses the given object in the current ring.",
1338: "Outputs from SlaScala, Sschreyer may cause a trouble in other functions,",
1339: "because it uses the Schreyer order.",
1340: "In this case, ReParse the outputs from these functions.",
1341: "cf. IsExaxt_h"
1342: ]]);
1.16 takayama 1343:
1344: def ScheckIfSchreyer(s) {
1345: local ss;
1346: sm1(" (report) (grade) switch_function /ss set ");
1347: if (ss != "module1v") {
1348: Print("ScheckIfSchreyer: from "); Println(s);
1349: Error("grade is not module1v");
1350: }
1351: /*
1352: sm1(" (report) (mmLarger) switch_function /ss set ");
1353: if (ss != "tower") {
1354: Print("ScheckIfSchreyer: from "); Println(s);
1355: Error("mmLarger is not tower");
1356: }
1357: */
1358: sm1(" [(Schreyer)] system_variable (universalNumber) dc /ss set ");
1359: if (ss != 1) {
1360: Print("ScheckIfSchreyer: from "); Println(s);
1361: Error("Schreyer order is not set.");
1362: }
1363: /* More check will be necessary. */
1364: return(true);
1365: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>