source: git/Singular/LIB/ratgb.lib @ 0dd77c2

spielwiese
Last change on this file since 0dd77c2 was 0610f0e, checked in by Hans Schoenemann <hannes@…>, 14 years ago
format git-svn-id: file:///usr/local/Singular/svn/trunk@12790 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.7 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2version="$Id$";
3category="Noncommutative";
4info="
5LIBRARY: ratgb.lib  Groebner bases in Ore localizations of noncommutative G-algebras
6AUTHOR: Viktor Levandovskyy,     levandov@risc.uni-linz.ac.at
7
8THEORY: Let A be an operator algebra with R = K[x1,.,xN] as subring.
9The operators are usually denoted by {d1,..,dM}.
10@* Assume, that A is a G-algebra, then the set S=R-{0} is multiplicatively closed Ore set in A.
11@* That is, for any s in S and a in A, there exist t in S and b in A, such that sa=bt.
12@* In other words, one can transform any left fraction into the right fraction. The algebra A_S is called an Ore localization of A with respect to S.
13
14This library provides Groebner basis procedure for A_S, performing polynomial (that is fraction-free) computations only.
15
16PROCEDURES:
17ratstd(ideal I, int n);   compute Groebner basis and dimensions in Ore localization of the basering w.r.t. first n variables
18
19SUPPORT: SpezialForschungsBereich F1301 of the Austrian FWF and
20@* Transnational Access Program of RISC Linz, Austria
21"
22
23LIB "poly.lib";
24LIB "dmodapp.lib"; // for Appel1, Appel2, Appel4
25
26//static
27proc rm_content_id(def J)
28"USAGE:  rm_content_id(I);  I an ideal/module
29RETURN:  the same type as input
30PURPOSE: remove the content of every generator of I
31EXAMPLE: example rm_content_id; shows examples
32"
33{
34  def  I = J;
35  int i;
36  int s = ncols(I);
37  for (i=1; i<=s; i++)
38  {
39    if (I[i]!=0)
40    {
41      I[i] = I[i]/content(I[i]);
42    }
43  }
44  return(I);
45}
46example
47{
48  "EXAMPLE:"; echo = 2;
49  ring r = (0,k,n),(K,N),dp;
50  ideal I = n*((k+1)*K - (n-k)), k*((n-k+1)*N - (n+1));
51  I;
52  rm_content_id(I);
53  module M = I[1]*gen(1), I[2]*gen(2);
54  print(rm_content_id(M));
55}
56
57proc ratstd(def I, int is, list #)
58"USAGE:  ratstd(I, n [,eng]);  I an ideal/module, n an integer, eng an optional integer
59RETURN:  ring
60PURPOSE: compute the Groebner basis of I in the Ore localization of
61the basering with respect to the subalgebra, generated by first n variables
62ASSUME: the variables are organized in two blocks and
63@* the first block of length n contains the elements
64@*     with respect to which one localizes,
65@* the basering is equipped with the elimination block ordering
66@*     for the variables in the second block
67NOTE: the output ring C is commutative. The ideal rGBid in C
68represents the rational form of the output ideal pGBid in the basering.
69@* During the computation, the D-dimension of I and the corresponding
70dimension as K(x)-vector space of I are computed and printed out.
71@* Setting optional integer eng to 1, slimgb is taken as Groebner engine
72DISPLAY: In order to see the steps of the computation, set printlevel to >=2
73EXAMPLE: example ratstd; shows examples
74"
75{
76  int ppl = printlevel-voice+1;
77  int eng = 0;
78  // optional arguments
79  if (size(#)>0)
80  {
81    if (typeof(#[1]) == "int")
82    {
83      eng = int(#[1]);
84    }
85  }
86
87  dbprint(ppl,"engine chosen to be");
88  dbprint(ppl,eng);
89
90  // 0. do the subst's /reformulations
91  // for the time being, ASSUME
92  // the ord. is an elim. ord. for D
93  // and the block of X's is on the left
94  // its length is 'is'
95
96  int i,j,k;
97  dbprint(ppl,"// -1- creating K(x)[D]");
98
99  // 1. create K(x)[D], commutative
100  def save = basering;
101  list L = ringlist(save);
102  list RL, tmp1,tmp2,tmp3,tmp4;
103  intvec iv;
104  // copy: field, enlarge it with Xs
105
106  if ( size(L[1]) == 0)
107  {
108    // i.e. the field with char only
109    tmp2[1] = L[1];
110    //    tmp1 = L[2];
111    j    = size(L[2]);
112    iv   = 1;
113    for (i=1; i<=is; i++)
114    {
115      tmp1[i] = L[2][i];
116      iv = iv,1;
117    }
118    iv = iv[1..size(iv)-1]; //extra 1
119    tmp2[2]       = tmp1;
120    tmp3[1] = "lp";
121    tmp3[2] = iv;
122    //    tmp2[3] = 0;
123    tmp4[1] = tmp3;
124    tmp2[3] = tmp4;
125    //[1] = "lp";
126    //    tmp2[3][2] = iv;
127    tmp2[4]       = ideal(0);
128    RL[1] = tmp2;
129  }
130
131  if ( size(L[1]) >0 )
132  {
133    // TODO!!!!!
134    tmp2[1] = L[1][1]; //char K
135    // there are parameters
136    // add to them X's, IGNORE alg.extension
137    // the ordering on pars
138    tmp1 = L[1][2]; // param names
139    j    = size(tmp1);
140    iv = L[1][3][1][2];
141    for (i=1; i<=is; i++)
142    {
143      tmp1[j+i] = L[2][i];
144      iv = iv,1;
145    }
146    tmp2[2] = tmp1;
147    tmp2[3] = L[1][3];
148    tmp2[3][1][2] = iv;
149    tmp2[4] = ideal(0);
150    RL[1] = tmp2;
151  }
152
153  // vars: leave only D's
154  kill tmp1; list tmp1;
155  //  tmp1 = L[2];
156  for (i=is+1; i<= size(L[2]); i++)
157  {
158    tmp1[i-is] = L[2][i];
159  }
160  RL[2] = tmp1;
161
162  // old: assume the ordering is the block with (a(0:is),ORD)
163  // old :set up ORD as the ordering
164  //  L; "RL:"; RL;
165  if (size(L[3]) != 3)
166  {
167    //"note: strange ordering";
168    // NEW assume: ordering is the antiblock with (a(0:is),a(*1),a(*), ORD)
169    // get the a() parts after is => they should form a complete D-ordering
170    list L3 = L[3]; list NL3; kill tmp3; list tmp3;
171    int @sl = size(L3);
172    int w=1; int z; intvec va,vb;
173    while(L3[w][1] == "a")
174    {
175      va = L3[w][2];
176      for(z=1;z<=nvars(save)-is;z++)
177      {
178        vb[z] = va[is+z];
179      }
180      tmp3[1] = "a";
181      tmp3[2] = vb;
182      NL3[w] = tmp3; tmp3=0;
183      w++;
184    }
185    // check for completeness: must be >= nvars(save)-is rows
186    if (w < nvars(save)-is)
187    {
188      "note: ordering is incomplete on D. Adding lower Dp block";
189      // adding: positive things like Dp
190      tmp3[1]= "Dp";
191      for (z=1; z<=nvars(save)-is; z++)
192      {
193        va[is+z] = 1;
194      }
195      tmp3[2] = va;
196      NL3[w] = tmp3; tmp3 = 0;
197      w++;
198    }
199    NL3[w] = L3[@sl]; // module ord?
200    RL[3] = NL3;
201  }
202  else
203  {
204    kill tmp2; list tmp2;
205    tmp2[1] = L[3][2];
206    tmp2[2] = L[3][3];
207    RL[3]   = tmp2;
208  }
209  // factor ideal is ignored
210  RL[4] = ideal(0);
211
212  //  "ringlist:"; RL;
213
214  def @RAT = ring(RL);
215
216  dbprint(ppl,"// -2- preprocessing with content");
217  // 2. preprocess input with rm_content_id
218  setring @RAT;
219  dbprint(ppl-1, @RAT);
220  //  ideal CI = imap(save,I);
221  def CI = imap(save,I);
222  CI = rm_content_id(CI);
223  dbprint(ppl-1, CI);
224
225  dbprint(ppl,"// -3- running groebner");
226  // 3. compute G = GB(I) w.r.t. the elim. ord. for D
227  setring save;
228  //  ideal CI = imap(@RAT,CI);
229  def CI = imap(@RAT,CI);
230  option(redSB);
231  option(redTail);
232  if (eng)
233  {
234    def G = slimgb(CI);
235  }
236  else
237  {
238    def G = groebner(CI);
239  }
240  //  ideal G = groebner(CI); // although slimgb looks better
241  // def G = slimgb(CI);
242  G = simplify(G,2); // to be sure there are no 0's
243  dbprint(ppl-1, G);
244
245  dbprint(ppl,"// -4- postprocessing with content");
246  // 4. postprocess the output with 1) rm_content_id,  2) lm-minimization;
247  setring @RAT;
248  // ideal CG = imap(save,G);
249  def CG = imap(save,G);
250  CG = rm_content_id(CG);
251  CG = simplify(CG,2);
252  dbprint(ppl-1, CG);
253
254  // warning: a bugfarm! in this ring, the ordering might change!!! (see appelF4)
255  // so, simplify(32) should take place in the orig. ring! and NOT here
256  //  CG = simplify(CG,2+32);
257
258  // 4b. create L(G) with X's as coeffs (for minimization)
259  setring save;
260  G = imap(@RAT,CG);
261  int sG  = ncols(G);
262  //  ideal LG;
263  def LG = G;
264   for (i=1; i<= sG; i++)
265   {
266     LG[i] = lead(G[i]);
267   }
268  // compute the D-dimension of the ideal in the ring @RAT
269  setring @RAT;
270  //  ideal LG = imap(save,LG);
271  def LG = imap(save,LG);
272  //  ideal LGG = groebner(LG); // cosmetics
273  def LGG = groebner(LG); // cosmetics
274  int d = dim(LGG);
275  int Ddim = d;
276  printf("the D-dimension is %s",d);
277  if (d==0)
278  {
279    d = vdim(LGG);
280    int Dvdim = d;
281    printf("the K-dimension is %s",d);
282  }
283  //  ideal SLG = simplify(LG,8+32); //contains zeros
284  def SLG = simplify(LG,8+32); //contains zeros
285  setring save;
286  //  ideal SLG = imap(@RAT,SLG);
287  def SLG = imap(@RAT,SLG);
288  // simplify(LG,8+32); //contains zeros
289  intvec islg;
290  if (SLG[1] == 0)
291  {  islg = 0;  }
292  else
293  {    islg = 1;  }
294  for (i=2; i<= ncols(SLG); i++)
295  {
296    if (SLG[i] == 0)
297    {
298      islg = islg, 0;
299    }
300    else
301    {
302      islg = islg, 1;
303    }
304  }
305  for (i=1; i<= ncols(LG); i++)
306  {
307    if (islg[i] == 0)
308    {
309      G[i] = 0;
310    }
311  }
312  G = simplify(G,2); // ready!
313  //  G = imap(@RAT,CG);
314  // return the result
315  //  ideal pGBid = G;
316  def pGBid = G;
317  export pGBid;
318  //  export Ddim;
319  //  export Dvdim;
320  setring @RAT;
321  //  ideal rGBid = imap(save,G);
322  def rGBid = imap(save,G);
323  // CG;
324  export rGBid;
325  setring save;
326  return(@RAT);
327  //  kill @RAT;
328  //  return(G);
329}
330example
331{
332  "EXAMPLE:"; echo = 2;
333  ring r = 0,(k,n,K,N),(a(0,0,1,1),a(0,0,1,0),dp);
334  // note, that the ordering must be an antiblock ordering
335  matrix D[4][4]; D[1,3] = K; D[2,4] = N;
336  def S = nc_algebra(1,D);
337  setring S; // S is the 2nd shift algebra
338  ideal I = (k+1)*K - (n-k), (n-k+1)*N - (n+1);
339  int is = 2; // hence 1..2 variables will be treated as invertible
340  def A  = ratstd(I,is);
341  pGBid; // polynomial form
342  setring A;
343  rGBid; // rational form
344}
345
346/*
347proc exParamAppelF4()
348{
349  // Appel F4
350  LIB "ratgb.lib";
351  ring r = (0,a,b,c,d),(x,y,Dx,Dy),(a(0,0,1,1),a(0,0,1,0),dp);
352  matrix @D[4][4];
353  @D[1,3]=1; @D[2,4]=1;
354  def S=nc_algebra(1,@D);
355  setring S;
356  ideal I =
357    x*Dx*(x*Dx+c-1) - x*(x*Dx+y*Dy+a)*(x*Dx+y*Dy+b),
358    y*Dy*(y*Dy+d-1) - y*(x*Dx+y*Dy+a)*(x*Dx+y*Dy+b);
359  def A = ratstd(I,2);
360  pGBid; // polynomial form
361  setring A;
362  rGBid; // rational form
363  // hence, the K(x,y) basis is {1,Dx,Dy,Dy^2}
364}
365
366// more examples:
367
368// F1 is hard
369appel F1
370{
371  LIB "dmodapp.lib";
372  LIB "ratgb.lib";
373  def A = appelF1();
374  setring A;
375  IAppel1;
376  def F1 = ratstd(IAppel1,2);
377  lead(pGBid);
378  setring F1; rGBid;
379}
380
381// F2 is much easier
382appel F2
383{
384  LIB "dmodapp.lib";
385  LIB "ratgb.lib";
386  def A = appelF2();
387  setring A;
388  IAppel2;
389  def F1 = ratstd(IAppel2,2);
390  lead(pGBid);
391  setring F1; rGBid;
392}
393
394// F4 is feasible
395appel F4
396{
397  LIB "dmodapp.lib";
398  LIB "ratgb.lib";
399  def A = appelF4();
400  setring A;
401  IAppel4;
402  def F1 = ratstd(IAppel4,2);
403  lead(pGBid);
404  setring F1; rGBid;
405}
406
407
408*/
Note: See TracBrowser for help on using the repository browser.