=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Doc/gfan.sm1,v retrieving revision 1.4 retrieving revision 1.8 diff -u -p -r1.4 -r1.8 --- OpenXM/src/kan96xx/Doc/gfan.sm1 2004/09/15 07:41:59 1.4 +++ OpenXM/src/kan96xx/Doc/gfan.sm1 2004/10/13 23:36:52 1.8 @@ -1,8 +1,259 @@ -% $OpenXM: OpenXM/src/kan96xx/Doc/gfan.sm1,v 1.3 2004/09/14 08:30:47 takayama Exp $ +% $OpenXM: OpenXM/src/kan96xx/Doc/gfan.sm1,v 1.7 2004/09/30 07:45:04 takayama Exp $ % cp cone.sm1 $OpenXM_HOME/src/kan96xx/Doc/gfan.sm1 -% $Id: gfan.sm1,v 1.4 2004/09/15 07:41:59 takayama Exp $ +% $Id: gfan.sm1,v 1.8 2004/10/13 23:36:52 takayama Exp $ % iso-2022-jp +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Two examples are given below to get a global Grobner fan and +%% a local Grobner fan ; cone.sample and cone.sample2 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Global Grobner Fan +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% How to input data? An example. (cf. test13.sm1) +%% Modify the following or copy the /cone.sample { ... } def +%% to your own file, +%% edit it, and execute if by " cone.sample ; " +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +/cone.sample { + cone.load.cohom +% write a comment about the problem. "nl" means new line. +/cone.comment [ + (Toric ideal for 1-simplex x 2-simplex, in k[x]) nl +] cat def + +% List of variables +% If cone.type=1, then (H) should be added. +/cone.vlist [(x11) (x12) (x13) (x21) (x22) (x23) + (Dx11) (Dx12) (Dx13) (Dx21) (Dx22) (Dx23) (h)] def + +% List of variables in the form for define_ring. +/cone.vv (x11,x12,x13,x21,x22,x23) def + +% If cone.type=0, then x,Dx, +% If cone.type=1, then x,Dx,h,H (Doubly homogenized) +% If cone.type=2, then x,Dx,h +/cone.type 2 def + +% Set how to parametrize the weight space. +% In the example below, 6 means the number of variables x11,x12,x13,x21,x22,x33 +% p q parametrizeSmallFan (p >= q) : Enumerate Grobner cones in the Small +% Grobner fan. +% The weights for the last p-q variables +% are 0. +% Example. 6 2 parametrizeSmallFan weights for x12,x21,x22,x23 are 0. +% +% p q parametrizeTotalFan (p = q = number of variables in cone.vv) +% p > q has not yet been implemented. +% +/cone.parametrizeWeightSpace { + 6 6 parametrizeSmallFan +} def + +% If you want to enumerate Grobner cones in local order (i.e., x^e <= 0), +% then cone.local = 1 else cone.local = 0. +/cone.local 0 def + +% Initial value of the weight in the weight space of which dimension is +% cone.m +% If it is null, then a random weight is used. +/cone.w_start + null +def + +% If cone.h0=1, then the weight for h is 0. +% It is usally set to 1. +/cone.h0 1 def + +% Set input polynomials which generate the ideal. +% Input must be homogenized. +% (see also data/test14.sm1 for double homogenization.) +/cone.input + [ + (x11 x22 - x12 x21) + (x12 x23 - x13 x22) + (x11 x23 - x13 x21) + ] +def + +% Set a function to compute Grobner basis. +% cone.gb_Dh : For computing in Homogenized Weyl algebra h[1,1](D). +% cone.gb_DhH : For computing in doubly homogenized Weyl algebra. +% ( Computation in ^O and h[0,1](^D) need this +% as the first step. /cone.local 1 def ) +/cone.gb { + cone.gb_Dh +} def + + +cone.comment message +(cone.input = ) message +cone.input message +%%%% Step 1. Enumerating the Grobner Cones in a global ring. +%%%% The result is stored in cone.fan +getGrobnerFan + +%%%% If you want to print the output, then uncomment. +printGrobnerFan + +%%%% If you want to save the data to the file sm1out.txt, then uncomment. +% /cone.wightGblist 1 def saveGrobnerFan /ff set ff output + +%%%% Step 2. Dehomogenize the Grobner Cones +%%%% by the equivalence relation in a local ring (uncomment). +% dhCones_h + +%%%% Generate the final data dhcone2.fan (a list of local Grobner cones.) +% dhcone.rtable + +%%%% Output dhcone2.fan with explanations +% dhcone.printGrobnerFan + +} def +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% End of " How to input data? An example. " +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Local Grobner Fan +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% How to input data? The example 2 (cf. test14.sm1). +%% Modify the following or copy the /cone.sample2 { ... } def +%% to your own file, +%% edit it, and execute if by " cone.sample2 ; " +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +/cone.sample2 { + cone.load.cohom +% write a comment about the problem. "nl" means new line. +/cone.comment [ + (BS for y and y-(x-1)^2, t1, t2 space, in doubly homogenized Weyl algebra.) nl + (The Grobner cones are dehomogenized to get local Grobner fan.) nl +] cat def + +% List of variables +% If cone.type=1, then (H) should be added. +/cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h) (H)] def + +% List of variables in the form for define_ring. +/cone.vv (t1,t2,x,y) def + +% If cone.type=0, then x,Dx, +% If cone.type=1, then x,Dx,h,H (Doubly homogenized) +% If cone.type=2, then x,Dx,h +/cone.type 1 def + +% Set how to parametrize the weight space. +% In the example below, 6 means the number of variables x11,x12,x13,x21,x22,x33 +% p q parametrizeSmallFan (p >= q) : Enumerate Grobner cones in the Small +% Grobner fan. +% The weights for the last p-q variables +% are 0. +% Example. 6 2 parametrizeSmallFan weights for x12,x21,x22,x23 are 0. +% +% p q parametrizeTotalFan (p = q = number of variables in cone.vv) +% p > q has not yet been implemented. +% +/cone.parametrizeWeightSpace { + 4 2 parametrizeSmallFan +} def + +% If you want to enumerate Grobner cones in local order (i.e., x^e <= 0), +% then cone.local = 1 else cone.local = 0. +/cone.local 1 def + +% Initial value of the weight in the weight space of which dimension is +% cone.m +% If it is null, then a random weight is used. +/cone.w_start + null +def + +% If cone.h0=1, then the weight for h is 0. +% It is usally set to 1. +/cone.h0 1 def + +% Set input polynomials which generate the ideal. +% Input must be homogenized. +% (see also data/test14.sm1 for double homogenization.) +/cone.input + [ + (t1-y) (t2 - (y-(x-1)^2)) + ((-2 x + 2)*Dt2+Dx) + (Dt1+Dt2+Dy) + ] +def +% homogenize + [cone.vv ring_of_differential_operators + [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector + 0] define_ring + dh.begin + cone.input { . homogenize toString } map /cone.input set + dh.end + +% Set a function to compute Grobner basis. +% cone.gb_Dh : For computing in Homogenized Weyl algebra h[1,1](D). +% cone.gb_DhH : For computing in doubly homogenized Weyl algebra. +% ( Computation in ^O and h[0,1](^D) need this +% as the first step. /cone.local 1 def ) +/cone.gb { + cone.gb_DhH +} def + +cone.comment message +(cone.input = ) message +cone.input message +%%%% Step 1. Enumerating the Grobner Cones in a global ring. +%%%% The result is stored in cone.fan +getGrobnerFan + +%%%% If you want to print the output, then uncomment. +printGrobnerFan + +%%%% If you want to save the data to the file sm1out.txt, then uncomment. +% /cone.wightGblist 1 def saveGrobnerFan /ff set ff output + +%%%% Step 2. Dehomogenize the Grobner Cones +%%%% by the equivalence relation in a local ring (uncomment). +dhCones_h + +%%%% Generate the final data dhcone2.fan (a list of local Grobner cones.) +dhcone.rtable + +%%%% Output dhcone2.fan with explanations +dhcone.printGrobnerFan + +} def +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% End of " How to input data? The example 2. " +%% Do not touch below. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +[(parse) (cgi.sm1) pushfile] extension + +% If you use local polymake, then comment out. +% If you use the cgi/polymake on the net, then uncomment out. +%/doPolymake {doPolymake.OoHG} def (Using doPolymake.OoHG ) message +%/polymake.start {polymake.start.OoHG} def (Using polymake.start.OoHG ) message +%% Choose it automatically. +[(which) (polymake)] oxshell tag 0 eq { + (Polymake is not installed in this system.) message + /doPolymake {doPolymake.OoHG} def + (Using doPolymake.OoHG ) message + /polymake.start {polymake.start.OoHG} def + (Using polymake.start.OoHG ) message +} { (Local polymake will be used.) message } ifelse + /cone.debug 1 def /ox.k0.loaded boundp { @@ -10,12 +261,45 @@ [(parse) (ox.sm1) pushfile] extension } ifelse +/cone.load.cohom { + /cone.loaded boundp { } + { + [(parse) (cohom.sm1) pushfile] extension +% [(parse) (cone.sm1) pushfile] extension % BUG? cone.sm1 overrides a global + % in cohom.sm1? + [(parse) (dhecart.sm1) pushfile] extension + /cone.loaded 1 def + oxNoX + polymake.start ( ) message + } ifelse +} def + +%% Usages: cone.gb_DhH. h H (double homogenized) 用の GB. +%% dhecart.sm1 を load してあること. 入力は同次でないといけない. +%% [cone.vv ring_of_differential_operators +%% [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector +%% 0] define_ring +%% dh.begin homogenize dh.end などの方法で同次化できる. +/cone.gb_DhH { + /arg2 set /arg1 set + [/ff /ww] pushVariables + [ + /ff arg1 def + /ww arg2 def + /dh.gb.verbose 1 def + /dh.autoHomogenize 0 def + [(AutoReduce) 1] system_variable + [ff { toString } map cone.vv + [ww cone.vv generateD1_1]] dh.gb 0 get /arg1 set + ] pop + arg1 +} def + % % cone.fan, cone.gblist に fan のデータがはいる. % - -%%%%<<<< 初期データの設定例 data/test13 より. <<<<<<<<<<<<<< -/cone.sample.test13 { +%%%%<<<< 初期データの設定例. 日本語版 data/test13 より. <<<<<<<<<<<<<< +/cone.sample.test13.ja { /cone.loaded boundp { } { [(parse) (cohom.sm1) pushfile] extension @@ -2935,9 +3219,9 @@ def [(cones) [ ] cones] arrayToTree [(facets) [ ] facets] arrayToTree [(merged) [ ] merged] arrayToTree - [(nextcid) [ ] merged] arrayToTree - [(nextfid) [ ] merged] arrayToTree - [(coneid) [ ] merged] arrayToTree + [(nextcid) [ ] nextcid] arrayToTree + [(nextfid) [ ] nextfid] arrayToTree + [(coneid) [ ] coneid] arrayToTree ] ] arrayToTree /arg1 set ] pop @@ -2970,4 +3254,161 @@ def dhcone.fan } def -% Todo: print, save functions. Representative of weight & init. +%< +% Usages: dhcone.rtable +% dhcone の番号と cone の番号の 置換表を生成し dhcone2.fan (merge した cone の情報) +% を dhcone.fan から作る. dhcone2.gblist も作る補助関数. +% dhCones_h してから dhcone.rable する. +%> +/dhcone.rtable { + [/i /j /vv /cones /facets /facets2 /merged /nextcid /nextcid2 /ii /ww] pushVariables + [ +% 置換表 dhcone.h2dh を作る. + /dhcone.h2dh cone.fan length newVector.with-1 def + 0 1 , dhcone.fan length 1 sub { + /i set + dhcone.fan i get , (cones) getNode 2 get /vv set + 0 1 vv length 1 sub { + /j set + dhcone.h2dh , vv j get , i to_univNum , put + } for + } for +% merge した dhcone を整理したもの, dhcone2.fan を作る. + /dhcone2.fan dhcone.fan length newVector def + 0 1 , dhcone.fan length 1 sub { + /i set + dhcone.fan i get (facets) getNode 2 get /facets set + dhcone.fan i get (merged) getNode 2 get /merged set + dhcone.fan i get (nextcid) getNode 2 get /nextcid set + dhcone.fan i get (cones) getNode 2 get /cones set + /facets2 [ ] def + /nextcid2 [ ] def + 0 1 , facets length 1 sub { + /j set + merged j get , (3).. eq { + facets2 [ facets j get ] join /facets2 set +% となりの cone があるとき 変換表にしたがい, cone 番号を変換 + nextcid2 [ dhcone.h2dh , nextcid j get , get ] join /nextcid2 set + } { } ifelse + merged j get , (2).. eq { + facets2 [ facets j get ] join /facets2 set +% 境界のとき -2 を入れる. + nextcid2 [ (-2).. ] join /nextcid2 set + } { } ifelse + } for + + dhcone2.fan i , + [(dhcone) [ ] + [ + [(facets) [ ] facets2] arrayToTree + [(nextcid) [ ] nextcid2] arrayToTree + [(cones) [ ] cones] arrayToTree + ] + ] arrayToTree , put + + } for + +% 最後に dhcone2.gblist を作る. + /dhcone2.gblist , dhcone2.fan length newVector , def + 0 1 , dhcone2.fan length 1 sub { + /i set + dhcone2.fan i get (cones) getNode 2 get /cones set + cone.grGblist , cones 0 get , get , /ii set % GB of initial (H->1). + cone.gblist i get , (weight) getNode , [ 2 0 2 ] get /ww set + + dhcone2.gblist i, + [(gbasis) [ ] + [ + [(initial) [ ] ii] arrayToTree + [(weight) [ ] ww] arrayToTree + ] + ] arrayToTree , put + + } for + (dhcone2.fan, dhcone2.gblist, dhcone.h2dh are set.) message + + ] pop + popVariables +} def + +%< +% 表の見方の解説を印刷する関数. +% Usages: dhcone.explain +%> +/dhcone.explain { + [ + ( ) nl + (Data format in << dhcone2.fan >>, which is a dehomogenized Grobner fan.) nl nl + (<< cone.vlist >> is the list of the variables.) nl + @@@.Hsymbol ( is the homogenization variable to be dehomogenized.) nl nl + (<< cone.input >> is generators of a given ideal.) nl nl + (<< cone.d >> is the dimension of parametrization space of the weights P_w) nl + ( P_w is a cone in R^m where the number m is stored in << cone.m >>) nl + ( P_w --- W ---> R^n [weight space]. ) nl + ( W is stored in << cone.W >> ) nl + ( << u cone.W mul >> gives the weight vector standing for u) nl nl + (All cones in the data lie in the weight parametrization space P_w.) nl + ( "facets" are the inner normal vector of the cone. ) nl + ( "nextcid" is a list of the cone id's of the adjacent cones.) nl + ( -2 in "nextcid" means that this facet lies on the border of the weight space.) nl + ( "cones" is a list of the cone id's of the NON-dehomonized Grobner fan) nl + ( stored in << cone.fan >>) nl + ] cat +} def + +%< +% dhcone.printGrobnerFan +% dhcone の印刷関数 +%> +/dhcone.printGrobnerFan { + [/i] pushVariables + [ + (========== Grobner Fan (for dehomogenized cones) ============) message + [ + (cone.comment) + (cone.vlist) (cone.vv) + (cone.input) + (cone.type) (cone.local) (cone.h0) + (cone.n) (cone.m) (cone.d) + (cone.W) (cone.Wpos) (cone.Wt) + (cone.L) (cone.Lp) (cone.Lpt) + (cone.weightBorder) + (cone.incidence) + ] { printGrobnerFan.1 } map + ( ) message + (The number of cones = ) messagen dhcone.fan length message + ( ) message + 0 1 dhcone2.fan length 1 sub { + /ii set + ii messagen ( : ) messagen + dhcone2.fan ii get printTree + } for + 1 { + 0 1 dhcone2.gblist length 1 sub { + /ii set + ii messagen ( : ) messagen + dhcone2.gblist ii get printTree + } for + } { } ifelse + + + (=========================================) message + %(cone.withGblist = ) messagen cone.withGblist message + dhcone.explain message + ( ) message + ] pop + popVariables +} def + +% +% 試し方 test14, 22, 25 +% +% (data/test14.sm1) run (data/test14-data.sm1) run +% printGrobnerFan ; % H 付きで印刷. +% dhCones_h ; % dehomogenize Cones. +% dhcone.rtable ; % dhcone2.fan 等を生成. +% dhcone.printGrobnerFan ; % 印刷. +% 印刷したものは test*-print.txt へ格納してある. +% + +% Todo: save functions.