source: git/Singular/LIB/ratgb.lib @ 334c21f

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