=================================================================== RCS file: /home/cvs/OpenXM/src/k097/lib/minimal/minimal.k,v retrieving revision 1.6 retrieving revision 1.14 diff -u -p -r1.6 -r1.14 --- OpenXM/src/k097/lib/minimal/minimal.k 2000/05/06 07:58:37 1.6 +++ OpenXM/src/k097/lib/minimal/minimal.k 2000/06/09 08:04:54 1.14 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/k097/lib/minimal/minimal.k,v 1.5 2000/05/05 08:13:49 takayama Exp $ */ +/* $OpenXM: OpenXM/src/k097/lib/minimal/minimal.k,v 1.13 2000/06/08 08:37:53 takayama Exp $ */ #define DEBUG 1 /* #define ORDINARY 1 */ /* If you run this program on openxm version 1.1.2 (FreeBSD), @@ -6,7 +6,7 @@ ln -s /usr/bin/cpp /lib/cpp */ #define OFFSET 0 -#define TOTAL_STRATEGY +#define TOTAL_STRATEGY 1 /* #define OFFSET 20*/ /* Test sequences. Use load["minimal.k"];; @@ -37,6 +37,7 @@ def load_tower() { sm1(" [(parse) (k0-tower.sm1) pushfile ] extension "); sm1(" /k0-tower.sm1.loaded 1 def "); } + sm1(" oxNoX "); } load_tower(); SonAutoReduce = true; @@ -131,6 +132,7 @@ sm1(" [(AvoidTheSameRing)] pushEnv [ [(AvoidTheSameRing) 0] system_variable [(gbListTower) tower (list) dc] system_variable ] pop popEnv "); + /* sm1("(hoge) message show_ring "); */ } def SresolutionFrameWithTower(g,opt) { @@ -290,7 +292,10 @@ def Sres0FrameWithSkelton(g) { def StotalDegree(f) { - sm1(" [(grade) f] gbext (universalNumber) dc /FunctionValue set "); + local d0; + sm1(" [(grade) f] gbext (universalNumber) dc /d0 set "); + /* Print("degree of "); Print(f); Print(" is "); Println(d0); */ + return(d0); } /* Sord_w(x^2*Dx*Dy,[x,-1,Dx,1]); */ @@ -443,6 +448,7 @@ def SlaScala(g) { ww = WeightOfSweyl; Print("WeightOfSweyl="); Println(WeightOfSweyl); rf = SresolutionFrameWithTower(g); + Print("rf="); sm1_pmat(rf); redundant_seq = 1; redundant_seq_ordinary = 1; tower = rf[1]; reductionTable = SgenerateTable(tower); @@ -660,6 +666,12 @@ def MonomialPart(f) { sm1(" [(lmonom) f] gbext /FunctionValue set "); } +/* WARNING: + When you use SwhereInTower, you have to change gbList + as below. Ofcourse, you should restrore the gbList + SsetTower(StowerOf(tower,level)); + pos = SwhereInTower(syzHead,tower[level]); +*/ def SwhereInTower(f,tower) { local i,n,p,q; if (f == Poly("0")) return(-1); @@ -696,6 +708,8 @@ def SpairAndReduction(skel,level,ii,freeRes,tower,ww) tower2 = StowerOf(tower,level-1); SsetTower(tower2); + Println(["level=",level]); + Println(["tower2=",tower2]); /** sm1(" show_ring "); */ gi = Stoes_vec(bases[i]); @@ -729,7 +743,11 @@ def SpairAndReduction(skel,level,ii,freeRes,tower,ww) sj = sj*tmp[1]+t_syz[j]; t_syz[i] = si; t_syz[j] = sj; + + SsetTower(StowerOf(tower,level)); pos = SwhereInTower(syzHead,tower[level]); + + SsetTower(StowerOf(tower,level-1)); pos2 = SwhereInTower(tmp[0],tower[level-1]); ans = [tmp[0],t_syz,pos,pos2,vdeg,vdeg_reduced]; /* pos is the place to put syzygy at level. */ @@ -842,10 +860,23 @@ def Sbases_to_vec(bases,size) { return(newbases); } +HelpAdd(["Sminimal", +["It constructs the V-minimal free resolution by LaScala-Stillman's algorithm", + "Example: Sweyl(\"x,y\",[[\"x\",-1,\"y\",-1,\"Dx\",1,\"Dy\",1]]);", + " v=[[2*x*Dx + 3*y*Dy+6, 0],", + " [3*x^2*Dy + 2*y*Dx, 0],", + " [0, x^2+y^2],", + " [0, x*y]];", + " a=Sminimal(v);", + " Sweyl(\"x,y\",[[\"x\",-1,\"y\",-1,\"Dx\",1,\"Dy\",1]]);", + " b = ReParse(a[0]); sm1_pmat(b); ", + " IsExact_h(b,[x,y]):", + "Note: a[0] is the V-minimal resolution. a[3] is the Schreyer resolution."]]); + def Sminimal(g) { local r, freeRes, redundantTable, reducer, maxLevel, minRes, seq, maxSeq, level, betti, q, bases, dr, - betti_levelplus, newbases, i, j,qq; + betti_levelplus, newbases, i, j,qq, tminRes; r = SlaScala(g); /* Should I turn off the tower?? */ freeRes = r[0]; @@ -903,7 +934,8 @@ def Sminimal(g) { } } } - return([Stetris(minRes,redundantTable), + tminRes = Stetris(minRes,redundantTable); + return([SpruneZeroRow(tminRes), tminRes, [ minRes, redundantTable, reducer,r[3],r[4]],r[0]]); /* r[4] is the redundantTable_ordinary */ /* r[0] is the freeResolution */ @@ -1043,12 +1075,25 @@ def Sannfs2(f) { Sweyl("x,y",[["x",1,"y",1,"Dx",1,"Dy",1,"h",1], ["x",-1,"y",-1,"Dx",1,"Dy",1]]); */ /* Sweyl("x,y",[["x",1,"y",1,"Dx",1,"Dy",1,"h",1]]); */ + Sweyl("x,y",[["x",-1,"y",-1,"Dx",1,"Dy",1]]); pp = Map(p,"Spoly"); return(Sminimal_v(pp)); /* return(Sminimal(pp)); */ } +HelpAdd(["Sannfs2", +["Sannfs2(f) constructs the V-minimal free resolution for the weight (-1,1)", + "of the Laplace transform of the annihilating ideal of the polynomial f in x,y.", + "See also Sminimal_v, Sannfs3.", + "Example: a=Sannfs2(\"x^3-y^2\");", + " b=a[0]; sm1_pmat(b);", + " b[1]*b[0]:", + "Example: a=Sannfs2(\"x*y*(x-y)*(x+y)\");", + " b=a[0]; sm1_pmat(b);", + " b[1]*b[0]:" +]]); + /* Do not forget to turn on TOTAL_STRATEGY */ def Sannfs2_laScala(f) { local p,pp; @@ -1062,6 +1107,17 @@ def Sannfs2_laScala(f) { return(Sminimal(pp)); } +def Sannfs2_laScala2(f) { + local p,pp; + p = Sannfs(f,"x,y"); + sm1(" p 0 get { [(x) (y) (Dx) (Dy)] laplace0 } map /p set "); + p = [p]; + Sweyl("x,y",[["x",1,"y",1,"Dx",1,"Dy",1,"h",1], + ["x",-1,"y",-1,"Dx",1,"Dy",1]]); + pp = Map(p[0],"Spoly"); + return(Sminimal(pp)); +} + def Sannfs3(f) { local p,pp; p = Sannfs(f,"x,y,z"); @@ -1071,6 +1127,14 @@ def Sannfs3(f) { return(Sminimal_v(pp)); } +HelpAdd(["Sannfs3", +["Sannfs3(f) constructs the V-minimal free resolution for the weight (-1,1)", + "of the Laplace transform of the annihilating ideal of the polynomial f in x,y,z.", + "See also Sminimal_v, Sannfs2.", + "Example: a=Sannfs3(\"x^3-y^2*z^2\");", + " b=a[0]; sm1_pmat(b);", + " b[1]*b[0]: b[2]*b[1]:"]]); + /* The betti numbers of most examples are 2,1. (0-th and 1-th). a=Sannfs2("x*y*(x+y-1)"); ==> The betti numbers are 3, 2. @@ -1079,6 +1143,15 @@ def Sannfs3(f) { */ +def Sannfs3_laScala2(f) { + local p,pp; + p = Sannfs(f,"x,y,z"); + sm1(" p 0 get { [(x) (y) (z) (Dx) (Dy) (Dz)] laplace0 } map /p set "); + Sweyl("x,y,z",[["x",1,"y",1,"z",1,"Dx",1,"Dy",1,"Dz",1,"h",1], + ["x",-1,"y",-1,"z",-1,"Dx",1,"Dy",1,"Dz",1]]); + pp = Map(p,"Spoly"); + return(Sminimal(pp)); +} /* The below does not use LaScala-Stillman's algorithm. */ @@ -1152,22 +1225,49 @@ def Sschreyer(g) { /* i must be equal to f[2], I think. Double check. */ /* Correction Of Constant */ - c2 = -f[6]; /* or f[6]? Double check. */ + /* Correction of syzygy */ + c2 = f[6]; /* or -f[6]? Double check. */ + Print("c2="); Println(c2); nn = Length(bases); for (ii=0; ii=0; ii--) { if (!IsNull(reducerBase[ii])) { for (jj=ii-1; jj>=0; jj--) { if (!IsNull(reducerBase[jj])) { if (!IsZero(reducerBase[jj,ii])) { - reducerBase[jj] = reducerBase[jj]-reducerBase[jj,ii]*reducerBase[ii]; + /* reducerBase[ii,ii] should be always constant. */ + reducerBase[jj] = reducerBase[ii,ii]*reducerBase[jj]-reducerBase[jj,ii]*reducerBase[ii]; } } } @@ -1243,6 +1346,8 @@ def SpairAndReduction2(skel,level,ii,freeRes,tower,ww, tower2 = StowerOf(tower,level-1); SsetTower(tower2); + Println(["level=",level]); + Println(["tower2=",tower2]); /** sm1(" show_ring "); */ gi = Stoes_vec(bases[i]); @@ -1300,20 +1405,48 @@ def SpairAndReduction2(skel,level,ii,freeRes,tower,ww, Print("vdegree of the original = "); Println(vdeg); Print("vdegree of the remainder = "); Println(vdeg_reduced); + if (!IsNull(vdeg_reduced)) { + if (vdeg_reduced < vdeg) { + Println("--- Special in V-minimal!"); + Println(tmp[0]); + Println("syzygy="); sm1_pmat(t_syz); + Print("[vdeg, vdeg_reduced] = "); Println([vdeg,vdeg_reduced]); + } + } + + SsetTower(StowerOf(tower,level)); pos = SwhereInTower(syzHead,tower[level]); + + SsetTower(StowerOf(tower,level-1)); pos2 = SwhereInTower(tmp[0],tower[level-1]); ans = [tmp[0],t_syz,pos,pos2,vdeg,vdeg_reduced,c2]; /* pos is the place to put syzygy at level. */ /* pos2 is the place to put a new GB at level-1. */ Println(ans); - Println(" "); + Println("--- end of SpairAndReduction2 "); return(ans); } +HelpAdd(["Sminimal_v", +["It constructs the V-minimal free resolution from the Schreyer resolution", + "step by step.", + "This code still contains bugs. It sometimes outputs wrong answer.", + "Example: Sweyl(\"x,y\",[[\"x\",-1,\"y\",-1,\"Dx\",1,\"Dy\",1]]);", + " v=[[2*x*Dx + 3*y*Dy+6, 0],", + " [3*x^2*Dy + 2*y*Dx, 0],", + " [0, x^2+y^2],", + " [0, x*y]];", + " a=Sminimal_v(v);", + " sm1_pmat(a[0]); b=a[0]; b[1]*b[0]:", + "Note: a[0] is the V-minimal resolution. a[3] is the Schreyer resolution."]]); + +/* This code still contains bugs. It sometimes outputs wrong answer. */ +/* See test12() in minimal-test.k. */ +/* There may be remaining 1, too */ def Sminimal_v(g) { local r, freeRes, redundantTable, reducer, maxLevel, minRes, seq, maxSeq, level, betti, q, bases, dr, - betti_levelplus, newbases, i, j,qq; + betti_levelplus, newbases, i, j,qq,tminRes; r = Sschreyer(g); sm1_pmat(r); Debug_Sminimal_v = r; @@ -1337,14 +1470,15 @@ def Sminimal_v(g) { if (level < maxLevel-1) { bases = freeRes[level+1]; dr = reducer[level,q]; - dr[q] = -1; + /* dr[q] = -1; We do not need this in our reducer format. */ + /* dr[q] should be a non-zero constant. */ newbases = SnewArrayOfFormat(bases); betti_levelplus = Length(bases); /* bases[i,j] ---> bases[i,j]+bases[i,q]*dr[j] */ for (i=0; i (homogenized Weyl algebra)", + "cf. ReParse" +]]); + +def ReParse(a) { + local c; + if (IsArray(a)) { + c = Map(a,"ReParse"); + }else{ + sm1(a," toString . /c set"); + } + return(c); +} +HelpAdd(["ReParse", +["Reparse(obj): obj", + "It parses the given object in the current ring.", + "Outputs from SlaScala, Sschreyer may cause a trouble in other functions,", + "because it uses the Schreyer order.", + "In this case, ReParse the outputs from these functions.", + "cf. IsExaxt_h" +]]);