1 | // $Id: prim_dec.lib,v 1.3 1997-08-04 15:14:20 Singular Exp $ |
---|
2 | /////////////////////////////////////////////////////// |
---|
3 | // pseudoprimdec.lib |
---|
4 | // algorithms for primary decomposition based on |
---|
5 | // the ideas of Shimoyama/Yokoyama |
---|
6 | // written by Wolfram Decker and Hans Schoenemann |
---|
7 | ////////////////////////////////////////////////////// |
---|
8 | |
---|
9 | LIBRARY: prim_dec.lib: PROCEDURE FOR PRIMARY DECOMPOSITION (II) |
---|
10 | |
---|
11 | min_ass_prim_charsets (ideal I, int choose) |
---|
12 | // minimal associated primes via the characteristic set |
---|
13 | // package written by Michael Messollen. |
---|
14 | // The integer choose must be either 0 or 1. |
---|
15 | // If choose=0, the given ordering of the variables is used. |
---|
16 | // If choose=1, the system tries to find an "optimal ordering", |
---|
17 | // which in some cases may considerably speed up the algorithm |
---|
18 | |
---|
19 | // You may also may want to try one of the algorithms for |
---|
20 | // minimal associated primes in the the library |
---|
21 | // primdec.lib, written by Gerhard Pfister. |
---|
22 | // These algorithms are variants of the algorithm |
---|
23 | // of Gianni-Trager-Zacharias |
---|
24 | |
---|
25 | prim_dec (ideal I, int choose) |
---|
26 | |
---|
27 | // Computes a complete primary decomposition via |
---|
28 | // a variant of the pseudoprimary approach of |
---|
29 | // Shimoyama-Yokoyama. |
---|
30 | // The integer choose must be either 0, 1, 2 or 3. |
---|
31 | // If choose=0, min_ass_prim_charsets with the given |
---|
32 | // ordering of the variables is used. |
---|
33 | // If choose=1, min_ass_prim_charsets with the "optimized" |
---|
34 | // ordering of the variables is used. |
---|
35 | // If choose=2, minAssPrimes from primdec.lib is used |
---|
36 | // If choose=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
37 | |
---|
38 | LIB "general.lib"; |
---|
39 | LIB "elim.lib"; |
---|
40 | LIB "poly.lib"; |
---|
41 | LIB "primdec.lib"; |
---|
42 | /////////////////////////////////////////////////////// |
---|
43 | // ini_mod |
---|
44 | // input: a polynomial p |
---|
45 | // output: the initial term of p as needed |
---|
46 | // in the context of characteristic sets |
---|
47 | ////////////////////////////////////////////////////// |
---|
48 | |
---|
49 | proc ini_mod(poly p) |
---|
50 | { |
---|
51 | if (p==0) |
---|
52 | { |
---|
53 | return(0); |
---|
54 | } |
---|
55 | int n; matrix m; |
---|
56 | for( n=nvars(basering); n>0; n=n-1) |
---|
57 | { |
---|
58 | m=coef(p,var(n)); |
---|
59 | if(m[1,1]!=1) |
---|
60 | { |
---|
61 | p=m[2,1]; |
---|
62 | break; |
---|
63 | } |
---|
64 | } |
---|
65 | if(deg(p)==0) |
---|
66 | { |
---|
67 | p=0; |
---|
68 | } |
---|
69 | return(p); |
---|
70 | } |
---|
71 | /////////////////////////////////////////////////////// |
---|
72 | // min_ass_prim_charsets |
---|
73 | // input: generators of an ideal PS and an integer cho |
---|
74 | // If cho=0, the given ordering of the variables is used. |
---|
75 | // Otherwise, the system tries to find an "optimal ordering", |
---|
76 | // which in some cases may considerably speed up the algorithm |
---|
77 | // output: the minimal associated primes of PS |
---|
78 | // algorithm: via characteriostic sets |
---|
79 | ////////////////////////////////////////////////////// |
---|
80 | |
---|
81 | |
---|
82 | proc min_ass_prim_charsets (ideal PS, int cho) |
---|
83 | { |
---|
84 | if((cho<0) and (cho>1)) |
---|
85 | { |
---|
86 | "ERROR: <int> must be 0 or 1" |
---|
87 | return(); |
---|
88 | } |
---|
89 | if(system("version")>933) |
---|
90 | { |
---|
91 | verbose(notWarnSB); |
---|
92 | } |
---|
93 | if(cho==0) |
---|
94 | { |
---|
95 | return(min_ass_prim_charsets0(PS)); |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | return(min_ass_prim_charsets1(PS)); |
---|
100 | } |
---|
101 | } |
---|
102 | /////////////////////////////////////////////////////// |
---|
103 | // min_ass_prim_charsets0 |
---|
104 | // input: generators of an ideal PS |
---|
105 | // output: the minimal associated primes of PS |
---|
106 | // algorithm: via characteristic sets |
---|
107 | // the given ordering of the variables is used |
---|
108 | ////////////////////////////////////////////////////// |
---|
109 | |
---|
110 | |
---|
111 | proc min_ass_prim_charsets0 (ideal PS) |
---|
112 | { |
---|
113 | |
---|
114 | matrix m=char_series(PS); // We compute an irreducible |
---|
115 | // characteristic series |
---|
116 | int i,j,k; |
---|
117 | list PSI; |
---|
118 | list PHI; // the ideals given by the characteristic series |
---|
119 | for(i=nrows(m);i>=1; i--) |
---|
120 | { |
---|
121 | PHI[i]=ideal(m[i,1..ncols(m)]); |
---|
122 | } |
---|
123 | // We compute the radical of each ideal in PHI |
---|
124 | ideal I,JS,II; |
---|
125 | int sizeJS, sizeII; |
---|
126 | for(i=size(PHI);i>=1; i--) |
---|
127 | { |
---|
128 | I=0; |
---|
129 | for(j=size(PHI[i]);j>0;j=j-1) |
---|
130 | { |
---|
131 | I=I+ini_mod(PHI[i][j]); |
---|
132 | } |
---|
133 | JS=std(PHI[i]); |
---|
134 | sizeJS=size(JS); |
---|
135 | for(j=size(I);j>0;j=j-1) |
---|
136 | { |
---|
137 | II=0; |
---|
138 | sizeII=0; |
---|
139 | k=0; |
---|
140 | while(k<=sizeII) // successive saturation |
---|
141 | { |
---|
142 | option(returnSB); |
---|
143 | II=quotient(JS,I[j]); |
---|
144 | option(noreturnSB); |
---|
145 | //std |
---|
146 | // II=std(II); |
---|
147 | sizeII=size(II); |
---|
148 | if(sizeII==sizeJS) |
---|
149 | { |
---|
150 | for(k=1;k<=sizeII;k++) |
---|
151 | { |
---|
152 | if(leadexp(II[k])!=leadexp(JS[k])) break; |
---|
153 | } |
---|
154 | } |
---|
155 | JS=II; |
---|
156 | sizeJS=sizeII; |
---|
157 | } |
---|
158 | } |
---|
159 | PSI=insert(PSI,JS); |
---|
160 | } |
---|
161 | int sizePSI=size(PSI); |
---|
162 | // We eliminate redundant ideals |
---|
163 | for(i=1;i<sizePSI;i++) |
---|
164 | { |
---|
165 | for(j=i+1;j<=sizePSI;j++) |
---|
166 | { |
---|
167 | if(size(PSI[i])!=0) |
---|
168 | { |
---|
169 | if(size(PSI[j])!=0) |
---|
170 | { |
---|
171 | if(size(NF(PSI[i],PSI[j],1))==0) |
---|
172 | { |
---|
173 | PSI[j]=ideal(0); |
---|
174 | } |
---|
175 | else |
---|
176 | { |
---|
177 | if(size(NF(PSI[j],PSI[i],1))==0) |
---|
178 | { |
---|
179 | PSI[i]=ideal(0); |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | } |
---|
184 | } |
---|
185 | } |
---|
186 | for(i=sizePSI;i>=1;i--) |
---|
187 | { |
---|
188 | if(size(PSI[i])==0) |
---|
189 | { |
---|
190 | PSI=delete(PSI,i); |
---|
191 | } |
---|
192 | } |
---|
193 | return (PSI); |
---|
194 | } |
---|
195 | |
---|
196 | /////////////////////////////////////////////////////// |
---|
197 | // min_ass_prim_charsets1 |
---|
198 | // input: generators of an ideal PS |
---|
199 | // output: the minimal associated primes of PS |
---|
200 | // algorithm: via characteristic sets |
---|
201 | // input: generators of an ideal PS and an integer i |
---|
202 | // The system tries to find an "optimal ordering" of |
---|
203 | // the variables |
---|
204 | ////////////////////////////////////////////////////// |
---|
205 | |
---|
206 | |
---|
207 | proc min_ass_prim_charsets1 (ideal PS) |
---|
208 | { |
---|
209 | def oldring=basering; |
---|
210 | string n=system("neworder",PS); |
---|
211 | execute "ring r="+charstr(oldring)+",("+n+"),dp;"; |
---|
212 | ideal PS=imap(oldring,PS); |
---|
213 | matrix m=char_series(PS); // We compute an irreducible |
---|
214 | // characteristic series |
---|
215 | int i,j,k; |
---|
216 | ideal I; |
---|
217 | list PSI; |
---|
218 | list PHI; // the ideals given by the characteristic series |
---|
219 | list ITPHI; // their initial terms |
---|
220 | for(i=nrows(m);i>=1; i--) |
---|
221 | { |
---|
222 | PHI[i]=ideal(m[i,1..ncols(m)]); |
---|
223 | I=0; |
---|
224 | for(j=size(PHI[i]);j>0;j=j-1) |
---|
225 | { |
---|
226 | I=I,ini_mod(PHI[i][j]); |
---|
227 | } |
---|
228 | I=I[2..ncols(I)]; |
---|
229 | ITPHI[i]=I; |
---|
230 | } |
---|
231 | setring oldring; |
---|
232 | matrix m=imap(r,m); |
---|
233 | list PHI=imap(r,PHI); |
---|
234 | list ITPHI=imap(r,ITPHI); |
---|
235 | // We compute the radical of each ideal in PHI |
---|
236 | ideal I,JS,II; |
---|
237 | int sizeJS, sizeII; |
---|
238 | for(i=size(PHI);i>=1; i--) |
---|
239 | { |
---|
240 | I=0; |
---|
241 | for(j=size(PHI[i]);j>0;j=j-1) |
---|
242 | { |
---|
243 | I=I+ITPHI[i][j]; |
---|
244 | } |
---|
245 | JS=std(PHI[i]); |
---|
246 | sizeJS=size(JS); |
---|
247 | for(j=size(I);j>0;j=j-1) |
---|
248 | { |
---|
249 | II=0; |
---|
250 | sizeII=0; |
---|
251 | k=0; |
---|
252 | while(k<=sizeII) // successive iteration |
---|
253 | { |
---|
254 | option(returnSB); |
---|
255 | II=quotient(JS,I[j]); |
---|
256 | option(noreturnSB); |
---|
257 | //std |
---|
258 | // II=std(II); |
---|
259 | sizeII=size(II); |
---|
260 | if(sizeII==sizeJS) |
---|
261 | { |
---|
262 | for(k=1;k<=sizeII;k++) |
---|
263 | { |
---|
264 | if(leadexp(II[k])!=leadexp(JS[k])) break; |
---|
265 | } |
---|
266 | } |
---|
267 | JS=II; |
---|
268 | sizeJS=sizeII; |
---|
269 | } |
---|
270 | } |
---|
271 | PSI=insert(PSI,JS); |
---|
272 | } |
---|
273 | int sizePSI=size(PSI); |
---|
274 | // We eliminate redundant ideals |
---|
275 | for(i=1;i<sizePSI;i++) |
---|
276 | { |
---|
277 | for(j=i+1;j<=sizePSI;j++) |
---|
278 | { |
---|
279 | if(size(PSI[i])!=0) |
---|
280 | { |
---|
281 | if(size(PSI[j])!=0) |
---|
282 | { |
---|
283 | if(size(NF(PSI[i],PSI[j],1))==0) |
---|
284 | { |
---|
285 | PSI[j]=ideal(0); |
---|
286 | } |
---|
287 | else |
---|
288 | { |
---|
289 | if(size(NF(PSI[j],PSI[i],1))==0) |
---|
290 | { |
---|
291 | PSI[i]=ideal(0); |
---|
292 | } |
---|
293 | } |
---|
294 | } |
---|
295 | } |
---|
296 | } |
---|
297 | } |
---|
298 | for(i=sizePSI;i>=1;i--) |
---|
299 | { |
---|
300 | if(size(PSI[i])==0) |
---|
301 | { |
---|
302 | PSI=delete(PSI,i); |
---|
303 | } |
---|
304 | } |
---|
305 | return (PSI); |
---|
306 | } |
---|
307 | |
---|
308 | |
---|
309 | ///////////////////////////////////////////////////// |
---|
310 | // proc prim_dec |
---|
311 | // input: generators of an ideal I and an integer choose |
---|
312 | // If choose=0, min_ass_prim_charsets with the given |
---|
313 | // ordering of the variables is used. |
---|
314 | // If choose=1, min_ass_prim_charsets with the "optimized" |
---|
315 | // ordering of the variables is used. |
---|
316 | // If choose=2, minAssPrimes from primdec.lib is used |
---|
317 | // If choose=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
318 | // output: a primary decomposition of I, i.e., a list |
---|
319 | // of pairs consisting of a standard basis of a primary component |
---|
320 | // of I and a standard basis of the corresponding associated prime. |
---|
321 | // To compute the minimal associated primes of a given ideal |
---|
322 | // min_ass_prim_l is called, i.e., the minimal associated primes |
---|
323 | // are computed via characteristic sets. |
---|
324 | // In the homogeneous case, the performance of the procedure |
---|
325 | // will be improved if I is already given by a minimal set of |
---|
326 | // generators. Apply minbase if necessary. |
---|
327 | ////////////////////////////////////////////////////////// |
---|
328 | |
---|
329 | |
---|
330 | proc prim_dec(ideal I, int choose) |
---|
331 | { |
---|
332 | if((choose<0) or (choose>3)) |
---|
333 | { |
---|
334 | "ERROR: <int> must be 0 or 1 or 2 or 3"; |
---|
335 | return(); |
---|
336 | } |
---|
337 | if(system("version")>933) |
---|
338 | { |
---|
339 | verbose(notWarnSB); |
---|
340 | } |
---|
341 | ideal H=1; // The intersection of the primary components |
---|
342 | list U; // the leaves of the decomposition tree, i.e., |
---|
343 | // pairs consisting of a primary component of I |
---|
344 | // and the corresponding associated prime |
---|
345 | list W; // the non-leaf vertices in the decomposition tree. |
---|
346 | // every entry has 6 components: |
---|
347 | // 1- the vertex itself , i.e., a standard bais of the |
---|
348 | // given ideal I (type 1), or a standard basis of a |
---|
349 | // pseudo-primary component arising from |
---|
350 | // pseudo-primary decomposition (type 2), or a |
---|
351 | // standard basis of a remaining component arising from |
---|
352 | // pseudo-primary decomposition or extraction (type 3) |
---|
353 | // 2- the type of the vertex as indicated above |
---|
354 | // 3- the weighted_tree_depth of the vertex |
---|
355 | // 4- the tester of the vertex |
---|
356 | // 5- a standard basis of the associated prime |
---|
357 | // of a vertex of type 2, or 0 otherwise |
---|
358 | // 6- a list of pairs consisting of a standard |
---|
359 | // basis of a minimal associated prime ideal |
---|
360 | // of the father of the vertex and the |
---|
361 | // irreducible factors of the "minimal |
---|
362 | // divisor" of the seperator or extractor |
---|
363 | // corresponding to the prime ideal |
---|
364 | // as computed by the procedure minsat, |
---|
365 | // if the vertex is of type 3, or |
---|
366 | // the empty list otherwise |
---|
367 | ideal SI=std(I); |
---|
368 | int ncolsSI=ncols(SI); |
---|
369 | int ncolsH=1; |
---|
370 | W[1]=list(I,1,0,poly(1),ideal(0),list()); // The root of the tree |
---|
371 | int weighted_tree_depth; |
---|
372 | int i,j; |
---|
373 | int check; |
---|
374 | list V; // current vertex |
---|
375 | list VV; // new vertex |
---|
376 | list QQ; |
---|
377 | list WI; |
---|
378 | ideal Qi,SQ,SRest,fac; |
---|
379 | poly tester; |
---|
380 | |
---|
381 | while(1) |
---|
382 | { |
---|
383 | i=1; |
---|
384 | while(1) |
---|
385 | { |
---|
386 | while(i<=size(W)) // find vertex V of smallest weighted tree-depth |
---|
387 | { |
---|
388 | if (W[i][3]<=weighted_tree_depth) break; |
---|
389 | i++; |
---|
390 | } |
---|
391 | if (i<=size(W)) break; |
---|
392 | i=1; |
---|
393 | weighted_tree_depth++; |
---|
394 | } |
---|
395 | V=W[i]; |
---|
396 | W=delete(W,i); // delete V from W |
---|
397 | |
---|
398 | // now proceed by type of vertex V |
---|
399 | |
---|
400 | if (V[2]==2) // extraction needed |
---|
401 | { |
---|
402 | SQ,SRest,fac=extraction(V[1],V[5]); |
---|
403 | // standard basis of primary component, |
---|
404 | // standard basis of remaining component, |
---|
405 | // irreducible factors of |
---|
406 | // the "minimal divisor" of the extractor |
---|
407 | // as computed by the procedure minsat, |
---|
408 | check=0; |
---|
409 | for(j=1;j<=ncolsH;j++) |
---|
410 | { |
---|
411 | if (NF(H[j],SQ,1)!=0) // Q is not redundant |
---|
412 | { |
---|
413 | check=1; |
---|
414 | break; |
---|
415 | } |
---|
416 | } |
---|
417 | if(check==1) // Q is not redundant |
---|
418 | { |
---|
419 | QQ=list(); |
---|
420 | QQ[1]=list(SQ,V[5]); // primary component, associated prime, |
---|
421 | // i.e., standard bases thereof |
---|
422 | U=U+QQ; |
---|
423 | H=intersect(H,SQ); |
---|
424 | H=std(H); |
---|
425 | ncolsH=ncols(H); |
---|
426 | check=0; |
---|
427 | if(ncolsH==ncolsSI) |
---|
428 | { |
---|
429 | for(j=1;j<=ncolsSI;j++) |
---|
430 | { |
---|
431 | if(leadexp(H[j])!=leadexp(SI[j])) |
---|
432 | { |
---|
433 | check=1; |
---|
434 | break; |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | else |
---|
439 | { |
---|
440 | check=1; |
---|
441 | } |
---|
442 | if(check==0) // H==I => U is a primary decomposition |
---|
443 | { |
---|
444 | return(U); |
---|
445 | } |
---|
446 | } |
---|
447 | if (SRest[1]!=1) // the remaining component is not |
---|
448 | // the whole ring |
---|
449 | { |
---|
450 | if (rad_con(V[4],SRest)==0) // the new vertex is not the |
---|
451 | // root of a redundant subtree |
---|
452 | { |
---|
453 | VV[1]=SRest; // remaining component |
---|
454 | VV[2]=3; // pseudoprimdec_special |
---|
455 | VV[3]=V[3]+1; // weighted depth |
---|
456 | VV[4]=V[4]; // the tester did not change |
---|
457 | VV[5]=ideal(0); |
---|
458 | VV[6]=list(list(V[5],fac)); |
---|
459 | W=insert(W,VV,size(W)); |
---|
460 | } |
---|
461 | } |
---|
462 | } |
---|
463 | else |
---|
464 | { |
---|
465 | if (V[2]==3) // pseudo_prim_dec_special is needed |
---|
466 | { |
---|
467 | QQ,SRest=pseudo_prim_dec_special_charsets(V[1],V[6],choose); |
---|
468 | // QQ = quadruples: |
---|
469 | // standard basis of pseudo-primary component, |
---|
470 | // standard basis of corresponding prime, |
---|
471 | // seperator, irreducible factors of |
---|
472 | // the "minimal divisor" of the seperator |
---|
473 | // as computed by the procedure minsat, |
---|
474 | // SRest=standard basis of remaining component |
---|
475 | } |
---|
476 | else // V is the root, pseudo_prim_dec is needed |
---|
477 | { |
---|
478 | QQ,SRest=pseudo_prim_dec_charsets(I,SI,choose); |
---|
479 | // QQ = quadruples: |
---|
480 | // standard basis of pseudo-primary component, |
---|
481 | // standard basis of corresponding prime, |
---|
482 | // seperator, irreducible factors of |
---|
483 | // the "minimal divisor" of the seperator |
---|
484 | // as computed by the procedure minsat, |
---|
485 | // SRest=standard basis of remaining component |
---|
486 | |
---|
487 | } |
---|
488 | //check |
---|
489 | for(i=size(QQ);i>=1;i--) |
---|
490 | //for(i=1;i<=size(QQ);i++) |
---|
491 | { |
---|
492 | tester=QQ[i][3]*V[4]; |
---|
493 | Qi=QQ[i][2]; |
---|
494 | if(NF(tester,Qi,1)!=0) // the new vertex is not the |
---|
495 | // root of a redundant subtree |
---|
496 | { |
---|
497 | VV[1]=QQ[i][1]; |
---|
498 | VV[2]=2; |
---|
499 | VV[3]=V[3]+1; |
---|
500 | VV[4]=tester; // the new tester as computed above |
---|
501 | VV[5]=Qi; // QQ[i][2]; |
---|
502 | VV[6]=list(); |
---|
503 | W=insert(W,VV,size(W)); |
---|
504 | } |
---|
505 | } |
---|
506 | if (SRest[1]!=1) // the remaining component is not |
---|
507 | // the whole ring |
---|
508 | { |
---|
509 | if (rad_con(V[4],SRest)==0) // the vertex is not the root |
---|
510 | // of a redundant subtree |
---|
511 | { |
---|
512 | VV[1]=SRest; |
---|
513 | VV[2]=3; |
---|
514 | VV[3]=V[3]+2; |
---|
515 | VV[4]=V[4]; // the tester did not change |
---|
516 | VV[5]=ideal(0); |
---|
517 | WI=list(); |
---|
518 | for(i=1;i<=size(QQ);i++) |
---|
519 | { |
---|
520 | WI=insert(WI,list(QQ[i][2],QQ[i][4])); |
---|
521 | } |
---|
522 | VV[6]=WI; |
---|
523 | W=insert(W,VV,size(W)); |
---|
524 | } |
---|
525 | } |
---|
526 | } |
---|
527 | } |
---|
528 | } |
---|
529 | |
---|
530 | ////////////////////////////////////////////////////////////////////////// |
---|
531 | // proc pseudo_prim_dec_charsets |
---|
532 | // input: Generators of an arbitrary ideal I, a standard basis SI of I, |
---|
533 | // and an integer choo |
---|
534 | // If choo=0, min_ass_prim_charsets with the given |
---|
535 | // ordering of the variables is used. |
---|
536 | // If choo=1, min_ass_prim_charsets with the "optimized" |
---|
537 | // ordering of the variables is used. |
---|
538 | // If choo=2, minAssPrimes from primdec.lib is used |
---|
539 | // If choo=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
540 | // output: a pseudo primary decomposition of I, i.e., a list |
---|
541 | // of pseudo primary components together with a standard basis of the |
---|
542 | // remaining component. Each pseudo primary component is |
---|
543 | // represented by a quadrupel: A standard basis of the component, |
---|
544 | // a standard basis of the corresponding associated prime, the |
---|
545 | // seperator of the component, and the irreducible factors of the |
---|
546 | // "minimal divisor" of the seperator as computed by the procedure minsat, |
---|
547 | // calls proc pseudo_prim_dec_i |
---|
548 | ////////////////////////////////////////////////////////////////////////// |
---|
549 | |
---|
550 | |
---|
551 | proc pseudo_prim_dec_charsets (ideal I, ideal SI, int choo) |
---|
552 | { |
---|
553 | list L; // The list of minimal associated primes, |
---|
554 | // each one given by a standard basis |
---|
555 | if((choo==0) or (choo==1)) |
---|
556 | { |
---|
557 | L=min_ass_prim_charsets(I,choo); |
---|
558 | } |
---|
559 | else |
---|
560 | { |
---|
561 | if(choo==2) |
---|
562 | { |
---|
563 | L=minAssPrimes(I); |
---|
564 | } |
---|
565 | else |
---|
566 | { |
---|
567 | L=minAssPrimes(I,1); |
---|
568 | } |
---|
569 | for(int i=size(L);i>=1;i=i-1) |
---|
570 | { |
---|
571 | L[i]=std(L[i]); |
---|
572 | } |
---|
573 | } |
---|
574 | return (pseudo_prim_dec_i(SI,L)); |
---|
575 | } |
---|
576 | |
---|
577 | //////////////////////////////////////////////////////////////// |
---|
578 | // proc pseudo_prim_dec_special_charsets |
---|
579 | // input: a standard basis of an ideal I whose radical is the |
---|
580 | // intersection of the radicals of ideals generated by one prime ideal |
---|
581 | // P_i together with one polynomial f_i, the list V6 must be the list of |
---|
582 | // pairs (standard basis of P_i, irreducible factors of f_i), |
---|
583 | // and an integer choo |
---|
584 | // If choo=0, min_ass_prim_charsets with the given |
---|
585 | // ordering of the variables is used. |
---|
586 | // If choo=1, min_ass_prim_charsets with the "optimized" |
---|
587 | // ordering of the variables is used. |
---|
588 | // If choo=2, minAssPrimes from primdec.lib is used |
---|
589 | // If choo=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
590 | // output: a pseudo primary decomposition of I, i.e., a list |
---|
591 | // of pseudo primary components together with a standard basis of the |
---|
592 | // remaining component. Each pseudo primary component is |
---|
593 | // represented by a quadrupel: A standard basis of the component, |
---|
594 | // a standard basis of the corresponding associated prime, the |
---|
595 | // seperator of the component, and the irreducible factors of the |
---|
596 | // "minimal divisor" of the seperator as computed by the procedure minsat, |
---|
597 | // calls proc pseudo_prim_dec_i |
---|
598 | //////////////////////////////////////////////////////////////// |
---|
599 | |
---|
600 | |
---|
601 | proc pseudo_prim_dec_special_charsets (ideal SI,list V6, int choo) |
---|
602 | { |
---|
603 | int i,j,l; |
---|
604 | list m; |
---|
605 | list L; |
---|
606 | int sizeL; |
---|
607 | ideal P,SP; ideal fac; |
---|
608 | int dimSP; |
---|
609 | for(l=size(V6);l>=1;l--) // creates a list of associated primes |
---|
610 | // of I, possibly redundant |
---|
611 | { |
---|
612 | P=V6[l][1]; |
---|
613 | fac=V6[l][2]; |
---|
614 | for(i=ncols(fac);i>=1;i--) |
---|
615 | { |
---|
616 | SP=P+fac[i]; |
---|
617 | SP=std(SP); |
---|
618 | if(SP[1]!=1) |
---|
619 | { |
---|
620 | if((choo==0) or (choo==1)) |
---|
621 | { |
---|
622 | m=min_ass_prim_charsets(SP,choo); // a list of SB |
---|
623 | } |
---|
624 | else |
---|
625 | { |
---|
626 | if(choo==2) |
---|
627 | { |
---|
628 | m=minAssPrimes(SP); |
---|
629 | } |
---|
630 | else |
---|
631 | { |
---|
632 | m=minAssPrimes(SP,1); |
---|
633 | } |
---|
634 | for(j=size(m);j>=1;j=j-1) |
---|
635 | { |
---|
636 | m[j]=std(m[j]); |
---|
637 | } |
---|
638 | } |
---|
639 | dimSP=dim(SP); |
---|
640 | for(j=size(m);j>=1; j--) |
---|
641 | { |
---|
642 | if(dim(m[j])==dimSP) |
---|
643 | { |
---|
644 | L=insert(L,m[j],size(L)); |
---|
645 | } |
---|
646 | } |
---|
647 | } |
---|
648 | } |
---|
649 | } |
---|
650 | sizeL=size(L); |
---|
651 | for(i=1;i<sizeL;i++) // get rid of redundant primes |
---|
652 | { |
---|
653 | for(j=i+1;j<=sizeL;j++) |
---|
654 | { |
---|
655 | if(size(L[i])!=0) |
---|
656 | { |
---|
657 | if(size(L[j])!=0) |
---|
658 | { |
---|
659 | if(size(NF(L[i],L[j],1))==0) |
---|
660 | { |
---|
661 | L[j]=ideal(0); |
---|
662 | } |
---|
663 | else |
---|
664 | { |
---|
665 | if(size(NF(L[j],L[i],1))==0) |
---|
666 | { |
---|
667 | L[i]=ideal(0); |
---|
668 | } |
---|
669 | } |
---|
670 | } |
---|
671 | } |
---|
672 | } |
---|
673 | } |
---|
674 | for(i=sizeL;i>=1;i--) |
---|
675 | { |
---|
676 | if(size(L[i])==0) |
---|
677 | { |
---|
678 | L=delete(L,i); |
---|
679 | } |
---|
680 | } |
---|
681 | return (pseudo_prim_dec_i(SI,L)); |
---|
682 | } |
---|
683 | |
---|
684 | |
---|
685 | //////////////////////////////////////////////////////////////// |
---|
686 | // proc pseudo_prim_dec_i |
---|
687 | // input: A standard basis of an arbitrary ideal I, and standard bases |
---|
688 | // of the minimal associated primes of I |
---|
689 | // output: a pseudo primary decomposition of I, i.e., a list |
---|
690 | // of pseudo primary components together with a standard basis of the |
---|
691 | // remaining component. Each pseudo primary component is |
---|
692 | // represented by a quadrupel: A standard basis of the component Q_i, |
---|
693 | // a standard basis of the corresponding associated prime P_i, the |
---|
694 | // seperator of the component, and the irreducible factors of the |
---|
695 | // "minimal divisor" of the seperator as computed by the procedure minsat, |
---|
696 | //////////////////////////////////////////////////////////////// |
---|
697 | |
---|
698 | |
---|
699 | proc pseudo_prim_dec_i (ideal SI, list L) |
---|
700 | { |
---|
701 | list Q; |
---|
702 | if (size(L)==1) // one minimal associated prime only |
---|
703 | // the ideal is already pseudo primary |
---|
704 | { |
---|
705 | Q=SI,L[1],1; |
---|
706 | list QQ; |
---|
707 | QQ[1]=Q; |
---|
708 | return (QQ,ideal(1)); |
---|
709 | } |
---|
710 | |
---|
711 | poly f0,f,g; |
---|
712 | ideal fac; |
---|
713 | int i,j,k,l; |
---|
714 | ideal SQi; |
---|
715 | ideal I'=SI; |
---|
716 | list QP; |
---|
717 | int sizeL=size(L); |
---|
718 | for(i=1;i<=sizeL;i++) |
---|
719 | { |
---|
720 | fac=0; |
---|
721 | for(j=1;j<=sizeL;j++) // compute the seperator sep_i |
---|
722 | // of the i-th component |
---|
723 | { |
---|
724 | if (i!=j) // search g not in L[i], but L[j] |
---|
725 | { |
---|
726 | for(k=1;k<=ncols(L[j]);k++) |
---|
727 | { |
---|
728 | if(NF(L[j][k],L[i],1)!=0) |
---|
729 | { |
---|
730 | break; |
---|
731 | } |
---|
732 | } |
---|
733 | fac=fac+L[j][k]; |
---|
734 | } |
---|
735 | } |
---|
736 | // delete superfluous polynomials |
---|
737 | fac=simplify(fac,8); |
---|
738 | // saturation |
---|
739 | SQi,f0,f,fac=minsat_ppd(SI,fac); |
---|
740 | I'=I',f; |
---|
741 | QP=SQi,L[i],f0,fac; |
---|
742 | // the quadrupel: |
---|
743 | // a standard basis of Q_i, |
---|
744 | // a standard basis of P_i, |
---|
745 | // sep_i, |
---|
746 | // irreducible factors of |
---|
747 | // the "minimal divisor" of the seperator |
---|
748 | // as computed by the procedure minsat, |
---|
749 | Q[i]=QP; |
---|
750 | } |
---|
751 | I'=std(I'); |
---|
752 | return (Q, I'); |
---|
753 | // I' = remaining component |
---|
754 | } |
---|
755 | |
---|
756 | |
---|
757 | //////////////////////////////////////////////////////////////// |
---|
758 | // proc extraction |
---|
759 | // input: A standard basis of a pseudo primary ideal I, and a standard |
---|
760 | // basis of the unique minimal associated prime P of I |
---|
761 | // output: an extraction of I, i.e., a standard basis of the primary |
---|
762 | // component Q of I with associated prime P, a standard basis of the |
---|
763 | // remaining component, and the irreducible factors of the |
---|
764 | // "minimal divisor" of the extractor as computed by the procedure minsat |
---|
765 | //////////////////////////////////////////////////////////////// |
---|
766 | |
---|
767 | |
---|
768 | proc extraction (ideal SI, ideal SP) |
---|
769 | { |
---|
770 | list indsets=system("indsetall",SP,0); |
---|
771 | poly f; |
---|
772 | if(size(indsets)!=0) //check, whether dim P != 0 |
---|
773 | { |
---|
774 | intvec v; // a maximal independent set of variables |
---|
775 | // modulo P |
---|
776 | string U; // the independent variables |
---|
777 | string A; // the dependent variables |
---|
778 | int j,k; |
---|
779 | int a; // the size of A |
---|
780 | int degf; |
---|
781 | ideal g; |
---|
782 | list polys; |
---|
783 | int sizepolys; |
---|
784 | list newpoly; |
---|
785 | def R=basering; |
---|
786 | //intvec hv=hilb(SI,1); |
---|
787 | for (k=1;k<=size(indsets);k++) |
---|
788 | { |
---|
789 | v=indsets[k]; |
---|
790 | for (j=1;j<=nvars(R);j++) |
---|
791 | { |
---|
792 | if (v[j]==1) |
---|
793 | { |
---|
794 | U=U+varstr(j)+","; |
---|
795 | } |
---|
796 | else |
---|
797 | { |
---|
798 | A=A+varstr(j)+","; |
---|
799 | a++; |
---|
800 | } |
---|
801 | } |
---|
802 | |
---|
803 | U[size(U)]=")"; // we compute the extractor of I (w.r.t. U) |
---|
804 | execute "ring RAU="+charstr(basering)+",("+A+U+",(dp("+string(a)+"),dp);"; |
---|
805 | ideal I=imap(R,SI); |
---|
806 | //I=std(I,hv); // the standard basis in (R[U])[A] |
---|
807 | I=std(I); // the standard basis in (R[U])[A] |
---|
808 | A[size(A)]=")"; |
---|
809 | execute "ring Rloc=("+charstr(basering)+","+U+",("+A+",dp;"; |
---|
810 | ideal I=imap(RAU,I); |
---|
811 | //"std in lokalisierung:"+newline,I; |
---|
812 | ideal h; |
---|
813 | for(j=ncols(I);j>=1;j--) |
---|
814 | { |
---|
815 | h[j]=leadcoef(I[j]); // consider I in (R(U))[A] |
---|
816 | } |
---|
817 | setring R; |
---|
818 | g=imap(Rloc,h); |
---|
819 | kill RAU,Rloc; |
---|
820 | U=""; |
---|
821 | A=""; |
---|
822 | a=0; |
---|
823 | f=lcm(g); |
---|
824 | newpoly[1]=f; |
---|
825 | polys=polys+newpoly; |
---|
826 | newpoly=list(); |
---|
827 | } |
---|
828 | f=polys[1]; |
---|
829 | degf=deg(f); |
---|
830 | sizepolys=size(polys); |
---|
831 | for (k=2;k<=sizepolys;k++) |
---|
832 | { |
---|
833 | if (deg(polys[k])<degf) |
---|
834 | { |
---|
835 | f=polys[k]; |
---|
836 | degf=deg(f); |
---|
837 | } |
---|
838 | } |
---|
839 | } |
---|
840 | else |
---|
841 | { |
---|
842 | f=1; |
---|
843 | } |
---|
844 | poly f0,h0; ideal SQ; ideal fac; |
---|
845 | if(f!=1) |
---|
846 | { |
---|
847 | SQ,f0,h0,fac=minsat(SI,f); |
---|
848 | return(SQ,std(SI+h0),fac); |
---|
849 | // the tripel |
---|
850 | // a standard basis of Q, |
---|
851 | // a standard basis of remaining component, |
---|
852 | // irreducible factors of |
---|
853 | // the "minimal divisor" of the extractor |
---|
854 | // as computed by the procedure minsat |
---|
855 | } |
---|
856 | else |
---|
857 | { |
---|
858 | return(SI,ideal(1),ideal(1)); |
---|
859 | } |
---|
860 | } |
---|
861 | |
---|
862 | ///////////////////////////////////////////////////// |
---|
863 | // proc minsat |
---|
864 | // input: a standard basis of an ideal I and a polynomial p |
---|
865 | // output: a standard basis IS of the saturation of I w.r. to p, |
---|
866 | // the maximal squarefree factor f0 of p, |
---|
867 | // the "minimal divisor" f of f0 such that the saturation of |
---|
868 | // I w.r. to f equals the saturation of I w.r. to f0 (which is IS), |
---|
869 | // the irreducible factors of f |
---|
870 | ////////////////////////////////////////////////////////// |
---|
871 | |
---|
872 | |
---|
873 | proc minsat(ideal SI, poly p) |
---|
874 | { |
---|
875 | ideal fac=factorize(p,1); //the irreducible factors of p |
---|
876 | fac=sort(fac)[1]; |
---|
877 | int i,k; |
---|
878 | poly f0=1; |
---|
879 | for(i=ncols(fac);i>=1;i--) |
---|
880 | { |
---|
881 | f0=f0*fac[i]; |
---|
882 | } |
---|
883 | poly f=1; |
---|
884 | ideal iold; |
---|
885 | list quotM; |
---|
886 | quotM[1]=SI; |
---|
887 | quotM[2]=fac; |
---|
888 | quotM[3]=f0; |
---|
889 | // we deal seperately with the first quotient; |
---|
890 | // factors, which do not contribute to this one, |
---|
891 | // are omitted |
---|
892 | iold=quotM[1]; |
---|
893 | quotM=minquot(quotM); |
---|
894 | fac=quotM[2]; |
---|
895 | if(quotM[3]==1) |
---|
896 | { |
---|
897 | return(quotM[1],f0,f,fac); |
---|
898 | } |
---|
899 | while(special_ideals_equal(iold,quotM[1])==0) |
---|
900 | { |
---|
901 | f=f*quotM[3]; |
---|
902 | iold=quotM[1]; |
---|
903 | quotM=minquot(quotM); |
---|
904 | } |
---|
905 | return(quotM[1],f0,f,fac); // the quadrupel ((I:p),f0,f, // irr. factors of f) |
---|
906 | } |
---|
907 | |
---|
908 | ///////////////////////////////////////////////////// |
---|
909 | // proc minsat_ppd |
---|
910 | // input: a standard basis of an ideal I and a polynomial p |
---|
911 | // output: a standard basis IS of the saturation of I w.r. to p, |
---|
912 | // the maximal squarefree factor f0 of p, |
---|
913 | // the "minimal divisor" f of f0 such that the saturation of |
---|
914 | // I w.r. to f equals the saturation of I w.r. to f0 (which is IS), |
---|
915 | // the irreducible factors of f |
---|
916 | ////////////////////////////////////////////////////////// |
---|
917 | |
---|
918 | |
---|
919 | proc minsat_ppd(ideal SI, ideal fac) |
---|
920 | { |
---|
921 | fac=sort(fac)[1]; |
---|
922 | int i,k; |
---|
923 | poly f0=1; |
---|
924 | for(i=ncols(fac);i>=1;i--) |
---|
925 | { |
---|
926 | f0=f0*fac[i]; |
---|
927 | } |
---|
928 | poly f=1; |
---|
929 | ideal iold; |
---|
930 | list quotM; |
---|
931 | quotM[1]=SI; |
---|
932 | quotM[2]=fac; |
---|
933 | quotM[3]=f0; |
---|
934 | // we deal seperately with the first quotient; |
---|
935 | // factors, which do not contribute to this one, |
---|
936 | // are omitted |
---|
937 | iold=quotM[1]; |
---|
938 | quotM=minquot(quotM); |
---|
939 | fac=quotM[2]; |
---|
940 | if(quotM[3]==1) |
---|
941 | { |
---|
942 | return(quotM[1],f0,f,fac); |
---|
943 | } |
---|
944 | while(special_ideals_equal(iold,quotM[1])==0) |
---|
945 | { |
---|
946 | f=f*quotM[3]; |
---|
947 | iold=quotM[1]; |
---|
948 | quotM=minquot(quotM); |
---|
949 | k++; |
---|
950 | } |
---|
951 | return(quotM[1],f0,f,fac); // the quadrupel ((I:p),f0,f, // irr. factors of f) |
---|
952 | } |
---|
953 | ///////////////////////////////////////////////////////////////// |
---|
954 | // proc minquot |
---|
955 | // input: a list with 3 components: a standard basis |
---|
956 | // of an ideal I, a set of irreducible polynomials, and |
---|
957 | // there product f0 |
---|
958 | // output: a standard basis of the ideal (I:f0), the irreducible |
---|
959 | // factors of the "minimal divisor" f of f0 with (I:f0) = (I:f), |
---|
960 | // the "minimal divisor" f |
---|
961 | ///////////////////////////////////////////////////////////////// |
---|
962 | |
---|
963 | proc minquot(list tsil) |
---|
964 | { |
---|
965 | int i,j,k,action; |
---|
966 | ideal verg; |
---|
967 | list l; |
---|
968 | poly g; |
---|
969 | ideal laedi=tsil[1]; |
---|
970 | ideal fac=tsil[2]; |
---|
971 | poly f=tsil[3]; |
---|
972 | |
---|
973 | //std |
---|
974 | // ideal star=quotient(laedi,f); |
---|
975 | // star=std(star); |
---|
976 | option(returnSB); |
---|
977 | ideal star=quotient(laedi,f); |
---|
978 | option(noreturnSB); |
---|
979 | if(special_ideals_equal(laedi,star)==1) |
---|
980 | { |
---|
981 | return(laedi,ideal(1),1); |
---|
982 | } |
---|
983 | action=1; |
---|
984 | while(action==1) |
---|
985 | { |
---|
986 | if(size(fac)==1) |
---|
987 | { |
---|
988 | action=0; |
---|
989 | break; |
---|
990 | } |
---|
991 | for(i=1;i<=size(fac);i++) |
---|
992 | { |
---|
993 | g=1; |
---|
994 | for(j=1;j<=size(fac);j++) |
---|
995 | { |
---|
996 | if(i!=j) |
---|
997 | { |
---|
998 | g=g*fac[j]; |
---|
999 | } |
---|
1000 | } |
---|
1001 | //std |
---|
1002 | // verg=quotient(laedi,g); |
---|
1003 | // verg=std(verg); |
---|
1004 | option(returnSB); |
---|
1005 | verg=quotient(laedi,g); |
---|
1006 | option(noreturnSB); |
---|
1007 | if(special_ideals_equal(verg,star)==1) |
---|
1008 | { |
---|
1009 | f=g; |
---|
1010 | fac[i]=0; |
---|
1011 | fac=simplify(fac,2); |
---|
1012 | break; |
---|
1013 | } |
---|
1014 | if(i==size(fac)) |
---|
1015 | { |
---|
1016 | action=0; |
---|
1017 | } |
---|
1018 | } |
---|
1019 | } |
---|
1020 | l=star,fac,f; |
---|
1021 | return(l); |
---|
1022 | } |
---|
1023 | ///////////////////////////////////////////////// |
---|
1024 | // proc special_ideals_equal |
---|
1025 | // input: standard bases of ideal k1 and k2 such that |
---|
1026 | // k1 is contained in k2, or k2 is contained ink1 |
---|
1027 | // output: 1, if k1 equals k2, 0 otherwise |
---|
1028 | ////////////////////////////////////////////////// |
---|
1029 | |
---|
1030 | proc special_ideals_equal( ideal k1, ideal k2) |
---|
1031 | { |
---|
1032 | int j; |
---|
1033 | if(size(k1)==size(k2)) |
---|
1034 | { |
---|
1035 | for(j=1;j<=size(k1);j++) |
---|
1036 | { |
---|
1037 | if(leadexp(k1[j])!=leadexp(k2[j])) |
---|
1038 | { |
---|
1039 | return(0); |
---|
1040 | } |
---|
1041 | } |
---|
1042 | return(1); |
---|
1043 | } |
---|
1044 | return(0); |
---|
1045 | } |
---|