source: git/Singular/LIB/primdecint.lib @ 40f038

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