source: git/Singular/LIB/sing.lib

spielwiese
Last change on this file was 9bfa4d, checked in by Hans Schoenemann <hannes@…>, 5 months ago
bigntvec - intvec use (stdhilb, eliminate)
  • Property mode set to 100644
File size: 34.1 KB
Line 
1////////////////////////////////////////////////////////////////////////////
2version="version sing.lib 4.4.0.0 Nov_2023 "; // $Id$
3category="Singularities";
4info="
5LIBRARY:  sing.lib      Invariants of Singularities
6AUTHORS:  Gert-Martin Greuel, email: greuel@mathematik.uni-kl.de @*
7          Bernd Martin, email: martin@math.tu-cottbus.de
8
9PROCEDURES:
10 codim(id1, id2);       vector space dimension of id2/id1 if finite
11 deform(i);             infinitesimal deformations of ideal i
12 dim_slocus(i);         dimension of singular locus of ideal i
13 is_active(f,id);       is polynomial f an active element mod id? (id ideal/module)
14 is_ci(i);              is ideal i a complete intersection?
15 is_is(i);              is ideal i an isolated singularity?
16 is_reg(f,id);          is polynomial f a regular element mod id? (id ideal/module)
17 is_regs(i[,id]);       are gen's of ideal i regular sequence modulo id?
18 locstd(i);             SB for local degree ordering without cancelling units
19 milnor(i);             milnor number of ideal i; (assume i is ICIS in nf)
20 nf_icis(i);            generic combinations of generators; get ICIS in nf
21 slocus(i);             ideal of singular locus of ideal i
22 qhspectrum(f,w);       spectrum numbers of w-homogeneous polynomial f
23 Tjurina(i);            SB of Tjurina module of ideal i (assume i is ICIS)
24 tjurina(i);            Tjurina number of ideal i (assume i is ICIS)
25 T_1(i);                T^1-module of ideal i
26 T_2((i);               T^2-module of ideal i
27 T_12(i);               T^1- and T^2-module of ideal i
28 tangentcone(id);       compute tangent cone of id
29
30";
31
32LIB "inout.lib";
33LIB "random.lib";
34LIB "primdec.lib";
35///////////////////////////////////////////////////////////////////////////////
36
37proc deform (ideal id)
38"USAGE:   deform(id); id=ideal or poly
39RETURN:  matrix, columns are kbase of infinitesimal deformations
40EXAMPLE: example deform; shows an example
41"
42{
43   list L=T_1(id,"");
44   def K=L[1]; attrib(K,"isSB",1);
45   return(matrix(L[2])*matrix(kbase(K)));
46}
47example
48{ "EXAMPLE:"; echo = 2;
49   ring r   = 32003,(x,y,z),ds;
50   ideal i  = xy,xz,yz;
51   matrix T = deform(i);
52   print(T);
53   print(deform(x3+y5+z2));
54}
55///////////////////////////////////////////////////////////////////////////////
56
57proc dim_slocus (ideal i)
58"USAGE:   dim_slocus(i);  i ideal or poly
59RETURN:  dimension of singular locus of i
60EXAMPLE: example dim_slocus; shows an example
61"
62{
63   return(dim(std(slocus(i))));
64}
65example
66{ "EXAMPLE:"; echo = 2;
67   ring r  = 32003,(x,y,z),ds;
68   ideal i = x5+y6+z6,x2+2y2+3z2;
69   dim_slocus(i);
70}
71///////////////////////////////////////////////////////////////////////////////
72
73proc is_active (poly f,def id)
74"USAGE:   is_active(f,id); f poly, id ideal or module
75RETURN:  1 if f is an active element modulo id (i.e. dim(id)=dim(id+f*R^n)+1,
76         if id is a submodule of R^n) resp. 0 if f is not active.
77         The basering may be a quotient ring
78NOTE:    regular parameters are active but not vice versa (id may have embedded
79         components). proc is_reg tests whether f is a regular parameter
80EXAMPLE: example is_active; shows an example
81"
82{
83   if( size(id)==0 ) { return(1); }
84   if( typeof(id)=="ideal" ) { ideal m=f; }
85   if( typeof(id)=="module" ) { module m=f*freemodule(nrows(id)); }
86   return(dim(std(id))-dim(std(id+m)));
87}
88example
89{ "EXAMPLE:"; echo = 2;
90   ring r   =32003,(x,y,z),ds;
91   ideal i  = yx3+y,yz3+y3z;
92   poly f   = x;
93   is_active(f,i);
94   qring q  = std(x4y5);
95   poly f   = x;
96   module m = [yx3+x,yx3+y3x];
97   is_active(f,m);
98}
99///////////////////////////////////////////////////////////////////////////////
100
101proc is_ci (ideal i)
102"USAGE:   is_ci(i); i ideal
103RETURN:  intvec = sequence of dimensions of ideals (j[1],...,j[k]), for
104         k=1,...,size(j), where j is minimal base of i. i is a complete
105         intersection if last number equals nvars-size(i)
106NOTE:    dim(0-ideal) = -1. You may first apply simplify(i,10); in order to
107         delete zeroes and multiples from set of generators
108         printlevel >=0: display comments (default)
109EXAMPLE: example is_ci; shows an example
110"
111{
112   int n; intvec dimvec; ideal id;
113   i=minbase(i);
114   int s = ncols(i);
115   int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
116//--------------------------- compute dimensions ------------------------------
117   for( n=1; n<=s; n=n+1 )
118   {
119      id = i[1..n];
120      dimvec[n] = dim(std(id));
121   }
122   n = dimvec[s];
123//--------------------------- output ------------------------------------------
124   if( n+s != nvars(basering) )
125   { dbprint(p,"// no complete intersection"); }
126   if( n+s == nvars(basering) )
127   { dbprint(p,"// complete intersection of dim "+string(n)); }
128   dbprint(p,"// dim-sequence:");
129   return(dimvec);
130}
131example
132{ "EXAMPLE:"; echo = 2;
133   int p      = printlevel;
134   printlevel = 1;                // display comments
135   ring r     = 32003,(x,y,z),ds;
136   ideal i    = x4+y5+z6,xyz,yx2+xz2+zy7;
137   is_ci(i);
138   i          = xy,yz;
139   is_ci(i);
140   printlevel = p;
141}
142///////////////////////////////////////////////////////////////////////////////
143
144proc is_is (ideal i)
145"USAGE:   is_is(id);  id ideal or poly
146RETURN:  intvec = sequence of dimensions of singular loci of ideals
147         generated by id[1]..id[i], k = 1..size(id); @*
148         dim(0-ideal) = -1;
149         id defines an isolated singularity if last number is 0
150NOTE:    printlevel >=0: display comments (default)
151EXAMPLE: example is_is; shows an example
152"
153{
154  int l; intvec dims; ideal j;
155  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
156//--------------------------- compute dimensions ------------------------------
157   for( l=1; l<=ncols(i); l=l+1 )
158   {
159     j = i[1..l];
160     dims[l] = dim(std(slocus(j)));
161   }
162   dbprint(p,"// dim of singular locus = "+string(dims[size(dims)]),
163             "// isolated singularity if last number is 0 in dim-sequence:");
164   return(dims);
165}
166example
167{ "EXAMPLE:"; echo = 2;
168   int p      = printlevel;
169   printlevel = 1;
170   ring r     = 32003,(x,y,z),ds;
171   ideal i    = x2y,x4+y5+z6,yx2+xz2+zy7;
172   is_is(i);
173   poly f     = xy+yz;
174   is_is(f);
175   printlevel = p;
176}
177///////////////////////////////////////////////////////////////////////////////
178
179proc is_reg (poly f,def id)
180"USAGE:   is_reg(f,id); f poly, id ideal or module
181RETURN:  1 if multiplication with f is injective modulo id, 0 otherwise
182NOTE:    Let R be the basering and id a submodule of R^n. The procedure checks
183         injectivity of multiplication with f on R^n/id. The basering may be a
184         quotient ring.
185EXAMPLE: example is_reg; shows an example
186"
187{
188   if( f==0 ) { return(0); }
189   int d,ii;
190   def q = quotient(id,ideal(f));
191   id=std(id);
192   d=size(q);
193   for( ii=1; ii<=d; ii=ii+1 )
194   {
195      if( reduce(q[ii],id)!=0 )
196      { return(0); }
197   }
198   return(1);
199}
200example
201{ "EXAMPLE:"; echo = 2;
202   ring r  = 32003,(x,y),ds;
203   ideal i = x8,y8;
204   ideal j = (x+y)^4;
205   i       = intersect(i,j);
206   poly f  = xy;
207   is_reg(f,i);
208}
209///////////////////////////////////////////////////////////////////////////////
210
211proc is_regs (ideal i, list #)
212"USAGE:   is_regs(i[,id]); i poly, id ideal or module (default: id=0)
213RETURN:  1 if generators of i are a regular sequence modulo id, 0 otherwise
214NOTE:    Let R be the basering and id a submodule of R^n. The procedure checks
215         injectivity of multiplication with i[k] on R^n/id+i[1..k-1].
216         The basering may be a quotient ring.
217         printlevel >=0: display comments (default)
218         printlevel >=1: display comments during computation
219EXAMPLE: example is_regs; shows an example
220"
221{
222   int d,ii,r;
223   int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
224   if( size(#)==0 ) { ideal id; }
225   else { def id=#[1]; }
226   if( size(i)==0 ) { return(0); }
227   d=size(i);
228   if( typeof(id)=="ideal" ) { ideal m=1; }
229   if( typeof(id)=="module" ) { module m=freemodule(nrows(id)); }
230   for( ii=1; ii<=d; ii=ii+1 )
231   {
232      if( p>=2 )
233      { "// checking whether element",ii,"is regular mod 1 ..",ii-1; }
234      if( is_reg(i[ii],id)==0 )
235      {
236        dbprint(p,"// elements 1.."+string(ii-1)+" are regular, " +
237                string(ii)+" is not regular mod 1.."+string(ii-1));
238         return(0);
239      }
240      id=id+i[ii]*m;
241   }
242   if( p>=1 ) { "// elements are a regular sequence of length",d; }
243   return(1);
244}
245example
246{ "EXAMPLE:"; echo = 2;
247   int p      = printlevel;
248   printlevel = 1;
249   ring r1    = 32003,(x,y,z),ds;
250   ideal i    = x8,y8,(x+y)^4;
251   is_regs(i);
252   module m   = [x,0,y];
253   i          = x8,(x+z)^4;;
254   is_regs(i,m);
255   printlevel = p;
256}
257///////////////////////////////////////////////////////////////////////////////
258
259proc milnor (ideal i)
260"USAGE:   milnor(i); i ideal or poly
261RETURN:  Milnor number of i, if i is ICIS (isolated complete intersection
262         singularity) in generic form, resp. -1 if not
263NOTE:    use proc nf_icis to put generators in generic form
264         printlevel >=1: display comments
265EXAMPLE: example milnor; shows an example
266"
267{
268  i = simplify(i,10);     //delete zeroes and multiples from set of generators
269  int n = size(i);
270  int l,q,m_nr;  ideal t;  intvec disc;
271  int p = printlevel-voice+2;             // p=printlevel+1 (default: p=0)
272//---------------------------- hypersurface case ------------------------------
273  if( n==1 or n==0 )
274  {
275     i = std(jacob(i[1]));
276     m_nr = vdim(i);
277     if( m_nr<0 and p>=1 ) { "// Milnor number is infinite"; }
278     return(m_nr);
279  }
280//------------ isolated complete intersection singularity (ICIS) --------------
281  for( l=n; l>0; l=l-1)
282  {   t      = minor(jacob(i),l);
283      i[l]   = 0;
284      q      = vdim(std(i+t));
285      disc[l]= q;
286      if( q ==-1 )
287      {  if( p>=1 )
288            {  "// not in generic form or no ICIS; use proc nf_icis to put";
289            "// generators in generic form and then try milnor again!";  }
290         return(q);
291      }
292      m_nr = q-m_nr;
293  }
294//---------------------------- change sign ------------------------------------
295  if (m_nr < 0) { m_nr=-m_nr; }
296  if( p>=1 ) { "//sequence of discriminant numbers:",disc; }
297  return(m_nr);
298}
299example
300{ "EXAMPLE:"; echo = 2;
301   int p      = printlevel;
302   printlevel = 2;
303   ring r     = 32003,(x,y,z),ds;
304   ideal j    = x5+y6+z6,x2+2y2+3z2,xyz+yx;
305   milnor(j);
306   poly f     = x7+y7+(x-y)^2*x2y2+z2;
307   milnor(f);
308   printlevel = p;
309}
310///////////////////////////////////////////////////////////////////////////////
311
312proc nf_icis (ideal i)
313"USAGE:   nf_icis(i); i ideal
314RETURN:  ideal = generic linear combination of generators of i if i is an ICIS
315         (isolated complete intersection singularity), return i if not
316NOTE:    this proc is useful in connection with proc milnor
317         printlevel >=0: display comments (default)
318EXAMPLE: example nf_icis; shows an example
319"
320{
321   i = simplify(i,10);  //delete zeroes and multiples from set of generators
322   int p,b = 100,0;
323   int n = size(i);
324   matrix mat=freemodule(n);
325   int P = printlevel-voice+3;  // P=printlevel+1 (default: P=1)
326//---------------------------- test: complete intersection? -------------------
327   intvec sl = is_ci(i);
328   if( n+sl[n] != nvars(basering) )
329   {
330      dbprint(P,"// no complete intersection");
331      return(i);
332   }
333//--------------- test: isolated singularity in generic form? -----------------
334   sl = is_is(i);
335   if ( sl[n] != 0 )
336   {
337      dbprint(P,"// no isolated singularity");
338      return(i);
339   }
340//------------ produce generic linear combinations of generators --------------
341   int prob;
342   while ( sum(sl) != 0 )
343   {  prob=prob+1;
344      p=p-25; b=b+10;
345      i = genericid(i,p,b);          // proc genericid from random.lib
346      sl = is_is(i);
347   }
348   dbprint(P,"// ICIS in generic form after "+string(prob)+" genericity loop(s)");
349   return(i);
350}
351example
352{ "EXAMPLE:"; echo = 2;
353   int p      = printlevel;
354   printlevel = 1;
355   ring r     = 32003,(x,y,z),ds;
356   ideal i    = x3+y4,z4+yx;
357   nf_icis(i);
358   ideal j    = x3+y4,xy,yz;
359   nf_icis(j);
360   printlevel = p;
361}
362///////////////////////////////////////////////////////////////////////////////
363
364proc slocus(ideal i)
365"USAGE:   slocus(i);  i ideal
366RETURN:  ideal of singular locus of i. Quotient rings and rings with integer coefficients are currently not supported.
367EXAMPLE: example slocus; shows an example
368"
369{
370  // quotient rings currently not supported
371  ASSUME( 0, 0==isQuotientRing(basering) );
372  // integer coefficient rings currently not supported
373  ASSUME( 0, hasFieldCoefficient(basering) );
374
375
376  def R=basering;
377  int j,k;
378  ideal res;
379
380  if(ord_test(basering)!=1)
381  {
382     string va=varstr(basering);
383     if( size( parstr(basering))>0){va=va+","+parstr(basering);}
384     execute ("ring S = ("+charstr(basering)+"),("+va+"),dp;");
385     ideal i=imap(R,i);
386     list l=equidim(i);
387     setring R;
388     list l=imap(S,l);
389  }
390  else
391  {
392     list l=equidim(i);
393  }
394  int n=size(l);
395  if (n==1){return(slocusEqi(i));}
396  res=slocusEqi(l[1]);
397  for(j=2;j<=n;j++){res=intersect(res,slocusEqi(l[j]));}
398  for(j=1;j<n;j++)
399  {
400     for(k=j+1;k<=n;k++){res=intersect(res,l[j]+l[k]);}
401  }
402  return(res);
403}
404example
405{ "EXAMPLE:"; echo = 2;
406   ring r  = 0,(u,v,w,x,y,z),dp;
407   ideal i = wx,wy,wz,vx,vy,vz,ux,uy,uz,y3-x2;;
408   slocus(i);
409}
410///////////////////////////////////////////////////////////////////////////////
411
412static proc slocusEqi (ideal i)
413"USAGE:   slocus(i);  i ideal
414RETURN:  ideal of singular locus of i if i is pure dimensional
415NOTE:    this proc returns i and c-minors of jacobian ideal of i where c is the
416         codimension of i. Hence, if i is not pure dimensional, slocus may
417         return an ideal such that its 0-locus is strictly contained in the
418         singular locus of i
419EXAMPLE: example slocus; shows an example
420"
421{
422  ideal ist=std(i);
423  if ( size(ist)==0 ) // we have a zero ideal
424  {
425     // the zero locus of the zero ideal is nonsingular
426     return( ideal(1) ) ;
427  }
428  if( deg( ist[1] ) == 0 ) // the ideal has a constant generator
429  {
430    return(ist);
431  }
432  int cod  = nvars(basering) - dim(ist);
433  i        = i + minor( jacob(i), cod );
434  return(i);
435}
436example
437{ "EXAMPLE:"; echo = 2;
438   ring r  = 0,(x,y,z),ds;
439   ideal i = x5+y6+z6,x2+2y2+3z2;
440   slocus(i);
441}
442///////////////////////////////////////////////////////////////////////////////
443
444proc qhspectrum (poly f, intvec w)
445"USAGE:   qhspectrum(f,w);  f=poly, w=intvec
446ASSUME:  f is a weighted homogeneous isolated singularity w.r.t. the weights
447         given by w; w must consist of as many positive integers as there
448         are variables of the basering
449COMPUTE: the spectral numbers of the w-homogeneous polynomial f, computed in a
450         ring of characteristic 0
451RETURN:  intvec  d,s1,...,su  where:
452         d = w-degree(f)  and  si/d = i-th spectral-number(f)
453         No return value if basering has parameters or if f is no isolated
454         singularity, displays a warning in this case.
455EXAMPLE: example qhspectrum; shows an example
456"
457{
458   int i,d,W;
459   intvec sp;
460   def r   = basering;
461   if( find(charstr(r),",")!=0 )
462   {
463       "// coefficient field must not have parameters!";
464       return();
465    }
466   ring s  = 0,x(1..nvars(r)),ws(w);
467   map phi = r,maxideal(1);
468   poly f  = phi(f);
469   d       = ord(f);
470   W       = sum(w)-d;
471   ideal k = std(jacob(f));
472   if( vdim(k) == -1 )
473   {
474       "// f is no isolated singularity!";
475       return();
476    }
477   k = kbase(k);
478   for (i=1; i<=size(k); i++)
479   {
480      sp[i]=W+ord(k[i]);
481   }
482   list L  = sort(sp);
483   sp      = d,L[1];
484   return(sp);
485}
486example
487{ "EXAMPLE:"; echo = 2;
488   ring r;
489   poly f=x3+y5+z2;
490   intvec w=10,6,15;
491   qhspectrum(f,w);
492   // the spectrum numbers are:
493   // 1/30,7/30,11/30,13/30,17/30,19/30,23/30,29/30
494}
495///////////////////////////////////////////////////////////////////////////////
496
497proc Tjurina (def id, list #)
498"USAGE:   Tjurina(id[,<any>]);  id=ideal or poly
499ASSUME:  id=ICIS (isolated complete intersection singularity)
500RETURN:  standard basis of Tjurina-module of id,
501         of type module if id=ideal, resp. of type ideal if id=poly.
502         If a second argument is present (of any type) return a list: @*
503           [1] = Tjurina number,
504           [2] = k-basis of miniversal deformation,
505           [3] = SB of Tjurina module,
506           [4] = Tjurina module
507DISPLAY: Tjurina number if printlevel >= 0 (default)
508NOTE:    Tjurina number = -1 implies that id is not an ICIS
509EXAMPLE: example Tjurina; shows examples
510"
511{
512//---------------------------- initialisation ---------------------------------
513  def i = simplify(id,10);
514  int tau,n = 0,size(i);
515  if( size(ideal(i))==1 ) { def m=i; }  // hypersurface case
516  else { def m=i*freemodule(n); }       // complete intersection case
517//--------------- compute Tjurina module, Tjurina number etc ------------------
518  def t1 = jacob(i)+m;                  // Tjurina module/ideal
519  def st1 = std(t1);                    // SB of Tjurina module/ideal
520  tau = vdim(st1);                      // Tjurina number
521  dbprint(printlevel-voice+3,"// Tjurina number = "+string(tau));
522  if( size(#)>0 )
523  {
524     def kB = kbase(st1);               // basis of miniversal deformation
525     return(tau,kB,st1,t1);
526  }
527  return(st1);
528}
529example
530{ "EXAMPLE:"; echo = 2;
531   int p      = printlevel;
532   printlevel = 1;
533   ring r     = 0,(x,y,z),ds;
534   poly f     = x5+y6+z7+xyz;        // singularity T[5,6,7]
535   list T     = Tjurina(f,"");
536   show(T[1]);                       // Tjurina number, should be 16
537   show(T[2]);                       // basis of miniversal deformation
538   show(T[3]);                       // SB of Tjurina ideal
539   show(T[4]); "";                   // Tjurina ideal
540   ideal j    = x2+y2+z2,x2+2y2+3z2;
541   show(kbase(Tjurina(j)));          // basis of miniversal deformation
542   hilb(Tjurina(j));                 // Hilbert series of Tjurina module
543   printlevel = p;
544}
545///////////////////////////////////////////////////////////////////////////////
546
547proc tjurina (ideal i)
548"USAGE:   tjurina(id);  id=ideal or poly
549ASSUME:  id=ICIS (isolated complete intersection singularity)
550RETURN:  int = Tjurina number of id
551NOTE:    Tjurina number = -1 implies that id is not an ICIS
552EXAMPLE: example tjurina; shows an example
553"
554{
555   return(vdim(Tjurina(i)));
556}
557example
558{ "EXAMPLE:"; echo = 2;
559   ring r=32003,(x,y,z),(c,ds);
560   ideal j=x2+y2+z2,x2+2y2+3z2;
561   tjurina(j);
562}
563///////////////////////////////////////////////////////////////////////////////
564
565proc T_1 (ideal id, list #)
566"USAGE:   T_1(id[,<any>]);  id = ideal or poly
567RETURN:  T_1(id): of type module/ideal if id is of type ideal/poly.
568         We call T_1(id) the T_1-module of id. It is a std basis of the
569         presentation of 1st order deformations of P/id, if P is the basering.
570         If a second argument is present (of any type) return a list of
571         3 modules:
572            [1]= T_1(id)
573            [2]= generators of normal bundle of id, lifted to P
574            [3]= module of relations of [2], lifted to P
575                 (note: transpose[3]*[2]=0 mod id)
576         The list contains all non-easy objects which must be computed
577         to get T_1(id).
578DISPLAY: k-dimension of T_1(id) if printlevel >= 0 (default)
579NOTE:    T_1(id) itself is usually of minor importance. Nevertheless, from it
580         all relevant information can be obtained. The most important are
581         probably vdim(T_1(id)); (which computes the Tjurina number),
582         hilb(T_1(id)); and kbase(T_1(id)).
583         If T_1 is called with two arguments, then matrix([2])*(kbase([1]))
584         represents a basis of 1st order semiuniversal deformation of id
585         (use proc 'deform', to get this in a direct way).
586         For a complete intersection the proc Tjurina is faster.
587EXAMPLE: example T_1; shows an example
588"
589{
590   def RR=basering;
591   list RRL=ring_list(RR);
592   if(RRL[4]!=0)
593   {
594      int aa=size(#);
595      ideal QU=RRL[4];
596      RRL[4]=ideal(0);
597      def RS=ring(RRL);
598      setring RS;
599      ideal id=imap(RR,id);
600      ideal QU=imap(RR,QU);
601      if(aa)
602      {
603         list RES=T_1(id+QU,1);
604      }
605      else
606      {
607         module RES=T_1(id+QU);
608      }
609      setring RR;
610      def RES=imap(RS,RES);
611      return(RES);
612   }
613   ideal J=simplify(id,10);
614//--------------------------- hypersurface case -------------------------------
615  if( size(J)<2 )
616  {
617     ideal t1  = std(J+jacob(J[1]));
618     module nb = [1]; module pnb;
619     dbprint(printlevel-voice+3,"// dim T_1 = "+string(vdim(t1)));
620     if( size(#)>0 )
621     {
622        module st1 = t1*gen(1);
623        attrib(st1,"isSB",1);
624        return(st1,nb,pnb);
625     }
626     return(t1);
627  }
628//--------------------------- presentation of J -------------------------------
629   int rk;
630   def P = basering;
631   module jac, t1;
632   jac  = jacob(J);                 // jacobian matrix of J converted to module
633   list A=nres(J,2);                // compute presentation of J
634   def A(1..2)=A[1..2]; kill A;     // A(2) = 1st syzygy module of J
635//---------- go to quotient ring mod J and compute normal bundle --------------
636   qring  R    = std(J);
637   module jac = fetch(P,jac);
638   module t1  = transpose(fetch(P,A(2)));
639   list B=nres(t1,2);               // resolve t1, B(2)=(J/J^2)*=normal_bdl
640   def B(1..2)=B[1..2]; kill B;
641   t1         = modulo(B(2),jac);   // pres. of normal_bdl/trivial_deformations
642   rk=nrows(t1);
643//-------------------------- pull back to basering ----------------------------
644   setring P;
645   t1 = fetch(R,t1)+J*freemodule(rk);  // T_1-module, presentation of T_1
646   t1 = std(t1);
647   dbprint(printlevel-voice+3,"// dim T_1 = "+string(vdim(t1)));
648   if( size(#)>0 )
649   {
650      module B2 = fetch(R,B(2));        // presentation of normal bundle
651      list L = t1,B2,A(2);
652      attrib(L[1],"isSB",1);
653      return(L);
654   }
655   return(t1);
656}
657example
658{ "EXAMPLE:"; echo = 2;
659   int p      = printlevel;
660   printlevel = 1;
661   ring r     = 32003,(x,y,z),(c,ds);
662   ideal i    = xy,xz,yz;
663   module T   = T_1(i);
664   vdim(T);                      // Tjurina number = dim_K(T_1), should be 3
665   list L=T_1(i,"");
666   module kB  = kbase(L[1]);
667   print(matrix(L[2])*matrix(kB)); // basis of 1st order miniversal deformation
668   show(L[2]);                   // presentation of normal bundle
669   print(L[3]);                  // relations of i
670   print(transpose(matrix(L[3]))*matrix(L[2]));  // should be 0 (mod i)
671   printlevel = p;
672}
673///////////////////////////////////////////////////////////////////////////////
674
675proc T_2 (ideal id, list #)
676"USAGE:   T_2(id[,<any>]);  id = ideal
677RETURN:  T_2(id): T_2-module of id . This is a std basis of a presentation of
678         the module of obstructions of R=P/id, if P is the basering.
679         If a second argument is present (of any type) return a list of
680         4 modules and 1 ideal:
681            [1]= T_2(id)
682            [2]= standard basis of id (ideal)
683            [3]= module of relations of id (=1st syzygy module of id) @*
684            [4]= presentation of syz/kos
685            [5]= relations of Hom_P([3]/kos,R), lifted to P
686         The list contains all non-easy objects which must be computed
687         to get T_2(id).
688DISPLAY: k-dimension of T_2(id) if printlevel >= 0 (default)
689NOTE:    The most important information is probably vdim(T_2(id)).
690         Use proc miniversal to get equations of the miniversal deformation.
691EXAMPLE: example T_2; shows an example
692"
693{
694   def RR=basering;
695   list RRL=ring_list(RR);
696   if(RRL[4]!=0)
697   {
698      int aa=size(#);
699      ideal QU=RRL[4];
700      RRL[4]=ideal(0);
701      def RS=ring(RRL);
702      setring RS;
703      ideal id=imap(RR,id);
704      ideal QU=imap(RR,QU);
705      if(aa)
706      {
707         list RES=T_2(id+QU,1);
708      }
709      else
710      {
711         module RES=T_2(id+QU);
712      }
713      setring RR;
714      def RES=imap(RS,RES);
715      return(RES);
716   }
717
718//--------------------------- initialisation ----------------------------------
719  def P = basering;
720   ideal J = id;
721   module kos,SK,B2,t2;
722   list L;
723   int n,rk;
724//------------------- presentation of non-trivial syzygies --------------------
725   list A=nres(J,2);                      // resolve J, A(2)=syz
726   def A(1..2)=A[1..2]; kill A;
727   kos  = koszul(2,J);                    // module of Koszul relations
728   SK   = modulo(A(2),kos);               // presentation of syz/kos
729   ideal J0 = std(J);                     // standard basis of J
730//?*** sollte bei der Berechnung von res mit anfallen, zu aendern!!
731//---------------------- fetch to quotient ring mod J -------------------------
732   qring R = J0;                          // make P/J the basering
733   module A2' = transpose(fetch(P,A(2))); // dual of syz
734   module t2  = transpose(fetch(P,SK));   // dual of syz/kos
735   list B=nres(t2,2);                     // resolve (syz/kos)*
736   def B(1..2)=B[1..2]; kill B;
737   t2 = modulo(B(2),A2');                 // presentation of T_2
738   rk = nrows(t2);
739//---------------------  fetch back to basering -------------------------------
740   setring P;
741   t2 = fetch(R,t2)+J*freemodule(rk);
742   t2 = std(t2);
743   dbprint(printlevel-voice+3,"// dim T_2 = "+string(vdim(t2)));
744   if( size(#)>0 )
745   {
746      B2 = fetch(R,B(2));        // generators of Hom_P(syz/kos,R)
747      L  = t2,J0,A(2),SK,B2;
748      return(L);
749   }
750   return(t2);
751}
752example
753{ "EXAMPLE:"; echo = 2;
754   int p      = printlevel;
755   printlevel = 1;
756   ring  r    = 32003,(x,y),(c,dp);
757   ideal j    = x6-y4,x6y6,x2y4-x5y2;
758   module T   = T_2(j);
759   vdim(T);
760   hilb(T);"";
761   ring r1    = 0,(x,y,z),dp;
762   ideal id   = xy,xz,yz;
763   list L     = T_2(id,"");
764   vdim(L[1]);                           // vdim of T_2
765   print(L[3]);                          // syzygy module of id
766   printlevel = p;
767}
768///////////////////////////////////////////////////////////////////////////////
769
770proc T_12 (ideal i, list #)
771"USAGE:   T_12(i[,any]);  i = ideal
772RETURN:  T_12(i): list of 2 modules: @*
773           *  standard basis of T_1-module =T_1(i), 1st order deformations @*
774           *  standard basis of T_2-module =T_2(i), obstructions of R=P/i @*
775         If a second argument is present (of any type) return a list of
776         9 modules, matrices, integers: @*
777             [1]= standard basis of T_1-module
778             [2]= standard basis of T_2-module
779             [3]= vdim of T_1
780             [4]= vdim of T_2
781             [5]= matrix, whose cols present infinitesimal deformations @*
782             [6]= matrix, whose cols are generators of relations of i(=syz(i)) @*
783             [7]= matrix, presenting Hom_P(syz/kos,R), lifted to P @*
784             [8]= presentation of T_1-module, no std basis
785             [9]= presentation of T_2-module, no std basis
786DISPLAY: k-dimension of T_1 and T_2 if printlevel >= 0 (default)
787NOTE:    Use proc miniversal from deform.lib to get miniversal deformation of i,
788         the list contains all objects used by proc miniversal.
789EXAMPLE: example T_12; shows an example
790"
791{
792   def RR=basering;
793   list RRL=ring_list(RR);
794   if(RRL[4]!=0)
795   {
796      int aa=size(#);
797      ideal QU=RRL[4];
798      RRL[4]=ideal(0);
799      def RS=ring(RRL);
800      setring RS;
801      ideal id=imap(RR,id);
802      ideal QU=imap(RR,QU);
803      if(aa)
804      {
805         list RES=T_12(id+QU,1);
806      }
807      else
808      {
809         list RES=T_12(id+QU);
810      }
811      setring RR;
812      list RES=imap(RS,RES);
813      return(RES);
814   }
815
816//--------------------------- initialisation ----------------------------------
817   int  n,r1,r2,d1,d2;
818   def P = basering;
819   i = simplify(i,10);
820   module jac,t1,t2,sbt1,sbt2;
821   matrix Kos,Syz,SK,kbT_1,Sx;
822   list L;
823   ideal  i0 = std(i);
824//-------------------- presentation of non-trivial syzygies -------------------
825   list I= nres(i,2);                           // resolve i
826   Syz  = matrix(I[2]);                         // syz(i)
827   jac = jacob(i);                              // jacobi ideal
828   Kos = koszul(2,i);                           // koszul-relations
829   SK  = modulo(Syz,Kos);                       // presentation of syz/kos
830//--------------------- fetch to quotient ring  mod i -------------------------
831   qring   Ox  = i0;                             // make P/i the basering
832   module Jac = fetch(P,jac);
833   matrix No  = transpose(fetch(P,Syz));        // ker(No) = Hom(syz,Ox)
834   module So  = transpose(fetch(P,SK));         // Hom(syz/kos,R)
835   list resS  = nres(So,2);
836   matrix Sx  = resS[2];
837   list resN  = nres(No,2);
838   matrix Nx  = resN[2];
839   module T_2  = modulo(Sx,No);                  // presentation of T_2
840   r2         = nrows(T_2);
841   module T_1  = modulo(Nx,Jac);                 // presentation of T_1
842   r1         = nrows(T_1);
843//------------------------ pull back to basering ------------------------------
844   setring P;
845   t1   = fetch(Ox,T_1)+i*freemodule(r1);
846   t2   = fetch(Ox,T_2)+i*freemodule(r2);
847   sbt1 = std(t1);
848   d1   = vdim(sbt1);
849   sbt2 = std(t2);
850   d2   = vdim(sbt2);
851   dbprint(printlevel-voice+3,"// dim T_1 = "+string(d1),"// dim T_2 = "+string(d2));
852   if  ( size(#)>0)
853   {
854     if (d1>0)
855     {
856       kbT_1 = fetch(Ox,Nx)*kbase(sbt1);
857     }
858     else
859     {
860       kbT_1 = 0;
861     }
862     Sx   = fetch(Ox,Sx);
863     L = sbt1,sbt2,d1,d2,kbT_1,Syz,Sx,t1,t2;
864     return(L);
865   }
866   L = sbt1,sbt2;
867   return(L);
868}
869example
870{ "EXAMPLE:"; echo = 2;
871   int p      = printlevel;
872   printlevel = 1;
873   ring r     = 199,(x,y,z,u,v),(c,ws(4,3,2,3,4));
874   ideal i    = xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2;
875                            //a cyclic quotient singularity
876   list L     = T_12(i,1);
877   print(L[5]);             //matrix of infin. deformations
878   printlevel = p;
879}
880///////////////////////////////////////////////////////////////////////////////
881proc codim (def id1,def id2)
882"USAGE:   codim(id1,id2); id1,id2 ideal or module, both must be standard bases
883RETURN:  int, which is:
884         1. the vectorspace dimension of id1/id2 if id2 is contained in id1
885            and if this number is finite@*
886         2. -1 if the dimension of id1/id2 is infinite@*
887         3. -2 if id2 is not contained in id1
888COMPUTE: consider the Hilbert series iv1(t) of id1 and iv2(t) of id2.
889         If codim(id1,id2) is finite,  q(t)=(iv2(t)-iv1(t))/(1-t)^n is
890         rational, and the codimension is the sum of the coefficients of q(t)
891         (n = dimension of basering).
892EXAMPLE: example codim; shows an example
893"
894{
895   if (attrib(id1,"isSB")!=1) { "first argument of codim is not a SB";}
896   if (attrib(id2,"isSB")!=1) { "second argument of codim is not a SB";}
897   intvec iv1, iv2, iv;
898   int i, d1, d2, dd, i1, i2, ia, ie;
899  //--------------------------- check id2 < id1 -------------------------------
900   ideal led = lead(id1);
901   attrib(led, "isSB",1);
902   i = size(NF(lead(id2),led));
903   if ( i > 0 )
904   {
905     return(-2);
906   }
907  //--------------------------- 1. check finiteness ---------------------------
908   i1 = dim(id1);
909   i2 = dim(id2);
910   if (i1 < 0)
911   {
912     if ( i2 < 0 )
913     {
914        return(0);
915     }
916     if (i2 == 0)
917     {
918       return (vdim(id2));
919     }
920     else
921     {
922       return(-1);
923     }
924   }
925   if (i2 != i1)
926   {
927     return(-1);
928   }
929   if (i2 <= 0)
930   {
931     return(vdim(id2)-vdim(id1));
932   }
933 // if (mult(id2) != mult(id1))
934 //{
935 //  return(-1);
936 // }
937  //--------------------------- module ---------------------------------------
938   d1 = nrows(module(id1));
939   d2 = nrows(module(id2));
940   dd = 0;
941   if (d1 > d2)
942   {
943     id2=id2,maxideal(1)*gen(d1);
944     dd = -1;
945   }
946   if (d2 > d1)
947   {
948     id1=id1,maxideal(1)*gen(d2);
949     dd = 1;
950   }
951  //--------------------------- compute first hilbertseries ------------------
952   iv1 = intvec(hilb(id1,1));
953   i1 = size(iv1);
954   iv2 = intvec(hilb(id2,1));
955   i2 = size(iv2);
956  //--------------------------- difference of hilbertseries ------------------
957   if (i2 > i1)
958   {
959     for ( i=1; i<=i1; i=i+1)
960     {
961       iv2[i] = iv2[i]-iv1[i];
962     }
963     ie = i2;
964     iv = iv2;
965   }
966   else
967   {
968     for ( i=1; i<=i2; i=i+1)
969     {
970       iv1[i] = iv2[i]-iv1[i];
971     }
972     iv = iv1;
973     for (ie=i1;ie>=0;ie=ie-1)
974     {
975       if (ie == 0)
976       {
977         return(0);
978       }
979       if (iv[ie] != 0)
980       {
981         break;
982       }
983     }
984   }
985   ia = 1;
986   while (iv[ia] == 0) { ia=ia+1; }
987  //--------------------------- ia <= nonzeros <= ie -------------------------
988   iv1 = iv[ia];
989   for(i=ia+1;i<=ie;i=i+1)
990   {
991     iv1=iv1,iv[i];
992   }
993  //--------------------------- compute second hilbertseries -----------------
994   iv2 = hilb(iv1);
995  //--------------------------- check finitenes ------------------------------
996   i2 = size(iv2);
997   i1 = ie - ia + 1 - i2;
998   if (i1 != nvars(basering))
999   {
1000     return(-1);
1001   }
1002  //--------------------------- compute result -------------------------------
1003   i1 = 0;
1004   for ( i=1; i<=i2; i=i+1)
1005   {
1006     i1 = i1 + iv2[i];
1007   }
1008   return(i1+dd);
1009}
1010example
1011{ "EXAMPLE:"; echo = 2;
1012   ring r  = 0,(x,y),dp;
1013   ideal j = y6,x4;
1014   ideal m = x,y;
1015   attrib(m,"isSB",1);  //let Singular know that ideals are a standard basis
1016   attrib(j,"isSB",1);
1017   codim(m,j);          // should be 23 (Milnor number -1 of y7-x5)
1018}
1019
1020///////////////////////////////////////////////////////////////////////////////
1021
1022proc tangentcone (def id,list #)
1023"USAGE:   tangentcone(id [,n]); id = ideal, n = int
1024RETURN:  the tangent cone of id
1025NOTE:    The procedure works for any monomial ordering.
1026         If n=0 use std w.r.t. local ordering ds, if n=1 use locstd.
1027EXAMPLE: example tangentcone; shows an example
1028"
1029{
1030  int ii,n;
1031  def bas = basering;
1032  ideal tang;
1033  if (size(#) !=0) { n= #[1]; }
1034  if( n==0 )
1035  {
1036     def @newr@=changeord(list(list("ds",1:nvars(basering))));
1037     setring @newr@;
1038     ideal @id = imap(bas,id);
1039     @id = std(@id);
1040     setring bas;
1041     id = imap(@newr@,@id);
1042     kill @newr@;
1043  }
1044  else
1045  {
1046    id = locstd(id);
1047  }
1048
1049  for(ii=1; ii<=size(id); ii++)
1050  {
1051    tang[ii]=jet(id[ii],mindeg(id[ii]));
1052  }
1053  return(tang);
1054}
1055example
1056{ "EXAMPLE:"; echo = 2;
1057   ring R = 0,(x,y,z),ds;
1058   ideal i  = 7xyz+z5,x2+y3+z7,5z5+y5;
1059   tangentcone(i);
1060}
1061///////////////////////////////////////////////////////////////////////////////
1062
1063proc locstd (def id)
1064"USAGE:   locstd (id); id = ideal
1065RETURN:  a standard basis for a local degree ordering
1066NOTE:    the procedure homogenizes id w.r.t. a new 1st variable @t@, computes
1067         a SB w.r.t. (dp(1),dp) and substitutes @t@ by 1.
1068         Hence the result is a SB with respect to an ordering which sorts
1069         first w.r.t. the order and then refines it with dp. This is a
1070         local degree ordering.
1071         This is done in order to avoid cancellation of units and thus
1072         be able to use option(contentSB);
1073EXAMPLE: example locstd; shows an example
1074"
1075{
1076  int ii;
1077  def bas = basering;
1078  ring @r_locstd = create_ring(ring_list(bas)[1], "(@t@,"+varstr(bas)+")", "(dp(1),dp)", "no_minpoly");
1079  ideal @id = imap(bas,id);
1080  ideal @hid = homog(@id,@t@);
1081  @hid = std(@hid);
1082  @hid = subst(@hid,@t@,1);
1083  setring bas;
1084  def @hid = imap(@r_locstd,@hid);
1085  attrib(@hid,"isSB",1);
1086  kill @r_locstd;
1087  return(@hid);
1088}
1089example
1090{ "EXAMPLE:"; echo = 2;
1091   ring R = 0,(x,y,z),ds;
1092   ideal i  = xyz+z5,2x2+y3+z7,3z5+y5;
1093   locstd(i);
1094}
Note: See TracBrowser for help on using the repository browser.