source: git/Singular/LIB/primdecint.lib @ 09830b6

fieker-DuValspielwiese
Last change on this file since 09830b6 was 09830b6, checked in by Gerhard Pfister <pfister@…>, 11 years ago
Procedures for primariy decomposition of modules added.
  • Property mode set to 100644
File size: 42.1 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2version="version primdecint.lib 4.0.0.0 Jun_2013 ";
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////////////////////////////////////////////////////////////////////////////////
1067
1068static proc extractZ(ideal J, int j, list L, list B)
1069{
1070   //=== P is an associated prime of J, the corresponding primary ideal is
1071   //=== computed,
1072   //=== L is a list of maximal independent sets for P in Z/p[variables]
1073   def R=basering;
1074   ideal P=B[j];
1075
1076   //=== first compute a pseudo primary ideal I, radical of I is P
1077   //=== method of Eisenbud
1078   //ideal I=addIdealZ(J,specialPowerZ(P,20));
1079
1080   //=== method of Shimoyama-Yokoyama
1081   poly s=separatorsZ(j,B);
1082   ideal I=satZ(J,s);
1083   //=== size(L)=0 means P is maximal ideal and I is primary
1084   if(size(L)>0)
1085   {
1086      if(L[1][3]!=0)
1087      {
1088         //=== if u in x is an independent set of L then we compute a Groebner
1089         //=== Basis in Z[u][x-u]
1090         execute("ring S=integer,("+L[1][1]+"),lp;");
1091         ideal I=imap(R,I);
1092         I=stdZ(I);
1093         list rl=ringlist(S);
1094         rl[1]=0;
1095         def Shelp =ring(rl);
1096         setring Shelp;
1097         ideal I=imap(S,I);
1098         I[1]=0;
1099         I=simplify(I,2);
1100         //=== this is our way to obtain the coefficients in Z[u] of the
1101         //=== leading terms of the Groebner basis above
1102         string quotring=Primdec::prepareQuotientring(nvars(basering)-L[1][3]);
1103         execute(quotring);
1104         ideal I=imap(Shelp,I);
1105         list C;
1106         int i;
1107         for(i=1;i<=size(I);i++)
1108         {
1109            C[i]=leadcoef(I[i]);
1110         }
1111         setring Shelp;
1112         list C=imap(quring,C);
1113
1114         setring R;
1115         list C=imap(Shelp,C);
1116      }
1117      else
1118      {
1119         I=stdZ(I);
1120         list C;
1121         int i;
1122         for(i=1;i<=size(I);i++)
1123         {
1124            C[i]=I[i];
1125         }
1126         list rl=ringlist(R);
1127         rl[1]=0;
1128         def Shelp =ring(rl);
1129      }
1130      poly h=1;
1131      for(i=1;i<=size(C);i++)
1132      {
1133         if(deg(C[i])>0){h=h*C[i];}  // das muss noch besser gemacht werden,
1134                                     // nicht ausmultiplizieren!
1135      }
1136      setring Shelp;
1137      poly h=imap(R,h);
1138      ideal fac=factorize(h,1);
1139      setring R;
1140      ideal fac=imap(Shelp,fac);
1141      for(i=1;i<=size(fac);i++)
1142      {
1143         I=satZ(I,fac[i]);
1144      }
1145   }
1146   I=stdZ(I);
1147   return(I);
1148}
1149////////////////////////////////////////////////////////////////////////////////
1150
1151static proc normalizeZ(ideal I)
1152{
1153//=== if I[1]=q in Z, it replaces all other coeffs of polys in I by there value
1154//=== mod q, std should do this automatically and then this procedure should be
1155//=== removed
1156   if(deg(I[1])>0){return(I);}
1157   int i,j;
1158   number n;
1159   poly p;
1160   for(i=2;i<=size(I);i++)
1161   {
1162      j=1;
1163      while(j<=size(I[i]))
1164      {
1165         n=leadcoef(I[i][j]) mod leadcoef(I[1]);
1166         p=n*leadmonom(I[i][j]);
1167         I[i]=I[i]-I[i][j]+p;
1168         if(p!=0){j++;}
1169      }
1170   }
1171   return(I);
1172}
1173
1174////////////////////////////////////////////////////////////////////////////////
1175
1176static proc satZ(ideal I,poly h)
1177{
1178//=== saturates I by h
1179   ideal J=quotientOneZ(I,h);
1180   while(size(reduce(J,stdZ(I)))!=0)
1181   {
1182      I=J;
1183      J=quotientOneZ(I,h);
1184      J=normalizeZ(J);
1185   }
1186   return(J);
1187}
1188
1189////////////////////////////////////////////////////////////////////////////////
1190
1191static proc quotientOneZ(ideal I, poly f)
1192{
1193//=== this is needed because quotient(I,f) does not work properly, should be
1194//=== replaced by quotient later
1195   def R=basering;
1196   int i;
1197   ideal K=intersectZ(I,ideal(f));
1198   //ideal K=intersect(I,ideal(f));
1199   //=== K[i]/f; does not work in rings with integer! This should be replaced
1200   //=== later
1201   execute("ring Rhelp=0,("+varstr(R)+"),dp;");
1202   ideal K=imap(R,K);
1203   poly f=imap(R,f);
1204   for(i=1;i<=size(K);i++)
1205   {
1206      K[i]=K[i]/f;
1207   }
1208   setring R;
1209   K=imap(Rhelp,K);
1210   return(K);
1211}
1212
1213////////////////////////////////////////////////////////////////////////////////
1214
1215static proc quotientZ(ideal I, ideal J)
1216{
1217//=== this is needed because quotient(I,J) does not work properly, should be
1218//=== replaced by quotient later
1219   int i;
1220   ideal K=quotientOneZ(I,J[1]);
1221   for(i=2;i<=size(J);i++)
1222   {
1223      K=intersectZ(K,quotientOneZ(I,J[i]));
1224      //K=intersect(K,quotientOneZ(I,J[i]));
1225   }
1226   return(K);
1227}
1228
1229////////////////////////////////////////////////////////////////////////////////
1230
1231static proc reduceZ(poly f, ideal I)
1232{
1233//=== this is needed because reduce(f,I) does not work properly, should be
1234//=== replaced by reduce later
1235   if(f==0){return(f);}
1236   def R=basering;
1237   execute("ring Rhelp=0,("+varstr(R)+"),dp;");
1238   ideal I=imap(R,I);
1239   poly f=imap(R,f);
1240   int i,j;
1241   poly m;
1242   number n;
1243   while(!i)
1244   {
1245      i=1;
1246      j=0;
1247      while(j<size(I))
1248      {
1249         j++;
1250         m=leadmonom(f)/leadmonom(I[j]);
1251         if(m!=0)
1252         {
1253            n=leadcoef(f) mod leadcoef(I[j]);
1254            if(n==0)
1255            {
1256               f=f-leadcoef(f)/leadcoef(I[j])*m*I[j];
1257               if(f==0){setring R;return(0);}
1258               i=0;
1259               break;
1260            }
1261            if(n!=leadcoef(f))
1262            {
1263               f=f+(n-leadcoef(f))/leadcoef(I[j])*m*I[j];
1264               i=0;
1265               break;
1266            }
1267         }
1268      }
1269   }
1270   setring R;
1271   f=imap(Rhelp,f);
1272   return(lead(f)+reduceZ(f-lead(f),I));
1273}
1274
1275////////////////////////////////////////////////////////////////////////////////
1276
1277static proc stdZ(ideal I)
1278{
1279//=== this is needed because we want the leading coefficients to be positive
1280//=== otherwhise reduce gives wrong results! should be replaced later by std
1281   I=simplify(I,2);
1282   I=normalizeZ(I);
1283   ideal J=std(I);
1284   int i;
1285   for(i=1;i<=size(J);i++)
1286   {
1287      if(leadcoef(J[i])<0){J[i]=-J[i];}
1288   }
1289   J=normalizeZ(J);
1290   attrib(J,"isSB",1);
1291   return(J);
1292}
1293
1294////////////////////////////////////////////////////////////////////////////////
1295
1296static proc addIdealZ(ideal I,ideal J)
1297{
1298//=== this is needed because I+J does not work, should be replaced by + later
1299   int i;
1300   for(i=1;i<=size(J);i++)
1301   {
1302      I[size(I)+1]=J[i];
1303   }
1304   return(I);
1305}
1306
1307////////////////////////////////////////////////////////////////////////////////
1308
1309static proc testPrimaryZ(ideal I, list L)
1310{
1311//=== test whether I is the intersection of the primary ideals in L
1312   int i;
1313   ideal K=L[1][1];
1314   for(i=2;i<=size(L);i++)
1315   {
1316      K=intersectZ(K,L[i][1]);
1317      //K=intersect(K,L[i][1]);
1318   }
1319   i=size(reduce(K,stdZ(I)))+size(reduce(I,stdZ(K)));
1320   if(!i){return(1);}
1321   return(0);
1322}
1323
1324////////////////////////////////////////////////////////////////////////////////
1325
1326static proc pseudo_primdecZM(module N)
1327{
1328   ideal I=quotient(N,freemodule(nrows(N)));
1329   if(size(I)==0){return(list(list(N,I)));}
1330   
1331   list B=minAssZ(I);
1332   list S,R,L;
1333   ideal K;
1334   if(size(B)==0){return(S);}
1335   for(int i=1;i<=size(B);i++)
1336   {
1337      S[i]=separatorsZ(i,B);
1338   }
1339   for(i=1;i<=size(B);i++)
1340   {
1341      L=sat(N,S[i]);
1342      K[i]=S[i]^L[2];
1343      R[i]=list(L[1],B[i]);
1344   }
1345   L=pseudo_primdecZM(N+K*freemodule(nrows(N)));
1346   for(i=1;i<=size(L);i++)
1347   {
1348      R[size(R)+1]=L[i];
1349   }
1350   return(R);
1351}
1352
1353
1354
1355static proc prepare_extractZM(list L)
1356{
1357   def R=basering;
1358   module N=L[1];
1359   ideal I=quotient(N,freemodule(nrows(N)));
1360   list B=primdecZ(I);
1361   list M;
1362   if(size(B)==1){return(M);}
1363   I=std(I);
1364   list rl=ringlist(R);
1365   if(deg(I[1])==0)
1366   {
1367      execute("int p="+string(I[1])+";");
1368      rl[1]=p;
1369   }
1370   else
1371   {
1372      rl[1]=0;
1373   }
1374   def Shelp =ring(rl);
1375   setring Shelp;
1376   ideal I=imap(R,I);
1377   I=std(I);
1378   M=Primdec::maxIndependSet(I);
1379   setring R;
1380   return(M);
1381}
1382
1383
1384static proc extractZM(list M, list L)
1385{
1386   //=== M is a list of a pseudo primary module and the corresponding prime
1387   //=== L is a list of maximal independent sets for P
1388   def R=basering;
1389   ideal P=M[2];
1390   module I=M[1];
1391   poly h=1;
1392
1393   //=== size(L)=0 means P is maximal ideal and I is primary
1394   if(size(L)>0)
1395   {
1396      if(L[1][3]!=0)
1397      {
1398         //=== if u in x is an independent set of L then we compute a Groebner
1399         //=== Basis in Z[u][x-u]
1400         execute("ring S=integer,("+L[1][1]+"),lp;");
1401         module I=imap(R,I);
1402         I=std(I);
1403         list rl=ringlist(S);
1404         rl[1]=0;
1405         def Shelp =ring(rl);
1406         setring Shelp;
1407         module I=imap(S,I);
1408         //=== this is our way to obtain the coefficients in Z[u] of the
1409         //=== leading terms of the Groebner basis above
1410         string quotring=Primdec::prepareQuotientring(nvars(basering)-L[1][3]);
1411         execute(quotring);
1412         module I=imap(Shelp,I);
1413         list C;
1414         int i;
1415         for(i=1;i<=size(I);i++)
1416         {
1417            C[i]=leadcoef(I[i]);
1418         }
1419         setring Shelp;
1420         list C=imap(quring,C);
1421         setring R;
1422         list C=imap(Shelp,C);
1423      }
1424      else
1425      {
1426         // this is the case that P=<p>, p prime
1427         I=std(I);
1428         ideal IC=simplify(flatten(lead(I)),2);
1429         list C;
1430         int i;
1431         for(i=1;i<=size(IC);i++)
1432         {
1433            C[i]=I[i];
1434         }
1435         list rl=ringlist(R);
1436         rl[1]=0;
1437         def Shelp =ring(rl);
1438      }
1439      for(i=1;i<=size(C);i++)
1440      {
1441         if(deg(C[i])>0){h=h*C[i];}  // das muss noch besser gemacht werden,
1442                                     // nicht ausmultiplizieren!
1443      }
1444      setring Shelp;
1445      poly h=imap(R,h);
1446      ideal fac=factorize(h,1);
1447      setring R;
1448      list II;
1449      h=1;
1450      ideal fac=imap(Shelp,fac);
1451      for(i=1;i<=size(fac);i++)
1452      {
1453         II=sat(I,fac[i]);
1454          I=II[1];
1455          h=h*fac[i]^II[2];
1456      }
1457   }
1458   I=std(I);
1459   return(list(I,h));
1460}
1461
1462
1463proc primdecZM(module N)
1464"USAGE:  primdecZM(N); N module
1465RETURN:  a list pr of primary modules and their associated primes:
1466@format
1467   pr[i][1]   the i-th primary component,
1468   pr[i][2]   the i-th prime component.
1469@end format
1470EXAMPLE: example primdecZM; shows an example
1471"
1472{
1473  list P,K,S;
1474  int i,j;
1475  list L=pseudo_primdecZM(N);
1476  list M,O;
1477  for(i=1;i<=size(L);i++)
1478  {
1479     if(size(L[i][2])!=0)
1480     {
1481        M=prepare_extractZM(L[i]);
1482        O=extractZM(L[i],M);
1483        P[size(P)+1]=list(O[1],L[i][2]);
1484        K[size(K)+1]=L[i][1]+O[2]*freemodule(nrows(L[i][1]));
1485     }
1486     else
1487     {
1488        P[size(P)+1]=L[i];
1489     }
1490  }
1491  for(j=1;j<=size(K);j++)
1492  {
1493     S=primdecZM(K[j]);
1494     for(i=1;i<=size(S);i++)
1495     {
1496        P[size(P)+1]=S[i];
1497     }
1498  }
1499  return(P);
1500}
1501example
1502{ "EXAMPLE:";  echo = 2;
1503   ring R=integer,(x,y),(c,lp);
1504   module N=[0,0,xy2-x2-xy],[0,y,x],[0,x,2xy-x],[x,0,-xy],[0,0,18x];
1505   primdecZM(N);
1506}
1507
1508
1509////////////////////////////////////////////////////////////////////////////////
1510
1511/*
1512Examples:
1513
1514//=== IQ[a,b,c,d,e,f,g] intersect Z[a,b,c,d,e,f,g] = I  (takes some time)
1515ring R1=integer,(a,b,c,d,e,f,g),dp;
1516ideal I=a2+2de+2cf+2bg+a,
1517        2ab+e2+2df+2cg+b,
1518        b2+2ac+2ef+2dg+c,
1519        2bc+2ad+f2+2eg+d,
1520        c2+2bd+2ae+2fg+e,
1521        2cd+2be+2af+g2+f,
1522        d2+2ce+2bf+2ag+g;
1523
1524ring R2=integer,(a,b,c,d,e,f,g),dp;
1525ideal I=181*32003,
1526        a2+2de+2cf+2bg+a,
1527        2ab+e2+2df+2cg+b,
1528        b2+2ac+2ef+2dg+c,
1529        2bc+2ad+f2+2eg+d,
1530        c2+2bd+2ae+2fg+e,
1531        2cd+2be+2af+g2+f,
1532        d2+2ce+2bf+2ag+g;
1533
1534ring R3=integer,(w,z,y,x),dp;
1535ideal I=xzw+(-y^2+y)*z^2,
1536        (-x^2+x)*w^2+yzw,
1537        ((y^4-2*y^3+y^2)*x-y^4+y^3)*z^3,
1538        y2z2w+(-y*4+2*y^3-y^2)*z3;
1539
1540ring R4=integer,(w,z,y,x),dp;
1541ideal I=-2*yxzw+(-yx-y^2+y)*z^2,
1542        xw^2-yz^2,
1543        (yx^2-(2*y^2+2*y)*x+y^3-2*y^2+y)*z^3,
1544        (-2*y^2+2*y)*z^2*w+(yx-3*y^2-y)*z^3;
1545
1546ring R5=integer,(x,y,z),dp;
1547ideal I=x2-y2-z2,
1548        xy-z2,
1549        y3+xz2-yz2+2z3+xy-z2,
1550        -y2z2+2z4+x2-y2+z2,
1551        y3z9+3y2z10+3yz11+z12-y2z2+2z4;
1552
1553ring R6=integer,(h, l, s, x, y, z),dp;  //takes some time
1554ideal I=hl-l2-4ls+hy,
1555        h2s-6ls3+h2z,
1556        xh2-l2s-h3;
1557
1558ring R7=integer,(x,y,z),dp;
1559ideal I=x2-y2-(z+2)^2,
1560        xy-(z+2)^2,
1561        y3+x*(z+2)^2-y*(z+2)^2+2*(z+2)^3+xy-(z+2)^2,
1562        -y^2*(z+2)^2+2*(z+2)^4+x2-y2+(z+2)^2,
1563        y3z9+3y2z10+3yz11+z12-y2z2+2z4;
1564
1565ring R8=integer,(x,y,z),dp;
1566ideal I=x2-y2-(z+2)^2,
1567        xy-(z+2)^2,
1568        y3+x*(z+2)^2-y*(z+2)^2+2*(z+2)^3+xy-(z+2)^2,
1569        -y^2*(z+2)^2+2*(z+2)^4+x2-y2+(z+2)^2,
1570        y3z9+3y2z10+3yz11+z12-y2z2+2z4;
1571
1572ring R9=integer,(w,z,y,x),dp;
1573ideal I=630,
1574        ((y^2-y)*x-y^3+y^2)*z^2,
1575        (x-y)*zw,
1576        (x-y^2)*zw+(-y^2+y)*z^2,
1577        (-x^2+x)*w^2+(-yx+y)*zw;
1578
1579ring R10=integer,(w,z,y,x),dp;
1580ideal I=1260,
1581        -yxzw+(-y^2+y)*z^2,
1582        (-x^2+x)*w^2-yxzw,
1583        ((-y^2+y)*x-y^3+2*y^2-y)*z^3,
1584        (y^2-y)*z^2*w+(-y^2+y)*z^2*w+(-y^2+y)*z^3;
1585
1586ring R11=integer,(w,z,y,x),dp;
1587ideal I=(4*y^2*x^2+(4*y^3+4*y^2-y)*x-y^2-y)*z^2,
1588        (x+y+1)*zw+(-4*y^2*x-4*y^3-4*y^2)*z^2,
1589        (-x-2*y^2 - 2*y - 1)*zw + (8*y^3*x + 8*y^4 + 8*y^3 + 2*y^2+y)*z^2,
1590        ((y^3 + y^2)*x - y^2 - y)*z^2,
1591        (y +1)*zw + (-y^3 -y^2)*z^2,
1592        (x + 1)*zw +(- y^2 -y)*z^2,
1593        (x^2 +x)*w^2 + (-yx - y)*zw;
1594
1595ring R12=integer,(w,z,y,x),dp;
1596ideal I=72,
1597        ((y^3 + y^2)*x - y^2 - y)*z^2,
1598        (y + 1)*zw + (-y^3 -y^2)*z^2,
1599        (x + 1)*zw + (-y^2 -y)*z^2, (x^2 + x)*w^2 + (-yx - y)*zw;
1600
1601ring R13=integer,(w,z,y,x),dp;
1602ideal I=(((12*y+8)*x^2 +(2*y+2)*x)*zw +((-15*y^2 -4*y)*x-4*y^2 -y)*z^2,
1603        -x*w^2 +((-12*y -8)*x+2*y)*zw +(15*y^2+4*y)*z^2,
1604        (81*y^4*x^2 +(-54*y^3 -12*y^2)*x-12*y^3 -3*y^2)*z^3,
1605        (-24*yx+6*y^2-6*y)*z^2*w + (-81*y^4*x + 81*y^3 + 24*y^2)*z^3,
1606        (48*x^2 + (-30*y + 12)*x - 6*y)*z^2*w + ((81*y^3 -54*y^2 -24*y)*x
1607        -21*y^2 -6*y)*z^3,
1608        (-96*yx-18*y^3 +18*y^2-24*y)*z^2*w +(243*y^5*x-243*y^4 +72*y^3
1609        +48*y^2)*z^3,
1610        6*y*z^2*w^2 +((576*y+384)*x^2 + (-81*y^3 -306*y^2 -168*y+96)*x+81*y^2
1611        -18*y)*z^3*w +((-720*y^2 - 192*y)*x + 450*y^3 - 60*y^2 - 48*y)*z^4);
1612
1613ring R14=integer,(x(1),x(2),x(3),x(4)),dp;
1614ideal I=181*49^2,
1615        x(4)^4,
1616        x(1)*x(4)^3,
1617        x(1)*x(2)*x(4)^2,
1618        x(2)^2*x(4)^2,
1619        x(2)^2*x(3)*x(4),
1620        x(1)*x(2)*x(3)*x(4),
1621        x(1)*x(3)^2*x(4),
1622        x(3)^3*x(4);
1623
1624
1625ring R15=integer,(x,y,z),dp;
1626ideal I=32003*181*64,
1627        ((z^2-z)*y^2 + (z^2 -z)*y)*x; (z*y^3 + z*y^2)*x,
1628        (y^4 - y^2)*x, (z^2 - z)*y*x^2, (y^3 - y^2)*x^2,
1629        (z^3 - z^2)*x^4 + (2*z^3 -2*z^2)*x^3 + (z^3 -z^2)*x^2,
1630        z*y^2*x^2, z*y*x^4 +z*y*x^3,
1631        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
1632        + (2*z^2 -z)*x^3 + (z^2 -z)*x^2,
1633        y*x^6 + 3*y*x^5 + 3*y*x^4 + y*x^3;
1634
1635
1636ring R16=integer,(x(1),x(2),x(3),x(4),x(5)),dp;
1637ideal I=x(5)^5,
1638        x(1)*x(5)^4,
1639        x(1)*x(2)*x(5)^3,
1640        x(2)^2*x(5)^3,
1641        x(2)^2*x(3)*x(5)^2,
1642        x(1)*x(2)*x(3)*x(5)^2,
1643        x(1)*x(3)^2*x(5)^2,
1644        x(3)^3*x(5)^2,
1645        x(3)^3*x(4)*x(5),
1646        x(1)*x(3)^2*x(4)*x(5),
1647        x(1)*x(2)*x(3)*x(4)*x(5),
1648        x(2)^2*x(3)*x(4)*x(5),
1649        x(2)^2*x(4)^2*x(5),
1650        x(1)*x(2)*x(4)^2*x(5),
1651        x(1)*x(4)^3*x(5),
1652        x(4)^4*x(5);
1653      I=intersectZ(I,ideal(64*181,x(1)^2));
1654
1655ring R17=integer,(x,y,z),dp;
1656ideal I=374,
1657        (z+2)^8-140z6+2622*(z+2)^4-1820*(z+2)^2+169,
1658        17y*(z+2)^4-374*y*(z+2)^2+221y+2z7-281z5+5240z3-3081z,
1659        204y2+136yz3-3128yz+z6-149z4+2739z2+117,
1660        17xz4-374xz2+221x+2z7-281z5+5240z3-3081z,
1661        136xy-136xz-136yz+2z6-281z4+5376z2-3081,
1662        204x2+136xz3-3128xz+z6-149z4+2739z2+117;
1663
1664ring R18=integer,(B,D,F,b,d,f),dp;
1665ideal I=6,
1666        (b-d)*(B-D)-2*F+2,
1667        (b-d)*(B+D-2*F)+2*(B-D),
1668        (b-d)^2-2*(b+d)+f+1,
1669        B^2*b^3-1,
1670        D^2*d^3-1,
1671        F^2*f^3-1;
1672
1673ring R19=integer,(a,b,c,d,e,f),dp;
1674ideal I=24,
1675        2*(f+2)*b+2ec+d2+a2+a,
1676        2*(f+2)*c+2ed+2ba+b,
1677        2*(f+2)*d+e2+2ca+c+b2,
1678        2*(f+2)*e+2da+d+2cb,
1679        (f+2)^2+2ea+e+2db+c2,
1680        2*(f+2)*a+f+2eb+2dc;
1681
1682ring R20=integer,(x,y,z,w,u),dp;
1683ideal I=24,
1684         2x2-2y2+2z2-2w2+2u2-1,
1685         2x3-2y3+2z3-2w3+2u3-1,
1686         2x4-2y4+2z4-2w4+2u4-1,
1687         2x5-2y5+2z5-2w5+2u5-1,
1688         2x6-2y6+2z6-2w6+2u6-1;
1689
1690ring R21=integer,(x,y,z,t,u,v,h),dp;
1691ideal I=66,
1692        2x2+2y2+2z2+2t2+2u2+v2-vh,
1693        xy+yz+2zt+2tu+2uv-uh,
1694        2xz+2yt+2zu+u2+2tv-th,
1695        2xt+2yu+2tu+2zv-zh,
1696        t2+2xv+2yv+2zv-yh,
1697        2x+2y+2z+2t+2u+v-h,
1698        x3+y3+z3+t3+u3+v3;
1699
1700ring R22=integer,(s,p,S,P,T,F,f),dp;
1701ideal I=35,
1702        2*T-S*s-2*F+2,
1703        8*F*p-4*p*S-2*F*s^2+S*s^2+4*T-2*S*s,
1704        -2*s-4*p+s^2+f+1,
1705        s*T^2-p*s*P-p*S*T-2,
1706        p^3*P^2-1,
1707        F^2*f^3-1;
1708
1709ring R=integer,(x,y),(c,lp);
1710module N=[0,0,xy2-x2-xy],[0,y,x],[0,x,2xy-x],[x,0,-xy],[0,0,18x];
1711
1712ring R=integer,(x,y),(c,lp);
1713module N=[0,0,xy2-x2-xy],[0,y,x],[0,x,2xy-x],[x,0,-xy],[0,0,18];
1714
1715ring R=integer,(x,y),(c,lp);
1716module N=[-y,7,0],[2y3-y2],[3x,y2],[2y-y2,x],[4,5x3];
1717
1718ring r=integer,(x,y),(c,lp);
1719module N=[0,0,xy2-x2-xy],[0,y,x],[0,x,xy-x],[x,0,-xy],[5x,0,0];
1720
1721ring R2=integer,(a(1),a(2),a(3),b(1),b(2),b(3)),(c,lp);
1722module 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)];
1723
1724ring R3=integer,(x,y,z),(c,lp);
1725module N=[y2+z2,xy,xz],[xy,x2+z2,yz],[xz,yz,x2+y2];
1726
1727ring R4=integer,(x,y,z,a,b,c),(c,lp);
1728module N=[x3y2z2c,x2y3z2c,x2y2z3c],[x3y2z2b,x2y3z2b,x2y2z3b],[x3y2z2a,x2y3z2a,x2y2z3a];
1729
1730*/
Note: See TracBrowser for help on using the repository browser.