source: git/Singular/LIB/normal.lib @ 367e88

spielwiese
Last change on this file since 367e88 was 367e88, checked in by Hans Schönemann <hannes@…>, 23 years ago
* hannes: interred git-svn-id: file:///usr/local/Singular/svn/trunk@5247 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 34.3 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: normal.lib,v 1.33 2001-02-21 10:08:16 Singular Exp $";
3category="Commutative Algebra";
4info="
5LIBRARY:  normal.lib     Normalization of Affine Rings
6AUTHORS:  G.-M. Greuel,  greuel@mathematik.uni-kl.de,
7@*        G. Pfister,    pfister@mathematik.uni-kl.de
8
9PROCEDURES:
10 normal(I);             computes the normalization of basering/I
11 HomJJ(L);              presentation of End_R(J) as affine ring, L a list
12";
13
14LIB "general.lib";
15LIB "sing.lib";
16LIB "primdec.lib";
17LIB "elim.lib";
18LIB "presolve.lib";
19LIB "inout.lib";
20LIB "ring.lib";
21///////////////////////////////////////////////////////////////////////////////
22static proc isR_HomJR (list Li)
23"USAGE:   isR_HomJR (Li);  Li = list: ideal SBid, ideal J, poly p
24COMPUTE: module Hom_R(J,R) = R:J and compare with R
25ASSUME:  R    = P/SBid,  P = basering
26         SBid = standard basis of an ideal in P,
27         J    = ideal in P containing the polynomial p,
28         p    = nonzero divisor of R
29RETURN:  1 if R = R:J, 0 if not
30EXAMPLE: example isR_HomJR;  shows an example
31"
32{
33   int n, ii;
34 def P = basering;
35   ideal SBid = Li[1];
36   ideal J = Li[2];
37   poly p = Li[3];
38   attrib(SBid,"isSB",1);
39   attrib(p,"isSB",1);
40 qring R    = SBid;
41   ideal J  = fetch(P,J);
42   poly p   = fetch(P,p);
43   ideal f  = quotient(p,J);
44   ideal lp = std(p);
45   n=1;
46   for (ii=1; ii<=size(f); ii++ )
47   {
48      if ( reduce(f[ii],lp) != 0)
49      { n = 0; break; }
50   }
51   return (n);
52 //?spaeter hier einen Test ob Hom(I,R) = Hom(I,I)?
53}
54example
55{"EXAMPLE:";  echo = 2;
56  ring r   = 0,(x,y,z),dp;
57  ideal id = y7-x5+z2;
58  ideal J  = x3,y+z;
59  poly p   = xy;
60  list Li  = std(id),J,p;
61  isR_HomJR (Li);
62
63  ring s   = 0,(t,x,y),dp;
64  ideal id = x2-y2*(y-t);
65  ideal J  = jacob(id);
66  poly p   = J[1];
67  list Li  = std(id),J,p;
68  isR_HomJR (Li);
69}
70///////////////////////////////////////////////////////////////////////////////
71
72proc HomJJ (list Li)
73"USAGE:   HomJJ (Li);  Li = list: ideal SBid, ideal id, ideal J, poly p
74ASSUME:  R    = P/id,  P = basering, a polynomial ring, id an ideal of P,
75@*       SBid = standard basis of id,
76@*       J    = ideal of P containing the polynomial p,
77@*       p    = nonzero divisor of R
78COMPUTE: Endomorphism ring End_R(J)=Hom_R(J,J) with its ring structure as
79         affine ring, together with the canonical map R --> Hom_R(J,J),
80         where R is the quotient ring of P modulo the standard basis SBid.
81RETURN:  a list l of two objects
82@format
83         l[1] : a polynomial ring, containing two ideals, 'endid' and 'endphi'
84               such that l[1]/endid = Hom_R(J,J) and
85               endphi describes the canonical map R -> Hom_R(J,J)
86         l[2] : an integer which is 1 if phi is an isomorphism, 0 if not
87@end format
88NOTE:    printlevel >=1: display comments (default: printlevel=0)
89EXAMPLE: example HomJJ;  shows an example
90"
91{
92//---------- initialisation ---------------------------------------------------
93
94   int isIso,isPr,isCo,isRe,isEq,ii,jj,q,y;
95   intvec rw,rw1;
96   list L;
97   y = printlevel-voice+2;  // y=printlevel (default: y=0)
98 def P = basering;
99   ideal SBid, id, J = Li[1], Li[2], Li[3];
100   poly p = Li[4];
101   attrib(SBid,"isSB",1);
102   int homo = homog(Li[2]);               //is 1 if id is homogeneous, 0 if not
103
104//---- set attributes for special cases where algorithm can be simplified -----
105   if( homo==1 )
106   {
107      rw = ringweights(P);
108   }
109   if( typeof(attrib(id,"isPrim"))=="int" )
110   {
111      if(attrib(id,"isPrim")==1)  { isPr=1; }
112   }
113   if( typeof(attrib(id,"isIsolatedSingularity"))=="int" )
114   {
115      if(attrib(id,"isIsolatedSingularity")==1) { isIso=1; }
116   }
117   if( typeof(attrib(id,"isCohenMacaulay"))=="int" )
118   {
119      if(attrib(id,"isCohenMacaulay")==1) { isCo=1; }
120   }
121   if( typeof(attrib(id,"isRegInCodim2"))=="int" )
122   {
123      if(attrib(id,"isRegInCodim2")==1) { isRe=1; }
124   }
125   if( typeof(attrib(id,"isEquidimensional"))=="int" )
126   {
127      if(attrib(id,"isEquidimensional")==1) { isEq=1; }
128   }
129//-------------------------- go to quotient ring ------------------------------
130 qring R  = SBid;
131   ideal id = fetch(P,id);
132   ideal J  = fetch(P,J);
133   poly p   = fetch(P,p);
134   ideal f,rf,f2;
135   module syzf;
136
137//---------- computation of p*Hom(J,J) as R-ideal -----------------------------
138   if ( y>=1 )
139   {
140     "// compute p*Hom(J,J) = p*J:J, p a non-zerodivisor";
141     "//   p is equal to:"; "";
142     p;
143     "";
144   }
145   f  = quotient(p*J,J);
146   if ( y>=1 )
147   { "// the module p*Hom(J,J) = p*J:J, p a non-zerodivisor";
148      "// p"; p;
149      "// f=p*J:J";f;
150   }
151   f2 = std(p);
152
153   if(isIso==0)
154   {
155     ideal f1=std(f);
156     attrib(f1,"isSB",1);
157    // if( codim(f1,f2) >= 0 )
158    // {
159    //  dbprint(printlevel-voice+3,"// dimension of non-normal locus is zero");
160    //    isIso=1;
161    // }
162  }
163//---------- Test: Hom(J,J) == R ?, if yes, go home ---------------------------
164
165   rf = interred(reduce(f,f2));       // represents p*Hom(J,J)/p*R = Hom(J,J)/R
166   if ( size(rf) == 0 )
167   {
168      if ( homog(f) && find(ordstr(basering),"s")==0 )
169      {
170         ring newR1 = char(P),(X(1..nvars(P))),(a(rw),dp);
171      }
172      else
173      {
174         ring newR1 = char(P),(X(1..nvars(P))),dp;
175      }
176      ideal endphi = maxideal(1);
177      ideal endid = fetch(P,id);
178      L=substpart(endid,endphi,homo,rw);
179      def lastRing=L[1];
180      setring lastRing;
181
182      attrib(endid,"isCohenMacaulay",isCo);
183      attrib(endid,"isPrim",isPr);
184      attrib(endid,"isIsolatedSingularity",isIso);
185      attrib(endid,"isRegInCodim2",isRe);
186      attrib(endid,"isEqudimensional",isEq);
187      attrib(endid,"isCompleteIntersection",0);
188      attrib(endid,"isRad",0);
189//      export endid;
190//      export endphi;
191//      L = newR1;
192      L=lastRing;
193      L = insert(L,1,1);
194      dbprint(y,"// case R = Hom(J,J)");
195      if(y>=1)
196      {
197         "//   R=Hom(J,J)";
198         "   ";
199         lastRing;
200         "   ";
201         "//   the new ideal";
202         endid;
203         "   ";
204         "//   the old ring";
205         "   ";
206         P;
207         "   ";
208         "//   the old ideal";
209         "   ";
210         setring P;
211         id;
212         "   ";
213         setring lastRing;
214         "//   the map";
215         "   ";
216         endphi;
217         "   ";
218         pause();
219         newline;
220      }
221      setring P;
222      return(L);
223   }
224   if(y>=1)
225   {
226      "// R is not equal to Hom(J,J), we have to try again";
227      pause();
228      newline;
229   }
230//---------- Hom(J,J) != R: create new ring and map from old ring -------------
231// the ring newR1/SBid+syzf will be isomorphic to Hom(J,J) as R-module
232
233   f = p,rf;          // generates pJ:J mod(p), i.e. p*Hom(J,J)/p*R as R-module
234   q = size(f);
235   syzf = syz(f);
236
237   if ( homo==1 )
238   {
239      rw1 = rw,0;
240      for ( ii=2; ii<=q; ii++ )
241      {
242         rw  = rw, deg(f[ii])-deg(f[1]);
243         rw1 = rw1, deg(f[ii])-deg(f[1]);
244      }
245      ring newR1 = char(R),(X(1..nvars(R)),T(1..q)),(a(rw1),dp);
246   }
247   else
248   {
249      ring newR1 = char(R),(X(1..nvars(R)),T(1..q)),dp;
250   }
251
252   map psi1 = P,maxideal(1);
253   ideal SBid = psi1(SBid);
254   attrib(SBid,"isSB",1);
255
256 qring newR = std(SBid);
257   map psi = R,ideal(X(1..nvars(R)));
258   ideal id = psi(id);
259   ideal f = psi(f);
260   module syzf = psi(syzf);
261   ideal pf,Lin,Quad,Q;
262   matrix T,A;
263   list L1;
264
265//---------- computation of Hom(J,J) as affine ring ---------------------------
266// determine kernel of: R[T1,...,Tq] -> J:J >-> R[1/p]=R[t]/(t*p-1),
267// Ti -> fi/p -> t*fi (p=f1=f[1]), to get ring structure. This is of course
268// the same as the kernel of R[T1,...,Tq] -> pJ:J >-> R, Ti -> fi.
269// It is a fact, that the kernel is generated by the linear and the quadratic
270// relations
271
272   pf = f[1]*f;
273   T = matrix(ideal(T(1..q)),1,q);
274   Lin = ideal(T*syzf);
275   if(y>=1)
276   {
277      "// the ring structure of Hom(J,J) as R-algebra";
278      " ";
279      "//   the linear relations";
280      " ";
281      Lin;
282      "   ";
283   }
284   for (ii=2; ii<=q; ii++ )
285   {
286      for ( jj=2; jj<=ii; jj++ )
287      {
288         A = lift(pf,f[ii]*f[jj]);
289         Quad = Quad, ideal(T(jj)*T(ii) - T*A);          // quadratic relations
290      }
291   }
292   if(y>=1)
293   {
294      "//   the quadratic relations";
295      "   ";
296      interred(Quad);
297      pause();
298      newline;
299   }
300   Q = Lin+Quad;
301   Q = subst(Q,T(1),1);
302   Q = interred(reduce(Q,std(0)));
303//---------- reduce number of variables by substitution, if possible ----------
304   if (homo==1)
305   {
306      ring newRing = char(R),(X(1..nvars(R)),T(2..q)),(a(rw),dp);
307   }
308   else
309   {
310      ring newRing = char(R),(X(1..nvars(R)),T(2..q)),dp;
311   }
312
313   ideal endid  = imap(newR,id)+imap(newR,Q);
314   ideal endphi = ideal(X(1..nvars(R)));
315
316   L=substpart(endid,endphi,homo,rw);
317   def lastRing=L[1];
318   setring lastRing;
319   attrib(endid,"isCohenMacaulay",isCo);
320   attrib(endid,"isPrim",isPr);
321   attrib(endid,"isIsolatedSingularity",isIso);
322   attrib(endid,"isRegInCodim2",isRe);
323   attrib(endid,"isEquidimensional",isEq);
324   attrib(endid,"isCompleteIntersection",0);
325   attrib(endid,"isRad",0);
326  // export(endid);
327  // export(endphi);
328   if(y>=1)
329   {
330      "//   the new ring after reduction of the number of variables";
331      "   ";
332      lastRing;
333      "   ";
334      "//   the new ideal";
335      "   ";
336      endid;
337      "   ";
338      "//   the old ring";
339      "   ";
340      P;
341      "   ";
342      "//   the old ideal";
343      "   ";
344      setring P;
345      id;
346      "   ";
347      setring lastRing;
348      "//   the map";
349      "   ";
350      endphi;
351      "   ";
352      pause();
353      newline;
354   }
355   L = lastRing;
356   L = insert(L,0,1);
357   return(L);
358}
359example
360{"EXAMPLE:";  echo = 2;
361  ring r   = 0,(x,y),wp(2,3);
362  ideal id = y^2-x^3;
363  ideal J  = x,y;
364  poly p   = x;
365  list Li = std(id),id,J,p;
366  list L   = HomJJ(Li);
367  def end = L[1];    // defines ring L[1], containing ideals endid, endphi
368  setring end;       // makes end the basering
369  end;
370  endid;             // end/endid is isomorphic to End(r/id) as ring
371  map psi = r,endphi;// defines the canonical map r/id -> End(r/id)
372  psi;
373}
374
375///////////////////////////////////////////////////////////////////////////////
376
377proc normal(ideal id, list #)
378"USAGE:   normal(i [,choose]);  i a radical ideal, choose empty or 1
379         if choose=1 the normalization of the associated primes is computed
380         (which is sometimes more efficient)
381ASSUME:  The ideal must be radical, for non radical ideals the output may
382         be wrong (i=radical(i); makes i radical)
383RETURN:   a list of rings, say nor:
384@format
385         each ring nor[i] contains two ideals
386         with given names norid and normap such that
387           - the direct sum of the rings nor[i]/norid is
388             the normalization of basering/id;
389           - normap gives the normalization map from basering/id
390             to nor[i]/norid (for each i)
391@end format
392NOTE:    to use the i-th ring type: def R=nor[i]; setring R;.
393@*       Increasing printlevel displays more comments (default: printlevel=0)
394@*       Not implemented for local or mixed orderings.
395@*       If the input ideal i is weighted homogeneous a weighted ordering may
396         be used (qhweight(i); computes weights).
397EXAMPLE: example normal; shows an example
398"
399{
400   int i,j,y;
401   string sr;
402   list result,prim,keepresult;
403   y = printlevel-voice+2;
404
405   attrib(id,"isRadical",1);
406   if ( ord_test(basering) != 1)
407   {
408     "";
409     "// Not implemented for this ordering,";
410     "// please change to global ordering!";
411     return(result);
412   }
413   if( typeof(attrib(id,"isCompleteIntersection"))=="int" )
414   {
415      if(attrib(id,"isCompleteIntersection")==1)
416      {
417         attrib(id,"isCohenMacaulay",1);
418         attrib(id,"isEquidimensional",1);
419      }
420   }
421   if( typeof(attrib(id,"isCohenMacaulay"))=="int" )
422   {
423      if(attrib(id,"isCohenMacaulay")==1)
424      {
425         attrib(id,"isEquidimensional",1);
426      }
427   }
428   if( typeof(attrib(id,"isPrim"))=="int" )
429   {
430      if(attrib(id,"isPrim")==1)
431      {
432         attrib(id,"isEquidimensional",1);
433      }
434   }
435   if(size(#)==0)
436   {
437      if( typeof(attrib(id,"isEquidimensional"))=="int" )
438      {
439         if(attrib(id,"isEquidimensional")==1)
440         {
441            prim[1]=id;
442         }
443         else
444         {
445            prim=equidim(id);
446         }
447      }
448      else
449      {
450         prim=equidim(id);
451      }
452      if(y>=1)
453      {
454         "// we have ",size(prim),"equidimensional components";
455      }
456   }
457   else
458   {
459      if( typeof(attrib(id,"isPrim"))=="int" )
460      {
461         if(attrib(id,"isPrim")==1)
462         {
463            prim[1]=id;
464         }
465         else
466         {
467            prim=minAssPrimes(id);
468         }
469      }
470      else
471      {
472         prim=minAssPrimes(id);
473      }
474      if(y>=1)
475      {
476         "// we have ",size(prim),"irreducible components";
477      }
478   }
479   for(i=1; i<=size(prim); i++)
480   {
481      if(y>=1)
482      {
483         "// we are in loop ",i;
484      }
485      attrib(prim[i],"isCohenMacaulay",0);
486      if(size(#)!=0)
487      {
488         attrib(prim[i],"isPrim",1);
489      }
490      else
491      {
492         attrib(prim[i],"isPrim",0);
493      }
494      attrib(prim[i],"isRegInCodim2",0);
495      attrib(prim[i],"isIsolatedSingularity",0);
496      attrib(prim[i],"isEquidimensional",1);
497      attrib(prim[i],"isCompleteIntersection",0);
498
499      if( typeof(attrib(id,"isIsolatedSingularity"))=="int" )
500      {
501            if(attrib(id,"isIsolatedSingularity")==1)
502             {attrib(prim[i],"isIsolatedSingularity",1); }
503      }
504
505      if( typeof(attrib(id,"isCompleteIntersection"))=="int" )
506      {
507            if((attrib(id,"isIsolatedSingularity")==1)&&(size(#)==0))
508             {attrib(prim[i],"isIsolatedSingularity",1); }
509      }
510      keepresult=normalizationPrimes(prim[i],maxideal(1));
511      for(j=1;j<=size(keepresult);j++)
512      {
513         result=insert(result,keepresult[j]);
514      }
515      sr = string(size(result));
516   }
517      dbprint(y+1,"
518// 'normal' created a list of "+sr+" ring(s).
519// To see the rings, type (if the name of your list is nor):
520     show( nor);
521// To access the 1-st ring and map (similair for the others), type:
522     def R = nor[1]; setring R;  norid; normap;
523// R/norid is the 1-st ring of the normalization and
524// normap the map from the original basering to R/norid");
525
526      //kill endphi,endid;
527      return(result);
528}
529example
530{ "EXAMPLE:"; echo = 2;
531   ring r=32003,(x,y,z),wp(2,1,2);
532   ideal i=z3-xy4;
533   list nor=normal(i);
534   show(nor);
535   def r1=nor[1];
536   setring r1;
537   norid;
538   normap;
539}
540
541///////////////////////////////////////////////////////////////////////////////
542static proc normalizationPrimes(ideal i,ideal ihp, list #)
543"USAGE:   normalizationPrimes(i,ihp[,si]);  i prime ideal, ihp map
544         (partial normalization), si SB of singular locus
545RETURN:  a list of one ring L=R, in  R are two ideals
546         S,M such that R/M is the normalization
547         S is a standardbasis of M
548NOTE:    to use the ring: def r=L[1];setring r;
549         printlevel >= voice+1: display comments (default: printlevel=0)
550EXAMPLE: example normalizationPrimes; shows an example
551"
552{
553   int y = printlevel-voice+2;  // y=printlevel (default: y=0)
554
555   if(y>=1)
556   {
557     "";
558     "// START a normalization loop with the ideal";  "";
559     i;  "";
560     basering;  "";
561     pause();
562     newline;
563   }
564
565   def BAS=basering;
566   list result,keepresult1,keepresult2;
567   ideal J,SB,MB;
568   int depth,lauf,prdim;
569   int ti=timer;
570
571   if(size(i)==0)
572   {
573      if(y>=1)
574      {
575          "// the ideal was the zero-ideal";
576      }
577         execute("ring newR7="+charstr(basering)+",("+varstr(basering)+"),("
578                      +ordstr(basering)+");");
579         ideal norid=ideal(0);
580         ideal normap=fetch(BAS,ihp);
581         export norid;
582         export normap;
583         result=newR7;
584         setring BAS;
585         return(result);
586   }
587
588   if(y>=1)
589   {
590     "// SB-computation of the input ideal";
591   }
592
593   list SM=mstd(i);                //here the work starts
594   int dimSM =  dim(SM[1]);        //dimension of variety to normalize
595  // Case: Get an ideal containing a unit
596   if( dimSM == -1)
597   {  "";
598      "      // A unit ideal was found.";
599      "      // Stop with partial result computed so far";"";
600
601         MB=SM[2];
602         intvec rw;
603         list LL=substpart(MB,ihp,0,rw);
604         def newR6=LL[1];
605         setring newR6;
606         ideal norid=endid;
607         ideal normap=endphi;
608         kill endid,endphi;
609         export norid;
610         export normap;
611         result=newR6;
612         setring BAS;
613         return(result);
614   }
615
616   if(y>=1)
617   {
618      "//   the dimension is:"; "";
619      dimSM;"";
620   }
621
622   if(size(#)>0)
623   {
624      list JM=mstd(#[1]);
625      if( typeof(attrib(#[1],"isRad"))!="int" )
626      {
627         attrib(JM[2],"isRad",0);
628      }
629   }
630
631   if(attrib(i,"isPrim")==1)
632   {
633      attrib(SM[2],"isPrim",1);
634   }
635   else
636   {
637      attrib(SM[2],"isPrim",0);
638   }
639   if(attrib(i,"isIsolatedSingularity")==1)
640   {
641      attrib(SM[2],"isIsolatedSingularity",1);
642   }
643   else
644   {
645      attrib(SM[2],"isIsolatedSingularity",0);
646   }
647   if(attrib(i,"isCohenMacaulay")==1)
648   {
649      attrib(SM[2],"isCohenMacaulay",1);
650   }
651   else
652   {
653      attrib(SM[2],"isCohenMacaulay",0);
654   }
655   if(attrib(i,"isRegInCodim2")==1)
656   {
657      attrib(SM[2],"isRegInCodim2",1);
658   }
659   else
660   {
661      attrib(SM[2],"isRegInCodim2",0);
662   }
663   if(attrib(i,"isEquidimensional")==1)
664   {
665      attrib(SM[2],"isEquidimensional",1);
666   }
667   else
668   {
669      attrib(SM[2],"isEquidimensional",0);
670   }
671    if(attrib(i,"isCompleteIntersection")==1)
672   {
673      attrib(SM[2],"isCompleteIntersection",1);
674   }
675   else
676   {
677      attrib(SM[2],"isCompleteIntersection",0);
678   }
679
680   //the smooth case
681   if(size(#)>0)
682   {
683      if(dim(JM[1])==-1)
684      {
685         if(y>=1)
686         {
687            "// the ideal was smooth";
688         }
689         MB=SM[2];
690         intvec rw;
691         list LL=substpart(MB,ihp,0,rw);
692         def newR6=LL[1];
693         setring newR6;
694         ideal norid=endid;
695         ideal normap=endphi;
696         kill endid,endphi;
697         export norid;
698         export normap;
699         result=newR6;
700         setring BAS;
701         return(result);
702     }
703   }
704
705   //the zero-dimensional case
706   if((dim(SM[1])==0)&&(homog(SM[2])==1))
707   {
708      if(y>=1)
709      {
710         "// the ideal was zero-dimensional and homogeneous";
711      }
712      MB=maxideal(1);
713      intvec rw;
714      list LL=substpart(MB,ihp,0,rw);
715      def newR5=LL[1];
716      setring newR5;
717      ideal norid=endid;
718      ideal normap=endphi;
719      kill endid,endphi;
720      export norid;
721      export normap;
722      result=newR5;
723      setring BAS;
724      return(result);
725   }
726
727   //the one-dimensional case
728   //in this case it is a line because
729   //it is irreducible and homogeneous
730   if((dim(SM[1])==1)&&(attrib(SM[2],"isPrim")==1)
731        &&(homog(SM[2])==1))
732   {
733      if(y>=1)
734      {
735         "// the ideal defines a line";
736      }
737      MB=SM[2];
738      intvec rw;
739      list LL=substpart(MB,ihp,0,rw);
740      def newR4=LL[1];
741      setring newR4;
742      ideal norid=endid;
743      ideal normap=endphi;
744      kill endid,endphi;
745      export norid;
746      export normap;
747      result=newR4;
748      setring BAS;
749      return(result);
750   }
751
752   //the higher dimensional case
753   //we test first of all CohenMacaulay and
754   //complete intersection
755   if(((size(SM[2])+dim(SM[1]))==nvars(basering))&&(homog(SM[2])==1))
756   {
757      //test for complete intersection
758      attrib(SM[2],"isCohenMacaulay",1);
759      attrib(SM[2],"isCompleteIntersection",1);
760      attrib(SM[2],"isEquidimensional",1);
761      if(y>=1)
762      {
763         "// the ideal is a complete intersection";
764      }
765   }
766
767   //compute the singular locus+lower dimensional components
768   if(((attrib(SM[2],"isIsolatedSingularity")==0)||(homog(SM[2])==0))
769        &&(size(#)==0))
770   {
771/*
772write (":a normal-fehler" ,
773         "basering:",string(basering),"nvars:", nvars(basering),
774       "dim(SM[1]):",dim(SM[1]),"ncols(jacob(SM[2]))",ncols(jacob(SM[2])),
775       "SM:", SM);
776
777     pause();
778*/
779      J=minor(jacob(SM[2]),nvars(basering)-dim(SM[1]));
780      //ti=timer;
781      if(y >=1 )
782      {
783         "// SB of singular locus will be computed";
784      }
785      ideal sin=J+SM[2];
786
787    //kills the embeded components
788
789      list JM=mstd(sin);
790      //JM[1] SB os singular locus, JM[2]=minbasis of singular locus
791      //SM[1] SB of irreducible component, SM[2] minbasis
792      if(y>=1)
793      {
794         "//   the dimension of the singular locus is:";"";
795         dim(JM[1]); "";
796      }
797      //   timer-ti;
798      attrib(JM[1],"isSB",1);
799      if(dim(JM[1])==-1)
800      {
801         if(y>=1)
802         {
803            "// the ideal is smooth";
804         }
805         MB=SM[2];
806         intvec rw;
807         list LL=substpart(MB,ihp,0,rw);
808         def newR3=LL[1];
809         setring newR3;
810         ideal norid=endid;
811         ideal normap=endphi;
812         kill endid,endphi;
813         export norid;
814         export normap;
815         result=newR3;
816         setring BAS;
817         return(result);
818      }
819      if(dim(JM[1])==0)
820      {
821         attrib(SM[2],"isIsolatedSingularity",1);
822      }
823      if(dim(JM[1])<=dim(SM[1])-2)
824      {
825         attrib(SM[2],"isRegInCodim2",1);
826      }
827   }
828   else
829   {
830     if(size(#)==0)
831     {
832        list JM=maxideal(1),maxideal(1);
833
834        attrib(JM[1],"isSB",1);
835        attrib(SM[2],"isRegInCodim2",1);
836     }
837   }
838   if((attrib(SM[2],"isRegInCodim2")==1)&&(attrib(SM[2],"isCohenMacaulay")==1))
839   {
840      if(y>=1)
841      {
842            "// the ideal was CohenMacaulay and regular in codimension 2";
843      }
844      MB=SM[2];
845      intvec rw;
846      list LL=substpart(MB,ihp,0,rw);
847      def newR6=LL[1];
848      setring newR6;
849      ideal norid=endid;
850      ideal normap=endphi;
851      kill endid,endphi;
852      export norid;
853      export normap;
854      result=newR6;
855      setring BAS;
856      return(result);
857   }
858   //if it is an isolated singularity things are easier
859   //JM ideal of singular locus, SM ideal of variety
860   if((dim(JM[1])==0)&&(homog(SM[2])==1))            //isolated sing. case
861   {
862      attrib(SM[2],"isIsolatedSingularity",1);
863      ideal SL=simplify(reduce(maxideal(1),SM[1]),2);
864           //vars not contained in ideal
865      ideal Ann=quotient(SM[2],SL[1]);
866      ideal qAnn=simplify(reduce(Ann,SM[1]),2);
867
868      //qAnn=0 ==> the first var(=SL[1]) not contained in SM is a nzd of R/SM
869      if(size(qAnn)==0)
870      {
871         if(y>=1)
872         {
873            "";
874            "//   the ideal rad(J):";
875            "";
876            maxideal(1);
877            newline;
878         }
879         //again test for normality
880         //Hom(I,R)=R
881         list RR;
882         RR=SM[1],SM[2],maxideal(1),SL[1];
883         ti=timer;
884         RR=HomJJ(RR,y);
885         if(RR[2]==0)
886         {
887            def newR=RR[1];
888            setring newR;
889            map psi=BAS,endphi;
890         //   ti=timer;
891            list tluser=normalizationPrimes(endid,psi(ihp));
892
893        //    timer-ti;
894            setring BAS;
895            return(tluser);
896         }
897         MB=SM[2];
898         execute("ring newR7="+charstr(basering)+",("+varstr(basering)+"),("
899                      +ordstr(basering)+");");
900         ideal norid=fetch(BAS,MB);
901         ideal normap=fetch(BAS,ihp);
902         export norid;
903         export normap;
904         result=newR7;
905         // the following 2 lines don't work : nor is not defined
906         //def R = nor[1]; setring R;     //make the 1-st ring the basering
907         //norid; normap;                 //data of the normalization)
908         setring BAS;
909         return(result);
910
911       }
912      //Now the case where qAnn!=0, i.e.SL[1] is a zero divisor of R/SM
913      //and we have found a splitting: id and id1
914      //id=qAnn+SM[2] defines components of R/SM in the complement of V(SL[1])
915      //id1 defines components of R/SM in the complement of V(id)
916      //?????instead of id1 we can take SL[1]+Ann+SM[2]???????????
917       else
918       {
919          ideal id=qAnn+SM[2];
920
921          attrib(id,"isCohenMacaulay",0);
922          attrib(id,"isPrim",0);
923          attrib(id,"isIsolatedSingularity",1);
924          attrib(id,"isRegInCodim2",0);
925          attrib(id,"isCompleteIntersection",0);
926          attrib(id,"isEquidimensional",0);
927
928          keepresult1=normalizationPrimes(id,ihp);
929          ideal id1=quotient(SM[2],Ann)+SM[2];
930//          evtl. qAnn statt Ann nehmen
931//          ideal id=SL[1]+SM[2];
932
933          attrib(id1,"isCohenMacaulay",0);
934          attrib(id1,"isPrim",0);
935          attrib(id1,"isIsolatedSingularity",1);
936          attrib(id1,"isRegInCodim2",0);
937          attrib(id1,"isCompleteIntersection",0);
938          attrib(id1,"isEquidimensional",0);
939
940          keepresult2=normalizationPrimes(id1,ihp);
941
942          for(lauf=1;lauf<=size(keepresult2);lauf++)
943          {
944             keepresult1=insert(keepresult1,keepresult2[lauf]);
945          }
946          return(keepresult1);
947       }
948   }
949
950   //test for non-normality
951   //Hom(I,I)<>R
952   //we can use Hom(I,I) to continue
953
954   ideal SL=simplify(reduce(JM[2],SM[1]),2);
955   ideal Ann=quotient(SM[2],SL[1]);
956   ideal qAnn=simplify(reduce(Ann,SM[1]),2);
957
958   if(size(qAnn)==0)
959   {
960      list RR;
961      list RS;
962      //now we have to compute the radical
963      if(y>=1)
964      {
965         "// radical computation of singular locus";
966      }
967
968      //J=radical(SM[2]+ideal(SL[1]));   //JM[2] contains SM[2]+ideal(SL[1])
969      J=radical(JM[2]);   //the singular locus
970      if(y>=1)
971      {
972        "//   radical is equal to:";"";
973        J;
974        "";
975      }
976
977      JM=J,J;
978
979      //evtl. fuer SL[1] anderen Nichtnullteiler aus J waehlen
980      RR=SM[1],SM[2],JM[2],SL[1];
981
982      //   evtl eine geeignete Potenz von JM?
983     if(y>=1)
984     {
985        "// compute Hom(rad(J),rad(J))";
986     }
987
988     RS=HomJJ(RR,y);
989
990      if(RS[2]==1)
991      {
992         def lastR=RS[1];
993         setring lastR;
994         map psi1=BAS,endphi;
995         ideal norid=endid;
996         ideal normap=psi1(ihp);
997         kill endid,endphi;
998         export norid;
999         export normap;
1000         setring BAS;
1001         return(lastR);
1002      }
1003      int n=nvars(basering);
1004      ideal MJ=JM[2];
1005
1006      def newR=RS[1];
1007      setring newR;
1008
1009      map psi=BAS,endphi;
1010      list tluser=
1011             normalizationPrimes(endid,psi(ihp),simplify(psi(MJ)+endid,4));
1012      setring BAS;
1013      return(tluser);
1014   }
1015    // A component with singular locus the whole component found
1016   if( Ann == 1)
1017   {
1018      "// Input appeared not to be a radical ideal!";
1019      "// A (everywhere singular) component with ideal";
1020      "// equal to its Jacobian ideal was found";
1021      "// Procedure will stop with partial result computed so far";"";
1022
1023         MB=SM[2];
1024         intvec rw;
1025         list LL=substpart(MB,ihp,0,rw);
1026         def newR6=LL[1];
1027         setring newR6;
1028         ideal norid=endid;
1029         ideal normap=endphi;
1030         kill endid,endphi;
1031         export norid;
1032         export normap;
1033         result=newR6;
1034         setring BAS;
1035         return(result);
1036   }
1037   else
1038   {
1039      int equi=attrib(SM[2],"isEquidimensional");
1040      ideal new1=qAnn+SM[2];
1041      execute("ring newR1="+charstr(basering)+",("+varstr(basering)+"),("
1042                      +ordstr(basering)+");");
1043      if(y>=1)
1044      {
1045         "// zero-divisor found";
1046      }
1047      ideal vid=fetch(BAS,new1);
1048      ideal ihp=fetch(BAS,ihp);
1049      attrib(vid,"isCohenMacaulay",0);
1050      attrib(vid,"isPrim",0);
1051      attrib(vid,"isIsolatedSingularity",0);
1052      attrib(vid,"isRegInCodim2",0);
1053      if(equi==1)
1054      {
1055         attrib(vid,"isEquidimensional",1);
1056      }
1057      else
1058      {
1059         attrib(vid,"isEquidimensional",0);
1060      }
1061      attrib(vid,"isCompleteIntersection",0);
1062
1063      keepresult1=normalizationPrimes(vid,ihp);
1064
1065      setring BAS;
1066      ideal new2=quotient(SM[2],Ann)+SM[2];
1067// evtl. qAnn nehmen
1068      execute("ring newR2="+charstr(basering)+",("+varstr(basering)+"),("
1069                      +ordstr(basering)+");");
1070
1071      ideal vid=fetch(BAS,new2);
1072      ideal ihp=fetch(BAS,ihp);
1073      attrib(vid,"isCohenMacaulay",0);
1074      attrib(vid,"isPrim",0);
1075      attrib(vid,"isIsolatedSingularity",0);
1076      attrib(vid,"isRegInCodim2",0);
1077      if(equi==1)
1078      {
1079         attrib(vid,"isEquidimensional",1);
1080      }
1081      else
1082      {
1083         attrib(vid,"isEquidimensional",0);
1084      }
1085      attrib(vid,"isCompleteIntersection",0);
1086
1087      keepresult2=normalizationPrimes(vid,ihp);
1088
1089      setring BAS;
1090      for(lauf=1;lauf<=size(keepresult2);lauf++)
1091      {
1092         keepresult1=insert(keepresult1,keepresult2[lauf]);
1093      }
1094      return(keepresult1);
1095   }
1096}
1097example
1098{ "EXAMPLE:";echo = 2;
1099   // Huneke
1100   ring qr=31991,(a,b,c,d,e),dp;
1101   ideal i=
1102   5abcde-a5-b5-c5-d5-e5,
1103   ab3c+bc3d+a3be+cd3e+ade3,
1104   a2bc2+b2cd2+a2d2e+ab2e2+c2de2,
1105   abc5-b4c2d-2a2b2cde+ac3d2e-a4de2+bcd2e3+abe5,
1106   ab2c4-b5cd-a2b3de+2abc2d2e+ad4e2-a2bce3-cde5,
1107   a3b2cd-bc2d4+ab2c3e-b5de-d6e+3abcd2e2-a2be4-de6,
1108   a4b2c-abc2d3-ab5e-b3c2de-ad5e+2a2bcde2+cd2e4,
1109   b6c+bc6+a2b4e-3ab2c2de+c4d2e-a3cde2-abd3e2+bce5;
1110
1111   list pr=normalizationPrimes(i);
1112   def r1=pr[1];
1113   setring r1;
1114   norid;
1115   normap;
1116}
1117///////////////////////////////////////////////////////////////////////////////
1118static proc substpart(ideal endid, ideal endphi, int homo, intvec rw)
1119
1120"//Repeated application of elimpart to endid, until no variables can be
1121//directy substituded. homo=1 if input is homogeneous, rw contains
1122//original weights, endphi (partial) normalization map";
1123
1124{
1125   def newRing=basering;
1126   int ii,jj;
1127   map phi = basering,maxideal(1);
1128
1129   //endid=diagon(endid);
1130
1131   list Le = elimpart(endid);
1132                                     //this proc and the next loop try to
1133   int q = size(Le[2]);              //substitute as many variables as possible
1134   intvec rw1 = 0;                   //indices of substituted variables
1135   rw1[nvars(basering)] = 0;
1136   rw1 = rw1+1;
1137
1138   while( size(Le[2]) != 0 )
1139   {
1140      endid = Le[1];
1141      map ps = newRing,Le[5];
1142
1143      phi = ps(phi);
1144      for(ii=1;ii<=size(Le[2])-1;ii++)
1145      {
1146         phi=phi(phi);
1147      }
1148      //eingefuegt wegen x2-y2z2+z3
1149      kill ps;
1150
1151      for( ii=1; ii<=size(rw1); ii++ )
1152      {
1153         if( Le[4][ii]==0 )
1154         {
1155            rw1[ii]=0;                             //look for substituted vars
1156         }
1157      }
1158      Le=elimpart(endid);
1159      q = q + size(Le[2]);
1160   }
1161   endphi = phi(endphi);
1162
1163//---------- return -----------------------------------------------------------
1164// in the homogeneous case put weights for the remaining vars correctly, i.e.
1165// delete from rw those weights for which the corresponding entry of rw1 is 0
1166
1167   if (homo==1 && nvars(newRing)-q >1 && size(endid) >0 )
1168   {
1169      jj=1;
1170      for( ii=2; ii<size(rw1); ii++)
1171      {
1172         jj++;
1173         if( rw1[ii]==0 )
1174         {
1175            rw=rw[1..jj-1],rw[jj+1..size(rw)];
1176            jj=jj-1;
1177         }
1178      }
1179      if( rw1[1]==0 ) { rw=rw[2..size(rw)]; }
1180      if( rw1[size(rw1)]==0 ){ rw=rw[1..size(rw)-1]; }
1181
1182      ring lastRing = char(basering),(T(1..nvars(newRing)-q)),(a(rw),dp);
1183   }
1184   else
1185   {
1186      ring lastRing = char(basering),(T(1..nvars(newRing)-q)),dp;
1187   }
1188
1189   ideal lastmap;
1190   q = 1;
1191   for(ii=1; ii<=size(rw1); ii++ )
1192   {
1193      if ( rw1[ii]==1 ) { lastmap[ii] = T(q); q=q+1; }
1194      if ( rw1[ii]==0 ) { lastmap[ii] = 0; }
1195   }
1196   map phi1 = newRing,lastmap;
1197   ideal endid  = phi1(endid);
1198   ideal endphi = phi1(endphi);
1199   export(endid);
1200   export(endphi);
1201   list L = lastRing;
1202   setring newRing;
1203   return(L);
1204}
1205///////////////////////////////////////////////////////////////////////////////
1206static
1207proc diagon(ideal i)
1208{
1209   matrix m;
1210   intvec iv = option(get);
1211   option(redSB);
1212   ideal j=liftstd(jet(i,1),m);
1213   option(set,iv);
1214   return(ideal(matrix(i)*m));
1215}
1216/////////////////////////////////////////////////////////////////////////////
1217/*
1218                           Examples:
1219LIB"normal.lib";
1220//Huneke
1221ring qr=31991,(a,b,c,d,e),dp;
1222ideal i=
12235abcde-a5-b5-c5-d5-e5,
1224ab3c+bc3d+a3be+cd3e+ade3,
1225a2bc2+b2cd2+a2d2e+ab2e2+c2de2,
1226abc5-b4c2d-2a2b2cde+ac3d2e-a4de2+bcd2e3+abe5,
1227ab2c4-b5cd-a2b3de+2abc2d2e+ad4e2-a2bce3-cde5,
1228a3b2cd-bc2d4+ab2c3e-b5de-d6e+3abcd2e2-a2be4-de6,
1229a4b2c-abc2d3-ab5e-b3c2de-ad5e+2a2bcde2+cd2e4,
1230b6c+bc6+a2b4e-3ab2c2de+c4d2e-a3cde2-abd3e2+bce5;
1231
1232
1233//Vasconcelos (dauert laenger: 60 sec)
1234ring r=32003,(x,y,z,w,t),dp;
1235ideal i=
1236x2+zw,
1237y3+xwt,
1238xw3+z3t+ywt2,
1239y2w4-xy2z2t-w3t3;
1240
1241//Theo1
1242ring r=32003,(x,y,z),wp(2,3,6);
1243ideal i=zy2-zx3-x6;
1244
1245//Theo1a (CohenMacaulay and regular in codimension 2)
1246ring r=32003,(x,y,z,u),wp(2,3,6,6);
1247ideal i=zy2-zx3-x6+u2;
1248
1249
1250//Theo2
1251ring r=32003,(x,y,z),wp(3,4,12);
1252ideal i=z*(y3-x4)+x8;
1253
1254//Theo2a
1255ring r=32003,(T(1..4)),wp(3,4,12,17);
1256ideal i=
1257T(1)^8-T(1)^4*T(3)+T(2)^3*T(3),
1258T(1)^4*T(2)^2-T(2)^2*T(3)+T(1)*T(4),
1259T(1)^7+T(1)^3*T(2)^3-T(1)^3*T(3)+T(2)*T(4),
1260T(1)^6*T(2)*T(3)+T(1)^2*T(2)^4*T(3)+T(1)^3*T(2)^2*T(4)-T(1)^2*T(2)*T(3)^2+T(4)^2;
1261
1262//Theo3
1263ring r=32003,(x,y,z),wp(3,5,15);
1264ideal i=z*(y3-x5)+x10;
1265
1266
1267//Theo4
1268ring r=32003,(x,y,z),dp;
1269ideal i=(x-y)*(x-z)*(y-z);
1270
1271//Theo5
1272ring r=32003,(x,y,z),wp(2,1,2);
1273ideal i=z3-xy4;
1274
1275//Theo6
1276ring r=32003,(x,y,z),dp;
1277ideal i=x2y2+x2z2+y2z2;
1278
1279ring r=32003,(a,b,c,d,e,f),dp;
1280ideal i=
1281bf,
1282af,
1283bd,
1284ad;
1285
1286//Beispiel, wo vorher Primaerzerlegung schneller (2 sec,sonst 860 sec)
1287//ist CM
1288//Sturmfels
1289ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
1290ideal i=
1291bv+su,
1292bw+tu,
1293sw+tv,
1294by+sx,
1295bz+tx,
1296sz+ty,
1297uy+vx,
1298uz+wx,
1299vz+wy,
1300bvz;
1301
1302//J S/Y
1303ring r=32003,(x,y,z,t),dp;
1304ideal i=
1305x2z+xzt,
1306xyz,
1307xy2-xyt,
1308x2y+xyt;
1309
1310//St_S/Y
1311ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
1312ideal i=
1313wy-vz,
1314vx-uy,
1315tv-sw,
1316su-bv,
1317tuy-bvz;
1318
1319//dauert laenger ohne Primaerzerlegung vorher (1 sec gegen
1320//Horrocks:
1321ring r=32003,(a,b,c,d,e,f),dp;
1322ideal i=
1323adef-16000be2f+16001cef2,
1324ad2f+8002bdef+8001cdf2,
1325abdf-16000b2ef+16001bcf2,
1326a2df+8002abef+8001acf2,
1327ad2e-8000bde2-7999cdef,
1328acde-16000bce2+16001c2ef,
1329a2de-8000abe2-7999acef,
1330acd2+8002bcde+8001c2df,
1331abd2-8000b2de-7999bcdf,
1332a2d2+9603abde-10800b2e2-9601acdf+800bcef+11601c2f2,
1333abde-8000b2e2-acdf-16001bcef-8001c2f2,
1334abcd-16000b2ce+16001bc2f,
1335a2cd+8002abce+8001ac2f,
1336a2bd-8000ab2e-7999abcf,
1337ab3f-3bdf3,
1338a2b2f-2adf3-16000bef3+16001cf4,
1339a3bf+4aef3,
1340ac3e-10668cde3,
1341a2c2e+10667ade3+16001be4+5334ce3f,
1342a3ce+10669ae3f,
1343bc3d+8001cd3e,
1344ac3d+8000bc3e+16001cd2e2+8001c4f,
1345b2c2d+16001ad4+4000bd3e+12001cd3f,
1346b2c2e-10668bc3f-10667cd2ef,
1347abc2e-cde2f,
1348b3cd-8000bd3f,
1349b3ce-10668b2c2f-10667bd2ef,
1350abc2f-cdef2,
1351a2bce-16000be3f+16001ce2f2,
1352ab3d-8000b4e-8001b3cf+16000bd2f2,
1353ab2cf-bdef2,
1354a2bcf-16000be2f2+16001cef3,
1355a4d-8000a3be+8001a3cf-2ae2f2;
1356
1357
1358ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
1359
1360ideal k=
1361wy-vz,
1362vx-uy,
1363tv-sw,
1364su-bv,
1365tuy-bvz;
1366ideal j=x2y2+x2z2+y2z2;
1367ideal i=mstd(intersect(j,k))[2];
1368
1369//22
1370ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
1371ideal i=
1372wx2y3-vx2y2z+wx2yz2+wy3z2-vx2z3-vy2z3,
1373vx3y2-ux2y3+vx3z2-ux2yz2+vxy2z2-uy3z2,
1374tvx2y2-swx2y2+tvx2z2-swx2z2+tvy2z2-swy2z2,
1375sux2y2-bvx2y2+sux2z2-bvx2z2+suy2z2-bvy2z2,
1376tux2y3-bvx2y2z+tux2yz2+tuy3z2-bvx2z3-bvy2z3;
1377
1378
1379//riemenschneider
1380//33
1381//normal+primary 3
1382//primary 9
1383//radical 1
1384//minAssPrimes 2
1385ring r=32000,(p,q,s,t,u,v,w,x,y,z),wp(1,1,1,1,1,1,2,1,1,1);
1386ideal i=
1387xz,
1388vx,
1389ux,
1390su,
1391qu,
1392txy,
1393stx,
1394qtx,
1395uv2z-uwz,
1396uv3-uvw,
1397puv2-puw;
1398
1399ring r=0,(u,v,w,x,y,z),wp(1,1,1,3,2,1);
1400ideal i=wx,wy,wz,vx,vy,vz,ux,uy,uz,y3-x2;
1401*/
1402
Note: See TracBrowser for help on using the repository browser.