1 | // $Id: primdec.lib,v 1.13 1998-05-05 11:55:34 krueger Exp $ |
---|
2 | /////////////////////////////////////////////////////// |
---|
3 | // primdec.lib |
---|
4 | // algorithms for primary decomposition based on |
---|
5 | // the ideas of Gianni,Trager,Zacharias |
---|
6 | // written by Gerhard Pfister |
---|
7 | // |
---|
8 | // algorithms for primary decomposition based on |
---|
9 | // the ideas of Shimoyama/Yokoyama |
---|
10 | // written by Wolfram Decker and Hans Schoenemann |
---|
11 | ////////////////////////////////////////////////////// |
---|
12 | |
---|
13 | version="$Id: primdec.lib,v 1.13 1998-05-05 11:55:34 krueger Exp $"; |
---|
14 | info=" |
---|
15 | LIBRARY: primdec.lib: PROCEDURE FOR PRIMARY DECOMPOSITION (I) |
---|
16 | |
---|
17 | minAssPrimes (ideal I) |
---|
18 | //computes the minimal associated primes of the ideal I |
---|
19 | |
---|
20 | primdecGTZ (ideal I) |
---|
21 | // Computes a complete primary decomposition via Gianni,Trager,Zacharias |
---|
22 | |
---|
23 | radical(ideal I) |
---|
24 | //computes the radical of the ideal I |
---|
25 | |
---|
26 | equiRadical(ideal I) |
---|
27 | //computes the radical of the equidimensional part of the ideal I |
---|
28 | |
---|
29 | prepareAss(ideal I) |
---|
30 | //computes the radicals of the equidimensional parts of I |
---|
31 | |
---|
32 | min_ass_prim_charsets (ideal I, int choose) |
---|
33 | // minimal associated primes via the characteristic set |
---|
34 | // package written by Michael Messollen. |
---|
35 | // The integer choose must be either 0 or 1. |
---|
36 | // If choose=0, the given ordering of the variables is used. |
---|
37 | // If choose=1, the system tries to find an \"optimal ordering\", |
---|
38 | // which in some cases may considerably speed up the algorithm |
---|
39 | |
---|
40 | // You may also may want to try one of the algorithms for |
---|
41 | // minimal associated primes in the the library |
---|
42 | // primdec.lib, written by Gerhard Pfister. |
---|
43 | // These algorithms are variants of the algorithm |
---|
44 | // of Gianni-Trager-Zacharias |
---|
45 | |
---|
46 | primdecSY (ideal I, int choose) |
---|
47 | |
---|
48 | // Computes a complete primary decomposition via |
---|
49 | // a variant of the pseudoprimary approach of |
---|
50 | // Shimoyama-Yokoyama. |
---|
51 | // The integer choose must be either 0, 1, 2 or 3. |
---|
52 | // If choose=0, min_ass_prim_charsets with the given |
---|
53 | // ordering of the variables is used. |
---|
54 | // If choose=1, min_ass_prim_charsets with the \"optimized\" |
---|
55 | // ordering of the variables is used. |
---|
56 | // If choose=2, minAssPrimes from primdec.lib is used |
---|
57 | // If choose=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
58 | "; |
---|
59 | |
---|
60 | LIB "general.lib"; |
---|
61 | LIB "elim.lib"; |
---|
62 | LIB "poly.lib"; |
---|
63 | LIB "random.lib"; |
---|
64 | /////////////////////////////////////////////////////////////////////////////// |
---|
65 | |
---|
66 | proc sat1 (ideal id, poly p) |
---|
67 | "USAGE: sat1(id,j); id ideal, j polynomial |
---|
68 | RETURN: saturation of id with respect to j (= union_(k=1...) of id:j^k) |
---|
69 | NOTE: result is a std basis in the basering |
---|
70 | EXAMPLE: example sat; shows an example |
---|
71 | " |
---|
72 | { |
---|
73 | int @k; |
---|
74 | ideal inew=std(id); |
---|
75 | ideal iold; |
---|
76 | option(returnSB); |
---|
77 | while(specialIdealsEqual(iold,inew)==0 ) |
---|
78 | { |
---|
79 | iold=inew; |
---|
80 | inew=quotient(iold,p); |
---|
81 | @k++; |
---|
82 | } |
---|
83 | @k--; |
---|
84 | option(noreturnSB); |
---|
85 | list L =inew,p^@k; |
---|
86 | return (L); |
---|
87 | } |
---|
88 | |
---|
89 | /////////////////////////////////////////////////////////////////////////////// |
---|
90 | |
---|
91 | proc sat2 (ideal id, ideal h) |
---|
92 | "USAGE: sat2(id,j); id ideal, j polynomial |
---|
93 | RETURN: saturation of id with respect to j (= union_(k=1...) of id:j^k) |
---|
94 | NOTE: result is a std basis in the basering |
---|
95 | EXAMPLE: example sat2; shows an example |
---|
96 | " |
---|
97 | { |
---|
98 | int @k,@i; |
---|
99 | def @P= basering; |
---|
100 | if(ordstr(basering)[1,2]!="dp") |
---|
101 | { |
---|
102 | execute "ring @Phelp=("+charstr(@P)+"),("+varstr(@P)+"),(C,dp);"; |
---|
103 | ideal inew=std(imap(@P,id)); |
---|
104 | ideal @h=imap(@P,h); |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | ideal @h=h; |
---|
109 | ideal inew=std(id); |
---|
110 | } |
---|
111 | ideal fac; |
---|
112 | |
---|
113 | for(@i=1;@i<=ncols(@h);@i++) |
---|
114 | { |
---|
115 | if(deg(@h[@i])>0) |
---|
116 | { |
---|
117 | fac=fac+factorize(@h[@i],1); |
---|
118 | } |
---|
119 | } |
---|
120 | fac=simplify(fac,4); |
---|
121 | poly @f=1; |
---|
122 | if(deg(fac[1])>0) |
---|
123 | { |
---|
124 | ideal iold; |
---|
125 | |
---|
126 | for(@i=1;@i<=size(fac);@i++) |
---|
127 | { |
---|
128 | @f=@f*fac[@i]; |
---|
129 | } |
---|
130 | option(returnSB); |
---|
131 | while(specialIdealsEqual(iold,inew)==0 ) |
---|
132 | { |
---|
133 | iold=inew; |
---|
134 | if(deg(iold[size(iold)])!=1) |
---|
135 | { |
---|
136 | inew=quotient(iold,@f); |
---|
137 | } |
---|
138 | else |
---|
139 | { |
---|
140 | inew=iold; |
---|
141 | } |
---|
142 | @k++; |
---|
143 | } |
---|
144 | option(noreturnSB); |
---|
145 | @k--; |
---|
146 | } |
---|
147 | |
---|
148 | if(ordstr(@P)[1,2]!="dp") |
---|
149 | { |
---|
150 | setring @P; |
---|
151 | ideal inew=std(imap(@Phelp,inew)); |
---|
152 | poly @f=imap(@Phelp,@f); |
---|
153 | } |
---|
154 | list L =inew,@f^@k; |
---|
155 | return (L); |
---|
156 | } |
---|
157 | |
---|
158 | /////////////////////////////////////////////////////////////////////////////// |
---|
159 | |
---|
160 | proc minSat(ideal inew, ideal h) |
---|
161 | { |
---|
162 | int i,k; |
---|
163 | poly f=1; |
---|
164 | ideal iold,fac; |
---|
165 | list quotM,l; |
---|
166 | |
---|
167 | for(i=1;i<=ncols(h);i++) |
---|
168 | { |
---|
169 | if(deg(h[i])>0) |
---|
170 | { |
---|
171 | fac=fac+factorize(h[i],1); |
---|
172 | } |
---|
173 | } |
---|
174 | fac=simplify(fac,4); |
---|
175 | if(size(fac)==0) |
---|
176 | { |
---|
177 | l=inew,1; |
---|
178 | return(l); |
---|
179 | } |
---|
180 | fac=sort(fac)[1]; |
---|
181 | for(i=1;i<=size(fac);i++) |
---|
182 | { |
---|
183 | f=f*fac[i]; |
---|
184 | } |
---|
185 | quotM[1]=inew; |
---|
186 | quotM[2]=fac; |
---|
187 | quotM[3]=f; |
---|
188 | f=1; |
---|
189 | option(returnSB); |
---|
190 | while(specialIdealsEqual(iold,quotM[1])==0) |
---|
191 | { |
---|
192 | if(k>0) |
---|
193 | { |
---|
194 | f=f*quotM[3]; |
---|
195 | } |
---|
196 | iold=quotM[1]; |
---|
197 | quotM=quotMin(quotM); |
---|
198 | k++; |
---|
199 | } |
---|
200 | option(noreturnSB); |
---|
201 | l=quotM[1],f; |
---|
202 | return(l); |
---|
203 | } |
---|
204 | |
---|
205 | proc quotMin(list tsil) |
---|
206 | { |
---|
207 | int i,j,k,action; |
---|
208 | ideal verg; |
---|
209 | list l; |
---|
210 | poly g; |
---|
211 | |
---|
212 | ideal laedi=tsil[1]; |
---|
213 | ideal fac=tsil[2]; |
---|
214 | poly f=tsil[3]; |
---|
215 | |
---|
216 | ideal star=quotient(laedi,f); |
---|
217 | action=1; |
---|
218 | |
---|
219 | while(action==1) |
---|
220 | { |
---|
221 | if(size(fac)==1) |
---|
222 | { |
---|
223 | action=0; |
---|
224 | break; |
---|
225 | } |
---|
226 | for(i=1;i<=size(fac);i++) |
---|
227 | { |
---|
228 | g=1; |
---|
229 | verg=laedi; |
---|
230 | |
---|
231 | for(j=1;j<=size(fac);j++) |
---|
232 | { |
---|
233 | if(i!=j) |
---|
234 | { |
---|
235 | g=g*fac[j]; |
---|
236 | } |
---|
237 | } |
---|
238 | verg=quotient(laedi,g); |
---|
239 | |
---|
240 | if(specialIdealsEqual(verg,star)==1) |
---|
241 | { |
---|
242 | f=g; |
---|
243 | fac[i]=0; |
---|
244 | fac=simplify(fac,2); |
---|
245 | break; |
---|
246 | } |
---|
247 | if(i==size(fac)) |
---|
248 | { |
---|
249 | action=0; |
---|
250 | } |
---|
251 | } |
---|
252 | } |
---|
253 | l=star,fac,f; |
---|
254 | return(l); |
---|
255 | } |
---|
256 | |
---|
257 | //////////////////////////////////////////////////////////////////////////////// |
---|
258 | proc testFactor(list act,poly p) |
---|
259 | { |
---|
260 | poly keep=p; |
---|
261 | |
---|
262 | int i; |
---|
263 | poly q=act[1][1]^act[2][1]; |
---|
264 | for(i=2;i<=size(act[1]);i++) |
---|
265 | { |
---|
266 | q=q*act[1][i]^act[2][i]; |
---|
267 | } |
---|
268 | q=1/leadcoef(q)*q; |
---|
269 | p=1/leadcoef(p)*p; |
---|
270 | if(p-q!=0) |
---|
271 | { |
---|
272 | "ERROR IN FACTOR"; |
---|
273 | basering; |
---|
274 | |
---|
275 | act; |
---|
276 | keep; |
---|
277 | pause; |
---|
278 | |
---|
279 | p; |
---|
280 | q; |
---|
281 | pause; |
---|
282 | } |
---|
283 | } |
---|
284 | //////////////////////////////////////////////////////////////////////////////// |
---|
285 | |
---|
286 | proc factor(poly p) |
---|
287 | "USAGE: factor(p) p poly |
---|
288 | RETURN: list=; |
---|
289 | NOTE: |
---|
290 | EXAMPLE: example factor; shows an example |
---|
291 | " |
---|
292 | { |
---|
293 | |
---|
294 | ideal @i; |
---|
295 | list @l; |
---|
296 | intvec @v,@w; |
---|
297 | int @j,@k,@n; |
---|
298 | |
---|
299 | if(deg(p)<=1) |
---|
300 | { |
---|
301 | @i=ideal(p); |
---|
302 | @v=1; |
---|
303 | @l[1]=@i; |
---|
304 | @l[2]=@v; |
---|
305 | return(@l); |
---|
306 | } |
---|
307 | if (size(p)==1) |
---|
308 | { |
---|
309 | @w=leadexp(p); |
---|
310 | for(@j=1;@j<=nvars(basering);@j++) |
---|
311 | { |
---|
312 | if(@w[@j]!=0) |
---|
313 | { |
---|
314 | @k++; |
---|
315 | @v[@k]=@w[@j]; |
---|
316 | @i=@i+ideal(var(@j)); |
---|
317 | } |
---|
318 | } |
---|
319 | @l[1]=@i; |
---|
320 | @l[2]=@v; |
---|
321 | return(@l); |
---|
322 | } |
---|
323 | // @l=factorize(p,2); |
---|
324 | @l=factorize(p); |
---|
325 | // if(npars(basering)>0) |
---|
326 | // { |
---|
327 | for(@j=1;@j<=size(@l[1]);@j++) |
---|
328 | { |
---|
329 | if(deg(@l[1][@j])==0) |
---|
330 | { |
---|
331 | @n++; |
---|
332 | } |
---|
333 | } |
---|
334 | if(@n>0) |
---|
335 | { |
---|
336 | if(@n==size(@l[1])) |
---|
337 | { |
---|
338 | @l[1]=ideal(1); |
---|
339 | @v=1; |
---|
340 | @l[2]=@v; |
---|
341 | } |
---|
342 | else |
---|
343 | { |
---|
344 | @k=0; |
---|
345 | int pleh; |
---|
346 | for(@j=1;@j<=size(@l[1]);@j++) |
---|
347 | { |
---|
348 | if(deg(@l[1][@j])!=0) |
---|
349 | { |
---|
350 | @k++; |
---|
351 | @i=@i+ideal(@l[1][@j]); |
---|
352 | if(size(@i)==pleh) |
---|
353 | { |
---|
354 | "factorization error"; |
---|
355 | @l; |
---|
356 | @k--; |
---|
357 | @v[@k]=@v[@k]+@l[2][@j]; |
---|
358 | } |
---|
359 | else |
---|
360 | { |
---|
361 | pleh++; |
---|
362 | @v[@k]=@l[2][@j]; |
---|
363 | } |
---|
364 | } |
---|
365 | } |
---|
366 | @l[1]=@i; |
---|
367 | @l[2]=@v; |
---|
368 | } |
---|
369 | } |
---|
370 | // } |
---|
371 | return(@l); |
---|
372 | } |
---|
373 | example |
---|
374 | { "EXAMPLE:"; echo = 2; |
---|
375 | ring r = 0,(x,y,z),lp; |
---|
376 | poly p = (x+y)^2*(y-z)^3; |
---|
377 | list l = factor(p); |
---|
378 | l; |
---|
379 | ring r1 =(0,b,d,f,g),(a,c,e),lp; |
---|
380 | poly p =(1*d)*e^2+(1*d*f^2*g); |
---|
381 | list l = factor(p); |
---|
382 | l; |
---|
383 | ring r2 =(0,b,f,g),(a,c,e,d),lp; |
---|
384 | poly p =(1*d)*e^2+(1*d*f^2*g); |
---|
385 | list l = factor(p); |
---|
386 | l; |
---|
387 | |
---|
388 | } |
---|
389 | |
---|
390 | |
---|
391 | |
---|
392 | //////////////////////////////////////////////////////////////////////////////// |
---|
393 | |
---|
394 | proc idealsEqual( ideal k, ideal j) |
---|
395 | { |
---|
396 | return(stdIdealsEqual(std(k),std(j))); |
---|
397 | } |
---|
398 | |
---|
399 | proc specialIdealsEqual( ideal k1, ideal k2) |
---|
400 | { |
---|
401 | int j; |
---|
402 | |
---|
403 | if(size(k1)==size(k2)) |
---|
404 | { |
---|
405 | for(j=1;j<=size(k1);j++) |
---|
406 | { |
---|
407 | if(leadexp(k1[j])!=leadexp(k2[j])) |
---|
408 | { |
---|
409 | return(0); |
---|
410 | } |
---|
411 | } |
---|
412 | return(1); |
---|
413 | } |
---|
414 | return(0); |
---|
415 | } |
---|
416 | |
---|
417 | proc stdIdealsEqual( ideal k1, ideal k2) |
---|
418 | { |
---|
419 | int j; |
---|
420 | |
---|
421 | if(size(k1)==size(k2)) |
---|
422 | { |
---|
423 | for(j=1;j<=size(k1);j++) |
---|
424 | { |
---|
425 | if(leadexp(k1[j])!=leadexp(k2[j])) |
---|
426 | { |
---|
427 | return(0); |
---|
428 | } |
---|
429 | } |
---|
430 | attrib(k2,"isSB",1); |
---|
431 | if(size(reduce(k1,k2,1))==0) |
---|
432 | { |
---|
433 | return(1); |
---|
434 | } |
---|
435 | } |
---|
436 | return(0); |
---|
437 | } |
---|
438 | |
---|
439 | |
---|
440 | //////////////////////////////////////////////////////////////////////////////// |
---|
441 | |
---|
442 | proc testPrimary(list pr, ideal k) |
---|
443 | "USAGE: testPrimary(pr,k) pr list, k ideal; |
---|
444 | RETURN: int = 1, if the intersection of the ideals in pr is k, 0 if not |
---|
445 | NOTE: |
---|
446 | EEXAMPLE: example testPrimary ; shows an example |
---|
447 | " |
---|
448 | { |
---|
449 | int i; |
---|
450 | ideal j=pr[1]; |
---|
451 | for (i=2;i<=size(pr)/2;i++) |
---|
452 | { |
---|
453 | j=intersect(j,pr[2*i-1]); |
---|
454 | } |
---|
455 | return(idealsEqual(j,k)); |
---|
456 | } |
---|
457 | example |
---|
458 | { "EXAMPLE:"; echo = 2; |
---|
459 | ring s = 0,(x,y,z),lp; |
---|
460 | ideal i=x3-x2-x+1,xy-y; |
---|
461 | ideal i1=x-1; |
---|
462 | ideal i2=x-1; |
---|
463 | ideal i3=y,x2-2x+1; |
---|
464 | ideal i4=y,x-1; |
---|
465 | ideal i5=y,x+1; |
---|
466 | ideal i6=y,x+1; |
---|
467 | list pr=i1,i2,i3,i4,i5,i6; |
---|
468 | testPrimary(pr,i); |
---|
469 | pr[5]=y+1,x+1; |
---|
470 | testPrimary(pr,i); |
---|
471 | } |
---|
472 | |
---|
473 | //////////////////////////////////////////////////////////////////////////////// |
---|
474 | proc printPrimary( list l, list #) |
---|
475 | "USAGE: printPrimary(l) l list; |
---|
476 | RETURN: nothing |
---|
477 | NOTE: |
---|
478 | EXAMPLE: example printPrimary; shows an example |
---|
479 | " |
---|
480 | { |
---|
481 | if(size(#)>0) |
---|
482 | { |
---|
483 | " "; |
---|
484 | " The primary decomposition of the ideal "; |
---|
485 | #[1]; |
---|
486 | " "; |
---|
487 | " is: "; |
---|
488 | " "; |
---|
489 | } |
---|
490 | int k; |
---|
491 | for (k=1;k<=size(l)/2;k=k+1) |
---|
492 | { |
---|
493 | " "; |
---|
494 | "primary ideal: "; |
---|
495 | l[2*k-1]; |
---|
496 | " "; |
---|
497 | "associated prime ideal "; |
---|
498 | l[2*k]; |
---|
499 | " "; |
---|
500 | } |
---|
501 | } |
---|
502 | example |
---|
503 | { "EXAMPLE:"; echo = 2; |
---|
504 | } |
---|
505 | |
---|
506 | //////////////////////////////////////////////////////////////////////////////// |
---|
507 | |
---|
508 | |
---|
509 | proc randomLast(int b) |
---|
510 | "USAGE: randomLast |
---|
511 | RETURN: ideal = maxideal(1) but the last variable exchanged by |
---|
512 | a sum of it with a linear random combination of the other |
---|
513 | variables |
---|
514 | NOTE: |
---|
515 | EXAMPLE: example randomLast; shows an example |
---|
516 | " |
---|
517 | { |
---|
518 | |
---|
519 | ideal i=maxideal(1); |
---|
520 | int k=size(i); |
---|
521 | i[k]=0; |
---|
522 | i=randomid(i,size(i),b); |
---|
523 | ideal ires=maxideal(1); |
---|
524 | ires[k]=i[1]+var(k); |
---|
525 | return(ires); |
---|
526 | } |
---|
527 | example |
---|
528 | { "EXAMPLE:"; echo = 2; |
---|
529 | ring r = 0,(x,y,z),lp; |
---|
530 | ideal i = randomLast(10); |
---|
531 | i; |
---|
532 | } |
---|
533 | |
---|
534 | |
---|
535 | //////////////////////////////////////////////////////////////////////////////// |
---|
536 | |
---|
537 | |
---|
538 | proc primaryTest (ideal i, poly p) |
---|
539 | { |
---|
540 | int m=1; |
---|
541 | int n=nvars(basering); |
---|
542 | int e; |
---|
543 | poly t; |
---|
544 | ideal h; |
---|
545 | |
---|
546 | ideal prm=p; |
---|
547 | attrib(prm,"isSB",1); |
---|
548 | |
---|
549 | while (n>1) |
---|
550 | { |
---|
551 | n=n-1; |
---|
552 | m=m+1; |
---|
553 | |
---|
554 | //search for i[m] which has a power of var(n) as leading term |
---|
555 | if (n==1) |
---|
556 | { |
---|
557 | m=size(i); |
---|
558 | } |
---|
559 | else |
---|
560 | { |
---|
561 | while (lead(i[m])/var(n-1)==0) |
---|
562 | { |
---|
563 | m=m+1; |
---|
564 | } |
---|
565 | m=m-1; |
---|
566 | } |
---|
567 | //check whether i[m] =(c*var(n)+h)^e modulo prm for some |
---|
568 | //h in K[var(n+1),...,var(nvars(basering))], c in K |
---|
569 | //if not (0) is returned, else var(n)+h is added to prm |
---|
570 | |
---|
571 | e=deg(lead(i[m])); |
---|
572 | // t=hilfe1(i,prm,m,n); |
---|
573 | t=leadcoef(i[m])*e*var(n)+(i[m]-lead(i[m]))/var(n)^(e-1); |
---|
574 | |
---|
575 | i[m]=poly(e)^e*leadcoef(i[m])^(e-1)*i[m]; |
---|
576 | |
---|
577 | if (reduce(i[m]-t^e,prm,1) !=0) |
---|
578 | { |
---|
579 | return(ideal(0)); |
---|
580 | } |
---|
581 | h=interred(t); |
---|
582 | t=h[1]; |
---|
583 | |
---|
584 | prm = prm,t; |
---|
585 | attrib(prm,"isSB",1); |
---|
586 | } |
---|
587 | return(prm); |
---|
588 | } |
---|
589 | |
---|
590 | proc hilfe(ideal i,ideal prm,int m) |
---|
591 | { |
---|
592 | poly t; |
---|
593 | int e; |
---|
594 | |
---|
595 | if(size(i[m])==1) |
---|
596 | { |
---|
597 | t=var(n); |
---|
598 | } |
---|
599 | else |
---|
600 | { |
---|
601 | e=deg(lead(i[m])); |
---|
602 | |
---|
603 | if(deg(poly(e))>=0) |
---|
604 | { |
---|
605 | t=leadcoef(i[m])*e*var(n)+(i[m]-lead(i[m]))/var(n)^(e-1); |
---|
606 | i[m]=poly(e)^e*leadcoef(i[m])^(e-1)*i[m]; |
---|
607 | } |
---|
608 | else |
---|
609 | { |
---|
610 | i[m]=i[m]/leadcoef(i[m]); |
---|
611 | t=reduce(coef(i[m],var(n))[2,e+1],prm); |
---|
612 | t=var(n)+factorize(t,1)[1]; |
---|
613 | } |
---|
614 | } |
---|
615 | return(t); |
---|
616 | } |
---|
617 | proc hilfe1(ideal i,ideal prm,int m,int n) |
---|
618 | { |
---|
619 | poly t; |
---|
620 | int e; |
---|
621 | if(size(i[m])==1) |
---|
622 | { |
---|
623 | t=var(n); |
---|
624 | } |
---|
625 | else |
---|
626 | { |
---|
627 | e=deg(lead(i[m])); |
---|
628 | i[m]=i[m]/leadcoef(i[m]); |
---|
629 | t=reduce(coeffs(i[m],var(n))[1,1],prm); |
---|
630 | if(size(t)==0){return(var(n));} |
---|
631 | t=var(n)+factorize(t,1)[1]; |
---|
632 | } |
---|
633 | return(t); |
---|
634 | } |
---|
635 | |
---|
636 | /////////////////////////////////////////////////////////////////////////////// |
---|
637 | proc splitPrimary(list l,ideal ser,int @wr,list sact) |
---|
638 | { |
---|
639 | int i,j,k,s,r,w; |
---|
640 | list keepresult,act,keepprime; |
---|
641 | poly @f; |
---|
642 | int sl=size(l); |
---|
643 | |
---|
644 | for(i=1;i<=sl/2;i++) |
---|
645 | { |
---|
646 | if(sact[2][i]>1) |
---|
647 | { |
---|
648 | keepprime[i]=l[2*i-1]+ideal(sact[1][i]); |
---|
649 | } |
---|
650 | else |
---|
651 | { |
---|
652 | keepprime[i]=l[2*i-1]; |
---|
653 | } |
---|
654 | } |
---|
655 | i=0; |
---|
656 | while(i<size(l)/2) |
---|
657 | { |
---|
658 | i++; |
---|
659 | if((size(ser)>0)&&(size(reduce(ser,l[2*i-1],1))==0)) |
---|
660 | { |
---|
661 | l[2*i-1]=ideal(1); |
---|
662 | l[2*i]=ideal(1); |
---|
663 | continue; |
---|
664 | } |
---|
665 | |
---|
666 | |
---|
667 | if(size(l[2*i])==0) |
---|
668 | { |
---|
669 | if(homog(l[2*i-1])==1) |
---|
670 | { |
---|
671 | l[2*i]=maxideal(1); |
---|
672 | continue; |
---|
673 | } |
---|
674 | j=0; |
---|
675 | if(i<=sl/2) |
---|
676 | { |
---|
677 | j=1; |
---|
678 | } |
---|
679 | while(j<size(l[2*i-1])) |
---|
680 | { |
---|
681 | j++; |
---|
682 | act=factor(l[2*i-1][j]); |
---|
683 | r=size(act[1]); |
---|
684 | attrib(l[2*i-1],"isSB",1); |
---|
685 | if((r==1)&&(vdim(l[2*i-1])==deg(l[2*i-1][j]))) |
---|
686 | { |
---|
687 | l[2*i]=std(l[2*i-1],act[1][1]); |
---|
688 | break; |
---|
689 | } |
---|
690 | if((r==1)&&(act[2][1]>1)) |
---|
691 | { |
---|
692 | keepprime[i]=interred(keepprime[i]+ideal(act[1][1])); |
---|
693 | if(homog(keepprime[i])==1) |
---|
694 | { |
---|
695 | l[2*i]=maxideal(1); |
---|
696 | break; |
---|
697 | } |
---|
698 | } |
---|
699 | if(gcdTest(act[1])==1) |
---|
700 | { |
---|
701 | for(k=2;k<=r;k++) |
---|
702 | { |
---|
703 | keepprime[size(l)/2+k-1]=interred(keepprime[i]+ideal(act[1][k])); |
---|
704 | } |
---|
705 | keepprime[i]=interred(keepprime[i]+ideal(act[1][1])); |
---|
706 | for(k=1;k<=r;k++) |
---|
707 | { |
---|
708 | if(@wr==0) |
---|
709 | { |
---|
710 | keepresult[k]=std(l[2*i-1],act[1][k]^act[2][k]); |
---|
711 | } |
---|
712 | else |
---|
713 | { |
---|
714 | keepresult[k]=std(l[2*i-1],act[1][k]); |
---|
715 | } |
---|
716 | } |
---|
717 | l[2*i-1]=keepresult[1]; |
---|
718 | if(vdim(keepresult[1])==deg(act[1][1])) |
---|
719 | { |
---|
720 | l[2*i]=keepresult[1]; |
---|
721 | } |
---|
722 | if((homog(keepresult[1])==1)||(homog(keepprime[i])==1)) |
---|
723 | { |
---|
724 | l[2*i]=maxideal(1); |
---|
725 | } |
---|
726 | s=size(l)-2; |
---|
727 | for(k=2;k<=r;k++) |
---|
728 | { |
---|
729 | l[s+2*k-1]=keepresult[k]; |
---|
730 | keepprime[s/2+k]=interred(keepresult[k]+ideal(act[1][k])); |
---|
731 | if(vdim(keepresult[k])==deg(act[1][k])) |
---|
732 | { |
---|
733 | l[s+2*k]=keepresult[k]; |
---|
734 | } |
---|
735 | else |
---|
736 | { |
---|
737 | l[s+2*k]=ideal(0); |
---|
738 | } |
---|
739 | if((homog(keepresult[k])==1)||(homog(keepprime[s/2+k])==1)) |
---|
740 | { |
---|
741 | l[s+2*k]=maxideal(1); |
---|
742 | } |
---|
743 | } |
---|
744 | i--; |
---|
745 | break; |
---|
746 | } |
---|
747 | if(r>=2) |
---|
748 | { |
---|
749 | s=size(l); |
---|
750 | @f=act[1][1]; |
---|
751 | act=sat1(l[2*i-1],act[1][1]); |
---|
752 | if(deg(act[1][1])>0) |
---|
753 | { |
---|
754 | l[s+1]=std(l[2*i-1],act[2]); |
---|
755 | if(homog(l[s+1])==1) |
---|
756 | { |
---|
757 | l[s+2]=maxideal(1); |
---|
758 | } |
---|
759 | else |
---|
760 | { |
---|
761 | l[s+2]=ideal(0); |
---|
762 | } |
---|
763 | keepprime[s/2+1]=interred(keepprime[i]+ideal(@f)); |
---|
764 | if(homog(keepprime[s/2+1])==1) |
---|
765 | { |
---|
766 | l[s+2]=maxideal(1); |
---|
767 | } |
---|
768 | keepprime[i]=act[1]; |
---|
769 | l[2*i-1]=act[1]; |
---|
770 | attrib(l[2*i-1],"isSB",1); |
---|
771 | if(homog(l[2*i-1])==1) |
---|
772 | { |
---|
773 | l[2*i]=maxideal(1); |
---|
774 | } |
---|
775 | |
---|
776 | i--; |
---|
777 | break; |
---|
778 | } |
---|
779 | } |
---|
780 | } |
---|
781 | } |
---|
782 | } |
---|
783 | if(sl==size(l)) |
---|
784 | { |
---|
785 | return(l); |
---|
786 | } |
---|
787 | for(i=1;i<=size(l)/2;i++) |
---|
788 | { |
---|
789 | attrib(l[2*i-1],"isSB",1); |
---|
790 | |
---|
791 | if((size(ser)>0)&&(size(reduce(ser,l[2*i-1],1))==0)&&(deg(l[2*i-1][1])>0)) |
---|
792 | { |
---|
793 | "Achtung in split"; |
---|
794 | |
---|
795 | l[2*i-1]=ideal(1); |
---|
796 | l[2*i]=ideal(1); |
---|
797 | } |
---|
798 | if((size(l[2*i])==0)&&(specialIdealsEqual(keepprime[i],l[2*i-1])!=1)) |
---|
799 | { |
---|
800 | keepprime[i]=std(keepprime[i]); |
---|
801 | if(homog(keepprime[i])==1) |
---|
802 | { |
---|
803 | l[2*i]=maxideal(1); |
---|
804 | } |
---|
805 | else |
---|
806 | { |
---|
807 | act=zero_decomp(keepprime[i],ideal(0),@wr,1); |
---|
808 | if(size(act)==2) |
---|
809 | { |
---|
810 | l[2*i]=act[2]; |
---|
811 | } |
---|
812 | } |
---|
813 | } |
---|
814 | } |
---|
815 | return(l); |
---|
816 | } |
---|
817 | example |
---|
818 | { "EXAMPLE:"; echo=2; |
---|
819 | LIB "primdec.lib"; |
---|
820 | ring r = 32003,(x,y,z),lp; |
---|
821 | ideal i1=x*(x+1),yz,(z+1)*(z-1); |
---|
822 | ideal i2=xy,yz,(x-2)*(x+3); |
---|
823 | list l=i1,ideal(0),i2,ideal(0),i2,ideal(1); |
---|
824 | list l1=splitPrimary(l,ideal(0),0); |
---|
825 | l1; |
---|
826 | } |
---|
827 | |
---|
828 | //////////////////////////////////////////////////////////////////////////////// |
---|
829 | |
---|
830 | proc zero_decomp (ideal j,ideal ser,int @wr,list #) |
---|
831 | "USAGE: zero_decomp(j,ser,@wr); j,ser ideals, @wr=0 or 1 |
---|
832 | (@wr=0 for primary decomposition, @wr=1 for computaion of associated |
---|
833 | primes) |
---|
834 | RETURN: list = list of primary ideals and their radicals (at even positions |
---|
835 | in the list) if the input is zero-dimensional and a standardbases |
---|
836 | with respect to lex-ordering |
---|
837 | If ser!=(0) and ser is contained in j or if j is not zero-dimen- |
---|
838 | sional then ideal(1),ideal(1) is returned |
---|
839 | NOTE: Algorithm of Gianni, Traeger, Zacharias |
---|
840 | EXAMPLE: example zero_decomp; shows an example |
---|
841 | " |
---|
842 | { |
---|
843 | def @P = basering; |
---|
844 | int nva = nvars(basering); |
---|
845 | int @k,@s,@n,@k1,zz; |
---|
846 | list primary,lres,lres1,act,@lh,@wh; |
---|
847 | map phi,psi,phi1,psi1; |
---|
848 | ideal jmap,jmap1,jmap2,helpprim,@qh,@qht,ser1; |
---|
849 | intvec @vh,@hilb; |
---|
850 | string @ri; |
---|
851 | poly @f; |
---|
852 | |
---|
853 | if (dim(j)>0) |
---|
854 | { |
---|
855 | primary[1]=ideal(1); |
---|
856 | primary[2]=ideal(1); |
---|
857 | return(primary); |
---|
858 | } |
---|
859 | |
---|
860 | j=interred(j); |
---|
861 | attrib(j,"isSB",1); |
---|
862 | if(vdim(j)==deg(j[1])) |
---|
863 | { |
---|
864 | act=factor(j[1]); |
---|
865 | for(@k=1;@k<=size(act[1]);@k++) |
---|
866 | { |
---|
867 | @qh=j; |
---|
868 | if(@wr==0) |
---|
869 | { |
---|
870 | @qh[1]=act[1][@k]^act[2][@k]; |
---|
871 | } |
---|
872 | else |
---|
873 | { |
---|
874 | @qh[1]=act[1][@k]; |
---|
875 | } |
---|
876 | primary[2*@k-1]=interred(@qh); |
---|
877 | @qh=j; |
---|
878 | @qh[1]=act[1][@k]; |
---|
879 | primary[2*@k]=interred(@qh); |
---|
880 | attrib( primary[2*@k-1],"isSB",1); |
---|
881 | |
---|
882 | if((size(ser)>0)&&(size(reduce(ser,primary[2*@k-1],1))==0)) |
---|
883 | { |
---|
884 | primary[2*@k-1]=ideal(1); |
---|
885 | primary[2*@k]=ideal(1); |
---|
886 | } |
---|
887 | } |
---|
888 | return(primary); |
---|
889 | } |
---|
890 | |
---|
891 | if(homog(j)==1) |
---|
892 | { |
---|
893 | primary[1]=j; |
---|
894 | if((size(ser)>0)&&(size(reduce(ser,j,1))==0)) |
---|
895 | { |
---|
896 | primary[1]=ideal(1); |
---|
897 | primary[2]=ideal(1); |
---|
898 | return(primary); |
---|
899 | } |
---|
900 | if(dim(j)==-1) |
---|
901 | { |
---|
902 | primary[1]=ideal(1); |
---|
903 | primary[2]=ideal(1); |
---|
904 | } |
---|
905 | else |
---|
906 | { |
---|
907 | primary[2]=maxideal(1); |
---|
908 | } |
---|
909 | return(primary); |
---|
910 | } |
---|
911 | |
---|
912 | //the first element in the standardbase is factorized |
---|
913 | if(deg(j[1])>0) |
---|
914 | { |
---|
915 | act=factor(j[1]); |
---|
916 | testFactor(act,j[1]); |
---|
917 | } |
---|
918 | else |
---|
919 | { |
---|
920 | primary[1]=ideal(1); |
---|
921 | primary[2]=ideal(1); |
---|
922 | return(primary); |
---|
923 | } |
---|
924 | |
---|
925 | //withe the factors new ideals (hopefully the primary decomposition) |
---|
926 | //are created |
---|
927 | |
---|
928 | if(size(act[1])>1) |
---|
929 | { |
---|
930 | if(size(#)>1) |
---|
931 | { |
---|
932 | primary[1]=ideal(1); |
---|
933 | primary[2]=ideal(1); |
---|
934 | primary[3]=ideal(1); |
---|
935 | primary[4]=ideal(1); |
---|
936 | return(primary); |
---|
937 | } |
---|
938 | for(@k=1;@k<=size(act[1]);@k++) |
---|
939 | { |
---|
940 | if(@wr==0) |
---|
941 | { |
---|
942 | primary[2*@k-1]=std(j,act[1][@k]^act[2][@k]); |
---|
943 | } |
---|
944 | else |
---|
945 | { |
---|
946 | primary[2*@k-1]=std(j,act[1][@k]); |
---|
947 | } |
---|
948 | if((act[2][@k]==1)&&(vdim(primary[2*@k-1])==deg(act[1][@k]))) |
---|
949 | { |
---|
950 | primary[2*@k] = primary[2*@k-1]; |
---|
951 | } |
---|
952 | else |
---|
953 | { |
---|
954 | primary[2*@k] = primaryTest(primary[2*@k-1],act[1][@k]); |
---|
955 | } |
---|
956 | } |
---|
957 | } |
---|
958 | else |
---|
959 | { |
---|
960 | primary[1]=j; |
---|
961 | if((size(#)>0)&&(act[2][1]>1)) |
---|
962 | { |
---|
963 | act[2]=1; |
---|
964 | primary[1]=std(primary[1],act[1][1]); |
---|
965 | } |
---|
966 | |
---|
967 | if((act[2][1]==1)&&(vdim(primary[1])==deg(act[1][1]))) |
---|
968 | { |
---|
969 | primary[2]=primary[1]; |
---|
970 | } |
---|
971 | else |
---|
972 | { |
---|
973 | primary[2]=primaryTest(primary[1],act[1][1]); |
---|
974 | } |
---|
975 | } |
---|
976 | if(size(#)==0) |
---|
977 | { |
---|
978 | |
---|
979 | primary=splitPrimary(primary,ser,@wr,act); |
---|
980 | |
---|
981 | } |
---|
982 | |
---|
983 | //test whether all ideals in the decomposition are primary and |
---|
984 | //in general position |
---|
985 | //if not after a random coordinate transformation of the last |
---|
986 | //variable the corresponding ideal is decomposed again. |
---|
987 | |
---|
988 | @k=0; |
---|
989 | while(@k<(size(primary)/2)) |
---|
990 | { |
---|
991 | @k++; |
---|
992 | if (size(primary[2*@k])==0) |
---|
993 | { |
---|
994 | for(zz=1;zz<size(primary[2*@k-1])-1;zz++) |
---|
995 | { |
---|
996 | if(vdim(primary[2*@k-1])==deg(primary[2*@k-1][zz])) |
---|
997 | { |
---|
998 | primary[2*@k]=primary[2*@k-1]; |
---|
999 | } |
---|
1000 | } |
---|
1001 | } |
---|
1002 | } |
---|
1003 | |
---|
1004 | @k=0; |
---|
1005 | ideal keep; |
---|
1006 | while(@k<(size(primary)/2)) |
---|
1007 | { |
---|
1008 | @k++; |
---|
1009 | if (size(primary[2*@k])==0) |
---|
1010 | { |
---|
1011 | |
---|
1012 | jmap=randomLast(100); |
---|
1013 | jmap1=maxideal(1); |
---|
1014 | jmap2=maxideal(1); |
---|
1015 | @qht=primary[2*@k-1]; |
---|
1016 | |
---|
1017 | for(@n=2;@n<=size(primary[2*@k-1]);@n++) |
---|
1018 | { |
---|
1019 | if(deg(lead(primary[2*@k-1][@n]))==1) |
---|
1020 | { |
---|
1021 | for(zz=1;zz<=nva;zz++) |
---|
1022 | { |
---|
1023 | if(lead(primary[2*@k-1][@n])/var(zz)!=0) |
---|
1024 | { |
---|
1025 | jmap1[zz]=-1/leadcoef(primary[2*@k-1][@n])*primary[2*@k-1][@n] |
---|
1026 | +2/leadcoef(primary[2*@k-1][@n])*lead(primary[2*@k-1][@n]); |
---|
1027 | jmap2[zz]=primary[2*@k-1][@n]; |
---|
1028 | @qht[@n]=var(zz); |
---|
1029 | |
---|
1030 | } |
---|
1031 | } |
---|
1032 | jmap[nva]=subst(jmap[nva],lead(primary[2*@k-1][@n]),0); |
---|
1033 | } |
---|
1034 | } |
---|
1035 | if(size(subst(jmap[nva],var(1),0)-var(nva))!=0) |
---|
1036 | { |
---|
1037 | jmap[nva]=subst(jmap[nva],var(1),0); |
---|
1038 | } |
---|
1039 | phi1=@P,jmap1; |
---|
1040 | phi=@P,jmap; |
---|
1041 | |
---|
1042 | for(@n=1;@n<=nva;@n++) |
---|
1043 | { |
---|
1044 | jmap[@n]=-(jmap[@n]-2*var(@n)); |
---|
1045 | } |
---|
1046 | psi=@P,jmap; |
---|
1047 | psi1=@P,jmap2; |
---|
1048 | |
---|
1049 | @qh=phi(@qht); |
---|
1050 | |
---|
1051 | if(npars(@P)>0) |
---|
1052 | { |
---|
1053 | @ri= "ring @Phelp =" |
---|
1054 | +string(char(@P))+", |
---|
1055 | ("+varstr(@P)+","+parstr(@P)+",@t),(C,dp);"; |
---|
1056 | } |
---|
1057 | else |
---|
1058 | { |
---|
1059 | @ri= "ring @Phelp =" |
---|
1060 | +string(char(@P))+",("+varstr(@P)+",@t),(C,dp);"; |
---|
1061 | } |
---|
1062 | execute(@ri); |
---|
1063 | ideal @qh=homog(imap(@P,@qht),@t); |
---|
1064 | |
---|
1065 | ideal @qh1=std(@qh); |
---|
1066 | @hilb=hilb(@qh1,1); |
---|
1067 | @ri= "ring @Phelp1 =" |
---|
1068 | +string(char(@P))+",("+varstr(@Phelp)+"),(C,lp);"; |
---|
1069 | execute(@ri); |
---|
1070 | ideal @qh=homog(imap(@P,@qh),@t); |
---|
1071 | kill @Phelp; |
---|
1072 | @qh=std(@qh,@hilb); |
---|
1073 | @qh=subst(@qh,@t,1); |
---|
1074 | setring @P; |
---|
1075 | @qh=imap(@Phelp1,@qh); |
---|
1076 | kill @Phelp1; |
---|
1077 | @qh=clearSB(@qh); |
---|
1078 | attrib(@qh,"isSB",1); |
---|
1079 | ser1=phi1(ser); |
---|
1080 | @lh=zero_decomp (@qh,phi(ser1),@wr); |
---|
1081 | // @lh=zero_decomp (@qh,psi(ser),@wr); |
---|
1082 | |
---|
1083 | |
---|
1084 | kill lres; |
---|
1085 | list lres; |
---|
1086 | if(size(@lh)==2) |
---|
1087 | { |
---|
1088 | helpprim=@lh[2]; |
---|
1089 | lres[1]=primary[2*@k-1]; |
---|
1090 | ser1=psi(helpprim); |
---|
1091 | lres[2]=psi1(ser1); |
---|
1092 | if(size(reduce(lres[2],lres[1],1))==0) |
---|
1093 | { |
---|
1094 | primary[2*@k]=primary[2*@k-1]; |
---|
1095 | continue; |
---|
1096 | } |
---|
1097 | } |
---|
1098 | else |
---|
1099 | { |
---|
1100 | act=factor(@qh[1]); |
---|
1101 | if(2*size(act[1])==size(@lh)) |
---|
1102 | { |
---|
1103 | for(@n=1;@n<=size(act[1]);@n++) |
---|
1104 | { |
---|
1105 | @f=act[1][@n]^act[2][@n]; |
---|
1106 | ser1=psi(@f); |
---|
1107 | lres[2*@n-1]=interred(primary[2*@k-1]+psi1(ser1)); |
---|
1108 | helpprim=@lh[2*@n]; |
---|
1109 | ser1=psi(helpprim); |
---|
1110 | lres[2*@n]=psi1(ser1); |
---|
1111 | } |
---|
1112 | } |
---|
1113 | else |
---|
1114 | { |
---|
1115 | lres1=psi(@lh); |
---|
1116 | lres=psi1(lres1); |
---|
1117 | } |
---|
1118 | } |
---|
1119 | if(npars(@P)>0) |
---|
1120 | { |
---|
1121 | @ri= "ring @Phelp =" |
---|
1122 | +string(char(@P))+", |
---|
1123 | ("+varstr(@P)+","+parstr(@P)+",@t),(C,dp);"; |
---|
1124 | } |
---|
1125 | else |
---|
1126 | { |
---|
1127 | @ri= "ring @Phelp =" |
---|
1128 | +string(char(@P))+",("+varstr(@P)+",@t),(C,dp);"; |
---|
1129 | } |
---|
1130 | execute(@ri); |
---|
1131 | list @lvec; |
---|
1132 | list @lr=imap(@P,lres); |
---|
1133 | ideal @lr1; |
---|
1134 | |
---|
1135 | if(size(@lr)==2) |
---|
1136 | { |
---|
1137 | @lr[2]=homog(@lr[2],@t); |
---|
1138 | @lr1=std(@lr[2]); |
---|
1139 | @lvec[2]=hilb(@lr1,1); |
---|
1140 | } |
---|
1141 | else |
---|
1142 | { |
---|
1143 | for(@n=1;@n<=size(@lr)/2;@n++) |
---|
1144 | { |
---|
1145 | if(specialIdealsEqual(@lr[2*@n-1],@lr[2*@n])==1) |
---|
1146 | { |
---|
1147 | @lr[2*@n-1]=homog(@lr[2*@n-1],@t); |
---|
1148 | @lr1=std(@lr[2*@n-1]); |
---|
1149 | @lvec[2*@n-1]=hilb(@lr1,1); |
---|
1150 | @lvec[2*@n]=@lvec[2*@n-1]; |
---|
1151 | } |
---|
1152 | else |
---|
1153 | { |
---|
1154 | @lr[2*@n-1]=homog(@lr[2*@n-1],@t); |
---|
1155 | @lr1=std(@lr[2*@n-1]); |
---|
1156 | @lvec[2*@n-1]=hilb(@lr1,1); |
---|
1157 | @lr[2*@n]=homog(@lr[2*@n],@t); |
---|
1158 | @lr1=std(@lr[2*@n]); |
---|
1159 | @lvec[2*@n]=hilb(@lr1,1); |
---|
1160 | |
---|
1161 | } |
---|
1162 | } |
---|
1163 | } |
---|
1164 | @ri= "ring @Phelp1 =" |
---|
1165 | +string(char(@P))+",("+varstr(@Phelp)+"),(C,lp);"; |
---|
1166 | execute(@ri); |
---|
1167 | list @lr=imap(@Phelp,@lr); |
---|
1168 | |
---|
1169 | kill @Phelp; |
---|
1170 | if(size(@lr)==2) |
---|
1171 | { |
---|
1172 | @lr[2]=std(@lr[2],@lvec[2]); |
---|
1173 | @lr[2]=subst(@lr[2],@t,1); |
---|
1174 | |
---|
1175 | } |
---|
1176 | else |
---|
1177 | { |
---|
1178 | for(@n=1;@n<=size(@lr)/2;@n++) |
---|
1179 | { |
---|
1180 | if(specialIdealsEqual(@lr[2*@n-1],@lr[2*@n])==1) |
---|
1181 | { |
---|
1182 | @lr[2*@n-1]=std(@lr[2*@n-1],@lvec[2*@n-1]); |
---|
1183 | @lr[2*@n-1]=subst(@lr[2*@n-1],@t,1); |
---|
1184 | @lr[2*@n]=@lr[2*@n-1]; |
---|
1185 | attrib(@lr[2*@n],"isSB",1); |
---|
1186 | } |
---|
1187 | else |
---|
1188 | { |
---|
1189 | @lr[2*@n-1]=std(@lr[2*@n-1],@lvec[2*@n-1]); |
---|
1190 | @lr[2*@n-1]=subst(@lr[2*@n-1],@t,1); |
---|
1191 | @lr[2*@n]=std(@lr[2*@n],@lvec[2*@n]); |
---|
1192 | @lr[2*@n]=subst(@lr[2*@n],@t,1); |
---|
1193 | } |
---|
1194 | } |
---|
1195 | } |
---|
1196 | kill @lvec; |
---|
1197 | setring @P; |
---|
1198 | lres=imap(@Phelp1,@lr); |
---|
1199 | kill @Phelp1; |
---|
1200 | for(@n=1;@n<=size(lres);@n++) |
---|
1201 | { |
---|
1202 | lres[@n]=clearSB(lres[@n]); |
---|
1203 | attrib(lres[@n],"isSB",1); |
---|
1204 | } |
---|
1205 | |
---|
1206 | primary[2*@k-1]=lres[1]; |
---|
1207 | primary[2*@k]=lres[2]; |
---|
1208 | @s=size(primary)/2; |
---|
1209 | for(@n=1;@n<=size(lres)/2-1;@n++) |
---|
1210 | { |
---|
1211 | primary[2*@s+2*@n-1]=lres[2*@n+1]; |
---|
1212 | primary[2*@s+2*@n]=lres[2*@n+2]; |
---|
1213 | } |
---|
1214 | @k--; |
---|
1215 | } |
---|
1216 | } |
---|
1217 | return(primary); |
---|
1218 | } |
---|
1219 | example |
---|
1220 | { "EXAMPLE:"; echo = 2; |
---|
1221 | ring r = 0,(x,y,z),lp; |
---|
1222 | poly p = z2+1; |
---|
1223 | poly q = z4+2; |
---|
1224 | ideal i = p^2*q^3,(y-z3)^3,(x-yz+z4)^4; |
---|
1225 | i=std(i); |
---|
1226 | list pr= zero_decomp(i,ideal(0),0); |
---|
1227 | pr; |
---|
1228 | } |
---|
1229 | |
---|
1230 | //////////////////////////////////////////////////////////////////////////////// |
---|
1231 | |
---|
1232 | proc ggt (ideal i) |
---|
1233 | "USAGE: ggt(i); i list of polynomials |
---|
1234 | RETURN: poly = ggt(i[1],...,i[size(i)]) |
---|
1235 | NOTE: |
---|
1236 | EXAMPLE: example ggt; shows an example |
---|
1237 | " |
---|
1238 | { |
---|
1239 | int k; |
---|
1240 | poly p=i[1]; |
---|
1241 | if(deg(p)==0) |
---|
1242 | { |
---|
1243 | return(1); |
---|
1244 | } |
---|
1245 | |
---|
1246 | |
---|
1247 | for (k=2;k<=size(i);k++) |
---|
1248 | { |
---|
1249 | if(deg(i[k])==0) |
---|
1250 | { |
---|
1251 | return(1) |
---|
1252 | } |
---|
1253 | p=GCD(p,i[k]); |
---|
1254 | if(deg(p)==0) |
---|
1255 | { |
---|
1256 | return(1); |
---|
1257 | } |
---|
1258 | } |
---|
1259 | return(p); |
---|
1260 | } |
---|
1261 | example |
---|
1262 | { "EXAMPLE:"; echo = 2; |
---|
1263 | ring r = 0,(x,y,z),lp; |
---|
1264 | poly p = (x+y)*(y+z); |
---|
1265 | poly q = (z4+2)*(y+z); |
---|
1266 | ideal l=p,q; |
---|
1267 | poly pr= ggt(l); |
---|
1268 | pr; |
---|
1269 | } |
---|
1270 | /////////////////////////////////////////////////////////////////////////////// |
---|
1271 | proc gcdTest(ideal act) |
---|
1272 | { |
---|
1273 | int i,j; |
---|
1274 | if(size(act)<=1) |
---|
1275 | { |
---|
1276 | return(0); |
---|
1277 | } |
---|
1278 | for (i=1;i<=size(act)-1;i++) |
---|
1279 | { |
---|
1280 | for(j=i+1;j<=size(act);j++) |
---|
1281 | { |
---|
1282 | if(deg(std(ideal(act[i],act[j]))[1])>0) |
---|
1283 | { |
---|
1284 | return(0); |
---|
1285 | } |
---|
1286 | } |
---|
1287 | } |
---|
1288 | return(1); |
---|
1289 | } |
---|
1290 | |
---|
1291 | /////////////////////////////////////////////////////////////////////////////// |
---|
1292 | proc coeffLcm(ideal h) |
---|
1293 | { |
---|
1294 | string @pa=parstr(basering); |
---|
1295 | if(size(@pa)==0) |
---|
1296 | { |
---|
1297 | return(lcmP(h)); |
---|
1298 | } |
---|
1299 | def bsr= basering; |
---|
1300 | string @id=string(h); |
---|
1301 | execute "ring @r=0,("+@pa+","+varstr(bsr)+"),(C,dp);"; |
---|
1302 | execute "ideal @i="+@id+";"; |
---|
1303 | poly @p=lcmP(@i); |
---|
1304 | string @ps=string(@p); |
---|
1305 | setring bsr; |
---|
1306 | execute "poly @p="+@ps+";"; |
---|
1307 | return(@p); |
---|
1308 | } |
---|
1309 | example |
---|
1310 | { |
---|
1311 | "EXAMPLE:"; echo = 2; |
---|
1312 | ring r =( 0,a,b),(x,y,z),lp; |
---|
1313 | poly p = (a+b)*(y-z); |
---|
1314 | poly q = (a+b)*(y+z); |
---|
1315 | ideal l=p,q; |
---|
1316 | poly pr= coeffLcm(l); |
---|
1317 | pr; |
---|
1318 | } |
---|
1319 | |
---|
1320 | /////////////////////////////////////////////////////////////////////////////// |
---|
1321 | |
---|
1322 | proc lcmP(ideal i) |
---|
1323 | "USAGE: lcm(i); i list of polynomials |
---|
1324 | RETURN: poly = lcm(i[1],...,i[size(i)]) |
---|
1325 | NOTE: |
---|
1326 | EXAMPLE: example lcm; shows an example |
---|
1327 | " |
---|
1328 | { |
---|
1329 | int k,j; |
---|
1330 | poly p,q; |
---|
1331 | i=simplify(i,10); |
---|
1332 | for(j=1;j<=size(i);j++) |
---|
1333 | { |
---|
1334 | if(deg(i[j])>0) |
---|
1335 | { |
---|
1336 | p=i[j]; |
---|
1337 | break; |
---|
1338 | } |
---|
1339 | } |
---|
1340 | if(deg(p)==-1) |
---|
1341 | { |
---|
1342 | return(1); |
---|
1343 | } |
---|
1344 | for (k=j+1;k<=size(i);k++) |
---|
1345 | { |
---|
1346 | if(deg(i[k])!=0) |
---|
1347 | { |
---|
1348 | q=GCD(p,i[k]); |
---|
1349 | if(deg(q)==0) |
---|
1350 | { |
---|
1351 | p=p*i[k]; |
---|
1352 | } |
---|
1353 | else |
---|
1354 | { |
---|
1355 | p=p/q; |
---|
1356 | p=p*i[k]; |
---|
1357 | } |
---|
1358 | } |
---|
1359 | } |
---|
1360 | return(p); |
---|
1361 | } |
---|
1362 | example |
---|
1363 | { "EXAMPLE:"; echo = 2; |
---|
1364 | ring r = 0,(x,y,z),lp; |
---|
1365 | poly p = (x+y)*(y+z); |
---|
1366 | poly q = (z4+2)*(y+z); |
---|
1367 | ideal l=p,q; |
---|
1368 | poly pr= lcmP(l); |
---|
1369 | pr; |
---|
1370 | l=1,-1,p,1,-1,q,1; |
---|
1371 | pr=lcmP(l); |
---|
1372 | pr; |
---|
1373 | } |
---|
1374 | |
---|
1375 | /////////////////////////////////////////////////////////////////////////////// |
---|
1376 | proc clearSB (ideal i,list #) |
---|
1377 | "USAGE: clearSB(i); i ideal which is SB ordered by monomial ordering |
---|
1378 | RETURN: ideal = minimal SB |
---|
1379 | NOTE: |
---|
1380 | EXAMPLE: example clearSB; shows an example |
---|
1381 | " |
---|
1382 | { |
---|
1383 | int k,j; |
---|
1384 | poly m; |
---|
1385 | int c=size(i); |
---|
1386 | |
---|
1387 | if(size(#)==0) |
---|
1388 | { |
---|
1389 | for(j=1;j<c;j++) |
---|
1390 | { |
---|
1391 | if(deg(i[j])==0) |
---|
1392 | { |
---|
1393 | i=ideal(1); |
---|
1394 | return(i); |
---|
1395 | } |
---|
1396 | if(deg(i[j])>0) |
---|
1397 | { |
---|
1398 | m=lead(i[j]); |
---|
1399 | for(k=j+1;k<=c;k++) |
---|
1400 | { |
---|
1401 | if(size(lead(i[k])/m)>0) |
---|
1402 | { |
---|
1403 | i[k]=0; |
---|
1404 | } |
---|
1405 | } |
---|
1406 | } |
---|
1407 | } |
---|
1408 | } |
---|
1409 | else |
---|
1410 | { |
---|
1411 | j=0; |
---|
1412 | while(j<c-1) |
---|
1413 | { |
---|
1414 | j++; |
---|
1415 | if(deg(i[j])==0) |
---|
1416 | { |
---|
1417 | i=ideal(1); |
---|
1418 | return(i); |
---|
1419 | } |
---|
1420 | if(deg(i[j])>0) |
---|
1421 | { |
---|
1422 | m=lead(i[j]); |
---|
1423 | for(k=j+1;k<=c;k++) |
---|
1424 | { |
---|
1425 | if(size(lead(i[k])/m)>0) |
---|
1426 | { |
---|
1427 | if((leadexp(m)!=leadexp(i[k]))||(#[j]<=#[k])) |
---|
1428 | { |
---|
1429 | i[k]=0; |
---|
1430 | } |
---|
1431 | else |
---|
1432 | { |
---|
1433 | i[j]=0; |
---|
1434 | break; |
---|
1435 | } |
---|
1436 | } |
---|
1437 | } |
---|
1438 | } |
---|
1439 | } |
---|
1440 | } |
---|
1441 | return(simplify(i,2)); |
---|
1442 | } |
---|
1443 | example |
---|
1444 | { "EXAMPLE:"; echo = 2; |
---|
1445 | LIB "primdec.lib"; |
---|
1446 | ring r = (0,a,b),(x,y,z),dp; |
---|
1447 | ideal i=ax2+y,a2x+y,bx; |
---|
1448 | list l=1,2,1; |
---|
1449 | ideal j=clearSB(i,l); |
---|
1450 | j; |
---|
1451 | } |
---|
1452 | |
---|
1453 | /////////////////////////////////////////////////////////////////////////////// |
---|
1454 | |
---|
1455 | proc independSet (ideal j) |
---|
1456 | "USAGE: independentSet(i); i ideal |
---|
1457 | RETURN: list = new varstring with the independent set at the end, |
---|
1458 | ordstring with the corresponding block ordering, |
---|
1459 | the integer where the independent set starts in the varstring |
---|
1460 | NOTE: |
---|
1461 | EXAMPLE: example independentSet; shows an example |
---|
1462 | " |
---|
1463 | { |
---|
1464 | int n,k,di; |
---|
1465 | list resu,hilf; |
---|
1466 | string var1,var2; |
---|
1467 | list v=system("indsetall",j,1); |
---|
1468 | |
---|
1469 | for(n=1;n<=size(v);n++) |
---|
1470 | { |
---|
1471 | di=0; |
---|
1472 | var1=""; |
---|
1473 | var2=""; |
---|
1474 | for(k=1;k<=size(v[n]);k++) |
---|
1475 | { |
---|
1476 | if(v[n][k]!=0) |
---|
1477 | { |
---|
1478 | di++; |
---|
1479 | var2=var2+"var("+string(k)+"),"; |
---|
1480 | } |
---|
1481 | else |
---|
1482 | { |
---|
1483 | var1=var1+"var("+string(k)+"),"; |
---|
1484 | } |
---|
1485 | } |
---|
1486 | if(di>0) |
---|
1487 | { |
---|
1488 | var1=var1+var2; |
---|
1489 | var1=var1[1..size(var1)-1]; |
---|
1490 | hilf[1]=var1; |
---|
1491 | hilf[2]="lp"; |
---|
1492 | //"lp("+string(nvars(basering)-di)+"),dp("+string(di)+")"; |
---|
1493 | hilf[3]=di; |
---|
1494 | resu[n]=hilf; |
---|
1495 | } |
---|
1496 | else |
---|
1497 | { |
---|
1498 | resu[n]=varstr(basering),ordstr(basering),0; |
---|
1499 | } |
---|
1500 | } |
---|
1501 | return(resu); |
---|
1502 | } |
---|
1503 | example |
---|
1504 | { "EXAMPLE:"; echo = 2; |
---|
1505 | ring s1=(0,x,y),(a,b,c,d,e,f,g),lp; |
---|
1506 | ideal i=ea-fbg,fa+be,ec-fdg,fc+de; |
---|
1507 | i=std(i); |
---|
1508 | list l=independSet(i); |
---|
1509 | l; |
---|
1510 | i=i,g; |
---|
1511 | l=independSet(i); |
---|
1512 | l; |
---|
1513 | |
---|
1514 | ring s=0,(x,y,z),lp; |
---|
1515 | ideal i=z,yx; |
---|
1516 | list l=independSet(i); |
---|
1517 | l; |
---|
1518 | |
---|
1519 | |
---|
1520 | } |
---|
1521 | /////////////////////////////////////////////////////////////////////////////// |
---|
1522 | |
---|
1523 | proc maxIndependSet (ideal j) |
---|
1524 | "USAGE: maxIndependentSet(i); i ideal |
---|
1525 | RETURN: list = new varstring with the maximal independent set at the end, |
---|
1526 | ordstring with the corresponding block ordering, |
---|
1527 | the integer where the independent set starts in the varstring |
---|
1528 | NOTE: |
---|
1529 | EXAMPLE: example maxIndependentSet; shows an example |
---|
1530 | " |
---|
1531 | { |
---|
1532 | int n,k,di; |
---|
1533 | list resu,hilf; |
---|
1534 | string var1,var2; |
---|
1535 | list v=system("indsetall",j,0); |
---|
1536 | |
---|
1537 | for(n=1;n<=size(v);n++) |
---|
1538 | { |
---|
1539 | di=0; |
---|
1540 | var1=""; |
---|
1541 | var2=""; |
---|
1542 | for(k=1;k<=size(v[n]);k++) |
---|
1543 | { |
---|
1544 | if(v[n][k]!=0) |
---|
1545 | { |
---|
1546 | di++; |
---|
1547 | var2=var2+"var("+string(k)+"),"; |
---|
1548 | } |
---|
1549 | else |
---|
1550 | { |
---|
1551 | var1=var1+"var("+string(k)+"),"; |
---|
1552 | } |
---|
1553 | } |
---|
1554 | if(di>0) |
---|
1555 | { |
---|
1556 | var1=var1+var2; |
---|
1557 | var1=var1[1..size(var1)-1]; |
---|
1558 | hilf[1]=var1; |
---|
1559 | hilf[2]="lp"; |
---|
1560 | hilf[3]=di; |
---|
1561 | resu[n]=hilf; |
---|
1562 | } |
---|
1563 | else |
---|
1564 | { |
---|
1565 | resu[n]=varstr(basering),ordstr(basering),0; |
---|
1566 | } |
---|
1567 | } |
---|
1568 | return(resu); |
---|
1569 | } |
---|
1570 | example |
---|
1571 | { "EXAMPLE:"; echo = 2; |
---|
1572 | ring s1=(0,x,y),(a,b,c,d,e,f,g),lp; |
---|
1573 | ideal i=ea-fbg,fa+be,ec-fdg,fc+de; |
---|
1574 | i=std(i); |
---|
1575 | list l=maxIndependSet(i); |
---|
1576 | l; |
---|
1577 | i=i,g; |
---|
1578 | l=maxIndependSet(i); |
---|
1579 | l; |
---|
1580 | |
---|
1581 | ring s=0,(x,y,z),lp; |
---|
1582 | ideal i=z,yx; |
---|
1583 | list l=maxIndependSet(i); |
---|
1584 | l; |
---|
1585 | |
---|
1586 | |
---|
1587 | } |
---|
1588 | |
---|
1589 | /////////////////////////////////////////////////////////////////////////////// |
---|
1590 | |
---|
1591 | proc prepareQuotientring (int nnp) |
---|
1592 | "USAGE: prepareQuotientring(nnp); nnp int |
---|
1593 | RETURN: string = to define Kvar(nnp+1),...,var(nvars)[..rest ] |
---|
1594 | NOTE: |
---|
1595 | EXAMPLE: example independentSet; shows an example |
---|
1596 | " |
---|
1597 | { |
---|
1598 | ideal @ih,@jh; |
---|
1599 | int npar=npars(basering); |
---|
1600 | int @n; |
---|
1601 | |
---|
1602 | string quotring= "ring quring = ("+charstr(basering); |
---|
1603 | for(@n=nnp+1;@n<=nvars(basering);@n++) |
---|
1604 | { |
---|
1605 | quotring=quotring+",var("+string(@n)+")"; |
---|
1606 | @ih=@ih+var(@n); |
---|
1607 | } |
---|
1608 | |
---|
1609 | quotring=quotring+"),(var(1)"; |
---|
1610 | @jh=@jh+var(1); |
---|
1611 | for(@n=2;@n<=nnp;@n++) |
---|
1612 | { |
---|
1613 | quotring=quotring+",var("+string(@n)+")"; |
---|
1614 | @jh=@jh+var(@n); |
---|
1615 | } |
---|
1616 | quotring=quotring+"),(C,lp);"; |
---|
1617 | |
---|
1618 | return(quotring); |
---|
1619 | |
---|
1620 | } |
---|
1621 | example |
---|
1622 | { "EXAMPLE:"; echo = 2; |
---|
1623 | ring s1=(0,x),(a,b,c,d,e,f,g),lp; |
---|
1624 | def @Q=basering; |
---|
1625 | list l= prepareQuotientring(3); |
---|
1626 | l; |
---|
1627 | execute l[1]; |
---|
1628 | execute l[2]; |
---|
1629 | basering; |
---|
1630 | phi; |
---|
1631 | setring @Q; |
---|
1632 | |
---|
1633 | } |
---|
1634 | |
---|
1635 | /////////////////////////////////////////////////////////////////////// |
---|
1636 | |
---|
1637 | proc projdim(list l) |
---|
1638 | { |
---|
1639 | int i=size(l)+1; |
---|
1640 | |
---|
1641 | while(i>2) |
---|
1642 | { |
---|
1643 | i--; |
---|
1644 | if((size(l[i])>0)&&(deg(l[i][1])>0)) |
---|
1645 | { |
---|
1646 | return(i); |
---|
1647 | } |
---|
1648 | } |
---|
1649 | } |
---|
1650 | |
---|
1651 | /////////////////////////////////////////////////////////////////////////////// |
---|
1652 | proc cleanPrimary(list l) |
---|
1653 | { |
---|
1654 | int i,j; |
---|
1655 | list lh; |
---|
1656 | for(i=1;i<=size(l)/2;i++) |
---|
1657 | { |
---|
1658 | if(deg(l[2*i-1][1])>0) |
---|
1659 | { |
---|
1660 | j++; |
---|
1661 | lh[j]=l[2*i-1]; |
---|
1662 | j++; |
---|
1663 | lh[j]=l[2*i]; |
---|
1664 | } |
---|
1665 | } |
---|
1666 | return(lh); |
---|
1667 | } |
---|
1668 | /////////////////////////////////////////////////////////////////////////////// |
---|
1669 | |
---|
1670 | proc minAssPrimes(ideal i, list #) |
---|
1671 | "USAGE: minAssPrimes(i); i ideal |
---|
1672 | minAssPrimes(i,1); i ideal (to use also the factorizing Groebner) |
---|
1673 | RETURN: list = the minimal associated prime ideals of i |
---|
1674 | NOTE: |
---|
1675 | EXAMPLE: example minAssPrimes; shows an example |
---|
1676 | " |
---|
1677 | { |
---|
1678 | #[1]=1; |
---|
1679 | def @P=basering; |
---|
1680 | list qr=simplifyIdeal(i); |
---|
1681 | map phi=@P,qr[2]; |
---|
1682 | i=qr[1]; |
---|
1683 | |
---|
1684 | execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),(" |
---|
1685 | +ordstr(basering)+");"; |
---|
1686 | |
---|
1687 | |
---|
1688 | ideal i=fetch(@P,i); |
---|
1689 | if(size(#)==0) |
---|
1690 | { |
---|
1691 | int @wr; |
---|
1692 | list tluser,@res; |
---|
1693 | list primary=decomp(i,2); |
---|
1694 | |
---|
1695 | @res[1]=primary; |
---|
1696 | |
---|
1697 | tluser=union(@res); |
---|
1698 | setring @P; |
---|
1699 | list @res=imap(gnir,tluser); |
---|
1700 | return(phi(@res)); |
---|
1701 | } |
---|
1702 | list @res,empty; |
---|
1703 | ideal ser; |
---|
1704 | option(redSB); |
---|
1705 | list @pr=facstd(i); |
---|
1706 | if(size(@pr)==1) |
---|
1707 | { |
---|
1708 | attrib(@pr[1],"isSB",1); |
---|
1709 | if((dim(@pr[1])==0)&&(homog(@pr[1])==1)) |
---|
1710 | { |
---|
1711 | setring @P; |
---|
1712 | list @res=maxideal(1); |
---|
1713 | return(phi(@res)); |
---|
1714 | } |
---|
1715 | if(dim(@pr[1])>1) |
---|
1716 | { |
---|
1717 | setring @P; |
---|
1718 | // kill gnir; |
---|
1719 | execute "ring gnir1 = ("+charstr(basering)+"), |
---|
1720 | ("+varstr(basering)+"),(C,lp);"; |
---|
1721 | ideal i=fetch(@P,i); |
---|
1722 | list @pr=facstd(i); |
---|
1723 | // ideal ser; |
---|
1724 | setring gnir; |
---|
1725 | @pr=fetch(gnir1,@pr); |
---|
1726 | kill gnir1; |
---|
1727 | } |
---|
1728 | } |
---|
1729 | option(noredSB); |
---|
1730 | int j,k,odim,ndim,count; |
---|
1731 | attrib(@pr[1],"isSB",1); |
---|
1732 | if(#[1]==77) |
---|
1733 | { |
---|
1734 | odim=dim(@pr[1]); |
---|
1735 | count=1; |
---|
1736 | intvec pos; |
---|
1737 | pos[size(@pr)]=0; |
---|
1738 | for(j=2;j<=size(@pr);j++) |
---|
1739 | { |
---|
1740 | attrib(@pr[j],"isSB",1); |
---|
1741 | ndim=dim(@pr[j]); |
---|
1742 | if(ndim>odim) |
---|
1743 | { |
---|
1744 | for(k=count;k<=j-1;k++) |
---|
1745 | { |
---|
1746 | pos[k]=1; |
---|
1747 | } |
---|
1748 | count=j; |
---|
1749 | odim=ndim; |
---|
1750 | } |
---|
1751 | if(ndim<odim) |
---|
1752 | { |
---|
1753 | pos[j]=1; |
---|
1754 | } |
---|
1755 | } |
---|
1756 | for(j=1;j<=size(@pr);j++) |
---|
1757 | { |
---|
1758 | if(pos[j]!=1) |
---|
1759 | { |
---|
1760 | @res[j]=decomp(@pr[j],2); |
---|
1761 | } |
---|
1762 | else |
---|
1763 | { |
---|
1764 | @res[j]=empty; |
---|
1765 | } |
---|
1766 | } |
---|
1767 | } |
---|
1768 | else |
---|
1769 | { |
---|
1770 | ser=ideal(1); |
---|
1771 | for(j=1;j<=size(@pr);j++) |
---|
1772 | { |
---|
1773 | //@pr[j]; |
---|
1774 | //pause; |
---|
1775 | @res[j]=decomp(@pr[j],2); |
---|
1776 | // @res[j]=decomp(@pr[j],2,@pr[j],ser); |
---|
1777 | // for(k=1;k<=size(@res[j]);k++) |
---|
1778 | // { |
---|
1779 | // ser=intersect(ser,@res[j][k]); |
---|
1780 | // } |
---|
1781 | } |
---|
1782 | } |
---|
1783 | |
---|
1784 | @res=union(@res); |
---|
1785 | setring @P; |
---|
1786 | list @res=imap(gnir,@res); |
---|
1787 | return(phi(@res)); |
---|
1788 | } |
---|
1789 | example |
---|
1790 | { "EXAMPLE:"; echo = 2; |
---|
1791 | ring r = 32003,(x,y,z),lp; |
---|
1792 | poly p = z2+1; |
---|
1793 | poly q = z4+2; |
---|
1794 | ideal i = p^2*q^3,(y-z3)^3,(x-yz+z4)^4; |
---|
1795 | LIB "primaryDecomposition.lib"; |
---|
1796 | list pr= minAssPrimes(i); |
---|
1797 | pr; |
---|
1798 | pr= minAssPrimes(i,1); |
---|
1799 | } |
---|
1800 | |
---|
1801 | /////////////////////////////////////////////////////////////////////////////// |
---|
1802 | |
---|
1803 | proc union(list li) |
---|
1804 | { |
---|
1805 | int i,j,k; |
---|
1806 | |
---|
1807 | def P=basering; |
---|
1808 | |
---|
1809 | execute "ring ir = ("+charstr(basering)+"),("+varstr(basering)+"),(C,lp);"; |
---|
1810 | list l=fetch(P,li); |
---|
1811 | list @erg; |
---|
1812 | |
---|
1813 | for(k=1;k<=size(l);k++) |
---|
1814 | { |
---|
1815 | for(j=1;j<=size(l[k])/2;j++) |
---|
1816 | { |
---|
1817 | if(deg(l[k][2*j][1])!=0) |
---|
1818 | { |
---|
1819 | i++; |
---|
1820 | @erg[i]=l[k][2*j]; |
---|
1821 | } |
---|
1822 | } |
---|
1823 | } |
---|
1824 | |
---|
1825 | list @wos; |
---|
1826 | i=0; |
---|
1827 | ideal i1,i2; |
---|
1828 | while(i<size(@erg)-1) |
---|
1829 | { |
---|
1830 | i++; |
---|
1831 | k=i+1; |
---|
1832 | i1=lead(@erg[i]); |
---|
1833 | attrib(i1,"isSB",1); |
---|
1834 | attrib(@erg[i],"isSB",1); |
---|
1835 | |
---|
1836 | while(k<=size(@erg)) |
---|
1837 | { |
---|
1838 | if(deg(@erg[i][1])==0) |
---|
1839 | { |
---|
1840 | break; |
---|
1841 | } |
---|
1842 | i2=lead(@erg[k]); |
---|
1843 | attrib(@erg[k],"isSB",1); |
---|
1844 | attrib(i2,"isSB",1); |
---|
1845 | |
---|
1846 | if(size(reduce(i1,i2,1))==0) |
---|
1847 | { |
---|
1848 | if(size(reduce(@erg[i],@erg[k],1))==0) |
---|
1849 | { |
---|
1850 | @erg[k]=ideal(1); |
---|
1851 | i2=ideal(1); |
---|
1852 | } |
---|
1853 | } |
---|
1854 | if(size(reduce(i2,i1,1))==0) |
---|
1855 | { |
---|
1856 | if(size(reduce(@erg[k],@erg[i],1))==0) |
---|
1857 | { |
---|
1858 | break; |
---|
1859 | } |
---|
1860 | } |
---|
1861 | k++; |
---|
1862 | if(k>size(@erg)) |
---|
1863 | { |
---|
1864 | @wos[size(@wos)+1]=@erg[i]; |
---|
1865 | } |
---|
1866 | } |
---|
1867 | } |
---|
1868 | if(deg(@erg[size(@erg)][1])!=0) |
---|
1869 | { |
---|
1870 | @wos[size(@wos)+1]=@erg[size(@erg)]; |
---|
1871 | } |
---|
1872 | setring P; |
---|
1873 | list @ser=fetch(ir,@wos); |
---|
1874 | return(@ser); |
---|
1875 | } |
---|
1876 | /////////////////////////////////////////////////////////////////////////////// |
---|
1877 | proc radicalOld(ideal i) |
---|
1878 | { |
---|
1879 | list pr=minAssPrimes(i,1); |
---|
1880 | int j; |
---|
1881 | ideal k=pr[1]; |
---|
1882 | for(j=2;j<=size(pr);j++) |
---|
1883 | { |
---|
1884 | k=intersect(k,pr[j]); |
---|
1885 | } |
---|
1886 | return(k); |
---|
1887 | } |
---|
1888 | /////////////////////////////////////////////////////////////////////////////// |
---|
1889 | proc equiRadical(ideal i) |
---|
1890 | { |
---|
1891 | return(radical(i,1)); |
---|
1892 | } |
---|
1893 | |
---|
1894 | /////////////////////////////////////////////////////////////////////////////// |
---|
1895 | proc decomp(ideal i,list #) |
---|
1896 | "USAGE: decomp(i); i ideal (for primary decomposition) (resp. |
---|
1897 | decomp(i,1); (for the minimal associated primes) ) |
---|
1898 | RETURN: list = list of primary ideals and their associated primes |
---|
1899 | (at even positions in the list) |
---|
1900 | (resp. a list of the minimal associated primes) |
---|
1901 | NOTE: Algorithm of Gianni, Traeger, Zacharias |
---|
1902 | EXAMPLE: example decomp; shows an example |
---|
1903 | " |
---|
1904 | { |
---|
1905 | def @P = basering; |
---|
1906 | list primary,indep,ltras; |
---|
1907 | intvec @vh,isat; |
---|
1908 | int @wr,@k,@n,@m,@n1,@n2,@n3,homo,seri,keepdi; |
---|
1909 | ideal peek=i; |
---|
1910 | ideal ser,tras; |
---|
1911 | |
---|
1912 | if(size(#)>0) |
---|
1913 | { |
---|
1914 | if((#[1]==1)||(#[1]==2)) |
---|
1915 | { |
---|
1916 | @wr=#[1]; |
---|
1917 | if(size(#)>1) |
---|
1918 | { |
---|
1919 | seri=1; |
---|
1920 | peek=#[2]; |
---|
1921 | ser=#[3]; |
---|
1922 | } |
---|
1923 | } |
---|
1924 | else |
---|
1925 | { |
---|
1926 | seri=1; |
---|
1927 | peek=#[1]; |
---|
1928 | ser=#[2]; |
---|
1929 | } |
---|
1930 | } |
---|
1931 | |
---|
1932 | homo=homog(i); |
---|
1933 | |
---|
1934 | if(homo==1) |
---|
1935 | { |
---|
1936 | if(attrib(i,"isSB")!=1) |
---|
1937 | { |
---|
1938 | ltras=mstd(i); |
---|
1939 | attrib(ltras[1],"isSB",1); |
---|
1940 | } |
---|
1941 | else |
---|
1942 | { |
---|
1943 | ltras=i,i; |
---|
1944 | } |
---|
1945 | tras=ltras[1]; |
---|
1946 | if(dim(tras)==0) |
---|
1947 | { |
---|
1948 | primary[1]=ltras[2]; |
---|
1949 | primary[2]=maxideal(1); |
---|
1950 | if(@wr>0) |
---|
1951 | { |
---|
1952 | list l; |
---|
1953 | l[1]=maxideal(1); |
---|
1954 | l[2]=maxideal(1); |
---|
1955 | return(l); |
---|
1956 | } |
---|
1957 | return(primary); |
---|
1958 | } |
---|
1959 | intvec @hilb=hilb(tras,1); |
---|
1960 | intvec keephilb=@hilb; |
---|
1961 | } |
---|
1962 | |
---|
1963 | //---------------------------------------------------------------- |
---|
1964 | //i is the zero-ideal |
---|
1965 | //---------------------------------------------------------------- |
---|
1966 | |
---|
1967 | if(size(i)==0) |
---|
1968 | { |
---|
1969 | primary=i,i; |
---|
1970 | return(primary); |
---|
1971 | } |
---|
1972 | |
---|
1973 | //---------------------------------------------------------------- |
---|
1974 | //pass to the lexicographical ordering and compute a standardbasis |
---|
1975 | //---------------------------------------------------------------- |
---|
1976 | |
---|
1977 | execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),(C,lp);"; |
---|
1978 | option(redSB); |
---|
1979 | |
---|
1980 | ideal ser=fetch(@P,ser); |
---|
1981 | |
---|
1982 | if(homo==1) |
---|
1983 | { |
---|
1984 | if((ordstr(@P)[1]!="(C,lp)")&&(ordstr(@P)[3]!="(C,lp)")) |
---|
1985 | { |
---|
1986 | ideal @j=std(fetch(@P,i),@hilb); |
---|
1987 | } |
---|
1988 | else |
---|
1989 | { |
---|
1990 | ideal @j=fetch(@P,tras); |
---|
1991 | attrib(@j,"isSB",1); |
---|
1992 | } |
---|
1993 | } |
---|
1994 | else |
---|
1995 | { |
---|
1996 | ideal @j=std(fetch(@P,i)); |
---|
1997 | } |
---|
1998 | option(noredSB); |
---|
1999 | if(seri==1) |
---|
2000 | { |
---|
2001 | ideal peek=fetch(@P,peek); |
---|
2002 | attrib(peek,"isSB",1); |
---|
2003 | } |
---|
2004 | else |
---|
2005 | { |
---|
2006 | ideal peek=@j; |
---|
2007 | } |
---|
2008 | if(size(ser)==0) |
---|
2009 | { |
---|
2010 | ideal fried; |
---|
2011 | @n=size(@j); |
---|
2012 | for(@k=1;@k<=@n;@k++) |
---|
2013 | { |
---|
2014 | if(deg(lead(@j[@k]))==1) |
---|
2015 | { |
---|
2016 | fried[size(fried)+1]=@j[@k]; |
---|
2017 | @j[@k]=0; |
---|
2018 | } |
---|
2019 | } |
---|
2020 | if(size(fried)>0) |
---|
2021 | { |
---|
2022 | @j=simplify(@j,2); |
---|
2023 | attrib(@j,"isSB",1); |
---|
2024 | list pr=decomp(@j); |
---|
2025 | for(@k=1;@k<=size(pr);@k++) |
---|
2026 | { |
---|
2027 | @j=pr[@k]+fried; |
---|
2028 | pr[@k]=@j; |
---|
2029 | } |
---|
2030 | setring @P; |
---|
2031 | return(fetch(gnir,pr)); |
---|
2032 | } |
---|
2033 | } |
---|
2034 | |
---|
2035 | //---------------------------------------------------------------- |
---|
2036 | //j is the ring |
---|
2037 | //---------------------------------------------------------------- |
---|
2038 | |
---|
2039 | if (dim(@j)==-1) |
---|
2040 | { |
---|
2041 | setring @P; |
---|
2042 | return(ideal(0)); |
---|
2043 | } |
---|
2044 | |
---|
2045 | //---------------------------------------------------------------- |
---|
2046 | // the case of one variable |
---|
2047 | //---------------------------------------------------------------- |
---|
2048 | |
---|
2049 | if(nvars(basering)==1) |
---|
2050 | { |
---|
2051 | |
---|
2052 | list fac=factor(@j[1]); |
---|
2053 | list gprimary; |
---|
2054 | for(@k=1;@k<=size(fac[1]);@k++) |
---|
2055 | { |
---|
2056 | if(@wr==0) |
---|
2057 | { |
---|
2058 | gprimary[2*@k-1]=ideal(fac[1][@k]^fac[2][@k]); |
---|
2059 | gprimary[2*@k]=ideal(fac[1][@k]); |
---|
2060 | } |
---|
2061 | else |
---|
2062 | { |
---|
2063 | gprimary[2*@k-1]=ideal(fac[1][@k]); |
---|
2064 | gprimary[2*@k]=ideal(fac[1][@k]); |
---|
2065 | } |
---|
2066 | } |
---|
2067 | setring @P; |
---|
2068 | primary=fetch(gnir,gprimary); |
---|
2069 | |
---|
2070 | return(primary); |
---|
2071 | } |
---|
2072 | |
---|
2073 | //------------------------------------------------------------------ |
---|
2074 | //the zero-dimensional case |
---|
2075 | //------------------------------------------------------------------ |
---|
2076 | |
---|
2077 | if (dim(@j)==0) |
---|
2078 | { |
---|
2079 | option(redSB); |
---|
2080 | list gprimary= zero_decomp(@j,ser,@wr); |
---|
2081 | option(noredSB); |
---|
2082 | setring @P; |
---|
2083 | primary=fetch(gnir,gprimary); |
---|
2084 | if(size(ser)>0) |
---|
2085 | { |
---|
2086 | primary=cleanPrimary(primary); |
---|
2087 | } |
---|
2088 | return(primary); |
---|
2089 | } |
---|
2090 | |
---|
2091 | poly @gs,@gh,@p; |
---|
2092 | string @va,quotring; |
---|
2093 | list quprimary,htprimary,collectprimary,lsau,lnew,allindep,restindep; |
---|
2094 | ideal @h; |
---|
2095 | int jdim=dim(@j); |
---|
2096 | list fett; |
---|
2097 | int lauf,di,newtest; |
---|
2098 | //------------------------------------------------------------------ |
---|
2099 | //search for a maximal independent set indep,i.e. |
---|
2100 | //look for subring such that the intersection with the ideal is zero |
---|
2101 | //j intersected with K[var(indep[3]+1),...,var(nvar] is zero, |
---|
2102 | //indep[1] is the new varstring and indep[2] the string for the block-ordering |
---|
2103 | //------------------------------------------------------------------ |
---|
2104 | |
---|
2105 | if(@wr!=1) |
---|
2106 | { |
---|
2107 | allindep=independSet(@j); |
---|
2108 | for(@m=1;@m<=size(allindep);@m++) |
---|
2109 | { |
---|
2110 | if(allindep[@m][3]==jdim) |
---|
2111 | { |
---|
2112 | di++; |
---|
2113 | indep[di]=allindep[@m]; |
---|
2114 | } |
---|
2115 | else |
---|
2116 | { |
---|
2117 | lauf++; |
---|
2118 | restindep[lauf]=allindep[@m]; |
---|
2119 | } |
---|
2120 | } |
---|
2121 | } |
---|
2122 | else |
---|
2123 | { |
---|
2124 | indep=maxIndependSet(@j); |
---|
2125 | } |
---|
2126 | |
---|
2127 | ideal jkeep=@j; |
---|
2128 | |
---|
2129 | if(ordstr(@P)[1]=="w") |
---|
2130 | { |
---|
2131 | execute "ring @Phelp=("+charstr(gnir)+"),("+varstr(gnir)+"),("+ordstr(@P)+");"; |
---|
2132 | } |
---|
2133 | else |
---|
2134 | { |
---|
2135 | execute "ring @Phelp=("+charstr(gnir)+"),("+varstr(gnir)+"),(C,dp);"; |
---|
2136 | } |
---|
2137 | |
---|
2138 | if(homo==1) |
---|
2139 | { |
---|
2140 | if((ordstr(@P)[3]=="d")||(ordstr(@P)[1]=="d")||(ordstr(@P)[1]=="w") |
---|
2141 | ||(ordstr(@P)[3]=="w")) |
---|
2142 | { |
---|
2143 | ideal jwork=imap(@P,tras); |
---|
2144 | attrib(jwork,"isSB",1); |
---|
2145 | } |
---|
2146 | else |
---|
2147 | { |
---|
2148 | ideal jwork=std(imap(gnir,@j),@hilb); |
---|
2149 | } |
---|
2150 | |
---|
2151 | } |
---|
2152 | else |
---|
2153 | { |
---|
2154 | ideal jwork=std(imap(gnir,@j)); |
---|
2155 | } |
---|
2156 | list hquprimary; |
---|
2157 | poly @p,@q; |
---|
2158 | ideal @h,fac,ser; |
---|
2159 | di=dim(jwork); |
---|
2160 | keepdi=di; |
---|
2161 | |
---|
2162 | setring gnir; |
---|
2163 | for(@m=1;@m<=size(indep);@m++) |
---|
2164 | { |
---|
2165 | isat=0; |
---|
2166 | @n2=0; |
---|
2167 | option(redSB); |
---|
2168 | if((indep[@m][1]==varstr(basering))&&(@m==1)) |
---|
2169 | //this is the good case, nothing to do, just to have the same notations |
---|
2170 | //change the ring |
---|
2171 | { |
---|
2172 | execute "ring gnir1 = ("+charstr(basering)+"),("+varstr(basering)+"),(" |
---|
2173 | +ordstr(basering)+");"; |
---|
2174 | ideal @j=fetch(gnir,@j); |
---|
2175 | attrib(@j,"isSB",1); |
---|
2176 | ideal ser=fetch(gnir,ser); |
---|
2177 | |
---|
2178 | } |
---|
2179 | else |
---|
2180 | { |
---|
2181 | @va=string(maxideal(1)); |
---|
2182 | execute "ring gnir1 = ("+charstr(basering)+"),("+indep[@m][1]+"),(" |
---|
2183 | +indep[@m][2]+");"; |
---|
2184 | execute "map phi=gnir,"+@va+";"; |
---|
2185 | if(homo==1) |
---|
2186 | { |
---|
2187 | ideal @j=std(phi(@j),@hilb); |
---|
2188 | } |
---|
2189 | else |
---|
2190 | { |
---|
2191 | ideal @j=std(phi(@j)); |
---|
2192 | } |
---|
2193 | ideal ser=phi(ser); |
---|
2194 | |
---|
2195 | } |
---|
2196 | option(noredSB); |
---|
2197 | if((deg(@j[1])==0)||(dim(@j)<jdim)) |
---|
2198 | { |
---|
2199 | setring gnir; |
---|
2200 | break; |
---|
2201 | } |
---|
2202 | for (lauf=1;lauf<=size(@j);lauf++) |
---|
2203 | { |
---|
2204 | fett[lauf]=size(@j[lauf]); |
---|
2205 | } |
---|
2206 | //------------------------------------------------------------------------------------ |
---|
2207 | //we have now the following situation: |
---|
2208 | //j intersected with K[var(nnp+1),..,var(nva)] is zero so we may pass |
---|
2209 | //to this quotientring, j is their still a standardbasis, the |
---|
2210 | //leading coefficients of the polynomials there (polynomials in |
---|
2211 | //K[var(nnp+1),..,var(nva)]) are collected in the list h, |
---|
2212 | //we need their ggt, gh, because of the following: |
---|
2213 | //let (j:gh^n)=(j:gh^infinity) then j*K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2214 | //intersected with K[var(1),...,var(nva)] is (j:gh^n) |
---|
2215 | //on the other hand j=(j,gh^n) intersected with (j:gh^n) |
---|
2216 | |
---|
2217 | //------------------------------------------------------------------------------------ |
---|
2218 | |
---|
2219 | //the arrangement for the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2220 | //and the map phi:K[var(1),...,var(nva)] ----->K(var(nnpr+1),..,var(nva))[..the rest..] |
---|
2221 | //------------------------------------------------------------------------------------- |
---|
2222 | |
---|
2223 | quotring=prepareQuotientring(nvars(basering)-indep[@m][3]); |
---|
2224 | |
---|
2225 | //--------------------------------------------------------------------- |
---|
2226 | //we pass to the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2227 | //--------------------------------------------------------------------- |
---|
2228 | |
---|
2229 | execute quotring; |
---|
2230 | |
---|
2231 | // @j considered in the quotientring |
---|
2232 | ideal @j=imap(gnir1,@j); |
---|
2233 | ideal ser=imap(gnir1,ser); |
---|
2234 | |
---|
2235 | kill gnir1; |
---|
2236 | |
---|
2237 | //j is a standardbasis in the quotientring but usually not minimal |
---|
2238 | //here it becomes minimal |
---|
2239 | |
---|
2240 | @j=clearSB(@j,fett); |
---|
2241 | attrib(@j,"isSB",1); |
---|
2242 | |
---|
2243 | //we need later ggt(h[1],...)=gh for saturation |
---|
2244 | ideal @h; |
---|
2245 | if(deg(@j[1])>0) |
---|
2246 | { |
---|
2247 | for(@n=1;@n<=size(@j);@n++) |
---|
2248 | { |
---|
2249 | @h[@n]=leadcoef(@j[@n]); |
---|
2250 | } |
---|
2251 | //the primary decomposition of j*K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2252 | option(redSB); |
---|
2253 | list uprimary= zero_decomp(@j,ser,@wr); |
---|
2254 | option(noredSB); |
---|
2255 | } |
---|
2256 | else |
---|
2257 | { |
---|
2258 | list uprimary; |
---|
2259 | uprimary[1]=ideal(1); |
---|
2260 | uprimary[2]=ideal(1); |
---|
2261 | } |
---|
2262 | |
---|
2263 | //we need the intersection of the ideals in the list quprimary with the |
---|
2264 | //polynomialring, i.e. let q=(f1,...,fr) in the quotientring such an ideal |
---|
2265 | //but fi polynomials, then the intersection of q with the polynomialring |
---|
2266 | //is the saturation of the ideal generated by f1,...,fr with respect to |
---|
2267 | //h which is the lcm of the leading coefficients of the fi considered in the |
---|
2268 | //quotientring: this is coded in saturn |
---|
2269 | |
---|
2270 | list saturn; |
---|
2271 | ideal hpl; |
---|
2272 | |
---|
2273 | for(@n=1;@n<=size(uprimary);@n++) |
---|
2274 | { |
---|
2275 | hpl=0; |
---|
2276 | for(@n1=1;@n1<=size(uprimary[@n]);@n1++) |
---|
2277 | { |
---|
2278 | hpl=hpl,leadcoef(uprimary[@n][@n1]); |
---|
2279 | } |
---|
2280 | saturn[@n]=hpl; |
---|
2281 | } |
---|
2282 | //-------------------------------------------------------------------- |
---|
2283 | //we leave the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2284 | //back to the polynomialring |
---|
2285 | //--------------------------------------------------------------------- |
---|
2286 | setring gnir; |
---|
2287 | |
---|
2288 | collectprimary=imap(quring,uprimary); |
---|
2289 | lsau=imap(quring,saturn); |
---|
2290 | @h=imap(quring,@h); |
---|
2291 | |
---|
2292 | kill quring; |
---|
2293 | |
---|
2294 | |
---|
2295 | @n2=size(quprimary); |
---|
2296 | @n3=@n2; |
---|
2297 | |
---|
2298 | for(@n1=1;@n1<=size(collectprimary)/2;@n1++) |
---|
2299 | { |
---|
2300 | if(deg(collectprimary[2*@n1][1])>0) |
---|
2301 | { |
---|
2302 | @n2++; |
---|
2303 | quprimary[@n2]=collectprimary[2*@n1-1]; |
---|
2304 | lnew[@n2]=lsau[2*@n1-1]; |
---|
2305 | @n2++; |
---|
2306 | lnew[@n2]=lsau[2*@n1]; |
---|
2307 | quprimary[@n2]=collectprimary[2*@n1]; |
---|
2308 | } |
---|
2309 | } |
---|
2310 | |
---|
2311 | //here the intersection with the polynomialring |
---|
2312 | //mentioned above is really computed |
---|
2313 | for(@n=@n3/2+1;@n<=@n2/2;@n++) |
---|
2314 | { |
---|
2315 | if(specialIdealsEqual(quprimary[2*@n-1],quprimary[2*@n])) |
---|
2316 | { |
---|
2317 | quprimary[2*@n-1]=sat2(quprimary[2*@n-1],lnew[2*@n-1])[1]; |
---|
2318 | quprimary[2*@n]=quprimary[2*@n-1]; |
---|
2319 | } |
---|
2320 | else |
---|
2321 | { |
---|
2322 | if(@wr==0) |
---|
2323 | { |
---|
2324 | quprimary[2*@n-1]=sat2(quprimary[2*@n-1],lnew[2*@n-1])[1]; |
---|
2325 | } |
---|
2326 | quprimary[2*@n]=sat2(quprimary[2*@n],lnew[2*@n])[1]; |
---|
2327 | } |
---|
2328 | } |
---|
2329 | |
---|
2330 | if(size(@h)>0) |
---|
2331 | { |
---|
2332 | //--------------------------------------------------------------- |
---|
2333 | //we change to @Phelp to have the ordering dp for saturation |
---|
2334 | //--------------------------------------------------------------- |
---|
2335 | setring @Phelp; |
---|
2336 | @h=imap(gnir,@h); |
---|
2337 | if(@wr!=1) |
---|
2338 | { |
---|
2339 | @q=minSat(jwork,@h)[2]; |
---|
2340 | } |
---|
2341 | else |
---|
2342 | { |
---|
2343 | fac=ideal(0); |
---|
2344 | for(lauf=1;lauf<=ncols(@h);lauf++) |
---|
2345 | { |
---|
2346 | if(deg(@h[lauf])>0) |
---|
2347 | { |
---|
2348 | fac=fac+factorize(@h[lauf],1); |
---|
2349 | } |
---|
2350 | } |
---|
2351 | fac=simplify(fac,4); |
---|
2352 | @q=1; |
---|
2353 | for(lauf=1;lauf<=size(fac);lauf++) |
---|
2354 | { |
---|
2355 | @q=@q*fac[lauf]; |
---|
2356 | } |
---|
2357 | } |
---|
2358 | jwork=std(jwork,@q); |
---|
2359 | keepdi=dim(jwork); |
---|
2360 | if(keepdi<di) |
---|
2361 | { |
---|
2362 | setring gnir; |
---|
2363 | @j=imap(@Phelp,jwork); |
---|
2364 | break; |
---|
2365 | } |
---|
2366 | if(homo==1) |
---|
2367 | { |
---|
2368 | @hilb=hilb(jwork,1); |
---|
2369 | } |
---|
2370 | |
---|
2371 | setring gnir; |
---|
2372 | @j=imap(@Phelp,jwork); |
---|
2373 | } |
---|
2374 | } |
---|
2375 | if((size(quprimary)==0)&&(@wr>0)) |
---|
2376 | { |
---|
2377 | @j=ideal(1); |
---|
2378 | quprimary[1]=ideal(1); |
---|
2379 | quprimary[2]=ideal(1); |
---|
2380 | } |
---|
2381 | if((size(quprimary)==0)) |
---|
2382 | { |
---|
2383 | keepdi=di-1; |
---|
2384 | } |
---|
2385 | //--------------------------------------------------------------- |
---|
2386 | //notice that j=sat(j,gh) intersected with (j,gh^n) |
---|
2387 | //we finished with sat(j,gh) and have to start with (j,gh^n) |
---|
2388 | //--------------------------------------------------------------- |
---|
2389 | if((deg(@j[1])!=0)&&(@wr!=1)) |
---|
2390 | { |
---|
2391 | if(size(quprimary)>0) |
---|
2392 | { |
---|
2393 | setring @Phelp; |
---|
2394 | ser=imap(gnir,ser); |
---|
2395 | hquprimary=imap(gnir,quprimary); |
---|
2396 | if(@wr==0) |
---|
2397 | { |
---|
2398 | ideal htest=hquprimary[1]; |
---|
2399 | for (@n1=2;@n1<=size(hquprimary)/2;@n1++) |
---|
2400 | { |
---|
2401 | htest=intersect(htest,hquprimary[2*@n1-1]); |
---|
2402 | } |
---|
2403 | } |
---|
2404 | else |
---|
2405 | { |
---|
2406 | ideal htest=hquprimary[2]; |
---|
2407 | |
---|
2408 | for (@n1=2;@n1<=size(hquprimary)/2;@n1++) |
---|
2409 | { |
---|
2410 | htest=intersect(htest,hquprimary[2*@n1]); |
---|
2411 | } |
---|
2412 | } |
---|
2413 | |
---|
2414 | if(size(ser)>0) |
---|
2415 | { |
---|
2416 | ser=intersect(htest,ser); |
---|
2417 | } |
---|
2418 | else |
---|
2419 | { |
---|
2420 | ser=htest; |
---|
2421 | } |
---|
2422 | setring gnir; |
---|
2423 | ser=imap(@Phelp,ser); |
---|
2424 | } |
---|
2425 | if(size(reduce(ser,peek,1))!=0) |
---|
2426 | { |
---|
2427 | for(@m=1;@m<=size(restindep);@m++) |
---|
2428 | { |
---|
2429 | // if(restindep[@m][3]>=keepdi) |
---|
2430 | // { |
---|
2431 | isat=0; |
---|
2432 | @n2=0; |
---|
2433 | option(redSB); |
---|
2434 | |
---|
2435 | if(restindep[@m][1]==varstr(basering)) |
---|
2436 | //this is the good case, nothing to do, just to have the same notations |
---|
2437 | //change the ring |
---|
2438 | { |
---|
2439 | execute "ring gnir1 = ("+charstr(basering)+"),("+varstr(basering)+"),(" |
---|
2440 | +ordstr(basering)+");"; |
---|
2441 | ideal @j=fetch(gnir,jkeep); |
---|
2442 | attrib(@j,"isSB",1); |
---|
2443 | } |
---|
2444 | else |
---|
2445 | { |
---|
2446 | @va=string(maxideal(1)); |
---|
2447 | execute "ring gnir1 = ("+charstr(basering)+"),("+restindep[@m][1]+"),(" |
---|
2448 | +restindep[@m][2]+");"; |
---|
2449 | execute "map phi=gnir,"+@va+";"; |
---|
2450 | if(homo==1) |
---|
2451 | { |
---|
2452 | ideal @j=std(phi(jkeep),keephilb); |
---|
2453 | } |
---|
2454 | else |
---|
2455 | { |
---|
2456 | ideal @j=std(phi(jkeep)); |
---|
2457 | } |
---|
2458 | ideal ser=phi(ser); |
---|
2459 | } |
---|
2460 | option(noredSB); |
---|
2461 | |
---|
2462 | for (lauf=1;lauf<=size(@j);lauf++) |
---|
2463 | { |
---|
2464 | fett[lauf]=size(@j[lauf]); |
---|
2465 | } |
---|
2466 | //------------------------------------------------------------------------------------ |
---|
2467 | //we have now the following situation: |
---|
2468 | //j intersected with K[var(nnp+1),..,var(nva)] is zero so we may pass |
---|
2469 | //to this quotientring, j is their still a standardbasis, the |
---|
2470 | //leading coefficients of the polynomials there (polynomials in |
---|
2471 | //K[var(nnp+1),..,var(nva)]) are collected in the list h, |
---|
2472 | //we need their ggt, gh, because of the following: |
---|
2473 | //let (j:gh^n)=(j:gh^infinity) then j*K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2474 | //intersected with K[var(1),...,var(nva)] is (j:gh^n) |
---|
2475 | //on the other hand j=(j,gh^n) intersected with (j:gh^n) |
---|
2476 | |
---|
2477 | //------------------------------------------------------------------------------------ |
---|
2478 | |
---|
2479 | //the arrangement for the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2480 | //and the map phi:K[var(1),...,var(nva)] ----->K(var(nnpr+1),..,var(nva))[..the rest..] |
---|
2481 | //------------------------------------------------------------------------------------- |
---|
2482 | |
---|
2483 | quotring=prepareQuotientring(nvars(basering)-restindep[@m][3]); |
---|
2484 | |
---|
2485 | //--------------------------------------------------------------------- |
---|
2486 | //we pass to the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2487 | //--------------------------------------------------------------------- |
---|
2488 | |
---|
2489 | execute quotring; |
---|
2490 | |
---|
2491 | // @j considered in the quotientring |
---|
2492 | ideal @j=imap(gnir1,@j); |
---|
2493 | ideal ser=imap(gnir1,ser); |
---|
2494 | |
---|
2495 | kill gnir1; |
---|
2496 | |
---|
2497 | //j is a standardbasis in the quotientring but usually not minimal |
---|
2498 | //here it becomes minimal |
---|
2499 | @j=clearSB(@j,fett); |
---|
2500 | attrib(@j,"isSB",1); |
---|
2501 | |
---|
2502 | //we need later ggt(h[1],...)=gh for saturation |
---|
2503 | ideal @h; |
---|
2504 | |
---|
2505 | for(@n=1;@n<=size(@j);@n++) |
---|
2506 | { |
---|
2507 | @h[@n]=leadcoef(@j[@n]); |
---|
2508 | } |
---|
2509 | //the primary decomposition of j*K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2510 | |
---|
2511 | option(redSB); |
---|
2512 | list uprimary= zero_decomp(@j,ser,@wr); |
---|
2513 | option(noredSB); |
---|
2514 | |
---|
2515 | |
---|
2516 | //we need the intersection of the ideals in the list quprimary with the |
---|
2517 | //polynomialring, i.e. let q=(f1,...,fr) in the quotientring such an ideal |
---|
2518 | //but fi polynomials, then the intersection of q with the polynomialring |
---|
2519 | //is the saturation of the ideal generated by f1,...,fr with respect to |
---|
2520 | //h which is the lcm of the leading coefficients of the fi considered in the |
---|
2521 | //quotientring: this is coded in saturn |
---|
2522 | |
---|
2523 | list saturn; |
---|
2524 | ideal hpl; |
---|
2525 | |
---|
2526 | for(@n=1;@n<=size(uprimary);@n++) |
---|
2527 | { |
---|
2528 | hpl=0; |
---|
2529 | for(@n1=1;@n1<=size(uprimary[@n]);@n1++) |
---|
2530 | { |
---|
2531 | hpl=hpl,leadcoef(uprimary[@n][@n1]); |
---|
2532 | } |
---|
2533 | saturn[@n]=hpl; |
---|
2534 | } |
---|
2535 | //-------------------------------------------------------------------- |
---|
2536 | //we leave the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2537 | //back to the polynomialring |
---|
2538 | //--------------------------------------------------------------------- |
---|
2539 | setring gnir; |
---|
2540 | |
---|
2541 | collectprimary=imap(quring,uprimary); |
---|
2542 | lsau=imap(quring,saturn); |
---|
2543 | @h=imap(quring,@h); |
---|
2544 | |
---|
2545 | kill quring; |
---|
2546 | |
---|
2547 | |
---|
2548 | @n2=size(quprimary); |
---|
2549 | @n3=@n2; |
---|
2550 | |
---|
2551 | for(@n1=1;@n1<=size(collectprimary)/2;@n1++) |
---|
2552 | { |
---|
2553 | if(deg(collectprimary[2*@n1][1])>0) |
---|
2554 | { |
---|
2555 | @n2++; |
---|
2556 | quprimary[@n2]=collectprimary[2*@n1-1]; |
---|
2557 | lnew[@n2]=lsau[2*@n1-1]; |
---|
2558 | @n2++; |
---|
2559 | lnew[@n2]=lsau[2*@n1]; |
---|
2560 | quprimary[@n2]=collectprimary[2*@n1]; |
---|
2561 | } |
---|
2562 | } |
---|
2563 | |
---|
2564 | |
---|
2565 | //here the intersection with the polynomialring |
---|
2566 | //mentioned above is really computed |
---|
2567 | |
---|
2568 | for(@n=@n3/2+1;@n<=@n2/2;@n++) |
---|
2569 | { |
---|
2570 | if(specialIdealsEqual(quprimary[2*@n-1],quprimary[2*@n])) |
---|
2571 | { |
---|
2572 | quprimary[2*@n-1]=sat2(quprimary[2*@n-1],lnew[2*@n-1])[1]; |
---|
2573 | quprimary[2*@n]=quprimary[2*@n-1]; |
---|
2574 | } |
---|
2575 | else |
---|
2576 | { |
---|
2577 | if(@wr==0) |
---|
2578 | { |
---|
2579 | quprimary[2*@n-1]=sat2(quprimary[2*@n-1],lnew[2*@n-1])[1]; |
---|
2580 | } |
---|
2581 | quprimary[2*@n]=sat2(quprimary[2*@n],lnew[2*@n])[1]; |
---|
2582 | } |
---|
2583 | } |
---|
2584 | if(@n2>=@n3+2) |
---|
2585 | { |
---|
2586 | setring @Phelp; |
---|
2587 | ser=imap(gnir,ser); |
---|
2588 | hquprimary=imap(gnir,quprimary); |
---|
2589 | for(@n=@n3/2+1;@n<=@n2/2;@n++) |
---|
2590 | { |
---|
2591 | if(@wr==0) |
---|
2592 | { |
---|
2593 | ser=intersect(ser,hquprimary[2*@n-1]); |
---|
2594 | } |
---|
2595 | else |
---|
2596 | { |
---|
2597 | ser=intersect(ser,hquprimary[2*@n]); |
---|
2598 | } |
---|
2599 | } |
---|
2600 | setring gnir; |
---|
2601 | ser=imap(@Phelp,ser); |
---|
2602 | } |
---|
2603 | |
---|
2604 | // } |
---|
2605 | } |
---|
2606 | if(size(reduce(ser,peek,1))!=0) |
---|
2607 | { |
---|
2608 | if(@wr>0) |
---|
2609 | { |
---|
2610 | htprimary=decomp(@j,@wr,peek,ser); |
---|
2611 | } |
---|
2612 | else |
---|
2613 | { |
---|
2614 | htprimary=decomp(@j,peek,ser); |
---|
2615 | } |
---|
2616 | // here we collect now both results primary(sat(j,gh)) |
---|
2617 | // and primary(j,gh^n) |
---|
2618 | @n=size(quprimary); |
---|
2619 | for (@k=1;@k<=size(htprimary);@k++) |
---|
2620 | { |
---|
2621 | quprimary[@n+@k]=htprimary[@k]; |
---|
2622 | } |
---|
2623 | } |
---|
2624 | } |
---|
2625 | |
---|
2626 | } |
---|
2627 | //------------------------------------------------------------ |
---|
2628 | //back to the ring we started with |
---|
2629 | //the final result: primary |
---|
2630 | //------------------------------------------------------------ |
---|
2631 | |
---|
2632 | setring @P; |
---|
2633 | primary=imap(gnir,quprimary); |
---|
2634 | return(primary); |
---|
2635 | } |
---|
2636 | |
---|
2637 | |
---|
2638 | example |
---|
2639 | { "EXAMPLE:"; echo = 2; |
---|
2640 | ring r = 32003,(x,y,z),lp; |
---|
2641 | poly p = z2+1; |
---|
2642 | poly q = z4+2; |
---|
2643 | ideal i = p^2*q^3,(y-z3)^3,(x-yz+z4)^4; |
---|
2644 | LIB "primdec.lib"; |
---|
2645 | list pr= decomp(i); |
---|
2646 | pr; |
---|
2647 | testPrimary( pr, i); |
---|
2648 | } |
---|
2649 | |
---|
2650 | /////////////////////////////////////////////////////////////////////////////// |
---|
2651 | proc primdecGTZ(ideal i) |
---|
2652 | { |
---|
2653 | return(decomp(i)); |
---|
2654 | } |
---|
2655 | /////////////////////////////////////////////////////////////////////////////// |
---|
2656 | proc primdecSY(ideal i,int j) |
---|
2657 | { |
---|
2658 | return(prim_dec(i,j)); |
---|
2659 | } |
---|
2660 | /////////////////////////////////////////////////////////////////////////////// |
---|
2661 | |
---|
2662 | proc radical(ideal i,list #) |
---|
2663 | { |
---|
2664 | def @P=basering; |
---|
2665 | int j,il; |
---|
2666 | if(size(#)>0) |
---|
2667 | { |
---|
2668 | il=#[1]; |
---|
2669 | } |
---|
2670 | ideal re=1; |
---|
2671 | option(redSB); |
---|
2672 | list qr=simplifyIdeal(i); |
---|
2673 | map phi=@P,qr[2]; |
---|
2674 | i=qr[1]; |
---|
2675 | |
---|
2676 | list pr=facstd(i); |
---|
2677 | |
---|
2678 | if(size(pr)==1) |
---|
2679 | { |
---|
2680 | attrib(pr[1],"isSB",1); |
---|
2681 | if((dim(pr[1])==0)&&(homog(pr[1])==1)) |
---|
2682 | { |
---|
2683 | ideal @res=maxideal(1); |
---|
2684 | return(phi(@res)); |
---|
2685 | } |
---|
2686 | if(dim(pr[1])>1) |
---|
2687 | { |
---|
2688 | execute "ring gnir = ("+charstr(basering)+"), |
---|
2689 | ("+varstr(basering)+"),(C,lp);"; |
---|
2690 | ideal i=fetch(@P,i); |
---|
2691 | list @pr=facstd(i); |
---|
2692 | setring @P; |
---|
2693 | pr=fetch(gnir,@pr); |
---|
2694 | } |
---|
2695 | } |
---|
2696 | option(noredSB); |
---|
2697 | int s=size(pr); |
---|
2698 | |
---|
2699 | if(s==1) |
---|
2700 | { |
---|
2701 | i=radicalEHV(i,ideal(1),il); |
---|
2702 | return(phi(i)); |
---|
2703 | } |
---|
2704 | intvec pos; |
---|
2705 | pos[s]=0; |
---|
2706 | if(il==1) |
---|
2707 | { |
---|
2708 | int ndim,k; |
---|
2709 | attrib(pr[1],"isSB",1); |
---|
2710 | int odim=dim(pr[1]); |
---|
2711 | int count=1; |
---|
2712 | |
---|
2713 | for(j=2;j<=s;j++) |
---|
2714 | { |
---|
2715 | attrib(pr[j],"isSB",1); |
---|
2716 | ndim=dim(pr[j]); |
---|
2717 | if(ndim>odim) |
---|
2718 | { |
---|
2719 | for(k=count;k<=j-1;k++) |
---|
2720 | { |
---|
2721 | pos[k]=1; |
---|
2722 | } |
---|
2723 | count=j; |
---|
2724 | odim=ndim; |
---|
2725 | } |
---|
2726 | if(ndim<odim) |
---|
2727 | { |
---|
2728 | pos[j]=1; |
---|
2729 | } |
---|
2730 | } |
---|
2731 | } |
---|
2732 | for(j=1;j<=s;j++) |
---|
2733 | { |
---|
2734 | if(pos[j]==0) |
---|
2735 | { |
---|
2736 | re=intersect(re,radicalEHV(pr[s+1-j],re,il)); |
---|
2737 | } |
---|
2738 | } |
---|
2739 | return(phi(re)); |
---|
2740 | } |
---|
2741 | |
---|
2742 | proc intersect1(ideal i,ideal j) |
---|
2743 | { |
---|
2744 | def R=basering; |
---|
2745 | execute "ring gnir = ("+charstr(basering)+"), |
---|
2746 | ("+varstr(basering)+",@t),(C,dp);"; |
---|
2747 | ideal i=var(nvars(basering))*imap(R,i)+(var(nvars(basering))-1)*imap(R,j); |
---|
2748 | ideal j=eliminate(i,var(nvars(basering))); |
---|
2749 | setring R; |
---|
2750 | map phi=gnir,maxideal(1); |
---|
2751 | return(phi(j)); |
---|
2752 | } |
---|
2753 | |
---|
2754 | |
---|
2755 | /////////////////////////////////////////////////////////////////////////////// |
---|
2756 | proc radicalKL (list m,ideal ser,list #) |
---|
2757 | "USAGE: decomp(i); i ideal (for primary decomposition) (resp. |
---|
2758 | decomp(i,1); (for the minimal associated primes) ) |
---|
2759 | RETURN: list = list of primary ideals and their associated primes |
---|
2760 | (at even positions in the list) |
---|
2761 | (resp. a list of the minimal associated primes) |
---|
2762 | NOTE: Algorithm of Gianni, Traeger, Zacharias |
---|
2763 | EXAMPLE: example decomp; shows an example |
---|
2764 | " |
---|
2765 | { |
---|
2766 | ideal i=m[2]; |
---|
2767 | //---------------------------------------------------------------- |
---|
2768 | //i is the zero-ideal |
---|
2769 | //---------------------------------------------------------------- |
---|
2770 | |
---|
2771 | if(size(i)==0) |
---|
2772 | { |
---|
2773 | return(ideal(0)); |
---|
2774 | } |
---|
2775 | |
---|
2776 | def @P = basering; |
---|
2777 | list indep,allindep,restindep,fett,@mu; |
---|
2778 | intvec @vh,isat; |
---|
2779 | int @wr,@k,@n,@m,@n1,@n2,@n3,lauf,di; |
---|
2780 | ideal @j,@j1,fac,@h,collectrad,htrad,lsau; |
---|
2781 | ideal rad=ideal(1); |
---|
2782 | ideal te=ser; |
---|
2783 | |
---|
2784 | poly @p,@q; |
---|
2785 | string @va,quotring; |
---|
2786 | int homo=homog(i); |
---|
2787 | |
---|
2788 | if(size(#)>0) |
---|
2789 | { |
---|
2790 | @wr=#[1]; |
---|
2791 | } |
---|
2792 | @j=m[1]; |
---|
2793 | @j1=m[2]; |
---|
2794 | int jdim=dim(@j); |
---|
2795 | if(size(reduce(ser,@j,1))==0) |
---|
2796 | { |
---|
2797 | return(ser); |
---|
2798 | } |
---|
2799 | if(homo==1) |
---|
2800 | { |
---|
2801 | if(jdim==0) |
---|
2802 | { |
---|
2803 | option(noredSB); |
---|
2804 | return(maxideal(1)); |
---|
2805 | } |
---|
2806 | intvec @hilb=hilb(@j,1); |
---|
2807 | } |
---|
2808 | |
---|
2809 | |
---|
2810 | //---------------------------------------------------------------- |
---|
2811 | //j is the ring |
---|
2812 | //---------------------------------------------------------------- |
---|
2813 | |
---|
2814 | if (jdim==-1) |
---|
2815 | { |
---|
2816 | option(noredSB); |
---|
2817 | return(ideal(0)); |
---|
2818 | } |
---|
2819 | |
---|
2820 | //---------------------------------------------------------------- |
---|
2821 | // the case of one variable |
---|
2822 | //---------------------------------------------------------------- |
---|
2823 | |
---|
2824 | if(nvars(basering)==1) |
---|
2825 | { |
---|
2826 | fac=factorize(@j[1],1); |
---|
2827 | @p=1; |
---|
2828 | for(@k=1;@k<=size(fac);@k++) |
---|
2829 | { |
---|
2830 | @p=@p*fac[@k]; |
---|
2831 | } |
---|
2832 | option(noredSB); |
---|
2833 | |
---|
2834 | return(ideal(@p)); |
---|
2835 | } |
---|
2836 | //------------------------------------------------------------------ |
---|
2837 | //the case of a complete intersection |
---|
2838 | //------------------------------------------------------------------ |
---|
2839 | if(jdim+size(@j1)==nvars(basering)) |
---|
2840 | { |
---|
2841 | // ideal jac=minor(jacob(@j1),size(@j1)); |
---|
2842 | // return(quotient(@j1,jac)); |
---|
2843 | } |
---|
2844 | |
---|
2845 | //------------------------------------------------------------------ |
---|
2846 | //the zero-dimensional case |
---|
2847 | //------------------------------------------------------------------ |
---|
2848 | |
---|
2849 | if (jdim==0) |
---|
2850 | { |
---|
2851 | @j1=finduni(@j); |
---|
2852 | for(@k=1;@k<=size(@j1);@k++) |
---|
2853 | { |
---|
2854 | fac=factorize(cleardenom(@j1[@k]),1); |
---|
2855 | @p=fac[1]; |
---|
2856 | for(@n=2;@n<=size(fac);@n++) |
---|
2857 | { |
---|
2858 | @p=@p*fac[@n]; |
---|
2859 | } |
---|
2860 | @j=@j,@p; |
---|
2861 | } |
---|
2862 | @j=std(@j); |
---|
2863 | option(noredSB); |
---|
2864 | return(@j); |
---|
2865 | } |
---|
2866 | |
---|
2867 | //------------------------------------------------------------------ |
---|
2868 | //search for a maximal independent set indep,i.e. |
---|
2869 | //look for subring such that the intersection with the ideal is zero |
---|
2870 | //j intersected with K[var(indep[3]+1),...,var(nvar] is zero, |
---|
2871 | //indep[1] is the new varstring and indep[2] the string for the block-ordering |
---|
2872 | //------------------------------------------------------------------ |
---|
2873 | |
---|
2874 | indep=maxIndependSet(@j); |
---|
2875 | |
---|
2876 | di=dim(@j); |
---|
2877 | |
---|
2878 | for(@m=1;@m<=size(indep);@m++) |
---|
2879 | { |
---|
2880 | if((indep[@m][1]==varstr(basering))&&(@m==1)) |
---|
2881 | //this is the good case, nothing to do, just to have the same notations |
---|
2882 | //change the ring |
---|
2883 | { |
---|
2884 | execute "ring gnir1 = ("+charstr(basering)+"),("+varstr(basering)+"),(" |
---|
2885 | +ordstr(basering)+");"; |
---|
2886 | ideal @j=fetch(@P,@j); |
---|
2887 | attrib(@j,"isSB",1); |
---|
2888 | } |
---|
2889 | else |
---|
2890 | { |
---|
2891 | @va=string(maxideal(1)); |
---|
2892 | execute "ring gnir1 = ("+charstr(basering)+"),("+indep[@m][1]+"),(" |
---|
2893 | +indep[@m][2]+");"; |
---|
2894 | execute "map phi=@P,"+@va+";"; |
---|
2895 | if(homo==1) |
---|
2896 | { |
---|
2897 | ideal @j=std(phi(@j),@hilb); |
---|
2898 | } |
---|
2899 | else |
---|
2900 | { |
---|
2901 | ideal @j=std(phi(@j)); |
---|
2902 | } |
---|
2903 | } |
---|
2904 | if((deg(@j[1])==0)||(dim(@j)<jdim)) |
---|
2905 | { |
---|
2906 | setring @P; |
---|
2907 | break; |
---|
2908 | } |
---|
2909 | for (lauf=1;lauf<=size(@j);lauf++) |
---|
2910 | { |
---|
2911 | fett[lauf]=size(@j[lauf]); |
---|
2912 | } |
---|
2913 | //------------------------------------------------------------------------------------ |
---|
2914 | //we have now the following situation: |
---|
2915 | //j intersected with K[var(nnp+1),..,var(nva)] is zero so we may pass |
---|
2916 | //to this quotientring, j is their still a standardbasis, the |
---|
2917 | //leading coefficients of the polynomials there (polynomials in |
---|
2918 | //K[var(nnp+1),..,var(nva)]) are collected in the list h, |
---|
2919 | //we need their ggt, gh, because of the following: |
---|
2920 | //let (j:gh^n)=(j:gh^infinity) then j*K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2921 | //intersected with K[var(1),...,var(nva)] is (j:gh^n) |
---|
2922 | //on the other hand j=(j,gh^n) intersected with (j:gh^n) |
---|
2923 | |
---|
2924 | //------------------------------------------------------------------------------------ |
---|
2925 | |
---|
2926 | //the arrangement for the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2927 | //and the map phi:K[var(1),...,var(nva)] ----->K(var(nnpr+1),..,var(nva))[..the rest..] |
---|
2928 | //------------------------------------------------------------------------------------- |
---|
2929 | |
---|
2930 | quotring=prepareQuotientring(nvars(basering)-indep[@m][3]); |
---|
2931 | |
---|
2932 | //--------------------------------------------------------------------- |
---|
2933 | //we pass to the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2934 | //--------------------------------------------------------------------- |
---|
2935 | |
---|
2936 | execute quotring; |
---|
2937 | |
---|
2938 | // @j considered in the quotientring |
---|
2939 | ideal @j=imap(gnir1,@j); |
---|
2940 | |
---|
2941 | kill gnir1; |
---|
2942 | |
---|
2943 | //j is a standardbasis in the quotientring but usually not minimal |
---|
2944 | //here it becomes minimal |
---|
2945 | |
---|
2946 | @j=clearSB(@j,fett); |
---|
2947 | attrib(@j,"isSB",1); |
---|
2948 | |
---|
2949 | //we need later ggt(h[1],...)=gh for saturation |
---|
2950 | ideal @h; |
---|
2951 | if(deg(@j[1])>0) |
---|
2952 | { |
---|
2953 | for(@n=1;@n<=size(@j);@n++) |
---|
2954 | { |
---|
2955 | @h[@n]=leadcoef(@j[@n]); |
---|
2956 | } |
---|
2957 | //the primary decomposition of j*K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2958 | option(redSB); |
---|
2959 | @j=interred(@j); |
---|
2960 | attrib(@j,"isSB",1); |
---|
2961 | list @mo=@j,@j; |
---|
2962 | ideal zero_rad= radicalKL(@mo,ideal(1)); |
---|
2963 | } |
---|
2964 | else |
---|
2965 | { |
---|
2966 | ideal zero_rad=ideal(1); |
---|
2967 | } |
---|
2968 | |
---|
2969 | //we need the intersection of the ideals in the list quprimary with the |
---|
2970 | //polynomialring, i.e. let q=(f1,...,fr) in the quotientring such an ideal |
---|
2971 | //but fi polynomials, then the intersection of q with the polynomialring |
---|
2972 | //is the saturation of the ideal generated by f1,...,fr with respect to |
---|
2973 | //h which is the lcm of the leading coefficients of the fi considered in the |
---|
2974 | //quotientring: this is coded in saturn |
---|
2975 | |
---|
2976 | ideal hpl; |
---|
2977 | |
---|
2978 | for(@n=1;@n<=size(zero_rad);@n++) |
---|
2979 | { |
---|
2980 | hpl=hpl,leadcoef(zero_rad[@n]); |
---|
2981 | } |
---|
2982 | |
---|
2983 | //-------------------------------------------------------------------- |
---|
2984 | //we leave the quotientring K(var(nnp+1),..,var(nva))[..the rest..] |
---|
2985 | //back to the polynomialring |
---|
2986 | //--------------------------------------------------------------------- |
---|
2987 | setring @P; |
---|
2988 | |
---|
2989 | collectrad=imap(quring,zero_rad); |
---|
2990 | lsau=simplify(imap(quring,hpl),2); |
---|
2991 | @h=imap(quring,@h); |
---|
2992 | |
---|
2993 | kill quring; |
---|
2994 | |
---|
2995 | |
---|
2996 | //here the intersection with the polynomialring |
---|
2997 | //mentioned above is really computed |
---|
2998 | |
---|
2999 | collectrad=sat2(collectrad,lsau)[1]; |
---|
3000 | |
---|
3001 | if(deg(@h[1])>=0) |
---|
3002 | { |
---|
3003 | fac=ideal(0); |
---|
3004 | for(lauf=1;lauf<=ncols(@h);lauf++) |
---|
3005 | { |
---|
3006 | if(deg(@h[lauf])>0) |
---|
3007 | { |
---|
3008 | fac=fac+factorize(@h[lauf],1); |
---|
3009 | } |
---|
3010 | } |
---|
3011 | fac=simplify(fac,4); |
---|
3012 | @q=1; |
---|
3013 | for(lauf=1;lauf<=size(fac);lauf++) |
---|
3014 | { |
---|
3015 | @q=@q*fac[lauf]; |
---|
3016 | } |
---|
3017 | |
---|
3018 | |
---|
3019 | @mu=mstd(quotient(@j+ideal(@q),rad)); |
---|
3020 | @j=@mu[1]; |
---|
3021 | attrib(@j,"isSB",1); |
---|
3022 | |
---|
3023 | } |
---|
3024 | if((deg(rad[1])>0)&&(deg(collectrad[1])>0)) |
---|
3025 | { |
---|
3026 | rad=intersect(rad,collectrad); |
---|
3027 | } |
---|
3028 | else |
---|
3029 | { |
---|
3030 | if(deg(collectrad[1])>0) |
---|
3031 | { |
---|
3032 | rad=collectrad; |
---|
3033 | } |
---|
3034 | } |
---|
3035 | |
---|
3036 | te=simplify(reduce(te*rad,@j),2); |
---|
3037 | |
---|
3038 | if((dim(@j)<di)||(size(te)==0)) |
---|
3039 | { |
---|
3040 | break; |
---|
3041 | } |
---|
3042 | if(homo==1) |
---|
3043 | { |
---|
3044 | @hilb=hilb(@j,1); |
---|
3045 | } |
---|
3046 | } |
---|
3047 | |
---|
3048 | if(((@wr==1)&&(dim(@j)<di))||(deg(@j[1])==0)||(size(te)==0)) |
---|
3049 | { |
---|
3050 | return(rad); |
---|
3051 | } |
---|
3052 | // rad=intersect(rad,radicalKL(@mu,rad,@wr)); |
---|
3053 | rad=intersect(rad,radicalKL(@mu,ideal(1),@wr)); |
---|
3054 | |
---|
3055 | |
---|
3056 | option(noredSB); |
---|
3057 | return(rad); |
---|
3058 | } |
---|
3059 | |
---|
3060 | |
---|
3061 | example |
---|
3062 | { "EXAMPLE:"; echo = 2; |
---|
3063 | } |
---|
3064 | |
---|
3065 | |
---|
3066 | proc radicalEHV(ideal i,ideal re,list #) |
---|
3067 | { |
---|
3068 | ideal J,I,I0,radI0,L,radI1,I2,radI2; |
---|
3069 | int l,il; |
---|
3070 | if(size(#)>0) |
---|
3071 | { |
---|
3072 | il=#[1]; |
---|
3073 | } |
---|
3074 | |
---|
3075 | option(redSB); |
---|
3076 | list m=mstd(i); |
---|
3077 | I=m[2]; |
---|
3078 | option(noredSB); |
---|
3079 | if(size(reduce(re,m[1],1))==0) |
---|
3080 | { |
---|
3081 | return(re); |
---|
3082 | } |
---|
3083 | int cod=nvars(basering)-dim(m[1]); |
---|
3084 | if((nvars(basering)<=5)&&(size(m[2])<=5)) |
---|
3085 | { |
---|
3086 | if(cod==size(m[2])) |
---|
3087 | { |
---|
3088 | J=minor(jacob(I),cod); |
---|
3089 | return(quotient(I,J)); |
---|
3090 | } |
---|
3091 | |
---|
3092 | for(l=1;l<=cod;l++) |
---|
3093 | { |
---|
3094 | I0[l]=I[l]; |
---|
3095 | } |
---|
3096 | if(dim(std(I0))+cod==nvars(basering)) |
---|
3097 | { |
---|
3098 | J=minor(jacob(I0),cod); |
---|
3099 | radI0=quotient(I0,J); |
---|
3100 | L=quotient(radI0,I); |
---|
3101 | radI1=quotient(radI0,L); |
---|
3102 | |
---|
3103 | if(size(reduce(radI1,m[1],1))==0) |
---|
3104 | { |
---|
3105 | return(I); |
---|
3106 | } |
---|
3107 | if(il==1) |
---|
3108 | { |
---|
3109 | |
---|
3110 | return(radI1); |
---|
3111 | } |
---|
3112 | |
---|
3113 | I2=sat(I,radI1)[1]; |
---|
3114 | |
---|
3115 | if(deg(I2[1])<=0) |
---|
3116 | { |
---|
3117 | return(radI1); |
---|
3118 | } |
---|
3119 | return(intersect(radI1,radicalEHV(I2,re,il))); |
---|
3120 | } |
---|
3121 | } |
---|
3122 | return(radicalKL(m,re,il)); |
---|
3123 | } |
---|
3124 | |
---|
3125 | proc Ann(module M) |
---|
3126 | { |
---|
3127 | M=prune(M); //to obtain a small embedding |
---|
3128 | ideal ann=quotient1(M,freemodule(nrows(M))); |
---|
3129 | return(ann); |
---|
3130 | } |
---|
3131 | |
---|
3132 | //computes the equidimensional part of the ideal i of codimension e |
---|
3133 | proc int_ass_primary_e(ideal i, int e) |
---|
3134 | { |
---|
3135 | if(homog(i)!=1) |
---|
3136 | { |
---|
3137 | i=std(i); |
---|
3138 | } |
---|
3139 | list re=sres(i,0); //the resolution |
---|
3140 | re=minres(re); //minimized resolution |
---|
3141 | ideal ann=AnnExt_R(e,re); |
---|
3142 | if(nvars(basering)-dim(std(ann))!=e) |
---|
3143 | { |
---|
3144 | return(ideal(1)); |
---|
3145 | } |
---|
3146 | return(ann); |
---|
3147 | } |
---|
3148 | |
---|
3149 | //computes all equidimensional parts of the ideal i |
---|
3150 | proc prepareAss(ideal i) |
---|
3151 | { |
---|
3152 | ideal j=std(i); |
---|
3153 | int cod=nvars(basering)-dim(j); |
---|
3154 | int e; |
---|
3155 | list er; |
---|
3156 | ideal ann; |
---|
3157 | if(homog(i)==1) |
---|
3158 | { |
---|
3159 | list re=sres(i,0); //the resolution |
---|
3160 | re=minres(re); //minimized resolution |
---|
3161 | } |
---|
3162 | else |
---|
3163 | { |
---|
3164 | list re=mres(i,0); //fehler in sres |
---|
3165 | } |
---|
3166 | for(e=cod;e<=nvars(basering);e++) |
---|
3167 | { |
---|
3168 | ann=AnnExt_R(e,re); |
---|
3169 | |
---|
3170 | if(nvars(basering)-dim(std(ann))==e) |
---|
3171 | { |
---|
3172 | er[size(er)+1]=equiRadical(ann); |
---|
3173 | } |
---|
3174 | } |
---|
3175 | return(er); |
---|
3176 | } |
---|
3177 | |
---|
3178 | //computes the annihilator of Ext^n(R/i,R) with given resolution re |
---|
3179 | //n is not necessarily the number of variables |
---|
3180 | proc AnnExt_R(int n,list re) |
---|
3181 | { |
---|
3182 | if(n<nvars(basering)) |
---|
3183 | { |
---|
3184 | matrix f=transpose(re[n+1]); //Hom(_,R) |
---|
3185 | module k=res(f,2)[2]; //the kernel |
---|
3186 | matrix g=transpose(re[n]); //the image of Hom(_,R) |
---|
3187 | |
---|
3188 | ideal ann=quotient(g,k); //the anihilator |
---|
3189 | } |
---|
3190 | else |
---|
3191 | { |
---|
3192 | ideal ann=Ann(transpose(re[n])); |
---|
3193 | } |
---|
3194 | return(ann); |
---|
3195 | } |
---|
3196 | |
---|
3197 | proc quotient1(module a,module b) |
---|
3198 | { |
---|
3199 | int i; |
---|
3200 | ideal re=quotient(a,module(b[1])); |
---|
3201 | for(i=2;i<=size(b);i++) |
---|
3202 | { |
---|
3203 | re=intersect1(re,quotient(a,module(b[i]))); |
---|
3204 | } |
---|
3205 | return(re); |
---|
3206 | } |
---|
3207 | |
---|
3208 | |
---|
3209 | |
---|
3210 | proc analyze(list pr) |
---|
3211 | { |
---|
3212 | int ii,jj; |
---|
3213 | for(ii=1;ii<=size(pr)/2;ii++) |
---|
3214 | { |
---|
3215 | dim(std(pr[2*ii])); |
---|
3216 | idealsEqual(pr[2*ii-1],pr[2*ii]); |
---|
3217 | "==========================="; |
---|
3218 | } |
---|
3219 | |
---|
3220 | for(ii=size(pr)/2;ii>1;ii--) |
---|
3221 | { |
---|
3222 | for(jj=1;jj<ii;jj++) |
---|
3223 | { |
---|
3224 | if(size(reduce(pr[2*jj],std(pr[2*ii],1)))==0) |
---|
3225 | { |
---|
3226 | "eingebette Komponente"; |
---|
3227 | jj; |
---|
3228 | ii; |
---|
3229 | } |
---|
3230 | } |
---|
3231 | } |
---|
3232 | } |
---|
3233 | |
---|
3234 | |
---|
3235 | proc simplifyIdeal(ideal i) |
---|
3236 | { |
---|
3237 | def r=basering; |
---|
3238 | |
---|
3239 | int j,k; |
---|
3240 | map phi; |
---|
3241 | poly p; |
---|
3242 | |
---|
3243 | ideal iwork=i; |
---|
3244 | ideal imap1=maxideal(1); |
---|
3245 | ideal imap2=maxideal(1); |
---|
3246 | |
---|
3247 | |
---|
3248 | for(j=1;j<=nvars(basering);j++) |
---|
3249 | { |
---|
3250 | for(k=1;k<=size(i);k++) |
---|
3251 | { |
---|
3252 | if(deg(iwork[k]/var(j))==0) |
---|
3253 | { |
---|
3254 | p=-1/leadcoef(iwork[k]/var(j))*iwork[k]; |
---|
3255 | imap1[j]=p+2*var(j); |
---|
3256 | phi=r,imap1; |
---|
3257 | iwork=phi(iwork); |
---|
3258 | iwork=subst(iwork,var(j),0); |
---|
3259 | iwork[k]=var(j); |
---|
3260 | imap1=maxideal(1); |
---|
3261 | imap2[j]=-p; |
---|
3262 | break; |
---|
3263 | } |
---|
3264 | } |
---|
3265 | } |
---|
3266 | return(iwork,imap2); |
---|
3267 | } |
---|
3268 | |
---|
3269 | |
---|
3270 | /////////////////////////////////////////////////////// |
---|
3271 | // ini_mod |
---|
3272 | // input: a polynomial p |
---|
3273 | // output: the initial term of p as needed |
---|
3274 | // in the context of characteristic sets |
---|
3275 | ////////////////////////////////////////////////////// |
---|
3276 | |
---|
3277 | proc ini_mod(poly p) |
---|
3278 | { |
---|
3279 | if (p==0) |
---|
3280 | { |
---|
3281 | return(0); |
---|
3282 | } |
---|
3283 | int n; matrix m; |
---|
3284 | for( n=nvars(basering); n>0; n=n-1) |
---|
3285 | { |
---|
3286 | m=coef(p,var(n)); |
---|
3287 | if(m[1,1]!=1) |
---|
3288 | { |
---|
3289 | p=m[2,1]; |
---|
3290 | break; |
---|
3291 | } |
---|
3292 | } |
---|
3293 | if(deg(p)==0) |
---|
3294 | { |
---|
3295 | p=0; |
---|
3296 | } |
---|
3297 | return(p); |
---|
3298 | } |
---|
3299 | /////////////////////////////////////////////////////// |
---|
3300 | // min_ass_prim_charsets |
---|
3301 | // input: generators of an ideal PS and an integer cho |
---|
3302 | // If cho=0, the given ordering of the variables is used. |
---|
3303 | // Otherwise, the system tries to find an "optimal ordering", |
---|
3304 | // which in some cases may considerably speed up the algorithm |
---|
3305 | // output: the minimal associated primes of PS |
---|
3306 | // algorithm: via characteriostic sets |
---|
3307 | ////////////////////////////////////////////////////// |
---|
3308 | |
---|
3309 | |
---|
3310 | proc min_ass_prim_charsets (ideal PS, int cho) |
---|
3311 | { |
---|
3312 | if((cho<0) and (cho>1)) |
---|
3313 | { |
---|
3314 | "ERROR: <int> must be 0 or 1" |
---|
3315 | return(); |
---|
3316 | } |
---|
3317 | if(system("version")>933) |
---|
3318 | { |
---|
3319 | option(notWarnSB); |
---|
3320 | } |
---|
3321 | if(cho==0) |
---|
3322 | { |
---|
3323 | return(min_ass_prim_charsets0(PS)); |
---|
3324 | } |
---|
3325 | else |
---|
3326 | { |
---|
3327 | return(min_ass_prim_charsets1(PS)); |
---|
3328 | } |
---|
3329 | } |
---|
3330 | /////////////////////////////////////////////////////// |
---|
3331 | // min_ass_prim_charsets0 |
---|
3332 | // input: generators of an ideal PS |
---|
3333 | // output: the minimal associated primes of PS |
---|
3334 | // algorithm: via characteristic sets |
---|
3335 | // the given ordering of the variables is used |
---|
3336 | ////////////////////////////////////////////////////// |
---|
3337 | |
---|
3338 | |
---|
3339 | proc min_ass_prim_charsets0 (ideal PS) |
---|
3340 | { |
---|
3341 | |
---|
3342 | matrix m=char_series(PS); // We compute an irreducible |
---|
3343 | // characteristic series |
---|
3344 | int i,j,k; |
---|
3345 | list PSI; |
---|
3346 | list PHI; // the ideals given by the characteristic series |
---|
3347 | for(i=nrows(m);i>=1; i--) |
---|
3348 | { |
---|
3349 | PHI[i]=ideal(m[i,1..ncols(m)]); |
---|
3350 | } |
---|
3351 | // We compute the radical of each ideal in PHI |
---|
3352 | ideal I,JS,II; |
---|
3353 | int sizeJS, sizeII; |
---|
3354 | for(i=size(PHI);i>=1; i--) |
---|
3355 | { |
---|
3356 | I=0; |
---|
3357 | for(j=size(PHI[i]);j>0;j=j-1) |
---|
3358 | { |
---|
3359 | I=I+ini_mod(PHI[i][j]); |
---|
3360 | } |
---|
3361 | JS=std(PHI[i]); |
---|
3362 | sizeJS=size(JS); |
---|
3363 | for(j=size(I);j>0;j=j-1) |
---|
3364 | { |
---|
3365 | II=0; |
---|
3366 | sizeII=0; |
---|
3367 | k=0; |
---|
3368 | while(k<=sizeII) // successive saturation |
---|
3369 | { |
---|
3370 | option(returnSB); |
---|
3371 | II=quotient(JS,I[j]); |
---|
3372 | option(noreturnSB); |
---|
3373 | //std |
---|
3374 | // II=std(II); |
---|
3375 | sizeII=size(II); |
---|
3376 | if(sizeII==sizeJS) |
---|
3377 | { |
---|
3378 | for(k=1;k<=sizeII;k++) |
---|
3379 | { |
---|
3380 | if(leadexp(II[k])!=leadexp(JS[k])) break; |
---|
3381 | } |
---|
3382 | } |
---|
3383 | JS=II; |
---|
3384 | sizeJS=sizeII; |
---|
3385 | } |
---|
3386 | } |
---|
3387 | PSI=insert(PSI,JS); |
---|
3388 | } |
---|
3389 | int sizePSI=size(PSI); |
---|
3390 | // We eliminate redundant ideals |
---|
3391 | for(i=1;i<sizePSI;i++) |
---|
3392 | { |
---|
3393 | for(j=i+1;j<=sizePSI;j++) |
---|
3394 | { |
---|
3395 | if(size(PSI[i])!=0) |
---|
3396 | { |
---|
3397 | if(size(PSI[j])!=0) |
---|
3398 | { |
---|
3399 | if(size(NF(PSI[i],PSI[j],1))==0) |
---|
3400 | { |
---|
3401 | PSI[j]=ideal(0); |
---|
3402 | } |
---|
3403 | else |
---|
3404 | { |
---|
3405 | if(size(NF(PSI[j],PSI[i],1))==0) |
---|
3406 | { |
---|
3407 | PSI[i]=ideal(0); |
---|
3408 | } |
---|
3409 | } |
---|
3410 | } |
---|
3411 | } |
---|
3412 | } |
---|
3413 | } |
---|
3414 | for(i=sizePSI;i>=1;i--) |
---|
3415 | { |
---|
3416 | if(size(PSI[i])==0) |
---|
3417 | { |
---|
3418 | PSI=delete(PSI,i); |
---|
3419 | } |
---|
3420 | } |
---|
3421 | return (PSI); |
---|
3422 | } |
---|
3423 | |
---|
3424 | /////////////////////////////////////////////////////// |
---|
3425 | // min_ass_prim_charsets1 |
---|
3426 | // input: generators of an ideal PS |
---|
3427 | // output: the minimal associated primes of PS |
---|
3428 | // algorithm: via characteristic sets |
---|
3429 | // input: generators of an ideal PS and an integer i |
---|
3430 | // The system tries to find an "optimal ordering" of |
---|
3431 | // the variables |
---|
3432 | ////////////////////////////////////////////////////// |
---|
3433 | |
---|
3434 | |
---|
3435 | proc min_ass_prim_charsets1 (ideal PS) |
---|
3436 | { |
---|
3437 | def oldring=basering; |
---|
3438 | string n=system("neworder",PS); |
---|
3439 | execute "ring r="+charstr(oldring)+",("+n+"),dp;"; |
---|
3440 | ideal PS=imap(oldring,PS); |
---|
3441 | matrix m=char_series(PS); // We compute an irreducible |
---|
3442 | // characteristic series |
---|
3443 | int i,j,k; |
---|
3444 | ideal I; |
---|
3445 | list PSI; |
---|
3446 | list PHI; // the ideals given by the characteristic series |
---|
3447 | list ITPHI; // their initial terms |
---|
3448 | for(i=nrows(m);i>=1; i--) |
---|
3449 | { |
---|
3450 | PHI[i]=ideal(m[i,1..ncols(m)]); |
---|
3451 | I=0; |
---|
3452 | for(j=size(PHI[i]);j>0;j=j-1) |
---|
3453 | { |
---|
3454 | I=I,ini_mod(PHI[i][j]); |
---|
3455 | } |
---|
3456 | I=I[2..ncols(I)]; |
---|
3457 | ITPHI[i]=I; |
---|
3458 | } |
---|
3459 | setring oldring; |
---|
3460 | matrix m=imap(r,m); |
---|
3461 | list PHI=imap(r,PHI); |
---|
3462 | list ITPHI=imap(r,ITPHI); |
---|
3463 | // We compute the radical of each ideal in PHI |
---|
3464 | ideal I,JS,II; |
---|
3465 | int sizeJS, sizeII; |
---|
3466 | for(i=size(PHI);i>=1; i--) |
---|
3467 | { |
---|
3468 | I=0; |
---|
3469 | for(j=size(PHI[i]);j>0;j=j-1) |
---|
3470 | { |
---|
3471 | I=I+ITPHI[i][j]; |
---|
3472 | } |
---|
3473 | JS=std(PHI[i]); |
---|
3474 | sizeJS=size(JS); |
---|
3475 | for(j=size(I);j>0;j=j-1) |
---|
3476 | { |
---|
3477 | II=0; |
---|
3478 | sizeII=0; |
---|
3479 | k=0; |
---|
3480 | while(k<=sizeII) // successive iteration |
---|
3481 | { |
---|
3482 | option(returnSB); |
---|
3483 | II=quotient(JS,I[j]); |
---|
3484 | option(noreturnSB); |
---|
3485 | //std |
---|
3486 | // II=std(II); |
---|
3487 | sizeII=size(II); |
---|
3488 | if(sizeII==sizeJS) |
---|
3489 | { |
---|
3490 | for(k=1;k<=sizeII;k++) |
---|
3491 | { |
---|
3492 | if(leadexp(II[k])!=leadexp(JS[k])) break; |
---|
3493 | } |
---|
3494 | } |
---|
3495 | JS=II; |
---|
3496 | sizeJS=sizeII; |
---|
3497 | } |
---|
3498 | } |
---|
3499 | PSI=insert(PSI,JS); |
---|
3500 | } |
---|
3501 | int sizePSI=size(PSI); |
---|
3502 | // We eliminate redundant ideals |
---|
3503 | for(i=1;i<sizePSI;i++) |
---|
3504 | { |
---|
3505 | for(j=i+1;j<=sizePSI;j++) |
---|
3506 | { |
---|
3507 | if(size(PSI[i])!=0) |
---|
3508 | { |
---|
3509 | if(size(PSI[j])!=0) |
---|
3510 | { |
---|
3511 | if(size(NF(PSI[i],PSI[j],1))==0) |
---|
3512 | { |
---|
3513 | PSI[j]=ideal(0); |
---|
3514 | } |
---|
3515 | else |
---|
3516 | { |
---|
3517 | if(size(NF(PSI[j],PSI[i],1))==0) |
---|
3518 | { |
---|
3519 | PSI[i]=ideal(0); |
---|
3520 | } |
---|
3521 | } |
---|
3522 | } |
---|
3523 | } |
---|
3524 | } |
---|
3525 | } |
---|
3526 | for(i=sizePSI;i>=1;i--) |
---|
3527 | { |
---|
3528 | if(size(PSI[i])==0) |
---|
3529 | { |
---|
3530 | PSI=delete(PSI,i); |
---|
3531 | } |
---|
3532 | } |
---|
3533 | return (PSI); |
---|
3534 | } |
---|
3535 | |
---|
3536 | |
---|
3537 | ///////////////////////////////////////////////////// |
---|
3538 | // proc prim_dec |
---|
3539 | // input: generators of an ideal I and an integer choose |
---|
3540 | // If choose=0, min_ass_prim_charsets with the given |
---|
3541 | // ordering of the variables is used. |
---|
3542 | // If choose=1, min_ass_prim_charsets with the "optimized" |
---|
3543 | // ordering of the variables is used. |
---|
3544 | // If choose=2, minAssPrimes from primdec.lib is used |
---|
3545 | // If choose=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
3546 | // output: a primary decomposition of I, i.e., a list |
---|
3547 | // of pairs consisting of a standard basis of a primary component |
---|
3548 | // of I and a standard basis of the corresponding associated prime. |
---|
3549 | // To compute the minimal associated primes of a given ideal |
---|
3550 | // min_ass_prim_l is called, i.e., the minimal associated primes |
---|
3551 | // are computed via characteristic sets. |
---|
3552 | // In the homogeneous case, the performance of the procedure |
---|
3553 | // will be improved if I is already given by a minimal set of |
---|
3554 | // generators. Apply minbase if necessary. |
---|
3555 | ////////////////////////////////////////////////////////// |
---|
3556 | |
---|
3557 | |
---|
3558 | proc prim_dec(ideal I, int choose) |
---|
3559 | { |
---|
3560 | if((choose<0) or (choose>3)) |
---|
3561 | { |
---|
3562 | "ERROR: <int> must be 0 or 1 or 2 or 3"; |
---|
3563 | return(); |
---|
3564 | } |
---|
3565 | if(system("version")>933) |
---|
3566 | { |
---|
3567 | option(notWarnSB); |
---|
3568 | } |
---|
3569 | ideal H=1; // The intersection of the primary components |
---|
3570 | list U; // the leaves of the decomposition tree, i.e., |
---|
3571 | // pairs consisting of a primary component of I |
---|
3572 | // and the corresponding associated prime |
---|
3573 | list W; // the non-leaf vertices in the decomposition tree. |
---|
3574 | // every entry has 6 components: |
---|
3575 | // 1- the vertex itself , i.e., a standard bais of the |
---|
3576 | // given ideal I (type 1), or a standard basis of a |
---|
3577 | // pseudo-primary component arising from |
---|
3578 | // pseudo-primary decomposition (type 2), or a |
---|
3579 | // standard basis of a remaining component arising from |
---|
3580 | // pseudo-primary decomposition or extraction (type 3) |
---|
3581 | // 2- the type of the vertex as indicated above |
---|
3582 | // 3- the weighted_tree_depth of the vertex |
---|
3583 | // 4- the tester of the vertex |
---|
3584 | // 5- a standard basis of the associated prime |
---|
3585 | // of a vertex of type 2, or 0 otherwise |
---|
3586 | // 6- a list of pairs consisting of a standard |
---|
3587 | // basis of a minimal associated prime ideal |
---|
3588 | // of the father of the vertex and the |
---|
3589 | // irreducible factors of the "minimal |
---|
3590 | // divisor" of the seperator or extractor |
---|
3591 | // corresponding to the prime ideal |
---|
3592 | // as computed by the procedure minsat, |
---|
3593 | // if the vertex is of type 3, or |
---|
3594 | // the empty list otherwise |
---|
3595 | ideal SI=std(I); |
---|
3596 | int ncolsSI=ncols(SI); |
---|
3597 | int ncolsH=1; |
---|
3598 | W[1]=list(I,1,0,poly(1),ideal(0),list()); // The root of the tree |
---|
3599 | int weighted_tree_depth; |
---|
3600 | int i,j; |
---|
3601 | int check; |
---|
3602 | list V; // current vertex |
---|
3603 | list VV; // new vertex |
---|
3604 | list QQ; |
---|
3605 | list WI; |
---|
3606 | ideal Qi,SQ,SRest,fac; |
---|
3607 | poly tester; |
---|
3608 | |
---|
3609 | while(1) |
---|
3610 | { |
---|
3611 | i=1; |
---|
3612 | while(1) |
---|
3613 | { |
---|
3614 | while(i<=size(W)) // find vertex V of smallest weighted tree-depth |
---|
3615 | { |
---|
3616 | if (W[i][3]<=weighted_tree_depth) break; |
---|
3617 | i++; |
---|
3618 | } |
---|
3619 | if (i<=size(W)) break; |
---|
3620 | i=1; |
---|
3621 | weighted_tree_depth++; |
---|
3622 | } |
---|
3623 | V=W[i]; |
---|
3624 | W=delete(W,i); // delete V from W |
---|
3625 | |
---|
3626 | // now proceed by type of vertex V |
---|
3627 | |
---|
3628 | if (V[2]==2) // extraction needed |
---|
3629 | { |
---|
3630 | SQ,SRest,fac=extraction(V[1],V[5]); |
---|
3631 | // standard basis of primary component, |
---|
3632 | // standard basis of remaining component, |
---|
3633 | // irreducible factors of |
---|
3634 | // the "minimal divisor" of the extractor |
---|
3635 | // as computed by the procedure minsat, |
---|
3636 | check=0; |
---|
3637 | for(j=1;j<=ncolsH;j++) |
---|
3638 | { |
---|
3639 | if (NF(H[j],SQ,1)!=0) // Q is not redundant |
---|
3640 | { |
---|
3641 | check=1; |
---|
3642 | break; |
---|
3643 | } |
---|
3644 | } |
---|
3645 | if(check==1) // Q is not redundant |
---|
3646 | { |
---|
3647 | QQ=list(); |
---|
3648 | QQ[1]=list(SQ,V[5]); // primary component, associated prime, |
---|
3649 | // i.e., standard bases thereof |
---|
3650 | U=U+QQ; |
---|
3651 | H=intersect(H,SQ); |
---|
3652 | H=std(H); |
---|
3653 | ncolsH=ncols(H); |
---|
3654 | check=0; |
---|
3655 | if(ncolsH==ncolsSI) |
---|
3656 | { |
---|
3657 | for(j=1;j<=ncolsSI;j++) |
---|
3658 | { |
---|
3659 | if(leadexp(H[j])!=leadexp(SI[j])) |
---|
3660 | { |
---|
3661 | check=1; |
---|
3662 | break; |
---|
3663 | } |
---|
3664 | } |
---|
3665 | } |
---|
3666 | else |
---|
3667 | { |
---|
3668 | check=1; |
---|
3669 | } |
---|
3670 | if(check==0) // H==I => U is a primary decomposition |
---|
3671 | { |
---|
3672 | return(U); |
---|
3673 | } |
---|
3674 | } |
---|
3675 | if (SRest[1]!=1) // the remaining component is not |
---|
3676 | // the whole ring |
---|
3677 | { |
---|
3678 | if (rad_con(V[4],SRest)==0) // the new vertex is not the |
---|
3679 | // root of a redundant subtree |
---|
3680 | { |
---|
3681 | VV[1]=SRest; // remaining component |
---|
3682 | VV[2]=3; // pseudoprimdec_special |
---|
3683 | VV[3]=V[3]+1; // weighted depth |
---|
3684 | VV[4]=V[4]; // the tester did not change |
---|
3685 | VV[5]=ideal(0); |
---|
3686 | VV[6]=list(list(V[5],fac)); |
---|
3687 | W=insert(W,VV,size(W)); |
---|
3688 | } |
---|
3689 | } |
---|
3690 | } |
---|
3691 | else |
---|
3692 | { |
---|
3693 | if (V[2]==3) // pseudo_prim_dec_special is needed |
---|
3694 | { |
---|
3695 | QQ,SRest=pseudo_prim_dec_special_charsets(V[1],V[6],choose); |
---|
3696 | // QQ = quadruples: |
---|
3697 | // standard basis of pseudo-primary component, |
---|
3698 | // standard basis of corresponding prime, |
---|
3699 | // seperator, irreducible factors of |
---|
3700 | // the "minimal divisor" of the seperator |
---|
3701 | // as computed by the procedure minsat, |
---|
3702 | // SRest=standard basis of remaining component |
---|
3703 | } |
---|
3704 | else // V is the root, pseudo_prim_dec is needed |
---|
3705 | { |
---|
3706 | QQ,SRest=pseudo_prim_dec_charsets(I,SI,choose); |
---|
3707 | // QQ = quadruples: |
---|
3708 | // standard basis of pseudo-primary component, |
---|
3709 | // standard basis of corresponding prime, |
---|
3710 | // seperator, irreducible factors of |
---|
3711 | // the "minimal divisor" of the seperator |
---|
3712 | // as computed by the procedure minsat, |
---|
3713 | // SRest=standard basis of remaining component |
---|
3714 | |
---|
3715 | } |
---|
3716 | //check |
---|
3717 | for(i=size(QQ);i>=1;i--) |
---|
3718 | //for(i=1;i<=size(QQ);i++) |
---|
3719 | { |
---|
3720 | tester=QQ[i][3]*V[4]; |
---|
3721 | Qi=QQ[i][2]; |
---|
3722 | if(NF(tester,Qi,1)!=0) // the new vertex is not the |
---|
3723 | // root of a redundant subtree |
---|
3724 | { |
---|
3725 | VV[1]=QQ[i][1]; |
---|
3726 | VV[2]=2; |
---|
3727 | VV[3]=V[3]+1; |
---|
3728 | VV[4]=tester; // the new tester as computed above |
---|
3729 | VV[5]=Qi; // QQ[i][2]; |
---|
3730 | VV[6]=list(); |
---|
3731 | W=insert(W,VV,size(W)); |
---|
3732 | } |
---|
3733 | } |
---|
3734 | if (SRest[1]!=1) // the remaining component is not |
---|
3735 | // the whole ring |
---|
3736 | { |
---|
3737 | if (rad_con(V[4],SRest)==0) // the vertex is not the root |
---|
3738 | // of a redundant subtree |
---|
3739 | { |
---|
3740 | VV[1]=SRest; |
---|
3741 | VV[2]=3; |
---|
3742 | VV[3]=V[3]+2; |
---|
3743 | VV[4]=V[4]; // the tester did not change |
---|
3744 | VV[5]=ideal(0); |
---|
3745 | WI=list(); |
---|
3746 | for(i=1;i<=size(QQ);i++) |
---|
3747 | { |
---|
3748 | WI=insert(WI,list(QQ[i][2],QQ[i][4])); |
---|
3749 | } |
---|
3750 | VV[6]=WI; |
---|
3751 | W=insert(W,VV,size(W)); |
---|
3752 | } |
---|
3753 | } |
---|
3754 | } |
---|
3755 | } |
---|
3756 | } |
---|
3757 | |
---|
3758 | ////////////////////////////////////////////////////////////////////////// |
---|
3759 | // proc pseudo_prim_dec_charsets |
---|
3760 | // input: Generators of an arbitrary ideal I, a standard basis SI of I, |
---|
3761 | // and an integer choo |
---|
3762 | // If choo=0, min_ass_prim_charsets with the given |
---|
3763 | // ordering of the variables is used. |
---|
3764 | // If choo=1, min_ass_prim_charsets with the "optimized" |
---|
3765 | // ordering of the variables is used. |
---|
3766 | // If choo=2, minAssPrimes from primdec.lib is used |
---|
3767 | // If choo=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
3768 | // output: a pseudo primary decomposition of I, i.e., a list |
---|
3769 | // of pseudo primary components together with a standard basis of the |
---|
3770 | // remaining component. Each pseudo primary component is |
---|
3771 | // represented by a quadrupel: A standard basis of the component, |
---|
3772 | // a standard basis of the corresponding associated prime, the |
---|
3773 | // seperator of the component, and the irreducible factors of the |
---|
3774 | // "minimal divisor" of the seperator as computed by the procedure minsat, |
---|
3775 | // calls proc pseudo_prim_dec_i |
---|
3776 | ////////////////////////////////////////////////////////////////////////// |
---|
3777 | |
---|
3778 | |
---|
3779 | proc pseudo_prim_dec_charsets (ideal I, ideal SI, int choo) |
---|
3780 | { |
---|
3781 | list L; // The list of minimal associated primes, |
---|
3782 | // each one given by a standard basis |
---|
3783 | if((choo==0) or (choo==1)) |
---|
3784 | { |
---|
3785 | L=min_ass_prim_charsets(I,choo); |
---|
3786 | } |
---|
3787 | else |
---|
3788 | { |
---|
3789 | if(choo==2) |
---|
3790 | { |
---|
3791 | L=minAssPrimes(I); |
---|
3792 | } |
---|
3793 | else |
---|
3794 | { |
---|
3795 | L=minAssPrimes(I,1); |
---|
3796 | } |
---|
3797 | for(int i=size(L);i>=1;i=i-1) |
---|
3798 | { |
---|
3799 | L[i]=std(L[i]); |
---|
3800 | } |
---|
3801 | } |
---|
3802 | return (pseudo_prim_dec_i(SI,L)); |
---|
3803 | } |
---|
3804 | |
---|
3805 | //////////////////////////////////////////////////////////////// |
---|
3806 | // proc pseudo_prim_dec_special_charsets |
---|
3807 | // input: a standard basis of an ideal I whose radical is the |
---|
3808 | // intersection of the radicals of ideals generated by one prime ideal |
---|
3809 | // P_i together with one polynomial f_i, the list V6 must be the list of |
---|
3810 | // pairs (standard basis of P_i, irreducible factors of f_i), |
---|
3811 | // and an integer choo |
---|
3812 | // If choo=0, min_ass_prim_charsets with the given |
---|
3813 | // ordering of the variables is used. |
---|
3814 | // If choo=1, min_ass_prim_charsets with the "optimized" |
---|
3815 | // ordering of the variables is used. |
---|
3816 | // If choo=2, minAssPrimes from primdec.lib is used |
---|
3817 | // If choo=3, minAssPrimes+factorizing Buchberger from primdec.lib is used |
---|
3818 | // output: a pseudo primary decomposition of I, i.e., a list |
---|
3819 | // of pseudo primary components together with a standard basis of the |
---|
3820 | // remaining component. Each pseudo primary component is |
---|
3821 | // represented by a quadrupel: A standard basis of the component, |
---|
3822 | // a standard basis of the corresponding associated prime, the |
---|
3823 | // seperator of the component, and the irreducible factors of the |
---|
3824 | // "minimal divisor" of the seperator as computed by the procedure minsat, |
---|
3825 | // calls proc pseudo_prim_dec_i |
---|
3826 | //////////////////////////////////////////////////////////////// |
---|
3827 | |
---|
3828 | |
---|
3829 | proc pseudo_prim_dec_special_charsets (ideal SI,list V6, int choo) |
---|
3830 | { |
---|
3831 | int i,j,l; |
---|
3832 | list m; |
---|
3833 | list L; |
---|
3834 | int sizeL; |
---|
3835 | ideal P,SP; ideal fac; |
---|
3836 | int dimSP; |
---|
3837 | for(l=size(V6);l>=1;l--) // creates a list of associated primes |
---|
3838 | // of I, possibly redundant |
---|
3839 | { |
---|
3840 | P=V6[l][1]; |
---|
3841 | fac=V6[l][2]; |
---|
3842 | for(i=ncols(fac);i>=1;i--) |
---|
3843 | { |
---|
3844 | SP=P+fac[i]; |
---|
3845 | SP=std(SP); |
---|
3846 | if(SP[1]!=1) |
---|
3847 | { |
---|
3848 | if((choo==0) or (choo==1)) |
---|
3849 | { |
---|
3850 | m=min_ass_prim_charsets(SP,choo); // a list of SB |
---|
3851 | } |
---|
3852 | else |
---|
3853 | { |
---|
3854 | if(choo==2) |
---|
3855 | { |
---|
3856 | m=minAssPrimes(SP); |
---|
3857 | } |
---|
3858 | else |
---|
3859 | { |
---|
3860 | m=minAssPrimes(SP,1); |
---|
3861 | } |
---|
3862 | for(j=size(m);j>=1;j=j-1) |
---|
3863 | { |
---|
3864 | m[j]=std(m[j]); |
---|
3865 | } |
---|
3866 | } |
---|
3867 | dimSP=dim(SP); |
---|
3868 | for(j=size(m);j>=1; j--) |
---|
3869 | { |
---|
3870 | if(dim(m[j])==dimSP) |
---|
3871 | { |
---|
3872 | L=insert(L,m[j],size(L)); |
---|
3873 | } |
---|
3874 | } |
---|
3875 | } |
---|
3876 | } |
---|
3877 | } |
---|
3878 | sizeL=size(L); |
---|
3879 | for(i=1;i<sizeL;i++) // get rid of redundant primes |
---|
3880 | { |
---|
3881 | for(j=i+1;j<=sizeL;j++) |
---|
3882 | { |
---|
3883 | if(size(L[i])!=0) |
---|
3884 | { |
---|
3885 | if(size(L[j])!=0) |
---|
3886 | { |
---|
3887 | if(size(NF(L[i],L[j],1))==0) |
---|
3888 | { |
---|
3889 | L[j]=ideal(0); |
---|
3890 | } |
---|
3891 | else |
---|
3892 | { |
---|
3893 | if(size(NF(L[j],L[i],1))==0) |
---|
3894 | { |
---|
3895 | L[i]=ideal(0); |
---|
3896 | } |
---|
3897 | } |
---|
3898 | } |
---|
3899 | } |
---|
3900 | } |
---|
3901 | } |
---|
3902 | for(i=sizeL;i>=1;i--) |
---|
3903 | { |
---|
3904 | if(size(L[i])==0) |
---|
3905 | { |
---|
3906 | L=delete(L,i); |
---|
3907 | } |
---|
3908 | } |
---|
3909 | return (pseudo_prim_dec_i(SI,L)); |
---|
3910 | } |
---|
3911 | |
---|
3912 | |
---|
3913 | //////////////////////////////////////////////////////////////// |
---|
3914 | // proc pseudo_prim_dec_i |
---|
3915 | // input: A standard basis of an arbitrary ideal I, and standard bases |
---|
3916 | // of the minimal associated primes of I |
---|
3917 | // output: a pseudo primary decomposition of I, i.e., a list |
---|
3918 | // of pseudo primary components together with a standard basis of the |
---|
3919 | // remaining component. Each pseudo primary component is |
---|
3920 | // represented by a quadrupel: A standard basis of the component Q_i, |
---|
3921 | // a standard basis of the corresponding associated prime P_i, the |
---|
3922 | // seperator of the component, and the irreducible factors of the |
---|
3923 | // "minimal divisor" of the seperator as computed by the procedure minsat, |
---|
3924 | //////////////////////////////////////////////////////////////// |
---|
3925 | |
---|
3926 | |
---|
3927 | proc pseudo_prim_dec_i (ideal SI, list L) |
---|
3928 | { |
---|
3929 | list Q; |
---|
3930 | if (size(L)==1) // one minimal associated prime only |
---|
3931 | // the ideal is already pseudo primary |
---|
3932 | { |
---|
3933 | Q=SI,L[1],1; |
---|
3934 | list QQ; |
---|
3935 | QQ[1]=Q; |
---|
3936 | return (QQ,ideal(1)); |
---|
3937 | } |
---|
3938 | |
---|
3939 | poly f0,f,g; |
---|
3940 | ideal fac; |
---|
3941 | int i,j,k,l; |
---|
3942 | ideal SQi; |
---|
3943 | ideal I'=SI; |
---|
3944 | list QP; |
---|
3945 | int sizeL=size(L); |
---|
3946 | for(i=1;i<=sizeL;i++) |
---|
3947 | { |
---|
3948 | fac=0; |
---|
3949 | for(j=1;j<=sizeL;j++) // compute the seperator sep_i |
---|
3950 | // of the i-th component |
---|
3951 | { |
---|
3952 | if (i!=j) // search g not in L[i], but L[j] |
---|
3953 | { |
---|
3954 | for(k=1;k<=ncols(L[j]);k++) |
---|
3955 | { |
---|
3956 | if(NF(L[j][k],L[i],1)!=0) |
---|
3957 | { |
---|
3958 | break; |
---|
3959 | } |
---|
3960 | } |
---|
3961 | fac=fac+L[j][k]; |
---|
3962 | } |
---|
3963 | } |
---|
3964 | // delete superfluous polynomials |
---|
3965 | fac=simplify(fac,8); |
---|
3966 | // saturation |
---|
3967 | SQi,f0,f,fac=minsat_ppd(SI,fac); |
---|
3968 | I'=I',f; |
---|
3969 | QP=SQi,L[i],f0,fac; |
---|
3970 | // the quadrupel: |
---|
3971 | // a standard basis of Q_i, |
---|
3972 | // a standard basis of P_i, |
---|
3973 | // sep_i, |
---|
3974 | // irreducible factors of |
---|
3975 | // the "minimal divisor" of the seperator |
---|
3976 | // as computed by the procedure minsat, |
---|
3977 | Q[i]=QP; |
---|
3978 | } |
---|
3979 | I'=std(I'); |
---|
3980 | return (Q, I'); |
---|
3981 | // I' = remaining component |
---|
3982 | } |
---|
3983 | |
---|
3984 | |
---|
3985 | //////////////////////////////////////////////////////////////// |
---|
3986 | // proc extraction |
---|
3987 | // input: A standard basis of a pseudo primary ideal I, and a standard |
---|
3988 | // basis of the unique minimal associated prime P of I |
---|
3989 | // output: an extraction of I, i.e., a standard basis of the primary |
---|
3990 | // component Q of I with associated prime P, a standard basis of the |
---|
3991 | // remaining component, and the irreducible factors of the |
---|
3992 | // "minimal divisor" of the extractor as computed by the procedure minsat |
---|
3993 | //////////////////////////////////////////////////////////////// |
---|
3994 | |
---|
3995 | |
---|
3996 | proc extraction (ideal SI, ideal SP) |
---|
3997 | { |
---|
3998 | list indsets=system("indsetall",SP,0); |
---|
3999 | poly f; |
---|
4000 | if(size(indsets)!=0) //check, whether dim P != 0 |
---|
4001 | { |
---|
4002 | intvec v; // a maximal independent set of variables |
---|
4003 | // modulo P |
---|
4004 | string U; // the independent variables |
---|
4005 | string A; // the dependent variables |
---|
4006 | int j,k; |
---|
4007 | int a; // the size of A |
---|
4008 | int degf; |
---|
4009 | ideal g; |
---|
4010 | list polys; |
---|
4011 | int sizepolys; |
---|
4012 | list newpoly; |
---|
4013 | def R=basering; |
---|
4014 | //intvec hv=hilb(SI,1); |
---|
4015 | for (k=1;k<=size(indsets);k++) |
---|
4016 | { |
---|
4017 | v=indsets[k]; |
---|
4018 | for (j=1;j<=nvars(R);j++) |
---|
4019 | { |
---|
4020 | if (v[j]==1) |
---|
4021 | { |
---|
4022 | U=U+varstr(j)+","; |
---|
4023 | } |
---|
4024 | else |
---|
4025 | { |
---|
4026 | A=A+varstr(j)+","; |
---|
4027 | a++; |
---|
4028 | } |
---|
4029 | } |
---|
4030 | |
---|
4031 | U[size(U)]=")"; // we compute the extractor of I (w.r.t. U) |
---|
4032 | execute "ring RAU="+charstr(basering)+",("+A+U+",(dp("+string(a)+"),dp);"; |
---|
4033 | ideal I=imap(R,SI); |
---|
4034 | //I=std(I,hv); // the standard basis in (R[U])[A] |
---|
4035 | I=std(I); // the standard basis in (R[U])[A] |
---|
4036 | A[size(A)]=")"; |
---|
4037 | execute "ring Rloc=("+charstr(basering)+","+U+",("+A+",dp;"; |
---|
4038 | ideal I=imap(RAU,I); |
---|
4039 | //"std in lokalisierung:"+newline,I; |
---|
4040 | ideal h; |
---|
4041 | for(j=ncols(I);j>=1;j--) |
---|
4042 | { |
---|
4043 | h[j]=leadcoef(I[j]); // consider I in (R(U))[A] |
---|
4044 | } |
---|
4045 | setring R; |
---|
4046 | g=imap(Rloc,h); |
---|
4047 | kill RAU,Rloc; |
---|
4048 | U=""; |
---|
4049 | A=""; |
---|
4050 | a=0; |
---|
4051 | f=lcm(g); |
---|
4052 | newpoly[1]=f; |
---|
4053 | polys=polys+newpoly; |
---|
4054 | newpoly=list(); |
---|
4055 | } |
---|
4056 | f=polys[1]; |
---|
4057 | degf=deg(f); |
---|
4058 | sizepolys=size(polys); |
---|
4059 | for (k=2;k<=sizepolys;k++) |
---|
4060 | { |
---|
4061 | if (deg(polys[k])<degf) |
---|
4062 | { |
---|
4063 | f=polys[k]; |
---|
4064 | degf=deg(f); |
---|
4065 | } |
---|
4066 | } |
---|
4067 | } |
---|
4068 | else |
---|
4069 | { |
---|
4070 | f=1; |
---|
4071 | } |
---|
4072 | poly f0,h0; ideal SQ; ideal fac; |
---|
4073 | if(f!=1) |
---|
4074 | { |
---|
4075 | SQ,f0,h0,fac=minsat(SI,f); |
---|
4076 | return(SQ,std(SI+h0),fac); |
---|
4077 | // the tripel |
---|
4078 | // a standard basis of Q, |
---|
4079 | // a standard basis of remaining component, |
---|
4080 | // irreducible factors of |
---|
4081 | // the "minimal divisor" of the extractor |
---|
4082 | // as computed by the procedure minsat |
---|
4083 | } |
---|
4084 | else |
---|
4085 | { |
---|
4086 | return(SI,ideal(1),ideal(1)); |
---|
4087 | } |
---|
4088 | } |
---|
4089 | |
---|
4090 | ///////////////////////////////////////////////////// |
---|
4091 | // proc minsat |
---|
4092 | // input: a standard basis of an ideal I and a polynomial p |
---|
4093 | // output: a standard basis IS of the saturation of I w.r. to p, |
---|
4094 | // the maximal squarefree factor f0 of p, |
---|
4095 | // the "minimal divisor" f of f0 such that the saturation of |
---|
4096 | // I w.r. to f equals the saturation of I w.r. to f0 (which is IS), |
---|
4097 | // the irreducible factors of f |
---|
4098 | ////////////////////////////////////////////////////////// |
---|
4099 | |
---|
4100 | |
---|
4101 | proc minsat(ideal SI, poly p) |
---|
4102 | { |
---|
4103 | ideal fac=factorize(p,1); //the irreducible factors of p |
---|
4104 | fac=sort(fac)[1]; |
---|
4105 | int i,k; |
---|
4106 | poly f0=1; |
---|
4107 | for(i=ncols(fac);i>=1;i--) |
---|
4108 | { |
---|
4109 | f0=f0*fac[i]; |
---|
4110 | } |
---|
4111 | poly f=1; |
---|
4112 | ideal iold; |
---|
4113 | list quotM; |
---|
4114 | quotM[1]=SI; |
---|
4115 | quotM[2]=fac; |
---|
4116 | quotM[3]=f0; |
---|
4117 | // we deal seperately with the first quotient; |
---|
4118 | // factors, which do not contribute to this one, |
---|
4119 | // are omitted |
---|
4120 | iold=quotM[1]; |
---|
4121 | quotM=minquot(quotM); |
---|
4122 | fac=quotM[2]; |
---|
4123 | if(quotM[3]==1) |
---|
4124 | { |
---|
4125 | return(quotM[1],f0,f,fac); |
---|
4126 | } |
---|
4127 | while(special_ideals_equal(iold,quotM[1])==0) |
---|
4128 | { |
---|
4129 | f=f*quotM[3]; |
---|
4130 | iold=quotM[1]; |
---|
4131 | quotM=minquot(quotM); |
---|
4132 | } |
---|
4133 | return(quotM[1],f0,f,fac); // the quadrupel ((I:p),f0,f, irr. factors of f) |
---|
4134 | } |
---|
4135 | |
---|
4136 | ///////////////////////////////////////////////////// |
---|
4137 | // proc minsat_ppd |
---|
4138 | // input: a standard basis of an ideal I and a polynomial p |
---|
4139 | // output: a standard basis IS of the saturation of I w.r. to p, |
---|
4140 | // the maximal squarefree factor f0 of p, |
---|
4141 | // the "minimal divisor" f of f0 such that the saturation of |
---|
4142 | // I w.r. to f equals the saturation of I w.r. to f0 (which is IS), |
---|
4143 | // the irreducible factors of f |
---|
4144 | ////////////////////////////////////////////////////////// |
---|
4145 | |
---|
4146 | |
---|
4147 | proc minsat_ppd(ideal SI, ideal fac) |
---|
4148 | { |
---|
4149 | fac=sort(fac)[1]; |
---|
4150 | int i,k; |
---|
4151 | poly f0=1; |
---|
4152 | for(i=ncols(fac);i>=1;i--) |
---|
4153 | { |
---|
4154 | f0=f0*fac[i]; |
---|
4155 | } |
---|
4156 | poly f=1; |
---|
4157 | ideal iold; |
---|
4158 | list quotM; |
---|
4159 | quotM[1]=SI; |
---|
4160 | quotM[2]=fac; |
---|
4161 | quotM[3]=f0; |
---|
4162 | // we deal seperately with the first quotient; |
---|
4163 | // factors, which do not contribute to this one, |
---|
4164 | // are omitted |
---|
4165 | iold=quotM[1]; |
---|
4166 | quotM=minquot(quotM); |
---|
4167 | fac=quotM[2]; |
---|
4168 | if(quotM[3]==1) |
---|
4169 | { |
---|
4170 | return(quotM[1],f0,f,fac); |
---|
4171 | } |
---|
4172 | while(special_ideals_equal(iold,quotM[1])==0) |
---|
4173 | { |
---|
4174 | f=f*quotM[3]; |
---|
4175 | iold=quotM[1]; |
---|
4176 | quotM=minquot(quotM); |
---|
4177 | k++; |
---|
4178 | } |
---|
4179 | return(quotM[1],f0,f,fac); // the quadrupel ((I:p),f0,f, irr. factors of f) |
---|
4180 | } |
---|
4181 | ///////////////////////////////////////////////////////////////// |
---|
4182 | // proc minquot |
---|
4183 | // input: a list with 3 components: a standard basis |
---|
4184 | // of an ideal I, a set of irreducible polynomials, and |
---|
4185 | // there product f0 |
---|
4186 | // output: a standard basis of the ideal (I:f0), the irreducible |
---|
4187 | // factors of the "minimal divisor" f of f0 with (I:f0) = (I:f), |
---|
4188 | // the "minimal divisor" f |
---|
4189 | ///////////////////////////////////////////////////////////////// |
---|
4190 | |
---|
4191 | proc minquot(list tsil) |
---|
4192 | { |
---|
4193 | int i,j,k,action; |
---|
4194 | ideal verg; |
---|
4195 | list l; |
---|
4196 | poly g; |
---|
4197 | ideal laedi=tsil[1]; |
---|
4198 | ideal fac=tsil[2]; |
---|
4199 | poly f=tsil[3]; |
---|
4200 | |
---|
4201 | //std |
---|
4202 | // ideal star=quotient(laedi,f); |
---|
4203 | // star=std(star); |
---|
4204 | option(returnSB); |
---|
4205 | ideal star=quotient(laedi,f); |
---|
4206 | option(noreturnSB); |
---|
4207 | if(special_ideals_equal(laedi,star)==1) |
---|
4208 | { |
---|
4209 | return(laedi,ideal(1),1); |
---|
4210 | } |
---|
4211 | action=1; |
---|
4212 | while(action==1) |
---|
4213 | { |
---|
4214 | if(size(fac)==1) |
---|
4215 | { |
---|
4216 | action=0; |
---|
4217 | break; |
---|
4218 | } |
---|
4219 | for(i=1;i<=size(fac);i++) |
---|
4220 | { |
---|
4221 | g=1; |
---|
4222 | for(j=1;j<=size(fac);j++) |
---|
4223 | { |
---|
4224 | if(i!=j) |
---|
4225 | { |
---|
4226 | g=g*fac[j]; |
---|
4227 | } |
---|
4228 | } |
---|
4229 | //std |
---|
4230 | // verg=quotient(laedi,g); |
---|
4231 | // verg=std(verg); |
---|
4232 | option(returnSB); |
---|
4233 | verg=quotient(laedi,g); |
---|
4234 | option(noreturnSB); |
---|
4235 | if(special_ideals_equal(verg,star)==1) |
---|
4236 | { |
---|
4237 | f=g; |
---|
4238 | fac[i]=0; |
---|
4239 | fac=simplify(fac,2); |
---|
4240 | break; |
---|
4241 | } |
---|
4242 | if(i==size(fac)) |
---|
4243 | { |
---|
4244 | action=0; |
---|
4245 | } |
---|
4246 | } |
---|
4247 | } |
---|
4248 | l=star,fac,f; |
---|
4249 | return(l); |
---|
4250 | } |
---|
4251 | ///////////////////////////////////////////////// |
---|
4252 | // proc special_ideals_equal |
---|
4253 | // input: standard bases of ideal k1 and k2 such that |
---|
4254 | // k1 is contained in k2, or k2 is contained ink1 |
---|
4255 | // output: 1, if k1 equals k2, 0 otherwise |
---|
4256 | ////////////////////////////////////////////////// |
---|
4257 | |
---|
4258 | proc special_ideals_equal( ideal k1, ideal k2) |
---|
4259 | { |
---|
4260 | int j; |
---|
4261 | if(size(k1)==size(k2)) |
---|
4262 | { |
---|
4263 | for(j=1;j<=size(k1);j++) |
---|
4264 | { |
---|
4265 | if(leadexp(k1[j])!=leadexp(k2[j])) |
---|
4266 | { |
---|
4267 | return(0); |
---|
4268 | } |
---|
4269 | } |
---|
4270 | return(1); |
---|
4271 | } |
---|
4272 | return(0); |
---|
4273 | } |
---|
4274 | |
---|
4275 | |
---|
4276 | |
---|