[1200f0] | 1 | ////////////////////////////////////////////////////////////////////////////// |
---|
[28734e] | 2 | version="$Id: ratgb.lib,v 1.14 2009-02-21 15:26:42 levandov Exp $"; |
---|
[1200f0] | 3 | category="Noncommutative"; |
---|
| 4 | info=" |
---|
[28734e] | 5 | LIBRARY: ratgb.lib Groebner bases in Ore localizations of noncommutative G-algebras |
---|
[1200f0] | 6 | AUTHOR: Viktor Levandovskyy, levandov@risc.uni-linz.ac.at |
---|
| 7 | |
---|
[28734e] | 8 | THEORY: Let A be an operator algebra with R = K[x1,.,xN] as subring. The operators |
---|
| 9 | are usually denoted by {d1,..,dM}. Assume, that A is a G-algebra, then the set S=R-{0} |
---|
| 10 | is multiplicatively closed and is an Ore set in A. That is, for any s in S and a in A, |
---|
| 11 | there exist t in S and b in A, such that sa=bt. In other words one can transform |
---|
| 12 | any left fraction into the right fraction. The algebra A_S is entermed an Ore |
---|
| 13 | localization of A with respect to S. This library provides Groebner basis |
---|
| 14 | procedure for A_S, performing polynomial computations only. |
---|
| 15 | |
---|
[a1c745] | 16 | PROCEDURES: |
---|
[3d6b567] | 17 | ratstd(ideal I, int n); compute Groebner basis in Ore localization of the basering wrt first n variables |
---|
[c38460] | 18 | |
---|
| 19 | SUPPORT: SpezialForschungsBereich F1301 of the Austrian FWF |
---|
[1200f0] | 20 | " |
---|
| 21 | |
---|
[74afd6e] | 22 | LIB "poly.lib"; |
---|
[28734e] | 23 | LIB "dmodapp.lib"; // for Appel1, Appel2, Appel4 |
---|
[74afd6e] | 24 | |
---|
[7f3ad4] | 25 | //static |
---|
[60544d] | 26 | proc rm_content_id(def J) |
---|
| 27 | "USAGE: rm_content_id(I); I an ideal/module |
---|
| 28 | RETURN: the same type as input |
---|
[74afd6e] | 29 | PURPOSE: remove the content of every generator of I |
---|
| 30 | EXAMPLE: example rm_content_id; shows examples |
---|
| 31 | " |
---|
| 32 | { |
---|
[60544d] | 33 | def I = J; |
---|
[74afd6e] | 34 | int i; |
---|
[60544d] | 35 | int s = ncols(I); |
---|
[74afd6e] | 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 | } |
---|
| 45 | example |
---|
| 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); |
---|
[60544d] | 52 | module M = I[1]*gen(1), I[2]*gen(2); |
---|
| 53 | print(rm_content_id(M)); |
---|
[74afd6e] | 54 | } |
---|
| 55 | |
---|
[285d21] | 56 | proc ratstd(def I, int is, list #) |
---|
| 57 | "USAGE: ratstd(I, n [,eng]); I an ideal/module, n an integer, eng an optional integer |
---|
[1200f0] | 58 | RETURN: ring |
---|
| 59 | PURPOSE: compute the Groebner basis of I in the Ore localization of |
---|
[3d6b567] | 60 | the basering with respect to the subalgebra, generated by first n variables |
---|
[c38460] | 61 | ASSUME: the variables are organized in two blocks and |
---|
| 62 | @* the first block of length n contains the elements |
---|
[a1c745] | 63 | @* with respect to which one localizes, |
---|
[28734e] | 64 | @* the basering is equipped with the elimination block ordering |
---|
[c38460] | 65 | @* for the variables in the second block |
---|
[3d6b567] | 66 | NOTE: the output ring O is commutative. The ideal rGBid in O |
---|
[1200f0] | 67 | represents the rational form of the output ideal pGBid in the basering. |
---|
| 68 | @* During the computation, the D-dimension of I and the corresponding |
---|
| 69 | vector space D-dimension of I are computed and printed out. |
---|
[285d21] | 70 | @* Setting optional integer eng to 1, slimgb is taken as Groebner engine |
---|
[28734e] | 71 | DISPLAY: In order to see the steps of the computation, set printlevel to >=2 |
---|
[1200f0] | 72 | EXAMPLE: example ratstd; shows examples |
---|
| 73 | " |
---|
| 74 | { |
---|
[285d21] | 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 | |
---|
[1200f0] | 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; |
---|
[9689f2] | 96 | dbprint(ppl,"// -1- creating K(x)[D]"); |
---|
[1200f0] | 97 | |
---|
[74afd6e] | 98 | // 1. create K(x)[D], commutative |
---|
[1200f0] | 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 | |
---|
[28734e] | 161 | // old: assume the ordering is the block with (a(0:is),ORD) |
---|
| 162 | // old :set up ORD as the ordering |
---|
[1200f0] | 163 | // L; "RL:"; RL; |
---|
| 164 | if (size(L[3]) != 3) |
---|
| 165 | { |
---|
[28734e] | 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; |
---|
[1200f0] | 207 | } |
---|
| 208 | // factor ideal is ignored |
---|
| 209 | RL[4] = ideal(0); |
---|
| 210 | |
---|
[28734e] | 211 | // "ringlist:"; RL; |
---|
| 212 | |
---|
[1200f0] | 213 | def @RAT = ring(RL); |
---|
[74afd6e] | 214 | |
---|
[9689f2] | 215 | dbprint(ppl,"// -2- preprocessing with content"); |
---|
[74afd6e] | 216 | // 2. preprocess input with rm_content_id |
---|
[1200f0] | 217 | setring @RAT; |
---|
[60544d] | 218 | dbprint(ppl-1, @RAT); |
---|
| 219 | // ideal CI = imap(save,I); |
---|
| 220 | def CI = imap(save,I); |
---|
[74afd6e] | 221 | CI = rm_content_id(CI); |
---|
[60544d] | 222 | dbprint(ppl-1, CI); |
---|
[1200f0] | 223 | |
---|
[9689f2] | 224 | dbprint(ppl,"// -3- running groebner"); |
---|
[74afd6e] | 225 | // 3. compute G = GB(I) wrt. the elim. ord. for D |
---|
| 226 | setring save; |
---|
[60544d] | 227 | // ideal CI = imap(@RAT,CI); |
---|
| 228 | def CI = imap(@RAT,CI); |
---|
[74afd6e] | 229 | option(redSB); |
---|
| 230 | option(redTail); |
---|
[285d21] | 231 | if (eng) |
---|
| 232 | { |
---|
| 233 | def G = slimgb(CI); |
---|
| 234 | } |
---|
| 235 | else |
---|
| 236 | { |
---|
| 237 | def G = groebner(CI); |
---|
| 238 | } |
---|
[60544d] | 239 | // ideal G = groebner(CI); // although slimgb looks better |
---|
[285d21] | 240 | // def G = slimgb(CI); |
---|
[74afd6e] | 241 | G = simplify(G,2); // to be sure there are no 0's |
---|
[60544d] | 242 | dbprint(ppl-1, G); |
---|
[1200f0] | 243 | |
---|
[9689f2] | 244 | dbprint(ppl,"// -4- postprocessing with content"); |
---|
[74afd6e] | 245 | // 4. postprocess the output with 1) rm_content_id, 2) lm-minimization; |
---|
| 246 | setring @RAT; |
---|
[60544d] | 247 | // ideal CG = imap(save,G); |
---|
| 248 | def CG = imap(save,G); |
---|
[74afd6e] | 249 | CG = rm_content_id(CG); |
---|
[4dcfc0f] | 250 | CG = simplify(CG,2); |
---|
[60544d] | 251 | dbprint(ppl-1, CG); |
---|
[4dcfc0f] | 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); |
---|
[a1c745] | 256 | |
---|
[74afd6e] | 257 | // 4b. create L(G) with X's as coeffs (for minimization) |
---|
[4dcfc0f] | 258 | setring save; |
---|
| 259 | G = imap(@RAT,CG); |
---|
| 260 | int sG = ncols(G); |
---|
[60544d] | 261 | // ideal LG; |
---|
| 262 | def LG = G; |
---|
| 263 | for (i=1; i<= sG; i++) |
---|
| 264 | { |
---|
| 265 | LG[i] = lead(G[i]); |
---|
| 266 | } |
---|
[4dcfc0f] | 267 | // compute the D-dimension of the ideal in the ring @RAT |
---|
| 268 | setring @RAT; |
---|
[60544d] | 269 | // ideal LG = imap(save,LG); |
---|
| 270 | def LG = imap(save,LG); |
---|
| 271 | // ideal LGG = groebner(LG); // cosmetics |
---|
| 272 | def LGG = groebner(LG); // cosmetics |
---|
[4dcfc0f] | 273 | int d = dim(LGG); |
---|
[1200f0] | 274 | int Ddim = d; |
---|
[3d6b567] | 275 | printf("the D-dimension is %s",d); |
---|
[1200f0] | 276 | if (d==0) |
---|
| 277 | { |
---|
[4dcfc0f] | 278 | d = vdim(LGG); |
---|
[1200f0] | 279 | int Dvdim = d; |
---|
| 280 | printf("the K-dimension is %s",d); |
---|
| 281 | } |
---|
[60544d] | 282 | // ideal SLG = simplify(LG,8+32); //contains zeros |
---|
| 283 | def SLG = simplify(LG,8+32); //contains zeros |
---|
[1200f0] | 284 | setring save; |
---|
[60544d] | 285 | // ideal SLG = imap(@RAT,SLG); |
---|
| 286 | def SLG = imap(@RAT,SLG); |
---|
[4dcfc0f] | 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); |
---|
[1200f0] | 313 | // return the result |
---|
[60544d] | 314 | // ideal pGBid = G; |
---|
| 315 | def pGBid = G; |
---|
[1200f0] | 316 | export pGBid; |
---|
| 317 | // export Ddim; |
---|
| 318 | // export Dvdim; |
---|
| 319 | setring @RAT; |
---|
[60544d] | 320 | // ideal rGBid = imap(save,G); |
---|
| 321 | def rGBid = imap(save,G); |
---|
[4dcfc0f] | 322 | // CG; |
---|
[1200f0] | 323 | export rGBid; |
---|
| 324 | setring save; |
---|
| 325 | return(@RAT); |
---|
| 326 | // kill @RAT; |
---|
| 327 | // return(G); |
---|
| 328 | } |
---|
| 329 | example |
---|
| 330 | { |
---|
| 331 | "EXAMPLE:"; echo = 2; |
---|
[28734e] | 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; |
---|
[4baf744] | 334 | def S = nc_algebra(1,D); |
---|
[28734e] | 335 | setring S; // S is the 2nd shift algebra |
---|
[a1c745] | 336 | ideal I = (k+1)*K - (n-k), (n-k+1)*N - (n+1); |
---|
[28734e] | 337 | int is = 2; // hence 1st and 2nd variables treated as units |
---|
[1200f0] | 338 | def A = ratstd(I,is); |
---|
| 339 | pGBid; // polynomial form |
---|
| 340 | setring A; |
---|
| 341 | rGBid; // rational form |
---|
| 342 | } |
---|
| 343 | |
---|
[28734e] | 344 | /* |
---|
| 345 | proc exParamAppelF4() |
---|
[1200f0] | 346 | { |
---|
| 347 | // Appel F4 |
---|
[74afd6e] | 348 | LIB "ratgb.lib"; |
---|
[28734e] | 349 | ring r = (0,a,b,c,d),(x,y,Dx,Dy),(a(0,0,1,1),a(0,0,1,0),dp); |
---|
[1200f0] | 350 | matrix @D[4][4]; |
---|
| 351 | @D[1,3]=1; @D[2,4]=1; |
---|
[74afd6e] | 352 | def S=nc_algebra(1,@D); |
---|
| 353 | setring S; |
---|
[1200f0] | 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 |
---|
[28734e] | 361 | // hence, the K(x,y) basis is {1,Dx,Dy,Dy^2} |
---|
[1200f0] | 362 | } |
---|
[28734e] | 363 | |
---|
| 364 | // more examples: |
---|
| 365 | |
---|
| 366 | // F1 is hard |
---|
| 367 | appel 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 |
---|
| 380 | appel 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 |
---|
| 393 | appel 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 | */ |
---|