source: git/Singular/LIB/sing.lib @ 7d56875

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