1 | // $Id: elim.lib,v 1.25 2008-11-13 10:50:17 Singular Exp $ |
---|
2 | /////////////////////////////////////////////////////////////////////////////// |
---|
3 | version="$Id: elim.lib,v 1.25 2008-11-13 10:50:17 Singular Exp $"; |
---|
4 | category="Commutative Algebra"; |
---|
5 | info=" |
---|
6 | LIBRARY: elim.lib Elimination, Saturation and Blowing up |
---|
7 | |
---|
8 | PROCEDURES: |
---|
9 | blowup0(j[,s1,s2]); create presentation of blownup ring of ideal j |
---|
10 | elimRing(p); create ring with block ordering for elimating vars in p |
---|
11 | elim(id,..); variables .. eliminated from id (ideal/module) |
---|
12 | elim1(id,p); p=product of vars to be eliminated from id |
---|
13 | elim2(id,..); variables .. eliminated from id (ideal/module) |
---|
14 | nselect(id,v); select generators not containing variables given by v |
---|
15 | sat(id,j); saturated quotient of ideal/module id by ideal j |
---|
16 | select(id,v]); select generators containing all variables given by v |
---|
17 | select1(id,v); select generators containing one variable given by v |
---|
18 | (parameters in square brackets [] are optional) |
---|
19 | "; |
---|
20 | |
---|
21 | LIB "inout.lib"; |
---|
22 | LIB "general.lib"; |
---|
23 | LIB "poly.lib"; |
---|
24 | |
---|
25 | /////////////////////////////////////////////////////////////////////////////// |
---|
26 | |
---|
27 | proc blowup0 (ideal J,ideal C, list #) |
---|
28 | "USAGE: blowup0(J,C [,W]); J,C,W ideals |
---|
29 | @* C = ideal of center of blowup, J = ideal to be blown up, |
---|
30 | W = ideal of ambient space |
---|
31 | ASSUME: inclusion of ideals : W in J, J in C. |
---|
32 | If not, the procedure replaces J by J+W and C by C+J+W |
---|
33 | RETURN: a ring, say B, containing the ideals C,J,W and the ideals |
---|
34 | @* - bR (ideal defining the blown up basering) |
---|
35 | @* - aS (ideal of blown up ambient space) |
---|
36 | @* - eD (ideal of exceptional divisor) |
---|
37 | @* - tT (ideal of total transform) |
---|
38 | @* - sT (ideal of strict transform) |
---|
39 | @* - bM (ideal of the blowup map from basering to B) |
---|
40 | @* such that B/bR is isomorphic to the blowup ring BC. |
---|
41 | PURPOSE: compute the projective blowup of the basering in the center C, the |
---|
42 | exceptional locus, the total and strict tranform of J, |
---|
43 | and the blowup map. |
---|
44 | The projective blowup is a presentation of the blowup ring |
---|
45 | BC = R[C] = R + t*C + t^2*C^2 + ... (also called Rees ring) of the |
---|
46 | ideal C in the ring basering R. |
---|
47 | THEORY: If basering = K[x1,...,xn] and C = <f1,...,fk> then let |
---|
48 | B = K[x1,...,xn,y1,...,yk] and aS the preimage in B of W |
---|
49 | under the map B -> K[x1,...,xn,t], xi -> xi, yi -> t*fi. |
---|
50 | aS is homogeneous in the variables yi and defines a variety |
---|
51 | Z=V(aS) in A^n x P^(k-1), the ambient space of the blowup of V(W). |
---|
52 | The projection Z -> A^n is an isomorphism outside the preimage |
---|
53 | of the center V(C) in A^n and is called the blowup of the center. |
---|
54 | The preimage of V(C) is called the exceptional set, the preimage of |
---|
55 | V(J) is called the total transform of V(J). The strict transform |
---|
56 | is the closure of (total transform - exceptional set). |
---|
57 | @* If C = <x1,...,xn> then aS = <yi*xj - yj*xi | i,j=1,...,n> |
---|
58 | and Z is the blowup of A^n in 0, the exceptional set is P^(k-1). |
---|
59 | NOTE: The procedure creates a new ring with variables y(1..k) and x(1..n) |
---|
60 | where n=nvars(basering) and k=ncols(C). The ordering is a block |
---|
61 | ordering where the x-block has the ordering of the basering and |
---|
62 | the y-block has ordering dp if C is not homogeneous |
---|
63 | resp. the weighted ordering wp(b1,...bk) if C is homogeneous |
---|
64 | with deg(C[i])=bi. |
---|
65 | SEE ALSO:blowUp |
---|
66 | EXAMPLE: example blowup0; shows examples |
---|
67 | "{ |
---|
68 | def br = basering; |
---|
69 | list l = ringlist(br); |
---|
70 | int n,k,i = nvars(br),ncols(C),0; |
---|
71 | ideal W; |
---|
72 | if (size(#) !=0) |
---|
73 | { W = #[1];} |
---|
74 | J = J,W; |
---|
75 | //J = interred(J+W); |
---|
76 | //------------------------- create rings for blowup ------------------------ |
---|
77 | //Create rings tr = K[x(1),...,x(n),t] and nr = K[x(1),...,x(n),y(1),...,y(k)] |
---|
78 | //and map Bl: nr --> tr, x(i)->x(i), y(i)->t*fi. |
---|
79 | //Let ord be the ordering of the basering. |
---|
80 | //We change the ringlist l by changing l[2] and l[3] |
---|
81 | //For K[t,x(1),...,x(n),t] |
---|
82 | // - l[2]: the variables to x(1),...,x(n),t |
---|
83 | // - l[3]: the ordering to a block ordering (ord,dp(1)) |
---|
84 | //For K[x(1),...,x(n),y(1),...,y(k)] |
---|
85 | // - l[2]: the variables to x(1),...,x(n),y(1),...,y(k), |
---|
86 | // - l[3]: the ordering to a block ordering (ord,dp) if C is |
---|
87 | // not homogeneous or to (ord,wp(b1,...bk),ord) if C is |
---|
88 | // homogeneous with deg(C[i])=bi; |
---|
89 | |
---|
90 | //--------------- create tr = K[x(1),...,x(n),t] --------------------------- |
---|
91 | int s = size(l[3]); |
---|
92 | for ( i=1; i<=n; i++) |
---|
93 | { |
---|
94 | l[2][i]="x("+string(i)+")"; |
---|
95 | } |
---|
96 | l[2]=insert(l[2],"t",n); |
---|
97 | l[3]=insert(l[3],list("dp",1),s-1); |
---|
98 | def tr = ring(l); |
---|
99 | |
---|
100 | //--------------- create nr = K[x(1),...,x(n),y(1),...,y(k)] --------------- |
---|
101 | l[2]=delete(l[2],n+1); |
---|
102 | l[3]=delete(l[3],s); |
---|
103 | for ( i=1; i<=k; i++) |
---|
104 | { |
---|
105 | l[2][n+i]="y("+string(i)+")"; |
---|
106 | } |
---|
107 | |
---|
108 | //---- change l[3]: |
---|
109 | l[3][s+1] = l[3][s]; // save the module ordering of the basering |
---|
110 | intvec w; |
---|
111 | w[k]=0; w=w+1; |
---|
112 | intvec v; // containing the weights for the varibale |
---|
113 | if( homog(C) ) |
---|
114 | { |
---|
115 | for( i=1; i<=k; i++) |
---|
116 | { |
---|
117 | v[i]=deg(C[i]); |
---|
118 | } |
---|
119 | if (v != w) |
---|
120 | { |
---|
121 | l[3][s]=list("wp",v); |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | l[3][s]=list("dp",v); |
---|
126 | } |
---|
127 | } |
---|
128 | else |
---|
129 | { |
---|
130 | for( i=1; i<=k; i++) |
---|
131 | { |
---|
132 | v[i]=1; |
---|
133 | } |
---|
134 | l[3][s]=list("dp",v); |
---|
135 | } |
---|
136 | def nr = ring(l); |
---|
137 | |
---|
138 | //-------- create blowup map Bl: nr --> tr, x(i)->x(i), y(i)->t*fi --------- |
---|
139 | setring tr; |
---|
140 | ideal C = fetch(br,C); |
---|
141 | ideal bl = x(1..n); |
---|
142 | for( i=1; i<=k; i++) { bl = bl,t*C[i]; } |
---|
143 | map Bl = nr,bl; |
---|
144 | ideal Z; |
---|
145 | //------------------ compute blown up objects and return ------------------- |
---|
146 | setring nr; |
---|
147 | ideal bR = preimage(tr,Bl,Z); //ideal of blown up affine space A^n |
---|
148 | ideal C = fetch(br,C); |
---|
149 | ideal J = fetch(br,J); |
---|
150 | ideal W = fetch(br,W); |
---|
151 | ideal aS = interred(bR+W); //ideal of ambient space |
---|
152 | ideal tT = interred(J+bR+W); //ideal of total transform |
---|
153 | ideal eD = interred(C+J+bR+W); //ideal of exceptional divisor |
---|
154 | ideal sT = sat(tT,C)[1]; //ideal of strict transform |
---|
155 | ideal bM = x(1..n); //ideal of blowup map br --> nr |
---|
156 | |
---|
157 | export(bR,C,J,W,aS,tT,eD,sT,bM); |
---|
158 | return(nr); |
---|
159 | } |
---|
160 | example |
---|
161 | { "EXAMPLE:"; echo = 2; |
---|
162 | ring r = 0,(x,y),dp; |
---|
163 | poly f = x2+y3; |
---|
164 | ideal C = x,y; //center of blowup |
---|
165 | def B1 = blowup0(f,C); |
---|
166 | setring B1; |
---|
167 | aS; //ideal of blown up ambient space |
---|
168 | tT; //ideal of total transform of f |
---|
169 | sT; //ideal of strict transform of f |
---|
170 | eD; //ideal of exceptional divisor |
---|
171 | bM; //ideal of blowup map r --> B1 |
---|
172 | |
---|
173 | ring R = 0,(x,y,z),ds; |
---|
174 | poly f = y2+x3+z5; |
---|
175 | ideal C = y2,x,z; |
---|
176 | ideal W = z-x; |
---|
177 | def B2 = blowup0(f,C,W); |
---|
178 | setring B2; |
---|
179 | B2; //weighted ordering |
---|
180 | bR; //ideal of blown up R |
---|
181 | aS; //ideal of blown up R/W |
---|
182 | sT; //strict transform of f |
---|
183 | eD; //ideal of exceptional divisor |
---|
184 | //Note that the different affine charts are {y(i)=1} |
---|
185 | } |
---|
186 | /////////////////////////////////////////////////////////////////////////////// |
---|
187 | proc elimRing ( poly vars, list #) |
---|
188 | "USAGE: elimRing(vars [,w]); vars = product of variables to be eliminated |
---|
189 | (type poly), w = intvec (specifying weights for all variables) |
---|
190 | RETURN: a ring, say R, s.t. the monomial ordering of R has 2 blocks. |
---|
191 | The first block corresponds to the (given) variables to be eliminated |
---|
192 | and has ordering dp if these variables have weight all 1; if w is |
---|
193 | given or if not all variables in vars have weight 1 the ordering is |
---|
194 | wp(w1) where w1 is the intvec of weights of the variables to be |
---|
195 | eliminated. |
---|
196 | The second block corresponds to variables not to be eliminated. |
---|
197 | @* If the first variable not to be eliminated is global (i.e. > 1), |
---|
198 | resp. local (i.e. < 1), the second block has ordering dp, resp. ds, |
---|
199 | (or wp(w2), resp. ws(w2), where w2 is the intvec of weights of the |
---|
200 | variables not to be eliminated). |
---|
201 | @* If the basering is a quotient ring P/Q, then R a quotient ring |
---|
202 | with Q replaced by a standard basis of Q w.r.t. the new ordering |
---|
203 | (parameters are not touched). |
---|
204 | NOTE: The ordering in R is an elimination ordering for the variables |
---|
205 | appearing in vars. |
---|
206 | PURPOSE: Prepare a ring for eliminating vars from an ideal/moduel by |
---|
207 | computing a standard basis in R with a fast monomial ordering. |
---|
208 | This procedure is used by the procedure elim. |
---|
209 | EXAMPLE: example elimRing; shows an example |
---|
210 | " |
---|
211 | { |
---|
212 | def BR = basering; |
---|
213 | int nvarBR = nvars(BR); |
---|
214 | list BRlist = ringlist(BR); |
---|
215 | intvec @w; //to store weights of all variables |
---|
216 | @w[nvarBR] = 0; |
---|
217 | @w = @w + 1; //initialize @w as 1..1 |
---|
218 | if (size(#) == 1) |
---|
219 | { |
---|
220 | if ( typeof(#[1]) == "intvec" ) |
---|
221 | { |
---|
222 | @w = #[1]; //take the given weights |
---|
223 | } |
---|
224 | } |
---|
225 | else |
---|
226 | { |
---|
227 | @w = ringweights(BR); //compute the ring weights (proc from ring.lib) |
---|
228 | } |
---|
229 | |
---|
230 | //--- get variables to be eliminated and ringweights: |
---|
231 | intvec w1,w2; //for ringweights of first (w1) and second (w2) block |
---|
232 | list v1,v2; //for variables of first (to be liminated) and second block |
---|
233 | |
---|
234 | int ii; |
---|
235 | for( ii=1; ii<=nvarBR; ii++ ) |
---|
236 | { |
---|
237 | if( vars/var(ii)==0 ) //treat variables not to be eliminated |
---|
238 | { |
---|
239 | w2 = w2,@w[ii]; |
---|
240 | v2 = v2+list(string(var(ii))); |
---|
241 | if ( defined(local) == 0 ) |
---|
242 | { |
---|
243 | int local = (var(ii) < 1); |
---|
244 | } |
---|
245 | } |
---|
246 | else |
---|
247 | { |
---|
248 | w1 = w1,@w[ii]; |
---|
249 | v1 = v1+list(string(var(ii))); |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | int l1, l2 = size(w1), size(w2); |
---|
254 | if ( l1 <= 1 ) |
---|
255 | { |
---|
256 | ERROR("no elimination ?"); |
---|
257 | //return(BR); |
---|
258 | } |
---|
259 | if ( l2 <= 1 ) |
---|
260 | { |
---|
261 | ERROR("## elimination of all variables is not possible"); |
---|
262 | } |
---|
263 | |
---|
264 | w1 = w1[2..size(w1)]; |
---|
265 | w2 = w2[2..size(w2)]; |
---|
266 | |
---|
267 | //--- put variables to be eliminated in front: |
---|
268 | BRlist[2] = v1 + v2; |
---|
269 | |
---|
270 | //--- create a block ordering with two blocks and weights: |
---|
271 | int nblock = size(BRlist[3]); //number of blocks |
---|
272 | list BR3 = BRlist[3]; //save ordering |
---|
273 | BRlist[3] = list(); |
---|
274 | list B3; |
---|
275 | |
---|
276 | if( w1==1 ) |
---|
277 | { |
---|
278 | B3[1] = list("dp", w1); |
---|
279 | } |
---|
280 | else |
---|
281 | { |
---|
282 | B3[1] = list("wp", w1); |
---|
283 | } |
---|
284 | |
---|
285 | if( w2==1 ) |
---|
286 | { |
---|
287 | if ( local==1 ) |
---|
288 | { |
---|
289 | B3[2] = list("ds", w2); |
---|
290 | } |
---|
291 | else |
---|
292 | { |
---|
293 | B3[2] = list("dp", w2); |
---|
294 | } |
---|
295 | } |
---|
296 | else |
---|
297 | { |
---|
298 | if ( local==1 ) |
---|
299 | { |
---|
300 | B3[2] = list("ws", w2); |
---|
301 | } |
---|
302 | else |
---|
303 | { |
---|
304 | B3[2] = list("wp", w2); |
---|
305 | } |
---|
306 | } |
---|
307 | |
---|
308 | BRlist[3] = B3; |
---|
309 | |
---|
310 | //Module ordering stays in front resp. at the end: |
---|
311 | if( BR3[nblock][1] =="c" || BR3[nblock][1] =="C" ) |
---|
312 | { |
---|
313 | BRlist[3] = insert(BRlist[3],BR3[nblock],size(B3)); |
---|
314 | } |
---|
315 | else |
---|
316 | { |
---|
317 | BRlist[3] = insert(BRlist[3],BR3[1]); |
---|
318 | } |
---|
319 | |
---|
320 | def eRing = ring(quotientList(BRlist)); |
---|
321 | return (eRing); |
---|
322 | } |
---|
323 | example |
---|
324 | { "EXAMPLE:"; echo = 2; |
---|
325 | ring R = 0,(x,y,z,u,v),(c,lp); |
---|
326 | def P = elimRing(yu); P; |
---|
327 | intvec w = 1,1,3,4,5; |
---|
328 | elimRing(yu,w); |
---|
329 | |
---|
330 | ring S = (0,a),(x,y,z,u,v),ws(1,2,3,4,5); |
---|
331 | minpoly = a2+1; |
---|
332 | qring T = std(ideal(x+y2+v3,(x+v)^2)); |
---|
333 | def Q = elimRing(yv); |
---|
334 | setring Q; Q; |
---|
335 | } |
---|
336 | /////////////////////////////////////////////////////////////////////////////// |
---|
337 | |
---|
338 | proc elim (id, list #) |
---|
339 | "USAGE: elim(id,arg[,\"withWeights\"]); id ideal/module, arg can be either |
---|
340 | an intvec vor a product p of variables (type poly) |
---|
341 | RETURN: ideal/module obtained from id by eliminating either the variables |
---|
342 | with indices appearing in v or the variables appearing in p. |
---|
343 | Works also in a qring. |
---|
344 | METHOD: elim uses elimRing to create a ring with block ordering with two |
---|
345 | blocks where the first block contains the variables to be eliminated |
---|
346 | and then uses groebner. If the variables in the basering have weights |
---|
347 | these weights are used in elimRing. |
---|
348 | @* If a string \"withWeigts\" as second, optional argument is given, |
---|
349 | Singular computes weights for the variables to make the input as |
---|
350 | homogeneous as possible. |
---|
351 | @* The method is different from that used by eliminate and elim1; |
---|
352 | in some examples elim can be significantly faster. |
---|
353 | NOTE: No special monomial ordering is required, i.e. the ordering can be |
---|
354 | local or mixed. The result is a SB with respect to the ordering of |
---|
355 | the second block used by elimRing. E.g. if the first var not to be |
---|
356 | eliminated is global, resp. local, this ordering is dp, resp. ds |
---|
357 | (or wp, resp. ws, with the given weights for these variables). |
---|
358 | If printlevel > 0 the ring for which the output is a SB is shown. |
---|
359 | SEE ALSO: eliminate, elim1 |
---|
360 | EXAMPLE: example elim; shows an example |
---|
361 | " |
---|
362 | { |
---|
363 | if (size(#) == 0) |
---|
364 | { |
---|
365 | ERROR("## specify variables to be eliminated"); |
---|
366 | } |
---|
367 | int pr = printlevel - voice + 2; //for ring display if printlevel > 0 |
---|
368 | def BR = basering; |
---|
369 | //-------------------------------- check input ------------------------------- |
---|
370 | poly vars; |
---|
371 | int ii; |
---|
372 | if (size(#) > 0) |
---|
373 | { |
---|
374 | if ( typeof(#[1]) == "poly" ) |
---|
375 | { |
---|
376 | vars = #[1]; |
---|
377 | } |
---|
378 | if ( typeof(#[1]) == "intvec") |
---|
379 | { |
---|
380 | vars=1; |
---|
381 | for( ii=1; ii<=size(#[1]); ii++ ) |
---|
382 | { |
---|
383 | vars=vars*var(#[1][ii]); |
---|
384 | } |
---|
385 | } |
---|
386 | } |
---|
387 | if (size(#) == 2) |
---|
388 | { |
---|
389 | if ( typeof(#[2]) == "string" ) |
---|
390 | { |
---|
391 | if ( #[2] == "withWeights" ) |
---|
392 | { |
---|
393 | intvec @w = weight(id); |
---|
394 | } |
---|
395 | } |
---|
396 | } |
---|
397 | |
---|
398 | //-------------- create new ring and map objects to new ring ------------------ |
---|
399 | if ( defined(@w) ) |
---|
400 | { |
---|
401 | def ER = elimRing(vars,@w); |
---|
402 | } |
---|
403 | else |
---|
404 | { |
---|
405 | def ER = elimRing(vars); |
---|
406 | } |
---|
407 | setring ER; |
---|
408 | def id = imap(BR,id); |
---|
409 | poly vars = imap(BR,vars); |
---|
410 | //---------- now eliminate in new ring and map back to old ring --------------- |
---|
411 | id = groebner(id); |
---|
412 | id = nselect(id,1..size(ringlist(ER)[3][1][2])); |
---|
413 | if ( pr > 0 ) |
---|
414 | { |
---|
415 | "// result is a SB in the following ring:"; |
---|
416 | ER; |
---|
417 | } |
---|
418 | setring BR; |
---|
419 | return(imap(ER,id)); |
---|
420 | } |
---|
421 | example |
---|
422 | { "EXAMPLE:"; echo = 2; |
---|
423 | ring r=0,(x,y,u,v,w),dp; |
---|
424 | ideal i=x-u,y-u2,w-u3,v-x+y3; |
---|
425 | elim(i,3..4); |
---|
426 | elim(i,uv); |
---|
427 | int p = printlevel; |
---|
428 | printlevel = 2; |
---|
429 | elim(i,uv,"withWeights"); |
---|
430 | printlevel = p; |
---|
431 | |
---|
432 | ring S = (0,a),(x,y,z,u,v),ws(1,2,3,4,5); |
---|
433 | minpoly = a2+1; |
---|
434 | qring T = std(ideal(ax+y2+v3,(x+v)^2)); |
---|
435 | ideal i=x-u,y-u2,az-u3,v-x+ay3; |
---|
436 | module m=i*gen(1)+i*gen(2); |
---|
437 | m=elim(m,xy); |
---|
438 | show(m); |
---|
439 | } |
---|
440 | /////////////////////////////////////////////////////////////////////////////// |
---|
441 | |
---|
442 | proc elim2 (id, intvec va) |
---|
443 | "USAGE: elim2(id,v); id ideal/module, v intvec |
---|
444 | RETURNS: ideal/module obtained from id by eliminating variables in v |
---|
445 | NOTE: no special monomial ordering is required, result is a SB with |
---|
446 | respect to ordering dp (resp. ls) if the first var not to be |
---|
447 | eliminated belongs to a -p (resp. -s) blockordering |
---|
448 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
449 | SEE ALSO: elim1, eliminate, elim |
---|
450 | EXAMPLE: example elim2; shows examples |
---|
451 | " |
---|
452 | { |
---|
453 | //---- get variables to be eliminated and create string for new ordering ------ |
---|
454 | int ii; poly vars=1; |
---|
455 | for( ii=1; ii<=size(va); ii++ ) { vars=vars*var(va[ii]); } |
---|
456 | if( attrib(basering,"global")) { string ordering = "),dp;"; } |
---|
457 | else { string ordering = "),ls;"; } |
---|
458 | string mpoly=string(minpoly); |
---|
459 | //-------------- create new ring and map objects to new ring ------------------ |
---|
460 | def br = basering; |
---|
461 | string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering; |
---|
462 | execute(str); |
---|
463 | if (mpoly!="0") { execute("minpoly="+mpoly+";"); } |
---|
464 | def i = imap(br,id); |
---|
465 | poly vars = imap(br,vars); |
---|
466 | //---------- now eliminate in new ring and map back to old ring --------------- |
---|
467 | i = eliminate(i,vars); |
---|
468 | setring br; |
---|
469 | return(imap(@newr,i)); |
---|
470 | } |
---|
471 | example |
---|
472 | { "EXAMPLE:"; echo = 2; |
---|
473 | ring r=0,(x,y,u,v,w),dp; |
---|
474 | ideal i=x-u,y-u2,w-u3,v-x+y3; |
---|
475 | elim2(i,3..4); |
---|
476 | module m=i*gen(1)+i*gen(2); |
---|
477 | m=elim2(m,3..4);show(m); |
---|
478 | } |
---|
479 | /////////////////////////////////////////////////////////////////////////////// |
---|
480 | proc elim1 (id, poly vars) |
---|
481 | "USAGE: elim1(id,p); id ideal/module, p product of vars to be eliminated |
---|
482 | RETURN: ideal/module obtained from id by eliminating vars occuring in poly |
---|
483 | METHOD: elim1 calls eliminate but in a ring with ordering dp (resp. ls) |
---|
484 | if the first var not to be eliminated belongs to a -p (resp. -s) |
---|
485 | ordering. |
---|
486 | NOTE: no special monomial ordering is required. |
---|
487 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
488 | SEE ALSO: elim, eliminate |
---|
489 | EXAMPLE: example elim1; shows examples |
---|
490 | " |
---|
491 | { |
---|
492 | def br = basering; |
---|
493 | if ( size(ideal(br)) != 0 ) |
---|
494 | { |
---|
495 | ERROR ("cannot eliminate in a qring"); |
---|
496 | } |
---|
497 | //---- get variables to be eliminated and create string for new ordering ------ |
---|
498 | int ii; |
---|
499 | for( ii=1; ii<=nvars(basering); ii++ ) |
---|
500 | { |
---|
501 | if( vars/var(ii)==0 ) { poly p = 1+var(ii); break;} |
---|
502 | } |
---|
503 | if( ord(p)==0 ) { string ordering = "),ls;"; } |
---|
504 | if( ord(p)>0 ) { string ordering = "),dp;"; } |
---|
505 | //-------------- create new ring and map objects to new ring ------------------ |
---|
506 | string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering; |
---|
507 | execute(str); |
---|
508 | def id = fetch(br,id); |
---|
509 | poly vars = fetch(br,vars); |
---|
510 | //---------- now eliminate in new ring and map back to old ring --------------- |
---|
511 | id = eliminate(id,vars); |
---|
512 | setring br; |
---|
513 | return(imap(@newr,id)); |
---|
514 | } |
---|
515 | example |
---|
516 | { "EXAMPLE:"; echo = 2; |
---|
517 | ring r=0,(x,y,t,s,z),dp; |
---|
518 | ideal i=x-t,y-t2,z-t3,s-x+y3; |
---|
519 | elim1(i,ts); |
---|
520 | module m=i*gen(1)+i*gen(2); |
---|
521 | m=elim1(m,st); show(m); |
---|
522 | } |
---|
523 | /////////////////////////////////////////////////////////////////////////////// |
---|
524 | proc nselect (id, intvec v) |
---|
525 | "USAGE: nselect(id,v); id = ideal, module or matrix, v = intvec |
---|
526 | RETURN: generators (or columns) of id not containing the variables with index |
---|
527 | an entry of v |
---|
528 | SEE ALSO: select, select1 |
---|
529 | EXAMPLE: example nselect; shows examples |
---|
530 | "{ |
---|
531 | if (typeof(id)!="ideal") |
---|
532 | { |
---|
533 | if (typeof(id)=="module" || typeof(id)=="matrix") |
---|
534 | { |
---|
535 | module id1 = module(id); |
---|
536 | } |
---|
537 | else |
---|
538 | { |
---|
539 | ERROR("// *** input must be of type ideal or module or matrix"); |
---|
540 | } |
---|
541 | } |
---|
542 | else |
---|
543 | { |
---|
544 | ideal id1 = id; |
---|
545 | } |
---|
546 | int j,k; |
---|
547 | int n,m = size(v), ncols(id1); |
---|
548 | for( k=1; k<=m; k++ ) |
---|
549 | { |
---|
550 | for( j=1; j<=n; j++ ) |
---|
551 | { |
---|
552 | if( size(id1[k]/var(v[j]))!=0 ) |
---|
553 | { |
---|
554 | id1[k]=0; break; |
---|
555 | } |
---|
556 | } |
---|
557 | } |
---|
558 | id1=simplify(id1,2); |
---|
559 | if(typeof(id)=="matrix") |
---|
560 | { |
---|
561 | return(matrix(id1)); |
---|
562 | } |
---|
563 | return(id1); |
---|
564 | } |
---|
565 | example |
---|
566 | { "EXAMPLE:"; echo = 2; |
---|
567 | ring r=0,(x,y,t,s,z),(c,dp); |
---|
568 | ideal i=x-y,y-z2,z-t3,s-x+y3; |
---|
569 | nselect(i,3); |
---|
570 | module m=i*(gen(1)+gen(2)); |
---|
571 | m; |
---|
572 | nselect(m,3..4); |
---|
573 | nselect(matrix(m),3..4); |
---|
574 | } |
---|
575 | /////////////////////////////////////////////////////////////////////////////// |
---|
576 | |
---|
577 | proc sat (id, ideal j) |
---|
578 | "USAGE: sat(id,j); id=ideal/module, j=ideal |
---|
579 | RETURN: list of an ideal/module [1] and an integer [2]: |
---|
580 | [1] = saturation of id with respect to j (= union_(k=1...) of id:j^k) |
---|
581 | [2] = saturation exponent (= min( k | id:j^k = id:j^(k+1) )) |
---|
582 | NOTE: [1] is a standard basis in the basering |
---|
583 | DISPLAY: saturation exponent during computation if printlevel >=1 |
---|
584 | EXAMPLE: example sat; shows an example |
---|
585 | "{ |
---|
586 | int ii,kk; |
---|
587 | def i=id; |
---|
588 | id=std(id); |
---|
589 | int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) |
---|
590 | while( ii<=size(i) ) |
---|
591 | { |
---|
592 | dbprint(p-1,"// compute quotient "+string(kk+1)); |
---|
593 | i=quotient(id,j); |
---|
594 | for( ii=1; ii<=size(i); ii++ ) |
---|
595 | { |
---|
596 | if( reduce(i[ii],id,1)!=0 ) break; |
---|
597 | } |
---|
598 | id=std(i); kk++; |
---|
599 | } |
---|
600 | dbprint(p-1,"// saturation becomes stable after "+string(kk-1)+" iteration(s)",""); |
---|
601 | list L = id,kk-1; |
---|
602 | return (L); |
---|
603 | } |
---|
604 | example |
---|
605 | { "EXAMPLE:"; echo = 2; |
---|
606 | int p = printlevel; |
---|
607 | ring r = 2,(x,y,z),dp; |
---|
608 | poly F = x5+y5+(x-y)^2*xyz; |
---|
609 | ideal j = jacob(F); |
---|
610 | sat(j,maxideal(1)); |
---|
611 | printlevel = 2; |
---|
612 | sat(j,maxideal(2)); |
---|
613 | printlevel = p; |
---|
614 | } |
---|
615 | /////////////////////////////////////////////////////////////////////////////// |
---|
616 | proc select (id, intvec v) |
---|
617 | "USAGE: select(id,n[,m]); id = ideal/module/matrix, v = intvec |
---|
618 | RETURN: generators/columns of id containing all variables with index |
---|
619 | an entry of v |
---|
620 | NOTE: use 'select1' for selecting generators/columns containing at least |
---|
621 | one of the variables with index an entry of v |
---|
622 | SEE ALSO: select1, nselect |
---|
623 | EXAMPLE: example select; shows examples |
---|
624 | "{ |
---|
625 | if (typeof(id)!="ideal") |
---|
626 | { |
---|
627 | if (typeof(id)=="module" || typeof(id)=="matrix") |
---|
628 | { |
---|
629 | module id1 = module(id); |
---|
630 | } |
---|
631 | else |
---|
632 | { |
---|
633 | ERROR("// *** input must be of type ideal or module or matrix"); |
---|
634 | } |
---|
635 | } |
---|
636 | else |
---|
637 | { |
---|
638 | ideal id1 = id; |
---|
639 | } |
---|
640 | int j,k; |
---|
641 | int n,m = size(v), ncols(id1); |
---|
642 | for( k=1; k<=m; k++ ) |
---|
643 | { |
---|
644 | for( j=1; j<=n; j++ ) |
---|
645 | { |
---|
646 | if( size(id1[k]/var(v[j]))==0) |
---|
647 | { |
---|
648 | id1[k]=0; break; |
---|
649 | } |
---|
650 | } |
---|
651 | } |
---|
652 | if(typeof(id)=="matrix") |
---|
653 | { |
---|
654 | return(matrix(simplify(id1,2))); |
---|
655 | } |
---|
656 | return(simplify(id1,2)); |
---|
657 | } |
---|
658 | example |
---|
659 | { "EXAMPLE:"; echo = 2; |
---|
660 | ring r=0,(x,y,t,s,z),(c,dp); |
---|
661 | ideal i=x-y,y-z2,z-t3,s-x+y3; |
---|
662 | ideal j=select(i,1); |
---|
663 | j; |
---|
664 | module m=i*(gen(1)+gen(2)); |
---|
665 | m; |
---|
666 | select(m,1..2); |
---|
667 | select(matrix(m),1..2); |
---|
668 | } |
---|
669 | /////////////////////////////////////////////////////////////////////////////// |
---|
670 | |
---|
671 | proc select1 (id, intvec v) |
---|
672 | "USAGE: select1(id,v); id = ideal/module/matrix, v = intvec |
---|
673 | RETURN: generators/columns of id containing at least one of the variables |
---|
674 | with index an entry of v |
---|
675 | NOTE: use 'select' for selecting generators/columns containing all variables |
---|
676 | with index an entry of v |
---|
677 | SEE ALSO: select, nselect |
---|
678 | EXAMPLE: example select1; shows examples |
---|
679 | "{ |
---|
680 | if (typeof(id)!="ideal") |
---|
681 | { |
---|
682 | if (typeof(id)=="module" || typeof(id)=="matrix") |
---|
683 | { |
---|
684 | module id1 = module(id); |
---|
685 | module I; |
---|
686 | } |
---|
687 | else |
---|
688 | { |
---|
689 | ERROR("// *** input must be of type ideal or module or matrix"); |
---|
690 | } |
---|
691 | } |
---|
692 | else |
---|
693 | { |
---|
694 | ideal id1 = id; |
---|
695 | ideal I; |
---|
696 | } |
---|
697 | int j,k; |
---|
698 | int n,m = size(v), ncols(id1); |
---|
699 | for( k=1; k<=m; k++ ) |
---|
700 | { for( j=1; j<=n; j++ ) |
---|
701 | { |
---|
702 | if( size(subst(id1[k],var(v[j]),0)) != size(id1[k]) ) |
---|
703 | { |
---|
704 | I = I,id1[k]; break; |
---|
705 | } |
---|
706 | } |
---|
707 | } |
---|
708 | I=simplify(I,2); |
---|
709 | if(typeof(id)=="matrix") |
---|
710 | { |
---|
711 | return(matrix(I)); |
---|
712 | } |
---|
713 | return(I); |
---|
714 | } |
---|
715 | example |
---|
716 | { "EXAMPLE:"; echo = 2; |
---|
717 | ring r=0,(x,y,t,s,z),(c,dp); |
---|
718 | ideal i=x-y,y-z2,z-t3,s-x+y3; |
---|
719 | ideal j=select1(i,1);j; |
---|
720 | module m=i*(gen(1)+gen(2)); m; |
---|
721 | select1(m,1..2); |
---|
722 | select1(matrix(m),1..2); |
---|
723 | } |
---|
724 | /////////////////////////////////////////////////////////////////////////////// |
---|