source: git/Singular/LIB/ratgb.lib @ 60544d

spielwiese
Last change on this file since 60544d was 60544d, checked in by Viktor Levandovskyy <levandov@…>, 16 years ago
*levandov: fixes and updates git-svn-id: file:///usr/local/Singular/svn/trunk@10574 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.9 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2version="$Id: ratgb.lib,v 1.11 2008-02-08 23:28:01 levandov Exp $";
3category="Noncommutative";
4info="
5LIBRARY: ratgb.lib  Groebner bases in Ore localizations
6AUTHOR: Viktor Levandovskyy,     levandov@risc.uni-linz.ac.at
7
8PROCEDURES:
9ratstd(ideal I, int n);   compute Groebner basis in Ore localization of the basering wrt first n variables
10
11SUPPORT: SpezialForschungsBereich F1301 of the Austrian FWF
12"
13
14LIB "poly.lib";
15
16//static
17proc rm_content_id(def J)
18"USAGE:  rm_content_id(I);  I an ideal/module
19RETURN:  the same type as input
20PURPOSE: remove the content of every generator of I
21EXAMPLE: example rm_content_id; shows examples
22"
23{
24  def  I = J;
25  int i;
26  int s = ncols(I);
27  for (i=1; i<=s; i++)
28  {
29    if (I[i]!=0)
30    {
31      I[i] = I[i]/content(I[i]);
32    }
33  }
34  return(I);
35}
36example
37{
38  "EXAMPLE:"; echo = 2;
39  ring r = (0,k,n),(K,N),dp;
40  ideal I = n*((k+1)*K - (n-k)), k*((n-k+1)*N - (n+1));
41  I;
42  rm_content_id(I);
43  module M = I[1]*gen(1), I[2]*gen(2);
44  print(rm_content_id(M));
45}
46
47proc ratstd(def I, int is)
48"USAGE:  ratstd(I, n);  I an ideal/module, n an integer
49RETURN:  ring
50PURPOSE: compute the Groebner basis of I in the Ore localization of
51the basering with respect to the subalgebra, generated by first n variables
52ASSUME: the variables are organized in two blocks and
53@* the first block of length n contains the elements
54@*     with respect to which one localizes,
55@* the basering is equipped with the elimination ordering
56@*     for the variables in the second block
57NOTE: the output ring O is commutative. The ideal rGBid in O
58represents the rational form of the output ideal pGBid in the basering.
59@* During the computation, the D-dimension of I and the corresponding
60vector space D-dimension of I are computed and printed out.
61TRACING: In order to see the steps of the computation, set printlevel to >=2
62EXAMPLE: example ratstd; shows examples
63"
64{
65  // 0. do the subst's /reformulations
66  // for the time being, ASSUME
67  // the ord. is an elim. ord. for D
68  // and the block of X's is on the left
69  // its length is 'is'
70
71  int i,j,k;
72  int ppl = printlevel-voice+1;
73  dbprint(ppl,"// -1- creating K(x)[D]");
74
75  // 1. create K(x)[D], commutative
76  def save = basering;
77  list L = ringlist(save);
78  list RL, tmp1,tmp2,tmp3,tmp4;
79  intvec iv;
80  // copy: field, enlarge it with Xs
81
82  if ( size(L[1]) == 0)
83  {
84    // i.e. the field with char only
85    tmp2[1] = L[1];
86    //    tmp1 = L[2];
87    j    = size(L[2]);
88    iv   = 1;
89    for (i=1; i<=is; i++)
90    {
91      tmp1[i] = L[2][i];
92      iv = iv,1;
93    }
94    iv = iv[1..size(iv)-1]; //extra 1
95    tmp2[2]       = tmp1;
96    tmp3[1] = "lp";
97    tmp3[2] = iv;
98    //    tmp2[3] = 0;
99    tmp4[1] = tmp3;
100    tmp2[3] = tmp4;
101    //[1] = "lp";
102    //    tmp2[3][2] = iv;
103    tmp2[4]       = ideal(0);
104    RL[1] = tmp2;
105  }
106
107  if ( size(L[1]) >0 )
108  {
109    // TODO!!!!!
110    tmp2[1] = L[1][1]; //char K
111    // there are parameters
112    // add to them X's, IGNORE alg.extension
113    // the ordering on pars
114    tmp1 = L[1][2]; // param names
115    j    = size(tmp1);
116    iv = L[1][3][1][2];
117    for (i=1; i<=is; i++)
118    {
119      tmp1[j+i] = L[2][i];
120      iv = iv,1;
121    }
122    tmp2[2] = tmp1;
123    tmp2[3] = L[1][3];
124    tmp2[3][1][2] = iv;
125    tmp2[4] = ideal(0);
126    RL[1] = tmp2;
127  }
128
129  // vars: leave only D's
130  kill tmp1; list tmp1;
131  //  tmp1 = L[2];
132  for (i=is+1; i<= size(L[2]); i++)
133  {
134    tmp1[i-is] = L[2][i];
135  }
136  RL[2] = tmp1;
137
138  // assume the ordering is the block with (a(0:is),ORD)
139  // set up ORD as the ordering
140  //  L; "RL:"; RL;
141  if (size(L[3]) != 3)
142  {
143    "note: strange ordering";
144  }
145  kill tmp2; list tmp2;
146  tmp2[1] = L[3][2];
147  tmp2[2] = L[3][3];
148  RL[3]   = tmp2;
149
150  // factor ideal is ignored
151  RL[4] = ideal(0);
152
153  def @RAT = ring(RL);
154
155  dbprint(ppl,"// -2- preprocessing with content");
156  // 2. preprocess input with rm_content_id
157  setring @RAT;
158  dbprint(ppl-1, @RAT);
159  //  ideal CI = imap(save,I);
160  def CI = imap(save,I);
161  CI = rm_content_id(CI);
162  dbprint(ppl-1, CI);
163
164  dbprint(ppl,"// -3- running groebner");
165  // 3. compute G = GB(I) wrt. the elim. ord. for D
166  setring save;
167  //  ideal CI = imap(@RAT,CI);
168  def CI = imap(@RAT,CI);
169  option(redSB);
170  option(redTail);
171  //  ideal G = groebner(CI); // although slimgb looks better
172  def G = groebner(CI);
173  G = simplify(G,2); // to be sure there are no 0's
174  dbprint(ppl-1, G);
175
176  dbprint(ppl,"// -4- postprocessing with content");
177  // 4. postprocess the output with 1) rm_content_id,  2) lm-minimization;
178  setring @RAT;
179  // ideal CG = imap(save,G);
180  def CG = imap(save,G);
181  CG = rm_content_id(CG);
182  CG = simplify(CG,2);
183  dbprint(ppl-1, CG);
184
185  // warning: a bugfarm! in this ring, the ordering might change!!! (see appelF4)
186  // so, simplify(32) should take place in the orig. ring! and NOT here
187  //  CG = simplify(CG,2+32);
188
189  // 4b. create L(G) with X's as coeffs (for minimization)
190  setring save;
191  G = imap(@RAT,CG);
192  int sG  = ncols(G);
193  //  ideal LG;
194  def LG = G;
195   for (i=1; i<= sG; i++)
196   {
197     LG[i] = lead(G[i]);
198   }
199  // compute the D-dimension of the ideal in the ring @RAT
200  setring @RAT;
201  //  ideal LG = imap(save,LG);
202  def LG = imap(save,LG);
203  //  ideal LGG = groebner(LG); // cosmetics
204  def LGG = groebner(LG); // cosmetics
205  int d = dim(LGG);
206  int Ddim = d;
207  printf("the D-dimension is %s",d);
208  if (d==0)
209  {
210    d = vdim(LGG);
211    int Dvdim = d;
212    printf("the K-dimension is %s",d);
213  }
214  //  ideal SLG = simplify(LG,8+32); //contains zeros
215  def SLG = simplify(LG,8+32); //contains zeros
216  setring save;
217  //  ideal SLG = imap(@RAT,SLG);
218  def SLG = imap(@RAT,SLG);
219  // simplify(LG,8+32); //contains zeros
220  intvec islg;
221  if (SLG[1] == 0)
222  {  islg = 0;  }
223  else
224  {    islg = 1;  }
225  for (i=2; i<= ncols(SLG); i++)
226  {
227    if (SLG[i] == 0)
228    {
229      islg = islg, 0;
230    }
231    else
232    {
233      islg = islg, 1;
234    }
235  }
236  for (i=1; i<= ncols(LG); i++)
237  {
238    if (islg[i] == 0)
239    {
240      G[i] = 0;
241    }
242  }
243  G = simplify(G,2); // ready!
244  //  G = imap(@RAT,CG);
245  // return the result
246  //  ideal pGBid = G;
247  def pGBid = G;
248  export pGBid;
249  //  export Ddim;
250  //  export Dvdim;
251  setring @RAT;
252  //  ideal rGBid = imap(save,G);
253  def rGBid = imap(save,G);
254  // CG;
255  export rGBid;
256  setring save;
257  return(@RAT);
258  //  kill @RAT;
259  //  return(G);
260}
261example
262{
263  "EXAMPLE:"; echo = 2;
264  ring r = 0,(k,n,K,N),(a(0,1),dp);
265  matrix D[4][4];
266  D[1,3] = K;
267  D[2,4] = N;
268  def S = nc_algebra(1,D);
269  setring S;
270  ideal I = (k+1)*K - (n-k), (n-k+1)*N - (n+1);
271  int is = 1;
272  def A  = ratstd(I,is);
273  pGBid; // polynomial form
274  setring A;
275  rGBid; // rational form
276}
277
278static proc exParam()
279{
280  // Appel F4
281  LIB "ratgb.lib";
282  ring r = (0,a,b,c,d),(x,y,Dx,Dy),(a(0,0,1,1),dp);
283  matrix @D[4][4];
284  @D[1,3]=1; @D[2,4]=1;
285  def S=nc_algebra(1,@D);
286  setring S;
287  ideal I =
288    x*Dx*(x*Dx+c-1) - x*(x*Dx+y*Dy+a)*(x*Dx+y*Dy+b),
289    y*Dy*(y*Dy+d-1) - y*(x*Dx+y*Dy+a)*(x*Dx+y*Dy+b);
290  def A = ratstd(I,2);
291  pGBid; // polynomial form
292  setring A;
293  rGBid; // rational form
294}
Note: See TracBrowser for help on using the repository browser.