source: git/Singular/LIB/sing.lib @ 4e4e24b

spielwiese
Last change on this file since 4e4e24b was 0463d5c, checked in by Hans Schoenemann <hannes@…>, 10 years ago
add data types to procedures, p4
  • Property mode set to 100644
File size: 33.6 KB
Line 
1////////////////////////////////////////////////////////////////////////////
2version="version sing.lib 4.0.0.0 Jun_2013 "; // $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(L[2]*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 i==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
367EXAMPLE: example slocus; shows an example
368"
369{
370  def R=basering;
371  int j,k;
372  ideal res;
373
374  if(ord_test(basering)!=1)
375  {
376     string va=varstr(basering);
377     if( size( parstr(basering))>0){va=va+","+parstr(basering);}
378     execute ("ring S = ("+charstr(basering)+"),("+va+"),dp;");
379     ideal i=imap(R,i);
380     list l=equidim(i);
381     setring R;
382     list l=imap(S,l);
383  }
384  else
385  {
386     list l=equidim(i);
387  }
388  int n=size(l);
389  if (n==1){return(slocusEqi(i));}
390  res=slocusEqi(l[1]);
391  for(j=2;j<=n;j++){res=intersect(res,slocusEqi(l[j]));}
392  for(j=1;j<n;j++)
393  {
394     for(k=j+1;k<=n;k++){res=intersect(res,l[j]+l[k]);}
395  }
396  return(res);
397}
398example
399{ "EXAMPLE:"; echo = 2;
400   ring r  = 0,(u,v,w,x,y,z),dp;
401   ideal i = wx,wy,wz,vx,vy,vz,ux,uy,uz,y3-x2;;
402   slocus(i);
403}
404///////////////////////////////////////////////////////////////////////////////
405
406static proc slocusEqi (ideal i)
407"USAGE:   slocus(i);  i ideal
408RETURN:  ideal of singular locus of i if i is pure dimensional
409NOTE:    this proc returns i and c-minors of jacobian ideal of i where c is the
410         codimension of i. Hence, if i is not pure dimensional, slocus may
411         return an ideal such that its 0-locus is strictly contained in the
412         singular locus of i
413EXAMPLE: example slocus; shows an example
414"
415{
416  ideal ist=std(i);
417  if(deg(ist[1])==0){return(ist);}
418  int cod  = nvars(basering)-dim(ist);
419  i        = i+minor(jacob(i),cod);
420  return(i);
421}
422example
423{ "EXAMPLE:"; echo = 2;
424   ring r  = 0,(x,y,z),ds;
425   ideal i = x5+y6+z6,x2+2y2+3z2;
426   slocus(i);
427}
428///////////////////////////////////////////////////////////////////////////////
429
430proc qhspectrum (poly f, intvec w)
431"USAGE:   qhspectrum(f,w);  f=poly, w=intvec
432ASSUME:  f is a weighted homogeneous isolated singularity w.r.t. the weights
433         given by w; w must consist of as many positive integers as there
434         are variables of the basering
435COMPUTE: the spectral numbers of the w-homogeneous polynomial f, computed in a
436         ring of characteristic 0
437RETURN:  intvec  d,s1,...,su  where:
438         d = w-degree(f)  and  si/d = i-th spectral-number(f)
439         No return value if basering has parameters or if f is no isolated
440         singularity, displays a warning in this case.
441EXAMPLE: example qhspectrum; shows an example
442"
443{
444   int i,d,W;
445   intvec sp;
446   def r   = basering;
447   if( find(charstr(r),",")!=0 )
448   {
449       "// coefficient field must not have parameters!";
450       return();
451    }
452   ring s  = 0,x(1..nvars(r)),ws(w);
453   map phi = r,maxideal(1);
454   poly f  = phi(f);
455   d       = ord(f);
456   W       = sum(w)-d;
457   ideal k = std(jacob(f));
458   if( vdim(k) == -1 )
459   {
460       "// f is no isolated singuarity!";
461       return();
462    }
463   k = kbase(k);
464   for (i=1; i<=size(k); i++)
465   {
466      sp[i]=W+ord(k[i]);
467   }
468   list L  = sort(sp);
469   sp      = d,L[1];
470   return(sp);
471}
472example
473{ "EXAMPLE:"; echo = 2;
474   ring r;
475   poly f=x3+y5+z2;
476   intvec w=10,6,15;
477   qhspectrum(f,w);
478   // the spectrum numbers are:
479   // 1/30,7/30,11/30,13/30,17/30,19/30,23/30,29/30
480}
481///////////////////////////////////////////////////////////////////////////////
482
483proc Tjurina (def id, list #)
484"USAGE:   Tjurina(id[,<any>]);  id=ideal or poly
485ASSUME:  id=ICIS (isolated complete intersection singularity)
486RETURN:  standard basis of Tjurina-module of id,
487         of type module if id=ideal, resp. of type ideal if id=poly.
488         If a second argument is present (of any type) return a list: @*
489           [1] = Tjurina number,
490           [2] = k-basis of miniversal deformation,
491           [3] = SB of Tjurina module,
492           [4] = Tjurina module
493DISPLAY: Tjurina number if printlevel >= 0 (default)
494NOTE:    Tjurina number = -1 implies that id is not an ICIS
495EXAMPLE: example Tjurina; shows examples
496"
497{
498//---------------------------- initialisation ---------------------------------
499  def i = simplify(id,10);
500  int tau,n = 0,size(i);
501  if( size(ideal(i))==1 ) { def m=i; }  // hypersurface case
502  else { def m=i*freemodule(n); }       // complete intersection case
503//--------------- compute Tjurina module, Tjurina number etc ------------------
504  def t1 = jacob(i)+m;                  // Tjurina module/ideal
505  def st1 = std(t1);                    // SB of Tjurina module/ideal
506  tau = vdim(st1);                      // Tjurina number
507  dbprint(printlevel-voice+3,"// Tjurina number = "+string(tau));
508  if( size(#)>0 )
509  {
510     def kB = kbase(st1);               // basis of miniversal deformation
511     return(tau,kB,st1,t1);
512  }
513  return(st1);
514}
515example
516{ "EXAMPLE:"; echo = 2;
517   int p      = printlevel;
518   printlevel = 1;
519   ring r     = 0,(x,y,z),ds;
520   poly f     = x5+y6+z7+xyz;        // singularity T[5,6,7]
521   list T     = Tjurina(f,"");
522   show(T[1]);                       // Tjurina number, should be 16
523   show(T[2]);                       // basis of miniversal deformation
524   show(T[3]);                       // SB of Tjurina ideal
525   show(T[4]); "";                   // Tjurina ideal
526   ideal j    = x2+y2+z2,x2+2y2+3z2;
527   show(kbase(Tjurina(j)));          // basis of miniversal deformation
528   hilb(Tjurina(j));                 // Hilbert series of Tjurina module
529   printlevel = p;
530}
531///////////////////////////////////////////////////////////////////////////////
532
533proc tjurina (ideal i)
534"USAGE:   tjurina(id);  id=ideal or poly
535ASSUME:  id=ICIS (isolated complete intersection singularity)
536RETURN:  int = Tjurina number of id
537NOTE:    Tjurina number = -1 implies that id is not an ICIS
538EXAMPLE: example tjurina; shows an example
539"
540{
541   return(vdim(Tjurina(i)));
542}
543example
544{ "EXAMPLE:"; echo = 2;
545   ring r=32003,(x,y,z),(c,ds);
546   ideal j=x2+y2+z2,x2+2y2+3z2;
547   tjurina(j);
548}
549///////////////////////////////////////////////////////////////////////////////
550
551proc T_1 (ideal id, list #)
552"USAGE:   T_1(id[,<any>]);  id = ideal or poly
553RETURN:  T_1(id): of type module/ideal if id is of type ideal/poly.
554         We call T_1(id) the T_1-module of id. It is a std basis of the
555         presentation of 1st order deformations of P/id, if P is the basering.
556         If a second argument is present (of any type) return a list of
557         3 modules:
558            [1]= T_1(id)
559            [2]= generators of normal bundle of id, lifted to P
560            [3]= module of relations of [2], lifted to P
561                 (note: transpose[3]*[2]=0 mod id)
562         The list contains all non-easy objects which must be computed
563         to get T_1(id).
564DISPLAY: k-dimension of T_1(id) if printlevel >= 0 (default)
565NOTE:    T_1(id) itself is usually of minor importance. Nevertheless, from it
566         all relevant information can be obtained. The most important are
567         probably vdim(T_1(id)); (which computes the Tjurina number),
568         hilb(T_1(id)); and kbase(T_1(id)).
569         If T_1 is called with two arguments, then matrix([2])*(kbase([1]))
570         represents a basis of 1st order semiuniversal deformation of id
571         (use proc 'deform', to get this in a direct way).
572         For a complete intersection the proc Tjurina is faster.
573EXAMPLE: example T_1; shows an example
574"
575{
576   def RR=basering;
577   list RRL=ringlist(RR);
578   if(RRL[4]!=0)
579   {
580      int aa=size(#);
581      ideal QU=RRL[4];
582      RRL[4]=ideal(0);
583      def RS=ring(RRL);
584      setring RS;
585      ideal id=imap(RR,id);
586      ideal QU=imap(RR,QU);
587      if(aa)
588      {
589         list RES=T_1(id+QU,1);
590      }
591      else
592      {
593         module RES=T_1(id+QU);
594      }
595      setring RR;
596      def RES=imap(RS,RES);
597      return(RES);
598   }
599   ideal J=simplify(id,10);
600//--------------------------- hypersurface case -------------------------------
601  if( size(J)<2 )
602  {
603     ideal t1  = std(J+jacob(J[1]));
604     module nb = [1]; module pnb;
605     dbprint(printlevel-voice+3,"// dim T_1 = "+string(vdim(t1)));
606     if( size(#)>0 )
607     {
608        module st1 = t1*gen(1);
609        attrib(st1,"isSB",1);
610        return(st1,nb,pnb);
611     }
612     return(t1);
613  }
614//--------------------------- presentation of J -------------------------------
615   int rk;
616   def P = basering;
617   module jac, t1;
618   jac  = jacob(J);                 // jacobian matrix of J converted to module
619   list A=nres(J,2);                // compute presentation of J
620   def A(1..2)=A[1..2]; kill A;     // A(2) = 1st syzygy module of J
621//---------- go to quotient ring mod J and compute normal bundle --------------
622   qring  R    = std(J);
623   module jac = fetch(P,jac);
624   module t1  = transpose(fetch(P,A(2)));
625   list B=nres(t1,2);               // resolve t1, B(2)=(J/J^2)*=normal_bdl
626   def B(1..2)=B[1..2]; kill B;
627   t1         = modulo(B(2),jac);   // pres. of normal_bdl/trivial_deformations
628   rk=nrows(t1);
629//-------------------------- pull back to basering ----------------------------
630   setring P;
631   t1 = fetch(R,t1)+J*freemodule(rk);  // T_1-module, presentation of T_1
632   t1 = std(t1);
633   dbprint(printlevel-voice+3,"// dim T_1 = "+string(vdim(t1)));
634   if( size(#)>0 )
635   {
636      module B2 = fetch(R,B(2));        // presentation of normal bundle
637      list L = t1,B2,A(2);
638      attrib(L[1],"isSB",1);
639      return(L);
640   }
641   return(t1);
642}
643example
644{ "EXAMPLE:"; echo = 2;
645   int p      = printlevel;
646   printlevel = 1;
647   ring r     = 32003,(x,y,z),(c,ds);
648   ideal i    = xy,xz,yz;
649   module T   = T_1(i);
650   vdim(T);                      // Tjurina number = dim_K(T_1), should be 3
651   list L=T_1(i,"");
652   module kB  = kbase(L[1]);
653   print(L[2]*kB);               // basis of 1st order miniversal deformation
654   show(L[2]);                   // presentation of normal bundle
655   print(L[3]);                  // relations of i
656   print(transpose(L[3])*L[2]);  // should be 0 (mod i)
657   printlevel = p;
658}
659///////////////////////////////////////////////////////////////////////////////
660
661proc T_2 (ideal id, list #)
662"USAGE:   T_2(id[,<any>]);  id = ideal
663RETURN:  T_2(id): T_2-module of id . This is a std basis of a presentation of
664         the module of obstructions of R=P/id, if P is the basering.
665         If a second argument is present (of any type) return a list of
666         4 modules and 1 ideal:
667            [1]= T_2(id)
668            [2]= standard basis of id (ideal)
669            [3]= module of relations of id (=1st syzygy module of id) @*
670            [4]= presentation of syz/kos
671            [5]= relations of Hom_P([3]/kos,R), lifted to P
672         The list contains all non-easy objects which must be computed
673         to get T_2(id).
674DISPLAY: k-dimension of T_2(id) if printlevel >= 0 (default)
675NOTE:    The most important information is probably vdim(T_2(id)).
676         Use proc miniversal to get equations of the miniversal deformation.
677EXAMPLE: example T_2; shows an example
678"
679{
680   def RR=basering;
681   list RRL=ringlist(RR);
682   if(RRL[4]!=0)
683   {
684      int aa=size(#);
685      ideal QU=RRL[4];
686      RRL[4]=ideal(0);
687      def RS=ring(RRL);
688      setring RS;
689      ideal id=imap(RR,id);
690      ideal QU=imap(RR,QU);
691      if(aa)
692      {
693         list RES=T_2(id+QU,1);
694      }
695      else
696      {
697         module RES=T_2(id+QU);
698      }
699      setring RR;
700      def RES=imap(RS,RES);
701      return(RES);
702   }
703
704//--------------------------- initialisation ----------------------------------
705  def P = basering;
706   ideal J = id;
707   module kos,SK,B2,t2;
708   list L;
709   int n,rk;
710//------------------- presentation of non-trivial syzygies --------------------
711   list A=nres(J,2);                      // resolve J, A(2)=syz
712   def A(1..2)=A[1..2]; kill A;
713   kos  = koszul(2,J);                    // module of Koszul relations
714   SK   = modulo(A(2),kos);               // presentation of syz/kos
715   ideal J0 = std(J);                     // standard basis of J
716//?*** sollte bei der Berechnung von res mit anfallen, zu aendern!!
717//---------------------- fetch to quotient ring mod J -------------------------
718   qring R = J0;                          // make P/J the basering
719   module A2' = transpose(fetch(P,A(2))); // dual of syz
720   module t2  = transpose(fetch(P,SK));   // dual of syz/kos
721   list B=nres(t2,2);                     // resolve (syz/kos)*
722   def B(1..2)=B[1..2]; kill B;
723   t2 = modulo(B(2),A2');                 // presentation of T_2
724   rk = nrows(t2);
725//---------------------  fetch back to basering -------------------------------
726   setring P;
727   t2 = fetch(R,t2)+J*freemodule(rk);
728   t2 = std(t2);
729   dbprint(printlevel-voice+3,"// dim T_2 = "+string(vdim(t2)));
730   if( size(#)>0 )
731   {
732      B2 = fetch(R,B(2));        // generators of Hom_P(syz/kos,R)
733      L  = t2,J0,A(2),SK,B2;
734      return(L);
735   }
736   return(t2);
737}
738example
739{ "EXAMPLE:"; echo = 2;
740   int p      = printlevel;
741   printlevel = 1;
742   ring  r    = 32003,(x,y),(c,dp);
743   ideal j    = x6-y4,x6y6,x2y4-x5y2;
744   module T   = T_2(j);
745   vdim(T);
746   hilb(T);"";
747   ring r1    = 0,(x,y,z),dp;
748   ideal id   = xy,xz,yz;
749   list L     = T_2(id,"");
750   vdim(L[1]);                           // vdim of T_2
751   print(L[3]);                          // syzygy module of id
752   printlevel = p;
753}
754///////////////////////////////////////////////////////////////////////////////
755
756proc T_12 (ideal i, list #)
757"USAGE:   T_12(i[,any]);  i = ideal
758RETURN:  T_12(i): list of 2 modules: @*
759           *  standard basis of T_1-module =T_1(i), 1st order deformations @*
760           *  standard basis of T_2-module =T_2(i), obstructions of R=P/i @*
761         If a second argument is present (of any type) return a list of
762         9 modules, matrices, integers: @*
763             [1]= standard basis of T_1-module
764             [2]= standard basis of T_2-module
765             [3]= vdim of T_1
766             [4]= vdim of T_2
767             [5]= matrix, whose cols present infinitesimal deformations @*
768             [6]= matrix, whose cols are generators of relations of i(=syz(i)) @*
769             [7]= matrix, presenting Hom_P(syz/kos,R), lifted to P @*
770             [8]= presentation of T_1-module, no std basis
771             [9]= presentation of T_2-module, no std basis
772DISPLAY: k-dimension of T_1 and T_2 if printlevel >= 0 (default)
773NOTE:    Use proc miniversal from deform.lib to get miniversal deformation of i,
774         the list contains all objects used by proc miniversal.
775EXAMPLE: example T_12; shows an example
776"
777{
778   def RR=basering;
779   list RRL=ringlist(RR);
780   if(RRL[4]!=0)
781   {
782      int aa=size(#);
783      ideal QU=RRL[4];
784      RRL[4]=ideal(0);
785      def RS=ring(RRL);
786      setring RS;
787      ideal id=imap(RR,id);
788      ideal QU=imap(RR,QU);
789      if(aa)
790      {
791         list RES=T_12(id+QU,1);
792      }
793      else
794      {
795         list RES=T_12(id+QU);
796      }
797      setring RR;
798      list RES=imap(RS,RES);
799      return(RES);
800   }
801
802//--------------------------- initialisation ----------------------------------
803   int  n,r1,r2,d1,d2;
804   def P = basering;
805   i = simplify(i,10);
806   module jac,t1,t2,sbt1,sbt2;
807   matrix Kos,Syz,SK,kbT_1,Sx;
808   list L;
809   ideal  i0 = std(i);
810//-------------------- presentation of non-trivial syzygies -------------------
811   list I= nres(i,2);                           // resolve i
812   Syz  = matrix(I[2]);                         // syz(i)
813   jac = jacob(i);                              // jacobi ideal
814   Kos = koszul(2,i);                           // koszul-relations
815   SK  = modulo(Syz,Kos);                       // presentation of syz/kos
816//--------------------- fetch to quotient ring  mod i -------------------------
817   qring   Ox  = i0;                             // make P/i the basering
818   module Jac = fetch(P,jac);
819   matrix No  = transpose(fetch(P,Syz));        // ker(No) = Hom(syz,Ox)
820   module So  = transpose(fetch(P,SK));         // Hom(syz/kos,R)
821   list resS  = nres(So,2);
822   matrix Sx  = resS[2];
823   list resN  = nres(No,2);
824   matrix Nx  = resN[2];
825   module T_2  = modulo(Sx,No);                  // presentation of T_2
826   r2         = nrows(T_2);
827   module T_1  = modulo(Nx,Jac);                 // presentation of T_1
828   r1         = nrows(T_1);
829//------------------------ pull back to basering ------------------------------
830   setring P;
831   t1   = fetch(Ox,T_1)+i*freemodule(r1);
832   t2   = fetch(Ox,T_2)+i*freemodule(r2);
833   sbt1 = std(t1);
834   d1   = vdim(sbt1);
835   sbt2 = std(t2);
836   d2   = vdim(sbt2);
837   dbprint(printlevel-voice+3,"// dim T_1 = "+string(d1),"// dim T_2 = "+string(d2));
838   if  ( size(#)>0)
839   {
840     if (d1>0)
841     {
842       kbT_1 = fetch(Ox,Nx)*kbase(sbt1);
843     }
844     else
845     {
846       kbT_1 = 0;
847     }
848     Sx   = fetch(Ox,Sx);
849     L = sbt1,sbt2,d1,d2,kbT_1,Syz,Sx,t1,t2;
850     return(L);
851   }
852   L = sbt1,sbt2;
853   return(L);
854}
855example
856{ "EXAMPLE:"; echo = 2;
857   int p      = printlevel;
858   printlevel = 1;
859   ring r     = 199,(x,y,z,u,v),(c,ws(4,3,2,3,4));
860   ideal i    = xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2;
861                            //a cyclic quotient singularity
862   list L     = T_12(i,1);
863   print(L[5]);             //matrix of infin. deformations
864   printlevel = p;
865}
866///////////////////////////////////////////////////////////////////////////////
867proc codim (def id1,def id2)
868"USAGE:   codim(id1,id2); id1,id2 ideal or module, both must be standard bases
869RETURN:  int, which is:
870         1. the vectorspace dimension of id1/id2 if id2 is contained in id1
871            and if this number is finite@*
872         2. -1 if the dimension of id1/id2 is infinite@*
873         3. -2 if id2 is not contained in id1
874COMPUTE: consider the Hilbert series iv1(t) of id1 and iv2(t) of id2.
875         If codim(id1,id2) is finite,  q(t)=(iv2(t)-iv1(t))/(1-t)^n is
876         rational, and the codimension is the sum of the coefficients of q(t)
877         (n = dimension of basering).
878EXAMPLE: example codim; shows an example
879"
880{
881   if (attrib(id1,"isSB")!=1) { "first argument of codim is not a SB";}
882   if (attrib(id2,"isSB")!=1) { "second argument of codim is not a SB";}
883   intvec iv1, iv2, iv;
884   int i, d1, d2, dd, i1, i2, ia, ie;
885  //--------------------------- check id2 < id1 -------------------------------
886   ideal led = lead(id1);
887   attrib(led, "isSB",1);
888   i = size(NF(lead(id2),led));
889   if ( i > 0 )
890   {
891     return(-2);
892   }
893  //--------------------------- 1. check finiteness ---------------------------
894   i1 = dim(id1);
895   i2 = dim(id2);
896   if (i1 < 0)
897   {
898     if ( i2 < 0 )
899     {
900        return(0);
901     }
902     if (i2 == 0)
903     {
904       return (vdim(id2));
905     }
906     else
907     {
908       return(-1);
909     }
910   }
911   if (i2 != i1)
912   {
913     return(-1);
914   }
915   if (i2 <= 0)
916   {
917     return(vdim(id2)-vdim(id1));
918   }
919 // if (mult(id2) != mult(id1))
920 //{
921 //  return(-1);
922 // }
923  //--------------------------- module ---------------------------------------
924   d1 = nrows(id1);
925   d2 = nrows(id2);
926   dd = 0;
927   if (d1 > d2)
928   {
929     id2=id2,maxideal(1)*gen(d1);
930     dd = -1;
931   }
932   if (d2 > d1)
933   {
934     id1=id1,maxideal(1)*gen(d2);
935     dd = 1;
936   }
937  //--------------------------- compute first hilbertseries ------------------
938   iv1 = hilb(id1,1);
939   i1 = size(iv1);
940   iv2 = hilb(id2,1);
941   i2 = size(iv2);
942  //--------------------------- difference of hilbertseries ------------------
943   if (i2 > i1)
944   {
945     for ( i=1; i<=i1; i=i+1)
946     {
947       iv2[i] = iv2[i]-iv1[i];
948     }
949     ie = i2;
950     iv = iv2;
951   }
952   else
953   {
954     for ( i=1; i<=i2; i=i+1)
955     {
956       iv1[i] = iv2[i]-iv1[i];
957     }
958     iv = iv1;
959     for (ie=i1;ie>=0;ie=ie-1)
960     {
961       if (ie == 0)
962       {
963         return(0);
964       }
965       if (iv[ie] != 0)
966       {
967         break;
968       }
969     }
970   }
971   ia = 1;
972   while (iv[ia] == 0) { ia=ia+1; }
973  //--------------------------- ia <= nonzeros <= ie -------------------------
974   iv1 = iv[ia];
975   for(i=ia+1;i<=ie;i=i+1)
976   {
977     iv1=iv1,iv[i];
978   }
979  //--------------------------- compute second hilbertseries -----------------
980   iv2 = hilb(iv1);
981  //--------------------------- check finitenes ------------------------------
982   i2 = size(iv2);
983   i1 = ie - ia + 1 - i2;
984   if (i1 != nvars(basering))
985   {
986     return(-1);
987   }
988  //--------------------------- compute result -------------------------------
989   i1 = 0;
990   for ( i=1; i<=i2; i=i+1)
991   {
992     i1 = i1 + iv2[i];
993   }
994   return(i1+dd);
995}
996example
997{ "EXAMPLE:"; echo = 2;
998   ring r  = 0,(x,y),dp;
999   ideal j = y6,x4;
1000   ideal m = x,y;
1001   attrib(m,"isSB",1);  //let Singular know that ideals are a standard basis
1002   attrib(j,"isSB",1);
1003   codim(m,j);          // should be 23 (Milnor number -1 of y7-x5)
1004}
1005
1006///////////////////////////////////////////////////////////////////////////////
1007
1008proc tangentcone (def id,list #)
1009"USAGE:   tangentcone(id [,n]); id = ideal, n = int
1010RETURN:  the tangent cone of id
1011NOTE:    The procedure works for any monomial ordering.
1012         If n=0 use std w.r.t. local ordering ds, if n=1 use locstd.
1013EXAMPLE: example tangentcone; shows an example
1014"
1015{
1016  int ii,n;
1017  def bas = basering;
1018  ideal tang;
1019  if (size(#) !=0) { n= #[1]; }
1020  if( n==0 )
1021  {
1022     def @newr@=changeord(list(list("ds",1:nvars(basering))));
1023     setring @newr@;
1024     ideal @id = imap(bas,id);
1025     @id = std(@id);
1026     setring bas;
1027     id = imap(@newr@,@id);
1028     kill @newr@;
1029  }
1030  else
1031  {
1032    id = locstd(id);
1033  }
1034
1035  for(ii=1; ii<=size(id); ii++)
1036  {
1037    tang[ii]=jet(id[ii],mindeg(id[ii]));
1038  }
1039  return(tang);
1040}
1041example
1042{ "EXAMPLE:"; echo = 2;
1043   ring R = 0,(x,y,z),ds;
1044   ideal i  = 7xyz+z5,x2+y3+z7,5z5+y5;
1045   tangentcone(i);
1046}
1047///////////////////////////////////////////////////////////////////////////////
1048
1049proc locstd (def id)
1050"USAGE:   locstd (id); id = ideal
1051RETURN:  a standard basis for a local degree ordering
1052NOTE:    the procedure homogenizes id w.r.t. a new 1st variable @t@, computes
1053         a SB w.r.t. (dp(1),dp) and substitutes @t@ by 1.
1054         Hence the result is a SB with respect to an ordering which sorts
1055         first w.r.t. the order and then refines it with dp. This is a
1056         local degree ordering.
1057         This is done in order to avoid cancellation of units and thus
1058         be able to use option(contentSB);
1059EXAMPLE: example locstd; shows an example
1060"
1061{
1062  int ii;
1063  def bas = basering;
1064  execute("ring  @r_locstd
1065     =("+charstr(bas)+"),(@t@,"+varstr(bas)+"),(dp(1),dp);");
1066  ideal @id = imap(bas,id);
1067  ideal @hid = homog(@id,@t@);
1068  @hid = std(@hid);
1069  @hid = subst(@hid,@t@,1);
1070  setring bas;
1071  def @hid = imap(@r_locstd,@hid);
1072  attrib(@hid,"isSB",1);
1073  kill @r_locstd;
1074  return(@hid);
1075}
1076example
1077{ "EXAMPLE:"; echo = 2;
1078   ring R = 0,(x,y,z),ds;
1079   ideal i  = xyz+z5,2x2+y3+z7,3z5+y5;
1080   locstd(i);
1081}
Note: See TracBrowser for help on using the repository browser.