source: git/Singular/LIB/primdecint.lib @ 6f92b7

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