1 | //////////////////////////////////////////////////////////////////////////////// |
---|
2 | version="$Id$"; |
---|
3 | category = "Commutative Algebra"; |
---|
4 | info=" |
---|
5 | LIBRARY: primdecint.lib primary decomposition of an ideal in the polynomial |
---|
6 | ring over the integers |
---|
7 | |
---|
8 | AUTHORS: G. Pfister pfister@mathematik.uni-kl.de |
---|
9 | @* A. Sadiq afshanatiq@gmail.com |
---|
10 | @* S. Steidel steidel@mathematik.uni-kl.de |
---|
11 | |
---|
12 | OVERVIEW: |
---|
13 | |
---|
14 | A library for computing the primary decomposition of an ideal in the |
---|
15 | polynomial ring over the integers, Z[x_1,...,x_n]. |
---|
16 | The first procedure 'primdecZ' can be used in parallel. |
---|
17 | |
---|
18 | PROCEDURES: |
---|
19 | primdecZ(I); compute the primary decomposition of I |
---|
20 | minAssZ(I); compute the minimal associated primes of I |
---|
21 | radicalZ(I); compute the radical of I |
---|
22 | heightZ(I); compute the height of I |
---|
23 | equidimZ(I); compute the equidimensional part of I |
---|
24 | intersectZ(I,J) compute the intersection of I and J |
---|
25 | "; |
---|
26 | |
---|
27 | LIB "crypto.lib"; |
---|
28 | |
---|
29 | //////////////////////////////////////////////////////////////////////////////// |
---|
30 | |
---|
31 | proc primdecZ(ideal I, list #) |
---|
32 | "USAGE: primdecZ(I[, n]); I ideal, n integer (number of processors) |
---|
33 | NOTE: If size(#) > 0, then #[1] is the number of available processors for |
---|
34 | the computation. |
---|
35 | RETURN: a list pr of primary ideals and their associated primes: |
---|
36 | @format |
---|
37 | pr[i][1] the i-th primary component, |
---|
38 | pr[i][2] the i-th prime component. |
---|
39 | @end format |
---|
40 | EXAMPLE: example primdecZ; shows an example |
---|
41 | " |
---|
42 | { |
---|
43 | if(size(I)==0){return(list(ideal(0),ideal(0)));} |
---|
44 | |
---|
45 | //-------------------- Initialize optional parameters ------------------------ |
---|
46 | if(size(#) > 0) |
---|
47 | { |
---|
48 | if(size(#) == 1) |
---|
49 | { |
---|
50 | int n = #[1]; |
---|
51 | ideal TES = 1; |
---|
52 | } |
---|
53 | if(size(#) == 2) |
---|
54 | { |
---|
55 | int n = #[1]; |
---|
56 | ideal TES = #[2]; |
---|
57 | } |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | int n = 1; |
---|
62 | ideal TES = 1; |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | if(deg(I[1]) == 0) |
---|
67 | { |
---|
68 | ideal J = I; |
---|
69 | } |
---|
70 | else |
---|
71 | { |
---|
72 | ideal J = stdZ(I); |
---|
73 | } |
---|
74 | |
---|
75 | ideal K,N; |
---|
76 | def R=basering; |
---|
77 | number s; |
---|
78 | list rl=ringlist(R); |
---|
79 | int i,j,p,m,ex,nu,k_link; |
---|
80 | list P,B,IS; |
---|
81 | ideal Q,JJ; |
---|
82 | ideal TQ=1; |
---|
83 | if(deg(J[1])==0) |
---|
84 | { |
---|
85 | //=== I intersected with Z is not zero |
---|
86 | list rp=rl; |
---|
87 | rp[1]=0; |
---|
88 | //=== q is generator of I intersect Z |
---|
89 | number q=leadcoef(J[1]); |
---|
90 | def Rhelp=ring(rp); |
---|
91 | setring Rhelp; |
---|
92 | number q=imap(R,q); |
---|
93 | //=== computes the primes occuring in a generator of I intersect Z |
---|
94 | |
---|
95 | list L = primefactors(q); |
---|
96 | |
---|
97 | list A; |
---|
98 | ideal J = imap(R,J); |
---|
99 | |
---|
100 | for(j=1;j<=size(L[2]);j++) |
---|
101 | { |
---|
102 | if(L[2][j] > 1){ ex = 1; break; } |
---|
103 | } |
---|
104 | |
---|
105 | if(printlevel >= 10) |
---|
106 | { |
---|
107 | "n = "+string(n); |
---|
108 | "size(L[2]) = "+string(size(L[2])); |
---|
109 | } |
---|
110 | |
---|
111 | int RT = rtimer; |
---|
112 | if((n > 1) && (n < size(L[2]))) |
---|
113 | { |
---|
114 | |
---|
115 | //----- Create n1 links l(1),...,l(n1), open all of them and compute --------- |
---|
116 | //----- standard basis for the primes L[1][2],...,L[1][n + 1]. --------- |
---|
117 | |
---|
118 | for(i = 1; i <= n; i++) |
---|
119 | { |
---|
120 | p=int(L[1][i + 1]); |
---|
121 | nu=int(L[2][i + 1]); |
---|
122 | //link l(i) = "MPtcp:fork"; |
---|
123 | link l(i) = "ssi:fork"; |
---|
124 | open(l(i)); |
---|
125 | write(l(i), quote(modp(eval(J), eval(p), eval(nu)))); |
---|
126 | } |
---|
127 | |
---|
128 | p = int(L[1][1]); |
---|
129 | nu = int(L[2][1]); |
---|
130 | int t = timer; |
---|
131 | A[size(A)+1] = modp(J, p, nu); |
---|
132 | t = timer - t; |
---|
133 | if(t > 60) { t = 60; } |
---|
134 | int i_sleep = system("sh", "sleep "+string(t)); |
---|
135 | |
---|
136 | j = n + 2; |
---|
137 | |
---|
138 | while(j <= size(L[2]) + 1) |
---|
139 | { |
---|
140 | for(i = 1; i <= n; i++) |
---|
141 | { |
---|
142 | //=== ask if link l(i) is ready otherwise sleep for t seconds |
---|
143 | if(status(l(i), "read", "ready")) |
---|
144 | { |
---|
145 | //=== read the result from l(i) |
---|
146 | A[size(A)+1] = read(l(i)); |
---|
147 | |
---|
148 | if(j <= size(L[2])) |
---|
149 | { |
---|
150 | p=int(L[1][j]); |
---|
151 | nu=int(L[2][j]); |
---|
152 | write(l(i), quote(modp(eval(J), eval(p), eval(nu)))); |
---|
153 | j++; |
---|
154 | } |
---|
155 | else |
---|
156 | { |
---|
157 | k_link++; |
---|
158 | close(l(i)); |
---|
159 | } |
---|
160 | } |
---|
161 | } |
---|
162 | //=== k_link describes the number of closed links |
---|
163 | if(k_link == n) |
---|
164 | { |
---|
165 | j++; |
---|
166 | } |
---|
167 | i_sleep = system("sh", "sleep "+string(t)); |
---|
168 | } |
---|
169 | |
---|
170 | } |
---|
171 | else |
---|
172 | { |
---|
173 | for(j=1;j<=size(L[2]);j++) |
---|
174 | { |
---|
175 | A[size(A)+1] = modp(J, L[1][j], L[2][j]); |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | setring R; |
---|
180 | list A = imap(Rhelp,A); |
---|
181 | if(printlevel >= 10) |
---|
182 | { |
---|
183 | "A is computed in "+string(rtimer - RT)+" seconds."; |
---|
184 | } |
---|
185 | for(i=1;i<=size(A);i++) |
---|
186 | { |
---|
187 | //=== computes for all p in L the minimal associated primes of |
---|
188 | //=== IZ/p[variables] |
---|
189 | p = int(A[i][2]); |
---|
190 | if(printlevel >= 10) |
---|
191 | { |
---|
192 | "p = "+string(p); |
---|
193 | RT = rtimer; |
---|
194 | } |
---|
195 | nu = int(A[i][3]); |
---|
196 | //=== maximal power of p dividing q, generator of I intersect Z |
---|
197 | s = p^nu; |
---|
198 | |
---|
199 | rp[1] = p; |
---|
200 | def S = ring(rp); |
---|
201 | setring S; |
---|
202 | ideal J = imap(R,J); |
---|
203 | setring R; |
---|
204 | |
---|
205 | if(nu>1) |
---|
206 | { |
---|
207 | //=== p is of multiplicity > 1 in q |
---|
208 | |
---|
209 | B = A[i][1]; |
---|
210 | for(j=1;j<=size(B);j++) |
---|
211 | { |
---|
212 | //=== the minimal associated primes of I |
---|
213 | K=B[j],p; |
---|
214 | K=stdZ(K); |
---|
215 | B[j]=K; |
---|
216 | } |
---|
217 | for(j=1;j<=size(B);j++) |
---|
218 | { |
---|
219 | K=B[j]; |
---|
220 | //=== compute maximal independent set for KZ/p[variables] |
---|
221 | |
---|
222 | setring S; |
---|
223 | J=imap(R,K); |
---|
224 | J=simplify(J,2); |
---|
225 | attrib(J,"isSB",1); |
---|
226 | IS=maxIndependSet(J); |
---|
227 | setring R; |
---|
228 | //=== computing the pseudo primary and extract it |
---|
229 | N=J,s; |
---|
230 | N=stdZ(N); |
---|
231 | Q=extractZ(N,j,IS,B); |
---|
232 | //=== test for useless primaries |
---|
233 | if(size(reduce(TES,Q))>0) |
---|
234 | { |
---|
235 | TQ=intersectZ(TQ,Q); |
---|
236 | //TQ=intersect(TQ,Q); |
---|
237 | P[size(P)+1]=list(Q,K); |
---|
238 | } |
---|
239 | } |
---|
240 | } |
---|
241 | else |
---|
242 | { |
---|
243 | //=== p is of multiplicity 1 in q we can compute the |
---|
244 | //=== primary decomposition directly |
---|
245 | |
---|
246 | B = A[i][1]; |
---|
247 | for(j=1;j<=size(B);j++) |
---|
248 | { |
---|
249 | K=B[j][2],p; |
---|
250 | K=stdZ(K); |
---|
251 | Q=B[j][1],p; |
---|
252 | Q=stdZ(Q); |
---|
253 | if(size(reduce(TES,Q))>0) |
---|
254 | { |
---|
255 | //TQ=intersectZ(TQ,Q); |
---|
256 | P[size(P)+1]=list(Q,K); |
---|
257 | } |
---|
258 | } |
---|
259 | if(ex) |
---|
260 | { |
---|
261 | JJ=imap(S,J); |
---|
262 | JJ=JJ,p; |
---|
263 | JJ=stdZ(JJ); |
---|
264 | TQ=intersectZ(TQ,JJ); |
---|
265 | //TQ=intersect(TQ,JJ); |
---|
266 | } |
---|
267 | } |
---|
268 | kill S; |
---|
269 | if(printlevel >= 10) |
---|
270 | { |
---|
271 | string(p)+" done in "+string(rtimer - RT)+" seconds."; |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | setring R; |
---|
276 | if(!ex){return(P);} |
---|
277 | J=stdZ(J); |
---|
278 | TQ=intersectZ(TQ,TES); |
---|
279 | //TQ=intersect(TQ,TES); |
---|
280 | if(size(reduce(TQ,J))!=0) |
---|
281 | { |
---|
282 | //=== taking care about embedded components |
---|
283 | K=stdZ(quotientZ(J,TQ)); |
---|
284 | ideal W=K; |
---|
285 | m++; |
---|
286 | while(size(reduce(intersectZ(W,TQ),J))!=0) |
---|
287 | //while(size(reduce(intersect(W,TQ),J))!=0) |
---|
288 | { |
---|
289 | //W=stdZ(addIdealZ(I,K^m)); |
---|
290 | W=stdZ(addIdealZ(I,specialPowerZ(K,m))); |
---|
291 | m++; |
---|
292 | } |
---|
293 | list E=primdecZ(W,n,TQ); |
---|
294 | for(i=1;i<=size(E);i++) |
---|
295 | { |
---|
296 | P[size(P)+1]=E[i]; |
---|
297 | } |
---|
298 | } |
---|
299 | return(P); |
---|
300 | } |
---|
301 | |
---|
302 | //==== the ideal intersected with Z is zero |
---|
303 | rl[1]=0; |
---|
304 | def Rhelp=ring(rl); |
---|
305 | setring Rhelp; |
---|
306 | ideal J=imap(R,J); |
---|
307 | J=std(J); |
---|
308 | //=== the primary decomposition over Q which gives the primary |
---|
309 | //=== decomposition of I:h for a suitable integer h |
---|
310 | list pr=primdecGTZ(J); |
---|
311 | for(i=1;i<=size(pr);i++) |
---|
312 | { |
---|
313 | pr[i]=list(std(pr[i][1]),std(pr[i][2])); |
---|
314 | } |
---|
315 | setring R; |
---|
316 | list pr=imap(Rhelp,pr); |
---|
317 | //=== intersection with Z[variables] |
---|
318 | for(i=1;i<=size(pr);i++) |
---|
319 | { |
---|
320 | pr[i]=list(coefZ(pr[i][1])[1],coefZ(pr[i][2])[1]); |
---|
321 | } |
---|
322 | //=== find h in Z such that I is the intersection of I:h and <I,h> |
---|
323 | //=== and I:h = IQ[variables] intersected with Z[varables] |
---|
324 | list H =coefZ(J); |
---|
325 | ideal Y=H[1]; |
---|
326 | int h=H[2]; |
---|
327 | J=J,h; |
---|
328 | //=== call primary decomposition over Z for <I,h> |
---|
329 | list M; |
---|
330 | if(h!=1) |
---|
331 | { |
---|
332 | M=primdecZ(J,n,Y); |
---|
333 | j=0; |
---|
334 | //=== remove useless primary ideals |
---|
335 | while(j<size(M)) |
---|
336 | { |
---|
337 | j++; |
---|
338 | M[j][1]=stdZ(M[j][1]); |
---|
339 | for(i=1;i<=size(pr);i++) |
---|
340 | { |
---|
341 | if(size(reduce(pr[i][1],M[j][1]))==0) |
---|
342 | { |
---|
343 | M=delete(M,j); |
---|
344 | j--; |
---|
345 | break; |
---|
346 | } |
---|
347 | } |
---|
348 | } |
---|
349 | for(i=1;i<=size(M);i++) |
---|
350 | { |
---|
351 | pr[size(pr)+1]=M[i]; |
---|
352 | } |
---|
353 | } |
---|
354 | return(pr); |
---|
355 | } |
---|
356 | example |
---|
357 | { "EXAMPLE:"; echo = 2; |
---|
358 | ring R=integer,(a,b,c,d),dp; |
---|
359 | ideal I1=9,a,b; |
---|
360 | ideal I2=3,c; |
---|
361 | ideal I3=11,2a,7b; |
---|
362 | ideal I4=13a2,17b4; |
---|
363 | ideal I5=9c5,6d5; |
---|
364 | ideal I6=17,a15,b15,c15,d15; |
---|
365 | ideal I=intersectZ(I1,I2); |
---|
366 | I=intersectZ(I,I3); |
---|
367 | I=intersectZ(I,I4); |
---|
368 | I=intersectZ(I,I5); |
---|
369 | I=intersectZ(I,I6); |
---|
370 | primdecZ(I); |
---|
371 | ideal J=intersectZ(ideal(17,a),ideal(17,a2,b)); |
---|
372 | primdecZ(J); |
---|
373 | ideal K=intersectZ(ideal(9,a+3),ideal(9,b+3)); |
---|
374 | primdecZ(K); |
---|
375 | } |
---|
376 | |
---|
377 | //////////////////////////////////////////////////////////////////////////////// |
---|
378 | |
---|
379 | proc minAssZ(ideal I) |
---|
380 | "USAGE: minAssZ(I); I ideal |
---|
381 | RETURN: a list pr of associated primes: |
---|
382 | EXAMPLE: example minAssZ; shows an example |
---|
383 | " |
---|
384 | { |
---|
385 | if(size(I)==0){return(list(ideal(0)));} |
---|
386 | if(deg(I[1])==0) |
---|
387 | { |
---|
388 | ideal J=I; |
---|
389 | } |
---|
390 | else |
---|
391 | { |
---|
392 | ideal J=stdZ(I); |
---|
393 | } |
---|
394 | ideal K; |
---|
395 | def R=basering; |
---|
396 | list rl=ringlist(R); |
---|
397 | int i,j,p,m; |
---|
398 | list P,B; |
---|
399 | if(deg(J[1])==0) |
---|
400 | { |
---|
401 | //=== I intersected with Z is not zero |
---|
402 | list rp=rl; |
---|
403 | rp[1]=0; |
---|
404 | number q=leadcoef(J[1]); |
---|
405 | def Rhelp=ring(rp); |
---|
406 | setring Rhelp; |
---|
407 | number q=imap(R,q); |
---|
408 | //=== computes the primes occuring in a generator of I intersect Z |
---|
409 | list L=PollardRho(q,5000,1); |
---|
410 | for(i=1;i<=size(L);i++) |
---|
411 | { |
---|
412 | //=== computes for all p in L the minimal associated primes of |
---|
413 | //=== IZ/p[variables] |
---|
414 | p=int(L[i]); |
---|
415 | setring R; |
---|
416 | rp[1]=p; |
---|
417 | def S=ring(rp); |
---|
418 | setring S; |
---|
419 | ideal J=imap(R,J); |
---|
420 | list A=minAssGTZ(J); |
---|
421 | setring R; |
---|
422 | B=imap(S,A); |
---|
423 | kill S; |
---|
424 | for(j=1;j<=size(B);j++) |
---|
425 | { |
---|
426 | //=== the minimal associated primes of I |
---|
427 | if(B[j][1]!=1) |
---|
428 | { |
---|
429 | K=B[j],p; |
---|
430 | K=stdZ(K); |
---|
431 | P[size(P)+1]=K; |
---|
432 | } |
---|
433 | } |
---|
434 | setring Rhelp; |
---|
435 | } |
---|
436 | setring R; |
---|
437 | return(P); |
---|
438 | } |
---|
439 | //==== the ideal intersected with Z is zero |
---|
440 | rl[1]=0; |
---|
441 | def Rhelp=ring(rl); |
---|
442 | setring Rhelp; |
---|
443 | ideal J=imap(R,J); |
---|
444 | J=std(J); |
---|
445 | //=== the primary decomposition over Q which gives the primary |
---|
446 | //=== decomposition of I:h for a suitable integer h |
---|
447 | list pr=minAssGTZ(J); |
---|
448 | for(i=1;i<=size(pr);i++) |
---|
449 | { |
---|
450 | pr[i]=std(pr[i]); |
---|
451 | } |
---|
452 | setring R; |
---|
453 | list pr=imap(Rhelp,pr); |
---|
454 | //=== intersection with Z[variables] |
---|
455 | for(i=1;i<=size(pr);i++) |
---|
456 | { |
---|
457 | pr[i]=coefZ(pr[i])[1]; |
---|
458 | } |
---|
459 | //=== find h in Z such that I is the intersection of I:h and I,h |
---|
460 | //=== and I:h =IQ[variables] intersected with Z[varables] |
---|
461 | list H=coefZ(J); |
---|
462 | int h=H[2]; |
---|
463 | J=J,h; |
---|
464 | //=== call associated primes over Z for I,h |
---|
465 | list M; |
---|
466 | if(h!=1) |
---|
467 | { |
---|
468 | M=minAssZ(J); |
---|
469 | //=== remove non-minimal primes |
---|
470 | j=0; |
---|
471 | while(j<size(M)) |
---|
472 | { |
---|
473 | j++; |
---|
474 | M[j]=stdZ(M[j]); |
---|
475 | for(i=1;i<=size(pr);i++) |
---|
476 | { |
---|
477 | if(size(reduce(pr[i],M[j]))==0) |
---|
478 | { |
---|
479 | M=delete(M,j); |
---|
480 | j--; |
---|
481 | break; |
---|
482 | } |
---|
483 | } |
---|
484 | } |
---|
485 | for(i=1;i<=size(M);i++) |
---|
486 | { |
---|
487 | pr[size(pr)+1]=M[i]; |
---|
488 | } |
---|
489 | } |
---|
490 | return(pr); |
---|
491 | } |
---|
492 | example |
---|
493 | { "EXAMPLE:"; echo = 2; |
---|
494 | ring R=integer,(a,b,c,d),dp; |
---|
495 | ideal I1=9,a,b; |
---|
496 | ideal I2=3,c; |
---|
497 | ideal I3=11,2a,7b; |
---|
498 | ideal I4=13a2,17b4; |
---|
499 | ideal I5=9c5,6d5; |
---|
500 | ideal I6=17,a15,b15,c15,d15; |
---|
501 | ideal I=intersectZ(I1,I2); |
---|
502 | I=intersectZ(I,I3); |
---|
503 | I=intersectZ(I,I4); |
---|
504 | I=intersectZ(I,I5); |
---|
505 | I=intersectZ(I,I6); |
---|
506 | minAssZ(I); |
---|
507 | ideal J=intersectZ(ideal(17,a),ideal(17,a2,b)); |
---|
508 | minAssZ(J); |
---|
509 | ideal K=intersectZ(ideal(9,a+3),ideal(9,b+3)); |
---|
510 | minAssZ(K); |
---|
511 | } |
---|
512 | |
---|
513 | //////////////////////////////////////////////////////////////////////////////// |
---|
514 | |
---|
515 | proc heightZ(ideal I) |
---|
516 | "USAGE: heightZ(I); I ideal |
---|
517 | RETURN: the height of the input ideal |
---|
518 | EXAMPLE: example heightZ; shows an example |
---|
519 | " |
---|
520 | { |
---|
521 | if(size(I)==0){return(0);} |
---|
522 | if(deg(I[1])==0) |
---|
523 | { |
---|
524 | ideal J=I; |
---|
525 | } |
---|
526 | else |
---|
527 | { |
---|
528 | ideal J=stdZ(I); |
---|
529 | } |
---|
530 | ideal K=1; |
---|
531 | def R=basering; |
---|
532 | list rl=ringlist(R); |
---|
533 | int i,j,p,m; |
---|
534 | list P; |
---|
535 | ideal B; |
---|
536 | if(deg(J[1])==0) |
---|
537 | { |
---|
538 | //=== I intersected with Z is not zero |
---|
539 | m=nvars(R); |
---|
540 | list rp=rl; |
---|
541 | rp[1]=0; |
---|
542 | number q=leadcoef(J[1]); |
---|
543 | def Rhelp=ring(rp); |
---|
544 | setring Rhelp; |
---|
545 | number q=imap(R,q); |
---|
546 | //=== computes the primes occuring in a generator of I intersect Z |
---|
547 | list L=PollardRho(q,5000,1); |
---|
548 | for(i=1;i<=size(L);i++) |
---|
549 | { |
---|
550 | //=== computes for all p in L the std of IZ/p[variables] |
---|
551 | p=int(L[i]); |
---|
552 | setring R; |
---|
553 | rp[1]=p; |
---|
554 | def S=ring(rp); |
---|
555 | setring S; |
---|
556 | ideal J=imap(R,J); |
---|
557 | j=nvars(R)-dim(std(J)); |
---|
558 | if(j<m){m=j;} |
---|
559 | setring Rhelp; |
---|
560 | kill S; |
---|
561 | } |
---|
562 | setring R; |
---|
563 | return(m+1); |
---|
564 | } |
---|
565 | //==== the ideal intersected with Z is zero |
---|
566 | rl[1]=0; |
---|
567 | def Rhelp=ring(rl); |
---|
568 | setring Rhelp; |
---|
569 | ideal J=imap(R,J); |
---|
570 | J=std(J); |
---|
571 | m=nvars(R)-dim(J); |
---|
572 | //=== the height over Q |
---|
573 | //=== of I:h for a suitable integer h |
---|
574 | setring R; |
---|
575 | //=== find h in Z such that I is the intersection of I:h and I,h |
---|
576 | //=== and I:h =IQ[variables] intersected with Z[varables] |
---|
577 | list H=coefZ(J); |
---|
578 | int h=H[2]; |
---|
579 | J=J,h; |
---|
580 | //=== call height over Z for I,h |
---|
581 | if(h!=1) |
---|
582 | { |
---|
583 | j=heightZ(J); |
---|
584 | if(j<m){m=j;} |
---|
585 | } |
---|
586 | return(m); |
---|
587 | } |
---|
588 | example |
---|
589 | { "EXAMPLE:"; echo = 2; |
---|
590 | ring R=integer,(a,b,c,d),dp; |
---|
591 | ideal I1=9,a,b; |
---|
592 | ideal I2=3,c; |
---|
593 | ideal I3=11,2a,7b; |
---|
594 | ideal I4=13a2,17b4; |
---|
595 | ideal I5=9c5,6d5; |
---|
596 | ideal I6=17,a15,b15,c15,d15; |
---|
597 | ideal I=intersectZ(I1,I2); |
---|
598 | I=intersectZ(I,I3); |
---|
599 | I=intersectZ(I,I4); |
---|
600 | I=intersectZ(I,I5); |
---|
601 | I=intersectZ(I,I6); |
---|
602 | heightZ(I); |
---|
603 | } |
---|
604 | |
---|
605 | //////////////////////////////////////////////////////////////////////////////// |
---|
606 | |
---|
607 | proc radicalZ(ideal I) |
---|
608 | "USAGE: radicalZ(I); I ideal |
---|
609 | RETURN: the radcal of the input ideal |
---|
610 | EXAMPLE: example radicalZ; shows an example |
---|
611 | " |
---|
612 | { |
---|
613 | if(size(I)==0){return(ideal(0));} |
---|
614 | if(deg(I[1])==0) |
---|
615 | { |
---|
616 | ideal J=I; |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | ideal J=stdZ(I); |
---|
621 | } |
---|
622 | ideal K=1; |
---|
623 | def R=basering; |
---|
624 | list rl=ringlist(R); |
---|
625 | int i,j,p,m; |
---|
626 | list P; |
---|
627 | ideal B; |
---|
628 | if(deg(J[1])==0) |
---|
629 | { |
---|
630 | //=== I intersected with Z is not zero |
---|
631 | list rp=rl; |
---|
632 | rp[1]=0; |
---|
633 | number q=leadcoef(J[1]); |
---|
634 | def Rhelp=ring(rp); |
---|
635 | setring Rhelp; |
---|
636 | number q=imap(R,q); |
---|
637 | //=== computes the primes occuring in a generator of I intersect Z |
---|
638 | list L=PollardRho(q,5000,1); |
---|
639 | for(i=1;i<=size(L);i++) |
---|
640 | { |
---|
641 | //=== computes for all p in L the radical of IZ/p[variables] |
---|
642 | p=int(L[i]); |
---|
643 | setring R; |
---|
644 | rp[1]=p; |
---|
645 | def S=ring(rp); |
---|
646 | setring S; |
---|
647 | ideal J=imap(R,J); |
---|
648 | ideal A=radical(J); |
---|
649 | setring R; |
---|
650 | B=imap(S,A); |
---|
651 | kill S; |
---|
652 | B=B,p; |
---|
653 | B=stdZ(B); |
---|
654 | K=stdZ(intersectZ(K,B)); |
---|
655 | //K=stdZ(intersect(K,B)); |
---|
656 | setring Rhelp; |
---|
657 | } |
---|
658 | setring R; |
---|
659 | return(K); |
---|
660 | } |
---|
661 | //==== the ideal intersected with Z is zero |
---|
662 | rl[1]=0; |
---|
663 | def Rhelp=ring(rl); |
---|
664 | setring Rhelp; |
---|
665 | ideal J=imap(R,J); |
---|
666 | J=std(J); |
---|
667 | //=== the radical over Q which gives the radical |
---|
668 | //=== of I:h for a suitable integer h |
---|
669 | ideal K=std(radical(J)); |
---|
670 | setring R; |
---|
671 | K=imap(Rhelp,K); |
---|
672 | //=== intersection with Z[variables] |
---|
673 | K=coefZ(K)[1]; |
---|
674 | //=== find h in Z such that I is the intersection of I:h and I,h |
---|
675 | //=== and I:h =IQ[variables] intersected with Z[varables] |
---|
676 | list H=coefZ(J); |
---|
677 | int h=H[2]; |
---|
678 | J=J,h; |
---|
679 | //=== call radical over Z for I,h |
---|
680 | if(h!=1) |
---|
681 | { |
---|
682 | ideal M=radicalZ(J); |
---|
683 | K=intersectZ(K,M); |
---|
684 | //K=intersect(K,M); |
---|
685 | } |
---|
686 | return(K); |
---|
687 | } |
---|
688 | example |
---|
689 | { "EXAMPLE:"; echo = 2; |
---|
690 | ring R=integer,(a,b,c,d),dp; |
---|
691 | ideal I1=9,a,b; |
---|
692 | ideal I2=3,c; |
---|
693 | ideal I3=11,2a,7b; |
---|
694 | ideal I4=13a2,17b4; |
---|
695 | ideal I5=9c5,6d5; |
---|
696 | ideal I6=17,a15,b15,c15,d15; |
---|
697 | ideal I=intersectZ(I1,I2); |
---|
698 | I=intersectZ(I,I3); |
---|
699 | I=intersectZ(I,I4); |
---|
700 | I=intersectZ(I,I5); |
---|
701 | I=intersectZ(I,I6); |
---|
702 | radicalZ(I); |
---|
703 | ideal J=intersectZ(ideal(17,a),ideal(17,a2,b)); |
---|
704 | radicalZ(J); |
---|
705 | } |
---|
706 | |
---|
707 | //////////////////////////////////////////////////////////////////////////////// |
---|
708 | |
---|
709 | proc equidimZ(ideal I) |
---|
710 | "USAGE: equidimZ(I); I ideal |
---|
711 | RETURN: the part of minimal height |
---|
712 | EXAMPLE: example equidimZ; shows an example |
---|
713 | " |
---|
714 | { |
---|
715 | if(size(I)==0){return(ideal(0));} |
---|
716 | if(deg(I[1])==0) |
---|
717 | { |
---|
718 | ideal J=I; |
---|
719 | } |
---|
720 | else |
---|
721 | { |
---|
722 | ideal J=stdZ(I); |
---|
723 | } |
---|
724 | int he=heightZ(J); |
---|
725 | ideal K,N; |
---|
726 | def R=basering; |
---|
727 | number s; |
---|
728 | list rl=ringlist(R); |
---|
729 | int i,j,p,m,ex; |
---|
730 | list P,IS,B; |
---|
731 | ideal Q,JJ,E; |
---|
732 | ideal TQ=1; |
---|
733 | if(deg(J[1])==0) |
---|
734 | { |
---|
735 | //=== I intersected with Z is not zero |
---|
736 | list rp=rl; |
---|
737 | rp[1]=0; |
---|
738 | //=== generator of I intersect Z |
---|
739 | number q=leadcoef(J[1]); |
---|
740 | def Rhelp=ring(rp); |
---|
741 | setring Rhelp; |
---|
742 | number q=imap(R,q); |
---|
743 | number s; |
---|
744 | //=== computes the primes occuring in a generator of I intersect Z |
---|
745 | list L=PollardRho(q,5000,1); |
---|
746 | list Le; |
---|
747 | for(i=1;i<=size(L);i++) |
---|
748 | { |
---|
749 | L[i]=int(L[i]); |
---|
750 | p=int(L[i]); |
---|
751 | j=0; |
---|
752 | s=q; |
---|
753 | while((s mod p)==0) |
---|
754 | { |
---|
755 | j++; |
---|
756 | s=s/p; |
---|
757 | } |
---|
758 | Le[i]=j; |
---|
759 | } |
---|
760 | for(i=1;i<=size(L);i++) |
---|
761 | { |
---|
762 | //=== computes for all p in L the minimal associated primes of |
---|
763 | //=== IZ/p[variables] |
---|
764 | p=int(L[i]); |
---|
765 | j=Le[i]; |
---|
766 | setring R; |
---|
767 | //=== maximal power of p dividing q, generator of I intersect Z |
---|
768 | s=p^j; |
---|
769 | rp[1]=p; |
---|
770 | def S=ring(rp); |
---|
771 | setring S; |
---|
772 | ideal J=imap(R,J); |
---|
773 | J=std(J); |
---|
774 | if(nvars(R)-dim(J)+1==he) |
---|
775 | { |
---|
776 | if(j>1) |
---|
777 | { |
---|
778 | //=== p is of multiplicity >1 in q |
---|
779 | list A=minAssGTZ(J); |
---|
780 | j=0; |
---|
781 | while(j<size(A)) |
---|
782 | { |
---|
783 | j++; |
---|
784 | if(dim(std(A[j]))!=nvars(R)-he+1) |
---|
785 | { |
---|
786 | A=delete(A,j); |
---|
787 | j--; |
---|
788 | } |
---|
789 | } |
---|
790 | setring R; |
---|
791 | B=imap(S,A); |
---|
792 | for(j=1;j<=size(B);j++) |
---|
793 | { |
---|
794 | //=== the minimal associated primes of I |
---|
795 | K=B[j],p; |
---|
796 | K=stdZ(K); |
---|
797 | B[j]=K; |
---|
798 | } |
---|
799 | for(j=1;j<=size(B);j++) |
---|
800 | { |
---|
801 | K=B[j]; |
---|
802 | //=== compute maximal independent set for KZ/p[variables] |
---|
803 | setring S; |
---|
804 | J=imap(R,K); |
---|
805 | J=simplify(J,2); |
---|
806 | attrib(J,"isSB",1); |
---|
807 | IS=maxIndependSet(J); |
---|
808 | setring R; |
---|
809 | //=== computing the pseudo primary and extract it |
---|
810 | N=J,s; |
---|
811 | N=stdZ(N); |
---|
812 | Q=extractZ(N,j,IS,B); |
---|
813 | TQ=intersectZ(TQ,Q); |
---|
814 | //TQ=intersect(TQ,Q); |
---|
815 | } |
---|
816 | setring Rhelp; |
---|
817 | } |
---|
818 | else |
---|
819 | { |
---|
820 | //=== p is of multiplicity 1 in q we can compute the |
---|
821 | //=== equidimensional part directly |
---|
822 | ideal E=equidimMax(J); |
---|
823 | setring R; |
---|
824 | E=imap(S,E); |
---|
825 | E=E,p; |
---|
826 | E=stdZ(E); |
---|
827 | TQ=intersectZ(TQ,E); |
---|
828 | //TQ=intersect(TQ,E); |
---|
829 | } |
---|
830 | } |
---|
831 | kill S; |
---|
832 | setring Rhelp; |
---|
833 | } |
---|
834 | setring R; |
---|
835 | return(TQ); |
---|
836 | } |
---|
837 | //==== the ideal intersected with Z is zero |
---|
838 | rl[1]=0; |
---|
839 | def Rhelp=ring(rl); |
---|
840 | setring Rhelp; |
---|
841 | ideal J=imap(R,J); |
---|
842 | J=std(J); |
---|
843 | //=== the equidimensional part over Q which gives the equdimensional |
---|
844 | //=== part of I:h for a suitable integer h |
---|
845 | ideal E=1; |
---|
846 | if(nvars(R)-he==dim(J)) |
---|
847 | { |
---|
848 | E=std(equidimMax(J)); |
---|
849 | } |
---|
850 | setring R; |
---|
851 | E =imap(Rhelp,E); |
---|
852 | //=== intersection with Z[variables] |
---|
853 | E=coefZ(E)[1]; |
---|
854 | //=== find h in Z such that I is the intersection of I:h and I,h |
---|
855 | //=== and I:h =IQ[variables] intersected with Z[varables] |
---|
856 | int h =coefZ(J)[2]; |
---|
857 | J=J,h; |
---|
858 | //=== call equidimensional part over Z for I,h |
---|
859 | ideal M; |
---|
860 | if(h!=1) |
---|
861 | { |
---|
862 | M=equidimZ(J); |
---|
863 | if(he==heightZ(M)) |
---|
864 | { |
---|
865 | E=intersectZ(M,E); |
---|
866 | //E=intersect(M,E); |
---|
867 | } |
---|
868 | } |
---|
869 | return(E); |
---|
870 | } |
---|
871 | example |
---|
872 | { "EXAMPLE:"; echo = 2; |
---|
873 | ring R=integer,(a,b,c,d),dp; |
---|
874 | ideal I1=9,a,b; |
---|
875 | ideal I2=3,c; |
---|
876 | ideal I3=11,2a,7b; |
---|
877 | ideal I4=13a2,17b4; |
---|
878 | ideal I5=9c5,6d5; |
---|
879 | ideal I6=17,a15,b15,c15,d15; |
---|
880 | ideal I=intersectZ(I1,I2); |
---|
881 | I=intersectZ(I,I3); |
---|
882 | I=intersectZ(I,I4); |
---|
883 | I=intersectZ(I,I5); |
---|
884 | I=intersectZ(I,I6); |
---|
885 | equidimZ(I); |
---|
886 | } |
---|
887 | |
---|
888 | //////////////////////////////////////////////////////////////////////////////// |
---|
889 | |
---|
890 | proc intersectZ(ideal I, ideal J) |
---|
891 | "USAGE: intersectZ(I,J); I,J ideals |
---|
892 | RETURN: the intersection of the input ideals |
---|
893 | NOTE: this is needed because intersect(I,J) does not work, should be replaced |
---|
894 | by intersect later |
---|
895 | EXAMPLE: example intersectZ; shows an example |
---|
896 | { |
---|
897 | def R = basering; |
---|
898 | execute("ring S=integer,(t,"+varstr(R)+"),(dp(1),dp(nvars(R)));"); |
---|
899 | ideal I=imap(R,I); |
---|
900 | ideal J=imap(R,J); |
---|
901 | ideal K=addIdealZ(t*I,(1-t)*J); |
---|
902 | K=stdZ(K); |
---|
903 | int i; |
---|
904 | ideal L; |
---|
905 | for(i=1;i<=size(K);i++) |
---|
906 | { |
---|
907 | if(lead(K[i])/t==0){L[size(L)+1]=K[i];} |
---|
908 | } |
---|
909 | setring R; |
---|
910 | ideal L=imap(S,L); |
---|
911 | return(L); |
---|
912 | } |
---|
913 | example |
---|
914 | { "EXAMPLE:"; echo = 2; |
---|
915 | ring R=integer,(a,b,c,d),dp; |
---|
916 | ideal I1=9,a,b; |
---|
917 | ideal I2=3,c; |
---|
918 | ideal I3=11,2a,7b; |
---|
919 | ideal I4=13a2,17b4; |
---|
920 | ideal I5=9c5,6d5; |
---|
921 | ideal I6=17,a15,b15,c15,d15; |
---|
922 | ideal I=intersectZ(I1,I2); I; |
---|
923 | I=intersectZ(I,I3); I; |
---|
924 | I=intersectZ(I,I4); I; |
---|
925 | I=intersectZ(I,I5); I; |
---|
926 | I=intersectZ(I,I6); I; |
---|
927 | } |
---|
928 | |
---|
929 | //////////////////////////////////////////////////////////////////////////////// |
---|
930 | |
---|
931 | static proc modp(ideal J, int p, int nu) |
---|
932 | { |
---|
933 | //=== computes the minimal associated primes (if nu > 1) resp. the primary |
---|
934 | //=== decomposition (else) of J in Z/p and maps the result back to the basering |
---|
935 | def R = basering; |
---|
936 | list rp = ringlist(R); |
---|
937 | rp[1] = p; |
---|
938 | def Rp = ring(rp); |
---|
939 | setring Rp; |
---|
940 | ideal J = imap(R,J); |
---|
941 | if(nu > 1) |
---|
942 | { |
---|
943 | //=== p is of multiplicity > 1 in q |
---|
944 | list A = minAssGTZ(J); |
---|
945 | setring R; |
---|
946 | list A = imap(Rp,A); |
---|
947 | return(list(A,p,nu)); |
---|
948 | } |
---|
949 | else |
---|
950 | { |
---|
951 | list A = primdecGTZ(J); |
---|
952 | setring R; |
---|
953 | list A = imap(Rp,A); |
---|
954 | return(list(A,p,nu)); |
---|
955 | } |
---|
956 | } |
---|
957 | |
---|
958 | //////////////////////////////////////////////////////////////////////////////// |
---|
959 | |
---|
960 | static proc coefPrimeZ(ideal I) |
---|
961 | { |
---|
962 | //=== computes the primes occuring in the product of the leading coefficients |
---|
963 | //=== of I |
---|
964 | number h=1; |
---|
965 | int i; |
---|
966 | for(i=1;i<=size(I);i++) |
---|
967 | { |
---|
968 | h=h*leadcoef(I[i]); // besser machen (gleich zerlegen, |
---|
969 | // nicht ausmultiplizieren) |
---|
970 | } |
---|
971 | def R=basering; |
---|
972 | ring Rhelp=0,x,dp; |
---|
973 | number h=imap(R,h); |
---|
974 | list L=PollardRho(h,5000,1); |
---|
975 | for(i=1;i<=size(L);i++){L[i]=int(L[i]);} |
---|
976 | setring R; |
---|
977 | return(L); |
---|
978 | } |
---|
979 | |
---|
980 | //////////////////////////////////////////////////////////////////////////////// |
---|
981 | |
---|
982 | static proc coefZ(ideal I) |
---|
983 | { |
---|
984 | //=== assume IQ[variables]=<g_1,...,g_s>, Groebner basis, g_i in Z[variables] |
---|
985 | //=== computes an integer h such that |
---|
986 | //=== <g_1,...,g_s>Z[variables]:h^infinity = IQ[variables] intersected |
---|
987 | //=== with Z[variables] |
---|
988 | //=== returns a list with IQ[variables] intersected with Z[variables] and h |
---|
989 | int h=1; |
---|
990 | int i,e; |
---|
991 | ideal K=1; |
---|
992 | list L=coefPrimeZ(I); |
---|
993 | if(size(L)==0){return(list(I,1));} |
---|
994 | int d=1; |
---|
995 | while(d!=0) |
---|
996 | { |
---|
997 | i++; |
---|
998 | K=quotientOneZ(I,L[i]); |
---|
999 | if(size(reduce(K,I))!=0) |
---|
1000 | { |
---|
1001 | h=h*L[i]; |
---|
1002 | I=stdZ(K); |
---|
1003 | e=1; |
---|
1004 | } |
---|
1005 | if(i==size(L)) |
---|
1006 | { |
---|
1007 | i=0; |
---|
1008 | if(e) |
---|
1009 | { |
---|
1010 | e=0; |
---|
1011 | } |
---|
1012 | else |
---|
1013 | { |
---|
1014 | d=0; |
---|
1015 | } |
---|
1016 | } |
---|
1017 | } |
---|
1018 | if(h<0){h=-h;} |
---|
1019 | return(list(K,h)); |
---|
1020 | } |
---|
1021 | |
---|
1022 | //////////////////////////////////////////////////////////////////////////////// |
---|
1023 | |
---|
1024 | static proc specialPowerZ(ideal I, int m) |
---|
1025 | { |
---|
1026 | //=== computes the ideal generated by the m-th power of the generators of I |
---|
1027 | int i; |
---|
1028 | for(i=1;i<=size(I);i++) |
---|
1029 | { |
---|
1030 | I[i]=I[i]^m; |
---|
1031 | } |
---|
1032 | return(I); |
---|
1033 | } |
---|
1034 | |
---|
1035 | //////////////////////////////////////////////////////////////////////////////// |
---|
1036 | |
---|
1037 | static proc separatorsZ(int j, list B) |
---|
1038 | { |
---|
1039 | //=== computes s such that s is not in B[j] but s is in B[i] for all i!=j |
---|
1040 | int i,k; |
---|
1041 | poly s=1; |
---|
1042 | for(i=1;i<=size(B);i++) |
---|
1043 | { |
---|
1044 | if(i!=j) |
---|
1045 | { |
---|
1046 | for(k=1;k<=size(B[i]);k++) |
---|
1047 | { |
---|
1048 | if(reduce(B[i][k],B[j])!=0) |
---|
1049 | { |
---|
1050 | s=s*B[i][k]; |
---|
1051 | break; |
---|
1052 | } |
---|
1053 | } |
---|
1054 | } |
---|
1055 | } |
---|
1056 | return(s); |
---|
1057 | } |
---|
1058 | |
---|
1059 | //////////////////////////////////////////////////////////////////////////////// |
---|
1060 | |
---|
1061 | static proc extractZ(ideal J, int j, list L, list B) |
---|
1062 | { |
---|
1063 | //=== P is an associated prime of J, the corresponding primary ideal is |
---|
1064 | //=== computed, |
---|
1065 | //=== L is a list of maximal independent sets for P in Z/p[variables] |
---|
1066 | def R=basering; |
---|
1067 | ideal P=B[j]; |
---|
1068 | |
---|
1069 | //=== first compute a pseudo primary ideal I, radical of I is P |
---|
1070 | //=== method of Eisenbud |
---|
1071 | //ideal I=addIdealZ(J,specialPowerZ(P,20)); |
---|
1072 | |
---|
1073 | //=== method of Shimoyama-Yokoyama |
---|
1074 | poly s=separatorsZ(j,B); |
---|
1075 | ideal I=satZ(J,s); |
---|
1076 | //=== size(L)=0 means P is maximal ideal and I is primary |
---|
1077 | if(size(L)>0) |
---|
1078 | { |
---|
1079 | if(L[1][3]!=0) |
---|
1080 | { |
---|
1081 | //=== if u in x is an independent set of L then we compute a Groebner |
---|
1082 | //=== Basis in Z[u][x-u] |
---|
1083 | execute("ring S=integer,("+L[1][1]+"),lp;"); |
---|
1084 | ideal I=imap(R,I); |
---|
1085 | I=stdZ(I); |
---|
1086 | list rl=ringlist(S); |
---|
1087 | rl[1]=0; |
---|
1088 | def Shelp =ring(rl); |
---|
1089 | setring Shelp; |
---|
1090 | ideal I=imap(S,I); |
---|
1091 | I[1]=0; |
---|
1092 | I=simplify(I,2); |
---|
1093 | //=== this is our way to obtain the coefficients in Z[u] of the |
---|
1094 | //=== leading terms of the Groebner basis above |
---|
1095 | string quotring=prepareQuotientring(nvars(basering)-L[1][3]); |
---|
1096 | execute(quotring); |
---|
1097 | ideal I=imap(Shelp,I); |
---|
1098 | list C; |
---|
1099 | int i; |
---|
1100 | for(i=1;i<=size(I);i++) |
---|
1101 | { |
---|
1102 | C[i]=leadcoef(I[i]); |
---|
1103 | } |
---|
1104 | setring Shelp; |
---|
1105 | list C=imap(quring,C); |
---|
1106 | |
---|
1107 | setring R; |
---|
1108 | list C=imap(Shelp,C); |
---|
1109 | } |
---|
1110 | else |
---|
1111 | { |
---|
1112 | I=stdZ(I); |
---|
1113 | list C; |
---|
1114 | int i; |
---|
1115 | for(i=1;i<=size(I);i++) |
---|
1116 | { |
---|
1117 | C[i]=I[i]; |
---|
1118 | } |
---|
1119 | list rl=ringlist(R); |
---|
1120 | rl[1]=0; |
---|
1121 | def Shelp =ring(rl); |
---|
1122 | } |
---|
1123 | poly h=1; |
---|
1124 | for(i=1;i<=size(C);i++) |
---|
1125 | { |
---|
1126 | if(deg(C[i])>0){h=h*C[i];} // das muss noch besser gemacht werden, |
---|
1127 | // nicht ausmultiplizieren! |
---|
1128 | } |
---|
1129 | setring Shelp; |
---|
1130 | poly h=imap(R,h); |
---|
1131 | ideal fac=factorize(h,1); |
---|
1132 | setring R; |
---|
1133 | ideal fac=imap(Shelp,fac); |
---|
1134 | for(i=1;i<=size(fac);i++) |
---|
1135 | { |
---|
1136 | I=satZ(I,fac[i]); |
---|
1137 | } |
---|
1138 | } |
---|
1139 | I=stdZ(I); |
---|
1140 | return(I); |
---|
1141 | } |
---|
1142 | //////////////////////////////////////////////////////////////////////////////// |
---|
1143 | |
---|
1144 | static proc normalizeZ(ideal I) |
---|
1145 | { |
---|
1146 | //=== if I[1]=q in Z, it replaces all other coeffs of polys in I by there value |
---|
1147 | //=== mod q, std should do this automatically and then this procedure should be |
---|
1148 | //=== removed |
---|
1149 | if(deg(I[1])>0){return(I);} |
---|
1150 | int i,j; |
---|
1151 | number n; |
---|
1152 | poly p; |
---|
1153 | for(i=2;i<=size(I);i++) |
---|
1154 | { |
---|
1155 | j=1; |
---|
1156 | while(j<=size(I[i])) |
---|
1157 | { |
---|
1158 | n=leadcoef(I[i][j]) mod leadcoef(I[1]); |
---|
1159 | p=n*leadmonom(I[i][j]); |
---|
1160 | I[i]=I[i]-I[i][j]+p; |
---|
1161 | if(p!=0){j++;} |
---|
1162 | } |
---|
1163 | } |
---|
1164 | return(I); |
---|
1165 | } |
---|
1166 | |
---|
1167 | //////////////////////////////////////////////////////////////////////////////// |
---|
1168 | |
---|
1169 | static proc satZ(ideal I,poly h) |
---|
1170 | { |
---|
1171 | //=== saturates I by h |
---|
1172 | ideal J=quotientOneZ(I,h); |
---|
1173 | while(size(reduce(J,stdZ(I)))!=0) |
---|
1174 | { |
---|
1175 | I=J; |
---|
1176 | J=quotientOneZ(I,h); |
---|
1177 | J=normalizeZ(J); |
---|
1178 | } |
---|
1179 | return(J); |
---|
1180 | } |
---|
1181 | |
---|
1182 | //////////////////////////////////////////////////////////////////////////////// |
---|
1183 | |
---|
1184 | static proc prepareQuotientring (int nnp) |
---|
1185 | { |
---|
1186 | //=== this is from primdec.lib, it is static there, should be imported later |
---|
1187 | //=== if it is no more static |
---|
1188 | ideal @ih,@jh; |
---|
1189 | int npar=npars(basering); |
---|
1190 | int @n; |
---|
1191 | |
---|
1192 | string quotring= "ring quring = ("+charstr(basering); |
---|
1193 | for(@n=nnp+1;@n<=nvars(basering);@n++) |
---|
1194 | { |
---|
1195 | quotring=quotring+",var("+string(@n)+")"; |
---|
1196 | @ih=@ih+var(@n); |
---|
1197 | } |
---|
1198 | |
---|
1199 | quotring=quotring+"),(var(1)"; |
---|
1200 | @jh=@jh+var(1); |
---|
1201 | for(@n=2;@n<=nnp;@n++) |
---|
1202 | { |
---|
1203 | quotring=quotring+",var("+string(@n)+")"; |
---|
1204 | @jh=@jh+var(@n); |
---|
1205 | } |
---|
1206 | quotring=quotring+"),(C,lp);"; |
---|
1207 | |
---|
1208 | return(quotring); |
---|
1209 | } |
---|
1210 | |
---|
1211 | //////////////////////////////////////////////////////////////////////////////// |
---|
1212 | |
---|
1213 | static proc maxIndependSet (ideal j) |
---|
1214 | { |
---|
1215 | //=== this is from primdec.lib, it is static there, should be imported later |
---|
1216 | //=== if it is no more static |
---|
1217 | int n,k,di; |
---|
1218 | |
---|
1219 | list resu,hilf; |
---|
1220 | if(size(j)==0) |
---|
1221 | { |
---|
1222 | resu[1]=varstr(basering); |
---|
1223 | resu[2]=ordstr(basering); |
---|
1224 | resu[3]=0; |
---|
1225 | return(list(resu)); |
---|
1226 | } |
---|
1227 | string var1,var2; |
---|
1228 | list v=indepSet(j,0); |
---|
1229 | |
---|
1230 | for(n=1;n<=size(v);n++) |
---|
1231 | { |
---|
1232 | di=0; |
---|
1233 | var1=""; |
---|
1234 | var2=""; |
---|
1235 | for(k=1;k<=size(v[n]);k++) |
---|
1236 | { |
---|
1237 | if(v[n][k]!=0) |
---|
1238 | { |
---|
1239 | di++; |
---|
1240 | var2=var2+"var("+string(k)+"),"; |
---|
1241 | } |
---|
1242 | else |
---|
1243 | { |
---|
1244 | var1=var1+"var("+string(k)+"),"; |
---|
1245 | } |
---|
1246 | } |
---|
1247 | if(di>0) |
---|
1248 | { |
---|
1249 | var1=var1+var2; |
---|
1250 | var1=var1[1..size(var1)-1]; |
---|
1251 | hilf[1]=var1; |
---|
1252 | hilf[2]="lp"; |
---|
1253 | hilf[3]=di; |
---|
1254 | resu[n]=hilf; |
---|
1255 | } |
---|
1256 | else |
---|
1257 | { |
---|
1258 | resu[n]=varstr(basering),ordstr(basering),0; |
---|
1259 | } |
---|
1260 | } |
---|
1261 | return(resu); |
---|
1262 | } |
---|
1263 | |
---|
1264 | //////////////////////////////////////////////////////////////////////////////// |
---|
1265 | |
---|
1266 | static proc quotientOneZ(ideal I, poly f) |
---|
1267 | { |
---|
1268 | //=== this is needed because quotient(I,f) does not work properly, should be |
---|
1269 | //=== replaced by quotient later |
---|
1270 | def R=basering; |
---|
1271 | int i; |
---|
1272 | ideal K=intersectZ(I,ideal(f)); |
---|
1273 | //ideal K=intersect(I,ideal(f)); |
---|
1274 | //=== K[i]/f; does not work in rings with integer! This should be replaced |
---|
1275 | //=== later |
---|
1276 | execute("ring Rhelp=0,("+varstr(R)+"),dp;"); |
---|
1277 | ideal K=imap(R,K); |
---|
1278 | poly f=imap(R,f); |
---|
1279 | for(i=1;i<=size(K);i++) |
---|
1280 | { |
---|
1281 | K[i]=K[i]/f; |
---|
1282 | } |
---|
1283 | setring R; |
---|
1284 | K=imap(Rhelp,K); |
---|
1285 | return(K); |
---|
1286 | } |
---|
1287 | |
---|
1288 | //////////////////////////////////////////////////////////////////////////////// |
---|
1289 | |
---|
1290 | static proc quotientZ(ideal I, ideal J) |
---|
1291 | { |
---|
1292 | //=== this is needed because quotient(I,J) does not work properly, should be |
---|
1293 | //=== replaced by quotient later |
---|
1294 | int i; |
---|
1295 | ideal K=quotientOneZ(I,J[1]); |
---|
1296 | for(i=2;i<=size(J);i++) |
---|
1297 | { |
---|
1298 | K=intersectZ(K,quotientOneZ(I,J[i])); |
---|
1299 | //K=intersect(K,quotientOneZ(I,J[i])); |
---|
1300 | } |
---|
1301 | return(K); |
---|
1302 | } |
---|
1303 | |
---|
1304 | //////////////////////////////////////////////////////////////////////////////// |
---|
1305 | |
---|
1306 | static proc reduceZ(poly f, ideal I) |
---|
1307 | { |
---|
1308 | //=== this is needed because reduce(f,I) does not work properly, should be |
---|
1309 | //=== replaced by reduce later |
---|
1310 | if(f==0){return(f);} |
---|
1311 | def R=basering; |
---|
1312 | execute("ring Rhelp=0,("+varstr(R)+"),dp;"); |
---|
1313 | ideal I=imap(R,I); |
---|
1314 | poly f=imap(R,f); |
---|
1315 | int i,j; |
---|
1316 | poly m; |
---|
1317 | number n; |
---|
1318 | while(!i) |
---|
1319 | { |
---|
1320 | i=1; |
---|
1321 | j=0; |
---|
1322 | while(j<size(I)) |
---|
1323 | { |
---|
1324 | j++; |
---|
1325 | m=leadmonom(f)/leadmonom(I[j]); |
---|
1326 | if(m!=0) |
---|
1327 | { |
---|
1328 | n=leadcoef(f) mod leadcoef(I[j]); |
---|
1329 | if(n==0) |
---|
1330 | { |
---|
1331 | f=f-leadcoef(f)/leadcoef(I[j])*m*I[j]; |
---|
1332 | if(f==0){setring R;return(0);} |
---|
1333 | i=0; |
---|
1334 | break; |
---|
1335 | } |
---|
1336 | if(n!=leadcoef(f)) |
---|
1337 | { |
---|
1338 | f=f+(n-leadcoef(f))/leadcoef(I[j])*m*I[j]; |
---|
1339 | i=0; |
---|
1340 | break; |
---|
1341 | } |
---|
1342 | } |
---|
1343 | } |
---|
1344 | } |
---|
1345 | setring R; |
---|
1346 | f=imap(Rhelp,f); |
---|
1347 | return(lead(f)+reduceZ(f-lead(f),I)); |
---|
1348 | } |
---|
1349 | |
---|
1350 | //////////////////////////////////////////////////////////////////////////////// |
---|
1351 | |
---|
1352 | static proc stdZ(ideal I) |
---|
1353 | { |
---|
1354 | //=== this is needed because we want the leading coefficients to be positive |
---|
1355 | //=== otherwhise reduce gives wrong results! should be replaced later by std |
---|
1356 | I=simplify(I,2); |
---|
1357 | I=normalizeZ(I); |
---|
1358 | ideal J=std(I); |
---|
1359 | int i; |
---|
1360 | for(i=1;i<=size(J);i++) |
---|
1361 | { |
---|
1362 | if(leadcoef(J[i])<0){J[i]=-J[i];} |
---|
1363 | } |
---|
1364 | J=normalizeZ(J); |
---|
1365 | attrib(J,"isSB",1); |
---|
1366 | return(J); |
---|
1367 | } |
---|
1368 | |
---|
1369 | //////////////////////////////////////////////////////////////////////////////// |
---|
1370 | |
---|
1371 | static proc addIdealZ(ideal I,ideal J) |
---|
1372 | { |
---|
1373 | //=== this is needed because I+J does not work, should be replaced by + later |
---|
1374 | int i; |
---|
1375 | for(i=1;i<=size(J);i++) |
---|
1376 | { |
---|
1377 | I[size(I)+1]=J[i]; |
---|
1378 | } |
---|
1379 | return(I); |
---|
1380 | } |
---|
1381 | |
---|
1382 | //////////////////////////////////////////////////////////////////////////////// |
---|
1383 | |
---|
1384 | static proc testPrimaryZ(ideal I, list L) |
---|
1385 | { |
---|
1386 | //=== test whether I is the intersection of the primary ideals in L |
---|
1387 | int i; |
---|
1388 | ideal K=L[1][1]; |
---|
1389 | for(i=2;i<=size(L);i++) |
---|
1390 | { |
---|
1391 | K=intersectZ(K,L[i][1]); |
---|
1392 | //K=intersect(K,L[i][1]); |
---|
1393 | } |
---|
1394 | i=size(reduce(K,stdZ(I)))+size(reduce(I,stdZ(K))); |
---|
1395 | if(!i){return(1);} |
---|
1396 | return(0); |
---|
1397 | } |
---|
1398 | |
---|
1399 | //////////////////////////////////////////////////////////////////////////////// |
---|
1400 | |
---|
1401 | /* |
---|
1402 | Examples: |
---|
1403 | |
---|
1404 | //=== IQ[a,b,c,d,e,f,g] intersect Z[a,b,c,d,e,f,g] = I (takes some time) |
---|
1405 | ring R1=integer,(a,b,c,d,e,f,g),dp; |
---|
1406 | ideal I=a2+2de+2cf+2bg+a, |
---|
1407 | 2ab+e2+2df+2cg+b, |
---|
1408 | b2+2ac+2ef+2dg+c, |
---|
1409 | 2bc+2ad+f2+2eg+d, |
---|
1410 | c2+2bd+2ae+2fg+e, |
---|
1411 | 2cd+2be+2af+g2+f, |
---|
1412 | d2+2ce+2bf+2ag+g; |
---|
1413 | |
---|
1414 | ring R2=integer,(a,b,c,d,e,f,g),dp; |
---|
1415 | ideal I=181*32003, |
---|
1416 | a2+2de+2cf+2bg+a, |
---|
1417 | 2ab+e2+2df+2cg+b, |
---|
1418 | b2+2ac+2ef+2dg+c, |
---|
1419 | 2bc+2ad+f2+2eg+d, |
---|
1420 | c2+2bd+2ae+2fg+e, |
---|
1421 | 2cd+2be+2af+g2+f, |
---|
1422 | d2+2ce+2bf+2ag+g; |
---|
1423 | |
---|
1424 | ring R3=integer,(w,z,y,x),dp; |
---|
1425 | ideal I=xzw+(-y^2+y)*z^2, |
---|
1426 | (-x^2+x)*w^2+yzw, |
---|
1427 | ((y^4-2*y^3+y^2)*x-y^4+y^3)*z^3, |
---|
1428 | y2z2w+(-y*4+2*y^3-y^2)*z3; |
---|
1429 | |
---|
1430 | ring R4=integer,(w,z,y,x),dp; |
---|
1431 | ideal I=-2*yxzw+(-yx-y^2+y)*z^2, |
---|
1432 | xw^2-yz^2, |
---|
1433 | (yx^2-(2*y^2+2*y)*x+y^3-2*y^2+y)*z^3, |
---|
1434 | (-2*y^2+2*y)*z^2*w+(yx-3*y^2-y)*z^3; |
---|
1435 | |
---|
1436 | ring R5=integer,(x,y,z),dp; |
---|
1437 | ideal I=x2-y2-z2, |
---|
1438 | xy-z2, |
---|
1439 | y3+xz2-yz2+2z3+xy-z2, |
---|
1440 | -y2z2+2z4+x2-y2+z2, |
---|
1441 | y3z9+3y2z10+3yz11+z12-y2z2+2z4; |
---|
1442 | |
---|
1443 | ring R6=integer,(h, l, s, x, y, z),dp; //takes some time |
---|
1444 | ideal I=hl-l2-4ls+hy, |
---|
1445 | h2s-6ls3+h2z, |
---|
1446 | xh2-l2s-h3; |
---|
1447 | |
---|
1448 | ring R7=integer,(x,y,z),dp; |
---|
1449 | ideal I=x2-y2-(z+2)^2, |
---|
1450 | xy-(z+2)^2, |
---|
1451 | y3+x*(z+2)^2-y*(z+2)^2+2*(z+2)^3+xy-(z+2)^2, |
---|
1452 | -y^2*(z+2)^2+2*(z+2)^4+x2-y2+(z+2)^2, |
---|
1453 | y3z9+3y2z10+3yz11+z12-y2z2+2z4; |
---|
1454 | |
---|
1455 | ring R8=integer,(x,y,z),dp; |
---|
1456 | ideal I=x2-y2-(z+2)^2, |
---|
1457 | xy-(z+2)^2, |
---|
1458 | y3+x*(z+2)^2-y*(z+2)^2+2*(z+2)^3+xy-(z+2)^2, |
---|
1459 | -y^2*(z+2)^2+2*(z+2)^4+x2-y2+(z+2)^2, |
---|
1460 | y3z9+3y2z10+3yz11+z12-y2z2+2z4; |
---|
1461 | |
---|
1462 | ring R9=integer,(w,z,y,x),dp; |
---|
1463 | ideal I=630, |
---|
1464 | ((y^2-y)*x-y^3+y^2)*z^2, |
---|
1465 | (x-y)*zw, |
---|
1466 | (x-y^2)*zw+(-y^2+y)*z^2, |
---|
1467 | (-x^2+x)*w^2+(-yx+y)*zw; |
---|
1468 | |
---|
1469 | ring R10=integer,(w,z,y,x),dp; |
---|
1470 | ideal I=1260, |
---|
1471 | -yxzw+(-y^2+y)*z^2, |
---|
1472 | (-x^2+x)*w^2-yxzw, |
---|
1473 | ((-y^2+y)*x-y^3+2*y^2-y)*z^3, |
---|
1474 | (y^2-y)*z^2*w+(-y^2+y)*z^2*w+(-y^2+y)*z^3; |
---|
1475 | |
---|
1476 | ring R11=integer,(w,z,y,x),dp; |
---|
1477 | ideal I=(4*y^2*x^2+(4*y^3+4*y^2-y)*x-y^2-y)*z^2, |
---|
1478 | (x+y+1)*zw+(-4*y^2*x-4*y^3-4*y^2)*z^2, |
---|
1479 | (-x-2*y^2 - 2*y - 1)*zw + (8*y^3*x + 8*y^4 + 8*y^3 + 2*y^2+y)*z^2, |
---|
1480 | ((y^3 + y^2)*x - y^2 - y)*z^2, |
---|
1481 | (y +1)*zw + (-y^3 -y^2)*z^2, |
---|
1482 | (x + 1)*zw +(- y^2 -y)*z^2, |
---|
1483 | (x^2 +x)*w^2 + (-yx - y)*zw; |
---|
1484 | |
---|
1485 | ring R12=integer,(w,z,y,x),dp; |
---|
1486 | ideal I=72, |
---|
1487 | ((y^3 + y^2)*x - y^2 - y)*z^2, |
---|
1488 | (y + 1)*zw + (-y^3 -y^2)*z^2, |
---|
1489 | (x + 1)*zw + (-y^2 -y)*z^2, (x^2 + x)*w^2 + (-yx - y)*zw; |
---|
1490 | |
---|
1491 | ring R13=integer,(w,z,y,x),dp; |
---|
1492 | ideal I=(((12*y+8)*x^2 +(2*y+2)*x)*zw +((-15*y^2 -4*y)*x-4*y^2 -y)*z^2, |
---|
1493 | -x*w^2 +((-12*y -8)*x+2*y)*zw +(15*y^2+4*y)*z^2, |
---|
1494 | (81*y^4*x^2 +(-54*y^3 -12*y^2)*x-12*y^3 -3*y^2)*z^3, |
---|
1495 | (-24*yx+6*y^2-6*y)*z^2*w + (-81*y^4*x + 81*y^3 + 24*y^2)*z^3, |
---|
1496 | (48*x^2 + (-30*y + 12)*x - 6*y)*z^2*w + ((81*y^3 -54*y^2 -24*y)*x |
---|
1497 | -21*y^2 -6*y)*z^3, |
---|
1498 | (-96*yx-18*y^3 +18*y^2-24*y)*z^2*w +(243*y^5*x-243*y^4 +72*y^3 |
---|
1499 | +48*y^2)*z^3, |
---|
1500 | 6*y*z^2*w^2 +((576*y+384)*x^2 + (-81*y^3 -306*y^2 -168*y+96)*x+81*y^2 |
---|
1501 | -18*y)*z^3*w +((-720*y^2 - 192*y)*x + 450*y^3 - 60*y^2 - 48*y)*z^4); |
---|
1502 | |
---|
1503 | ring R14=integer,(x(1),x(2),x(3),x(4)),dp; |
---|
1504 | ideal I=181*49^2, |
---|
1505 | x(4)^4, |
---|
1506 | x(1)*x(4)^3, |
---|
1507 | x(1)*x(2)*x(4)^2, |
---|
1508 | x(2)^2*x(4)^2, |
---|
1509 | x(2)^2*x(3)*x(4), |
---|
1510 | x(1)*x(2)*x(3)*x(4), |
---|
1511 | x(1)*x(3)^2*x(4), |
---|
1512 | x(3)^3*x(4); |
---|
1513 | |
---|
1514 | |
---|
1515 | ring R15=integer,(x,y,z),dp; |
---|
1516 | ideal I=32003*181*64, |
---|
1517 | ((z^2-z)*y^2 + (z^2 -z)*y)*x; (z*y^3 + z*y^2)*x, |
---|
1518 | (y^4 - y^2)*x, (z^2 - z)*y*x^2, (y^3 - y^2)*x^2, |
---|
1519 | (z^3 - z^2)*x^4 + (2*z^3 -2*z^2)*x^3 + (z^3 -z^2)*x^2, |
---|
1520 | z*y^2*x^2, z*y*x^4 +z*y*x^3, |
---|
1521 | 2*y^2*x^4 +6*y^2*x^3 +6*y^2*x^2 + (y^3 +y^2)*x, z*x^5 + (z^2 +z)*x^4 |
---|
1522 | + (2*z^2 -z)*x^3 + (z^2 -z)*x^2, |
---|
1523 | y*x^6 + 3*y*x^5 + 3*y*x^4 + y*x^3; |
---|
1524 | |
---|
1525 | |
---|
1526 | ring R16=integer,(x(1),x(2),x(3),x(4),x(5)),dp; |
---|
1527 | ideal I=x(5)^5, |
---|
1528 | x(1)*x(5)^4, |
---|
1529 | x(1)*x(2)*x(5)^3, |
---|
1530 | x(2)^2*x(5)^3, |
---|
1531 | x(2)^2*x(3)*x(5)^2, |
---|
1532 | x(1)*x(2)*x(3)*x(5)^2, |
---|
1533 | x(1)*x(3)^2*x(5)^2, |
---|
1534 | x(3)^3*x(5)^2, |
---|
1535 | x(3)^3*x(4)*x(5), |
---|
1536 | x(1)*x(3)^2*x(4)*x(5), |
---|
1537 | x(1)*x(2)*x(3)*x(4)*x(5), |
---|
1538 | x(2)^2*x(3)*x(4)*x(5), |
---|
1539 | x(2)^2*x(4)^2*x(5), |
---|
1540 | x(1)*x(2)*x(4)^2*x(5), |
---|
1541 | x(1)*x(4)^3*x(5), |
---|
1542 | x(4)^4*x(5); |
---|
1543 | I=intersectZ(I,ideal(64*181,x(1)^2)); |
---|
1544 | |
---|
1545 | ring R17=integer,(x,y,z),dp; |
---|
1546 | ideal I=374, |
---|
1547 | (z+2)^8-140z6+2622*(z+2)^4-1820*(z+2)^2+169, |
---|
1548 | 17y*(z+2)^4-374*y*(z+2)^2+221y+2z7-281z5+5240z3-3081z, |
---|
1549 | 204y2+136yz3-3128yz+z6-149z4+2739z2+117, |
---|
1550 | 17xz4-374xz2+221x+2z7-281z5+5240z3-3081z, |
---|
1551 | 136xy-136xz-136yz+2z6-281z4+5376z2-3081, |
---|
1552 | 204x2+136xz3-3128xz+z6-149z4+2739z2+117; |
---|
1553 | |
---|
1554 | ring R18=integer,(B,D,F,b,d,f),dp; |
---|
1555 | ideal I=6, |
---|
1556 | (b-d)*(B-D)-2*F+2, |
---|
1557 | (b-d)*(B+D-2*F)+2*(B-D), |
---|
1558 | (b-d)^2-2*(b+d)+f+1, |
---|
1559 | B^2*b^3-1, |
---|
1560 | D^2*d^3-1, |
---|
1561 | F^2*f^3-1; |
---|
1562 | |
---|
1563 | ring R19=integer,(a,b,c,d,e,f),dp; |
---|
1564 | ideal I=24, |
---|
1565 | 2*(f+2)*b+2ec+d2+a2+a, |
---|
1566 | 2*(f+2)*c+2ed+2ba+b, |
---|
1567 | 2*(f+2)*d+e2+2ca+c+b2, |
---|
1568 | 2*(f+2)*e+2da+d+2cb, |
---|
1569 | (f+2)^2+2ea+e+2db+c2, |
---|
1570 | 2*(f+2)*a+f+2eb+2dc; |
---|
1571 | |
---|
1572 | ring R20=integer,(x,y,z,w,u),dp; |
---|
1573 | ideal I=24, |
---|
1574 | 2x2-2y2+2z2-2w2+2u2-1, |
---|
1575 | 2x3-2y3+2z3-2w3+2u3-1, |
---|
1576 | 2x4-2y4+2z4-2w4+2u4-1, |
---|
1577 | 2x5-2y5+2z5-2w5+2u5-1, |
---|
1578 | 2x6-2y6+2z6-2w6+2u6-1; |
---|
1579 | |
---|
1580 | ring R21=integer,(x,y,z,t,u,v,h),dp; |
---|
1581 | ideal I=66, |
---|
1582 | 2x2+2y2+2z2+2t2+2u2+v2-vh, |
---|
1583 | xy+yz+2zt+2tu+2uv-uh, |
---|
1584 | 2xz+2yt+2zu+u2+2tv-th, |
---|
1585 | 2xt+2yu+2tu+2zv-zh, |
---|
1586 | t2+2xv+2yv+2zv-yh, |
---|
1587 | 2x+2y+2z+2t+2u+v-h, |
---|
1588 | x3+y3+z3+t3+u3+v3; |
---|
1589 | |
---|
1590 | ring R22=integer,(s,p,S,P,T,F,f),dp; |
---|
1591 | ideal I=35, |
---|
1592 | 2*T-S*s-2*F+2, |
---|
1593 | 8*F*p-4*p*S-2*F*s^2+S*s^2+4*T-2*S*s, |
---|
1594 | -2*s-4*p+s^2+f+1, |
---|
1595 | s*T^2-p*s*P-p*S*T-2, |
---|
1596 | p^3*P^2-1, |
---|
1597 | F^2*f^3-1; |
---|
1598 | */ |
---|