source: git/Singular/LIB/gaussman.lib @ 0fcdf0

spielwiese
Last change on this file since 0fcdf0 was 0fcdf0, checked in by Mathias Schulze <mschulze@…>, 23 years ago
*mschulze: GMGs canonical name modifications git-svn-id: file:///usr/local/Singular/svn/trunk@5478 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 32.0 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: gaussman.lib,v 1.43 2001-05-30 18:32:37 mschulze Exp $";
3category="Singularities";
4
5info="
6LIBRARY:  gaussman.lib  Gauss-Manin Connection of a Singularity
7
8AUTHOR:   Mathias Schulze, email: mschulze@mathematik.uni-kl.de
9
10OVERVIEW: A library to compute invariants related to the Gauss-Manin connection
11          of a an isolated hypersurface singularity
12
13PROCEDURES:
14 gmsring(f,s);              Brieskorn lattice in the Gauss-Manin system
15 gmsnf(p,K[,Kmax]);         Gauss-Manin system normal form
16 gmscoeffs(p,K[,Kmax]);     Gauss-Manin system basis representation
17 monodromy(f[,opt]);        monodromy matrix, spectrum of monodromy of f
18 vfiltration(f[,opt]);      V-filtration on H''/H', singularity spectrum of f
19 spectrum(f);               singularity spectrum of f
20 endfilt(poly f,list V);    endomorphism filtration of filtration V
21 spprint(list S);           print spectrum S
22 spadd(list S1,list S2);    sum of spectra S1 and S2
23 spsub(list S1,list S2);    difference of spectra S1 and S2
24 spmul(list S,int k);       product of spectrum S and integer k
25 spmul(list S,intvec k);    linear combination of spectra S with coefficients k
26 spissemicont(list S[,opt]);        test spectrum S for semicontinuity
27 spsemicont(list S0,list S[,opt]);  relative semicontinuity of spectra S0 and S
28 spmilnor(list S);          milnor number of spectrum S
29 spgeomgenus(list S);       geometrical genus of spectrum S
30 spgamma(list S);           gamma invariant of spectrum S
31
32SEE ALSO: mondromy_lib, spectrum_lib
33
34KEYWORDS: singularities; Gauss-Manin connection; monodromy; spectrum;
35          Brieskorn lattice; Hodge filtration; V-filtration
36";
37
38LIB "linalg.lib";
39
40///////////////////////////////////////////////////////////////////////////////
41
42static proc stdtrans(ideal I)
43{
44  def R=basering;
45
46  string s=ordstr(R);
47  int j=find(s,",C");
48  if(j==0)
49  {
50    j=find(s,"C,");
51  }
52  if(j==0)
53  {
54    j=find(s,",c");
55  }
56  if(j==0)
57  {
58    j=find(s,"c,");
59  }
60  if(j>0)
61  {
62    s[j..j+1]="  ";
63  }
64
65  execute("ring @S="+charstr(R)+",(gmspoly,"+varstr(R)+"),(c,dp,"+s+");");
66
67  ideal I=homog(imap(R,I),gmspoly);
68  module M=transpose(transpose(I)+freemodule(ncols(I)));
69  M=std(M);
70
71  setring(R);
72  execute("map h=@S,1,"+varstr(R)+";");
73
74  module M=h(M);
75
76  for(int i=ncols(M);i>=1;i--)
77  {
78    for(j=ncols(M);j>=1;j--)
79    {
80      if(M[i][1]==0)
81      {
82        M[i]=0;
83      }
84      if(i!=j&&M[j][1]!=0)
85      {
86        if(lead(M[i][1])/lead(M[j][1])!=0)
87        {
88          M[i]=0;
89        }
90      }
91    }
92  }
93
94  M=transpose(simplify(M,2));
95  I=M[1];
96  attrib(I,"isSB",1);
97  M=M[2..ncols(M)];
98  module U=transpose(M);
99
100  return(list(I,U));
101}
102///////////////////////////////////////////////////////////////////////////////
103
104proc gmsring(poly t,string s)
105"USAGE:    gmsring(f,s); poly f, string s;
106ASSUME:   basering has characteristic 0 and local degree ordering,
107          f has isolated singularity at 0
108RETURN:
109@format
110ring G:
111  G=C{{s}}*basering,
112  s is the inverse of the Gauss-Manin connection of f,
113  G contains:
114    poly gmspoly: image of f
115    ideal gmsjacob: image of Jacobian ideal
116    ideal gmsstd: image of standard basis of Jacobian ideal
117    matrix gmsmatrix: matrix(gmsjacob)*gmsmatrix=matrix(gmsstd)
118    ideal gmsbasis: image of monomial vector space basis of Jacobian algebra
119    int gmsmaxweight: maximal weight of variables of basering
120  G projects to H''=C{{s}}*gmsbasis
121@end format
122NOTE:     do not modify gms variables if you want to use gms procedures
123KEYWORDS: singularities; Gauss-Manin connection
124EXAMPLE:  example gms; shows examples
125"
126{
127  def R=basering;
128  if(charstr(R)!="0")
129  {
130    ERROR("characteristic 0 expected");
131  }
132  for(int i=nvars(R);i>=1;i--)
133  {
134    if(var(i)>1)
135    {
136      ERROR("local ordering expected");
137    }
138  }
139
140  ideal dt=jacob(t);
141  list l=stdtrans(dt);
142  ideal g=l[1];
143  if(vdim(g)<=0)
144  {
145    if(vdim(g)==0)
146    {
147      ERROR("singularity at 0 expected");
148    }
149    else
150    {
151      ERROR("isolated singularity at 0 expected");
152    }
153  } 
154  matrix a=l[2];
155  ideal m=kbase(g);
156
157  intvec w;
158  int gmsmaxweight;
159  for(i=nvars(R);i>=1;i--)
160  {
161    w[i+1]=deg(var(i));
162    if(deg(var(i))>gmsmaxweight)
163    {
164      gmsmaxweight=deg(var(i));
165    }
166  }
167  w[1]=deg(highcorner(g))+2*gmsmaxweight;
168
169  execute("ring G="+string(charstr(R))+",("+s+","+varstr(R)+"),ws("+
170    string(w)+");");
171
172  poly gmspoly=imap(R,t);
173  ideal gmsjacob=imap(R,dt);
174  ideal gmsstd=imap(R,g);
175  matrix gmsmatrix=imap(R,a);
176  ideal gmsbasis=imap(R,m);
177
178  attrib(gmsstd,"isSB",1);
179  export gmspoly,gmsjacob,gmsstd,gmsmatrix,gmsbasis,gmsmaxweight;
180
181  return(G);
182}
183example
184{ "EXAMPLE:"; echo=2;
185  ring R=0,(x,y),ds;
186  poly f=x5+x2y2+y5;
187  def G=gmsring(f,"s");
188  setring(G);
189  gmspoly;
190  print(gmsjacob);
191  print(gmsstd);
192  print(gmsmatrix);
193  gmsmaxweight;
194}
195///////////////////////////////////////////////////////////////////////////////
196
197proc gmsnf(ideal p,int K,list #)
198"USAGE:    gmsnf(p,K[,Kmax]); poly p, int K[, int Kmax];
199ASSUME:   basering was constructed by gms, K<=Kmax
200RETURN:
201@format
202list l:
203  ideal l[1]: projection of p to H''=C{{s}}*gmsbasis mod s^{K+1}
204  ideal l[2]: p=l[1]+l[2] mod s^(Kmax+1)
205@end format
206NOTE:     by setting p=l[2] the computation can be continued up to order
207          at most Kmax, by default Kmax=infinity
208KEYWORDS: singularities; Gauss-Manin connection
209EXAMPLE:  example gmsnf; shows examples
210"
211{
212  int Kmax=-1;
213  if(size(#)>0)
214  {
215    if(typeof(#[1])=="int")
216    {
217      Kmax=#[1];
218      if(K>Kmax)
219      {
220        Kmax=K;
221      }
222    }
223  }
224
225  intvec v=1;
226  v[nvars(basering)]=0;
227
228  int k;
229  if(Kmax>=0)
230  {
231    p=jet(jet(p,K,v),(Kmax+1)*deg(var(1))-2*gmsmaxweight);
232  }
233
234  ideal r,q;
235  r[ncols(p)]=0;
236  q[ncols(p)]=0;
237
238  poly s;
239  int i,j;
240  for(k=ncols(p);k>=1;k--)
241  {
242    while(p[k]!=0&&deg(lead(p[k]),v)<=K)
243    {
244      i=1;
245      s=lead(p[k])/lead(gmsstd[i]);
246      while(i<ncols(gmsstd)&&s==0)
247      {
248        i++;
249        s=lead(p[k])/lead(gmsstd[i]);
250      }
251      if(s!=0)
252      {
253        p[k]=p[k]-s*gmsstd[i];
254        for(j=1;j<=nrows(gmsmatrix);j++)
255        {
256          if(Kmax>=0)
257          {
258            p[k]=p[k]+
259              jet(jet(diff(s*gmsmatrix[j,i],var(j+1))*var(1),Kmax,v),
260                (Kmax+1)*deg(var(1))-2*gmsmaxweight);
261          }
262          else
263          {
264            p[k]=p[k]+diff(s*gmsmatrix[j,i],var(j+1))*var(1);
265          }
266        }
267      }
268      else
269      {
270        r[k]=r[k]+lead(p[k]);
271        p[k]=p[k]-lead(p[k]);
272      }
273      while(deg(lead(p[k]))>(K+1)*deg(var(1))-2*gmsmaxweight&&
274        deg(lead(p[k]),v)<=K)
275      {
276        q[k]=q[k]+lead(p[k]);
277        p[k]=p[k]-lead(p[k]);
278      }
279    }
280    q[k]=q[k]+p[k];
281  }
282
283  return(list(r,q));
284}
285example
286{ "EXAMPLE:"; echo=2;
287  ring R=0,(x,y),ds;
288  poly f=x5+x2y2+y5;
289  def G=gmsring(f,"s");
290  setring(G);
291  list l0=gmsnf(gmspoly,0);
292  print(l0[1]);
293  list l1=gmsnf(gmspoly,1);
294  print(l1[1]);
295  list l=gmsnf(l0[2],1);
296  print(l[1]);
297}
298///////////////////////////////////////////////////////////////////////////////
299
300proc gmscoeffs(ideal p,int K,list #)
301"USAGE:    gmscoeffs(p,K[,Kmax]); poly p, int K[, int Kmax];
302ASSUME:   basering was constructed by gms, K<=Kmax
303RETURN:
304@format
305list l:
306  matrix l[1]: projection of p to H''=C{{s}}*gmsbasis=C{{s}}^mu mod s^(K+1)
307  ideal l[2]: p=matrix(gmsbasis)*l[1]+l[2] mod s^(Kmax+1)
308@end format
309NOTE:     by setting p=l[2] the computation can be continued up to order
310          at most Kmax, by default Kmax=infinity
311KEYWORDS: singularities; Gauss-Manin connection
312EXAMPLE:  example gmscoeffs; shows examples
313"
314{
315  list l=gmsnf(p,K,#);
316  ideal r,q=l[1..2];
317  poly v=1;
318  for(int i=2;i<=nvars(basering);i++)
319  {
320    v=v*var(i);
321  }
322  matrix C=coeffs(r,gmsbasis,v);
323  return(C,q);
324}
325example
326{ "EXAMPLE:"; echo=2;
327  ring R=0,(x,y),ds;
328  poly f=x5+x2y2+y5;
329  def G=gmsring(f,"s");
330  setring(G);
331  list l0=gmscoeffs(gmspoly,0);
332  print(l0[1]);
333  list l1=gmscoeffs(gmspoly,1);
334  print(l1[1]);
335  list l=gmscoeffs(l0[2],1);
336  print(l[1]);
337}
338///////////////////////////////////////////////////////////////////////////////
339
340static proc maxintdif(ideal e)
341{
342  dbprint(printlevel-voice+2,"//gaussman::maxintdif");
343  int i,j,id;
344  int mid=0;
345  for(i=ncols(e);i>=1;i--)
346  {
347    for(j=i-1;j>=1;j--)
348    {
349      id=int(e[i]-e[j]);
350      if(id<0)
351      {
352        id=-id;
353      }
354      if(id>mid)
355      {
356        mid=id;
357      }
358    }
359  }
360  return(mid);
361}
362///////////////////////////////////////////////////////////////////////////////
363
364static proc maxorddif(matrix H)
365{
366  dbprint(printlevel-voice+2,"//gaussman::maxorddif");
367  int i,j,d;
368  int d0,d1=-1,-1;
369  for(i=nrows(H);i>=1;i--)
370  {
371    for(j=ncols(H);j>=1;j--)
372    {
373      d=ord(H[i,j]);
374      if(d>=0)
375      {
376        if(d0<0||d<d0)
377        {
378          d0=d;
379        }
380        if(d1<0||d>d1)
381        {
382          d1=d;
383        }
384      }
385    }
386  }
387  return(d1-d0);
388}
389///////////////////////////////////////////////////////////////////////////////
390
391proc monodromy(poly f,list #)
392"USAGE:    monodromy(f[,opt]); poly f, int opt
393ASSUME:   basering has characteristic 0 and local degree ordering,
394          f has isolated singularity at 0
395RETURN:
396@format
397if opt==0:
398  matrix M: exp(-2*pi*i*M) is a monodromy matrix of f
399if opt==1:
400  ideal e: exp(-2*pi*i*e) are the eigenvalues of the monodromy of f
401default: opt=1
402@end format
403SEE ALSO: mondromy_lib
404KEYWORDS: singularities; Gauss-Manin connection; monodromy
405EXAMPLE:  example monodromy; shows examples
406"
407{
408  int opt=1;
409  if(size(#)>0)
410  {
411    if(typeof(#[1])=="int")
412    {
413      opt=#[1];
414    }
415  }
416
417  def R=basering;
418  def G=gmsring(f,"s");
419  setring G;
420
421  int n=nvars(R)-1;
422  int mu,modm=ncols(gmsbasis),maxorddif(gmsbasis);
423  ideal w=gmspoly*gmsbasis;
424  list l;
425  matrix U=freemodule(mu);
426  matrix A0[mu][mu],A,C;
427  module H,dH=freemodule(mu),freemodule(mu);
428  module H0;
429  int sdH=1;
430  int k=-1;
431
432  while(sdH>0)
433  {
434    k++;
435    dbprint(printlevel-voice+2,"//gaussman::monodromy: k="+string(k));
436    dbprint(printlevel-voice+2,"//gaussman::monodromy: compute C");
437    if(opt==0)
438    {
439      l=gmscoeffs(w,k,mu);
440    }
441    else
442    {
443      l=gmscoeffs(w,k,mu+n);
444    }
445    C,w=l[1..2];
446    A0=A0+C;
447
448    H0=H;
449    dbprint(printlevel-voice+2,"//gaussman::monodromy: compute dH");
450    dH=jet(module(A0*dH+s^2*diff(matrix(dH),s)),k);
451    H=H*s+dH;
452
453    dbprint(printlevel-voice+2,"//gaussman::monodromy: test dH==0");
454    sdH=size(reduce(H,std(H0*s)));
455  }
456
457  A0=A0-s^k;
458
459  dbprint(printlevel-voice+2,
460    "//gaussman::monodromy: compute basis of saturation");
461  H=minbase(H0);
462  int modH=maxorddif(H)/deg(s);
463  dbprint(printlevel-voice+2,"//gaussman::monodromy: k="+string(modH+1));
464  dbprint(printlevel-voice+2,"//gaussman::monodromy: compute C");
465  if(opt==0)
466  {
467    l=gmscoeffs(w,modH+1,modH+1);
468  }
469  else
470  {
471    l=gmscoeffs(w,modH+1,modH+1+n);
472  }
473  C,w=l[1..2];
474  A0=A0+C;
475
476  dbprint(printlevel-voice+2,
477    "//gaussman::monodromy: compute A on saturation");
478  l=division(H*s,A0*H+s^2*diff(matrix(H),s));
479  A=jet(l[1],l[2],0);
480
481  dbprint(printlevel-voice+2,
482    "//gaussman::monodromy: compute eigenvalues e and "+
483    "multiplicities b of A");
484  l=eigenval(jet(A,0));
485  ideal e=l[1];
486  intvec b=l[2];
487  dbprint(printlevel-voice+2,"//gaussman::monodromy: e="+string(e));
488  dbprint(printlevel-voice+2,"//gaussman::monodromy: b="+string(b));
489
490  if(opt==0)
491  {
492    setring(R);
493    ideal e=imap(G,e);
494    return(e);
495  }
496
497  int mide=maxintdif(e);
498
499  if(mide>0)
500  {
501    dbprint(printlevel-voice+2,
502      "//gaussman::monodromy: k="+string(modH+1+mide));
503    dbprint(printlevel-voice+2,"//gaussman::monodromy: compute C");
504    l=gmscoeffs(w,modH+1+mide,modH+1+mide);
505    C,w=l[1..2];
506    A0=A0+C;
507
508    intvec ide;
509    ide[mu]=0;
510    int i,j;
511    for(i=ncols(e);i>=1;i--)
512    {
513      for(j=i-1;j>=1;j--)
514      {
515        k=int(e[j]-e[i]);
516        if(k>ide[i])
517        {
518          ide[i]=k;
519        }
520        if(-k>ide[j])
521        {
522          ide[j]=-k;
523        }
524      }
525    }
526    for(j,k=ncols(e),mu;j>=1;j--)
527    {
528      for(i=b[j];i>=1;i--)
529      {
530        ide[k]=ide[j];
531        k--;
532      }
533    }
534  }
535  while(mide>0)
536  {
537    dbprint(printlevel-voice+2,"//gaussman::monodromy: mide="+string(mide));
538
539    matrix U=0;
540    A0=jet(A,0);
541    for(i=ncols(e);i>=1;i--)
542    {
543      U=syz(power(A0-e[i],n+1))+U;
544    }
545    A=division(U,A*U)[1];
546
547    for(i=mu;i>=1;i--)
548    {
549      for(j=mu;j>=1;j--)
550      {
551        if(ide[i]==0&&ide[j]>0)
552        {
553          A[i,j]=A[i,j]*d;
554        }
555        else
556        {
557          if(ide[i]>0&&ide[j]==0)
558          {
559            A[i,j]=A[i,j]/d;
560          }
561        }
562      }
563    }
564    for(i=mu;i>=1;i--)
565    {
566      if(ide[i]>0)
567      {
568        A[i,i]=A[i,i]+1;
569        e[i]=e[i]+1;
570        ide[i]=ide[i]-1;
571      }
572    }
573    mide--;
574  }
575  A=jet(A,0);
576
577  setring(R);
578  matrix A=imap(G,A);
579  return(A);
580}
581example
582{ "EXAMPLE:"; echo=2;
583  ring R=0,(x,y),ds;
584  poly f=x5+x2y2+y5;
585  print(monodromy(f));
586}
587///////////////////////////////////////////////////////////////////////////////
588
589proc vfiltration(poly f,list #)
590"USAGE:    vfiltration(f[,opt]); poly f, int opt
591ASSUME:   basering has characteristic 0 and local degree ordering,
592          f has isolated singularity at 0
593RETURN:
594@format
595list V: V-filtration of f on H''/H'
596if opt==0 or opt==1:
597  intvec V[1]: numerators of spectral numbers
598  intvec V[2]: denominators of spectral numbers
599  intvec V[3]:
600    int V[3][i]: multiplicity of spectral number V[1][i]/V[2][i]
601if opt==1:
602  list V[4]:
603    module V[4][i]: vector space basis of V[1][i]/V[2][i]-th graded part
604                    in terms of V[5]
605  ideal V[5]: monomial vector space basis
606default: opt=1
607@end format
608NOTE:     H' and H'' denote the Brieskorn lattices
609SEE ALSO: spectrum_lib
610KEYWORDS: singularities; Gauss-Manin connection;
611          Brieskorn lattice; Hodge filtration; V-filtration; spectrum
612EXAMPLE:  example vfiltration; shows examples
613"
614{
615  int opt=1;
616  if(size(#)>0)
617  {
618    if(typeof(#[1])=="int")
619    {
620      opt=#[1];
621    }
622  }
623
624  def R=basering;
625  def G=gmsring(f,"s");
626  setring G;
627
628  int n=nvars(R)-1;
629  int mu,modm=ncols(gmsbasis),maxorddif(gmsbasis);
630  ideal w=gmspoly*gmsbasis;
631  list l;
632  matrix U=freemodule(mu);
633  matrix A[mu][mu],C;
634  module H,dH=freemodule(mu),freemodule(mu);
635  module H0;
636  int sdH=1;
637  int k=-1;
638  int N=n+1;
639
640  while(sdH>0)
641  {
642    k++;
643    dbprint(printlevel-voice+2,"//gaussman::vfiltration: k="+string(k));
644    dbprint(printlevel-voice+2,"//gaussman::vfiltration: compute C");
645    l=gmscoeffs(w,k);
646    C,w=l[1..2];
647    A=A+C;
648
649    H0=H;
650    dbprint(printlevel-voice+2,"//gaussman::vfiltration: compute dH");
651    dH=jet(module(A*dH+s^2*diff(matrix(dH),s)),k);
652    H=H*s+dH;
653
654    dbprint(printlevel-voice+2,"//gaussman::vfiltration: test dH==0");
655    sdH=size(reduce(H,std(H0*s)));
656  }
657
658  A=A-s^k;
659
660  dbprint(printlevel-voice+2,
661    "//gaussman::vfiltration: compute basis of saturation");
662  H=minbase(H0);
663  int modH=maxorddif(H)/deg(s);
664  dbprint(printlevel-voice+2,"//gaussman::monodromy: k="+string(N+modH));
665  dbprint(printlevel-voice+2,"//gaussman::monodromy: compute C");
666  l=gmscoeffs(w,N+modH,N+modH);
667  C,w=l[1..2];
668  A=A+C;
669
670  dbprint(printlevel-voice+2,
671    "//gaussman::vfiltration: transform H0 to saturation");
672  l=division(H,freemodule(mu)*s^k);
673  H0=jet(l[1],l[2],N-1);
674
675  dbprint(printlevel-voice+2,
676    "//gaussman::vfiltration: compute H0 as vector space V0");
677  dbprint(printlevel-voice+2,
678    "//gaussman::vfiltration: compute H1 as vector space V1");
679  poly p;
680  int i0,j0,i1,j1;
681  matrix V0[mu*N][mu*N];
682  matrix V1[mu*N][mu*(N-1)];
683  for(i0=mu;i0>=1;i0--)
684  {
685    for(i1=mu;i1>=1;i1--)
686    {
687      p=H0[i1,i0];
688      while(p!=0)
689      {
690        j1=leadexp(p)[1];
691        for(j0=N-j1-1;j0>=0;j0--)
692        {
693          V0[i1+(j1+j0)*mu,i0+j0*mu]=V0[i1+(j1+j0)*mu,i0+j0*mu]+leadcoef(p);
694          if(j1+j0+1<N)
695          {
696            V1[i1+(j1+j0+1)*mu,i0+j0*mu]=
697            V1[i1+(j1+j0+1)*mu,i0+j0*mu]+leadcoef(p);
698          }
699        }
700        p=p-lead(p);
701      }
702    }
703  }
704
705  dbprint(printlevel-voice+2,
706    "//gaussman::vfiltration: compute A on saturation");
707  l=division(H*s,A*H+s^2*diff(matrix(H),s));
708  A=jet(l[1],l[2],N-1);
709
710  dbprint(printlevel-voice+2,"//gaussman::vfiltration: compute matrix M of A");
711  matrix M[mu*N][mu*N];
712  for(i0=mu;i0>=1;i0--)
713  {
714    for(i1=mu;i1>=1;i1--)
715    {
716      p=A[i1,i0];
717      while(p!=0)
718      {
719        j1=leadexp(p)[1];
720        for(j0=N-j1-1;j0>=0;j0--)
721        {
722          M[i1+(j0+j1)*mu,i0+j0*mu]=leadcoef(p);
723        }
724        p=p-lead(p);
725      }
726    }
727  }
728  for(i0=mu;i0>=1;i0--)
729  {
730    for(j0=N-1;j0>=0;j0--)
731    {
732      M[i0+j0*mu,i0+j0*mu]=M[i0+j0*mu,i0+j0*mu]+j0;
733    }
734  }
735
736  dbprint(printlevel-voice+2,
737    "//gaussman::vfiltration: compute eigenvalues eA of A");
738  ideal eA=eigenval(jet(A,0))[1];
739  dbprint(printlevel-voice+2,"//gaussman::vfiltration: eA="+string(eA));
740
741  dbprint(printlevel-voice+2,
742    "//gaussman::vfiltration: compute eigenvalues eM of M");
743  ideal eM;
744  k=0;
745  intvec u;
746  for(int i=N;i>=1;i--)
747  {
748    u[i]=1;
749  }
750  i0=1;
751  while(u[N]<=ncols(eA))
752  {
753    for(i,i1=i0+1,i0;i<=N;i++)
754    {
755      if(eA[u[i]]+i<eA[u[i1]]+i1)
756      {
757        i1=i;
758      }
759    }
760    k++;
761    eM[k]=eA[u[i1]]+i1-1;
762    u[i1]=u[i1]+1;
763    if(u[i1]>ncols(eA))
764    {
765      i0=i1+1;
766    }
767  }
768  dbprint(printlevel-voice+2,"//gaussman::vfiltration: eM="+string(eM));
769
770  dbprint(printlevel-voice+2,
771    "//gaussman::vfiltration: compute V-filtration on H0/H1");
772  ideal a;
773  k=0;
774  list V;
775  V[ncols(eM)+1]=interred(V1);
776  intvec d;
777  if(opt==0)
778  {
779    for(i=ncols(eM);number(eM[i])-1>number(n-1)/2;i--)
780    {
781      dbprint(printlevel-voice+2,
782        "//gaussman::vfiltration: compute V["+string(i)+"]");
783      V1=module(V1)+syz(power(M-eM[i],n+1));
784      V[i]=interred(intersect(V1,V0));
785
786      if(size(V[i])>size(V[i+1]))
787      {
788        k++;
789        a[k]=eM[i]-1;
790        d[k]=size(V[i])-size(V[i+1]);
791      }
792    }
793
794    dbprint(printlevel-voice+2,
795      "//gaussman::vfiltration: symmetry index found");
796    int j=k;
797
798    if(number(eM[i])-1==number(n-1)/2)
799    {
800      dbprint(printlevel-voice+2,
801        "//gaussman::vfiltration: compute V["+string(i)+"]");
802      V1=module(V1)+syz(power(M-eM[i],n+1));
803      V[i]=interred(intersect(V1,V0));
804
805      if(size(V[i])>size(V[i+1]))
806      {
807        k++;
808        a[k]=eM[i]-1;
809        d[k]=size(V[i])-size(V[i+1]);
810      }
811    }
812
813    dbprint(printlevel-voice+2,"//gaussman::vfiltration: apply symmetry");
814    while(j>=1)
815    {
816      k++;
817      a[k]=a[j];
818      a[j]=n-1-a[k];
819      d[k]=d[j];
820      j--;
821    }
822
823    setring(R);
824    ideal a=imap(G,a);
825    return(list(a,d));
826  }
827  else
828  {
829    list v;
830    int j=-1;
831    for(i=ncols(eM);i>=1;i--)
832    {
833      dbprint(printlevel-voice+2,
834        "//gaussman::vfiltration: compute V["+string(i)+"]");
835      V1=module(V1)+syz(power(M-eM[i],n+1));
836      V[i]=interred(intersect(V1,V0));
837
838      if(size(V[i])>size(V[i+1]))
839      {
840        if(number(eM[i]-1)>=number(n-1)/2)
841        {
842          k++;
843          a[k]=eM[i]-1;
844          dbprint(printlevel-voice+2,
845            "//gaussman::vfiltration: transform to V0");
846          v[k]=matrix(freemodule(ncols(V[i])),mu,mu*N)*division(V0,V[i])[1];
847        }
848        else
849        {
850          if(j<0)
851          {
852            if(a[k]==number(n-1)/2)
853            {
854              j=k-1;
855            }
856            else
857            {
858              j=k;
859            }
860          }
861          k++;
862          a[k]=a[j];
863          a[j]=eM[i]-1;
864          v[k]=v[j];
865          dbprint(printlevel-voice+2,
866            "//gaussman::vfiltration: transform to V0");
867          v[j]=matrix(freemodule(ncols(V[i])),mu,mu*N)*division(V0,V[i])[1];
868          j--;
869        }
870      }
871    }
872
873    dbprint(printlevel-voice+2,
874      "//gaussman::vfiltration: compute graded parts");
875    for(k=1;k<size(v);k++)
876    {
877      v[k]=interred(reduce(v[k],std(v[k+1])));
878      d[k]=size(v[k]);
879    }
880    v[k]=interred(v[k]);
881    d[k]=size(v[k]);
882
883    setring(R);
884    ideal a=imap(G,a);
885    list v=imap(G,v);
886    ideal m=imap(G,gmsbasis);
887    return(list(a,d,v,m));
888  }
889}
890example
891{ "EXAMPLE:"; echo=2;
892  ring R=0,(x,y),ds;
893  poly f=x5+x2y2+y5;
894  vfiltration(f);
895}
896///////////////////////////////////////////////////////////////////////////////
897
898proc spectrum(poly f)
899"USAGE:    spectrum(f); poly f
900ASSUME:   basering has characteristic 0 and local degree ordering,
901          f has isolated singularity at 0
902RETURN:
903@format
904list S: singularity spectrum of f
905  ideal S[1]: spectral numbers in increasing order
906  intvec S[2]:
907    int S[2][i]: multiplicity of spectral number S[1][i]
908@end format
909SEE ALSO: spectrum_lib
910KEYWORDS: singularities; Gauss-Manin connection; spectrum
911EXAMPLE:  example spectrum; shows examples
912"
913{
914  return(vfiltration(f,0));
915}
916example
917{ "EXAMPLE:"; echo=2;
918  ring R=0,(x,y),ds;
919  poly f=x5+x2y2+y5;
920  spprint(spectrum(f));
921}
922///////////////////////////////////////////////////////////////////////////////
923
924proc endfilt(poly f,list V)
925"USAGE:   endfilt(f,V); poly f, list V
926ASSUME:  basering has characteristic 0 and local degree ordering,
927         f has isolated singularity at 0
928RETURN:
929@format
930list V1: endomorphim filtration of V on the Jacobian algebra of f
931  ideal V1[1]: spectral numbers in increasing order
932  intvec V1[2]:
933    int V1[2][i]: multiplicity of spectral number V1[1][i]
934  list V1[3]:
935    module V1[3][i]: vector space basis of the V1[1][i]-th graded part
936                     in terms of V1[4]
937  ideal V1[4]: monomial vector space basis
938@end format
939SEE ALSO: spectrum_lib
940KEYWORDS: singularities; Gauss-Manin connection; spectrum;
941          Brieskorn lattice; Hodge filtration; V-filtration
942EXAMPLE: example endfilt; shows examples
943"
944{
945  if(charstr(basering)!="0")
946  {
947    ERROR("characteristic 0 expected");
948  }
949  int n=nvars(basering)-1;
950  for(int i=n+1;i>=1;i--)
951  {
952    if(var(i)>1)
953    {
954      ERROR("local ordering expected");
955    }
956  }
957  ideal sJ=std(jacob(f));
958  if(vdim(sJ)<=0)
959  {
960    if(vdim(sJ)==0)
961    {
962      ERROR("singularity at 0 expected");
963    }
964    else
965    {
966      ERROR("isolated singularity at 0 expected");
967    }
968  }
969
970  def a,d,v,m=V[1..4];
971  int mu=ncols(m);
972
973  module V0=v[1];
974  for(i=2;i<=size(v);i++)
975  {
976    V0=V0,v[i];
977  }
978
979  dbprint(printlevel-voice+2,
980    "//gaussman::endfilt: compute multiplication in Jacobian algebra");
981  list M;
982  matrix U=freemodule(ncols(m));
983  for(i=ncols(m);i>=1;i--)
984  {
985    M[i]=lift(V0,coeffs(reduce(m[i]*m,U,sJ),m)*V0);
986  }
987
988  int j,k,i0,j0,i1,j1;
989  number b0=number(a[1]-a[ncols(a)]);
990  number b1,b2;
991  matrix M0;
992  module L;
993  list v0=freemodule(ncols(m));
994  ideal a0=b0;
995
996  while(b0<number(a[ncols(a)]-a[1]))
997  {
998    dbprint(printlevel-voice+2,
999      "//gaussman::endfilt: find next possible index");
1000    b1=number(a[ncols(a)]-a[1]);
1001    for(j=ncols(a);j>=1;j--)
1002    {
1003      for(i=ncols(a);i>=1;i--)
1004      {
1005        b2=number(a[i]-a[j]);
1006        if(b2>b0&&b2<b1)
1007        {
1008          b1=b2;
1009        }
1010        else
1011        {
1012          if(b2<=b0)
1013          {
1014            i=0;
1015          }
1016        }
1017      }
1018    }
1019    b0=b1;
1020
1021    list l=ideal();
1022    for(k=ncols(m);k>=2;k--)
1023    {
1024      l=l+list(ideal());
1025    }
1026
1027    dbprint(printlevel-voice+2,
1028      "//gaussman::endfilt: collect conditions for V1["+string(b0)+"]");
1029    j=ncols(a);
1030    j0=mu;
1031    while(j>=1)
1032    {
1033      i0=1;
1034      i=1;
1035      while(i<ncols(a)&&a[i]<a[j]+b0)
1036      {
1037        i0=i0+d[i];
1038        i++;
1039      }
1040      if(a[i]<a[j]+b0)
1041      {
1042        i0=i0+d[i];
1043        i++;
1044      }
1045      for(k=1;k<=ncols(m);k++)
1046      {
1047        M0=M[k];
1048        if(i0>1)
1049        {
1050          l[k]=l[k],M0[1..i0-1,j0-d[j]+1..j0];
1051        }
1052      }
1053      j0=j0-d[j];
1054      j--;
1055    }
1056
1057    dbprint(printlevel-voice+2,
1058      "//gaussman::endfilt: compose condition matrix");
1059    L=transpose(module(l[1]));
1060    for(k=2;k<=ncols(m);k++)
1061    {
1062      L=L,transpose(module(l[k]));
1063    }
1064
1065    dbprint(printlevel-voice+2,
1066      "//gaussman::endfilt: compute kernel of condition matrix");
1067    v0=v0+list(syz(L));
1068    a0=a0,b0;
1069  }
1070
1071  dbprint(printlevel-voice+2,"//gaussman::endfilt: compute graded parts");
1072  option(redSB);
1073  for(i=1;i<size(v0);i++)
1074  {
1075    v0[i+1]=std(v0[i+1]);
1076    v0[i]=std(reduce(v0[i],v0[i+1]));
1077  }
1078
1079  dbprint(printlevel-voice+2,
1080    "//gaussman::endfilt: remove trivial graded parts");
1081  i=1;
1082  while(size(v0[i])==0)
1083  {
1084    i++;
1085  }
1086  list v1=v0[i];
1087  intvec d1=size(v0[i]);
1088  ideal a1=a0[i];
1089  i++;
1090  while(i<=size(v0))
1091  {
1092    if(size(v0[i])>0)
1093    {
1094      v1=v1+list(v0[i]);
1095      d1=d1,size(v0[i]);
1096      a1=a1,a0[i];
1097    }
1098    i++;
1099  }
1100  return(list(a1,d1,v1,m));
1101}
1102example
1103{ "EXAMPLE:"; echo=2;
1104  ring R=0,(x,y),ds;
1105  poly f=x5+x2y2+y5;
1106  endfilt(f,vfiltration(f));
1107}
1108///////////////////////////////////////////////////////////////////////////////
1109
1110proc spprint(list S)
1111"USAGE:   spprint(S); list S
1112RETURN:  string: spectrum S
1113EXAMPLE: example spprint; shows examples
1114"
1115{
1116  string s;
1117  for(int i=1;i<size(S[2]);i++)
1118  {
1119    s=s+"("+string(S[1][i])+","+string(S[2][i])+"),";
1120  }
1121  s=s+"("+string(S[1][i])+","+string(S[2][i])+")";
1122  return(s);
1123}
1124example
1125{ "EXAMPLE:"; echo=2;
1126  ring R=0,(x,y),ds;
1127  list S=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1128  spprint(S);
1129}
1130///////////////////////////////////////////////////////////////////////////////
1131
1132proc spadd(list S1,list S2)
1133"USAGE:   spadd(S1,S2); list S1,S2
1134RETURN:  list: sum of spectra S1 and S2
1135EXAMPLE: example spadd; shows examples
1136"
1137{
1138  ideal s;
1139  intvec m;
1140  int i,i1,i2=1,1,1;
1141  while(i1<=size(S1[2])||i2<=size(S2[2]))
1142  {
1143    if(i1<=size(S1[2]))
1144    {
1145      if(i2<=size(S2[2]))
1146      {
1147        if(number(S1[1][i1])<number(S2[1][i2]))
1148        {
1149          s[i]=S1[1][i1];
1150          m[i]=S1[2][i1];
1151          i++;
1152          i1++;
1153        }
1154        else
1155        {
1156          if(number(S1[1][i1])>number(S2[1][i2]))
1157          {
1158            s[i]=S2[1][i2];
1159            m[i]=S2[2][i2];
1160            i++;
1161            i2++;
1162          }
1163          else
1164          {
1165            if(S1[2][i1]+S2[2][i2]!=0)
1166            {
1167              s[i]=S1[1][i1];
1168              m[i]=S1[2][i1]+S2[2][i2];
1169              i++;
1170            }
1171            i1++;
1172            i2++;
1173          }
1174        }
1175      }
1176      else
1177      {
1178        s[i]=S1[1][i1];
1179        m[i]=S1[2][i1];
1180        i++;
1181        i1++;
1182      }
1183    }
1184    else
1185    {
1186      s[i]=S2[1][i2];
1187      m[i]=S2[2][i2];
1188      i++;
1189      i2++;
1190    }
1191  }
1192  return(list(s,m));
1193}
1194example
1195{ "EXAMPLE:"; echo=2;
1196  ring R=0,(x,y),ds;
1197  list S1=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1198  spprint(S1);
1199  list S2=list(ideal(-1/6,1/6),intvec(1,1));
1200  spprint(S2);
1201  spprint(spadd(S1,S2));
1202}
1203///////////////////////////////////////////////////////////////////////////////
1204
1205proc spsub(list S1,list S2)
1206"USAGE:   spsub(S1,S2); list S1,S2
1207RETURN:  list: difference of spectra S1 and S2
1208EXAMPLE: example spsub; shows examples
1209"
1210{
1211  return(spadd(S1,spmul(S2,-1)));
1212}
1213example
1214{ "EXAMPLE:"; echo=2;
1215  ring R=0,(x,y),ds;
1216  list S1=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1217  spprint(S1);
1218  list S2=list(ideal(-1/6,1/6),intvec(1,1));
1219  spprint(S2);
1220  spprint(spsub(S1,S2));
1221}
1222///////////////////////////////////////////////////////////////////////////////
1223
1224proc spmul(list #)
1225"USAGE:
1226@format
12271) spmul(S,k); list S, int k
12282) spmul(S,k); list S, intvec k
1229@end format
1230RETURN:
1231@format
12321) list: product of spectrum S and integer k
12332) list: linear combination of spectra S with coefficients k
1234@end format
1235EXAMPLE: example spmul; shows examples
1236"
1237{
1238  if(size(#)==2)
1239  {
1240    if(typeof(#[1])=="list")
1241    {
1242      if(typeof(#[2])=="int")
1243      {
1244        return(list(#[1][1],#[1][2]*#[2]));
1245      }
1246      if(typeof(#[2])=="intvec")
1247      {
1248        list S0=list(ideal(),intvec(0));
1249        for(int i=size(#[2]);i>=1;i--)
1250        {
1251          S0=spadd(S0,spmul(#[1][i],#[2][i]));
1252        }
1253        return(S0);
1254      }
1255    }
1256  }
1257  return(list(ideal(),intvec(0)));
1258}
1259example
1260{ "EXAMPLE:"; echo=2;
1261  ring R=0,(x,y),ds;
1262  list S=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1263  spprint(S);
1264  spprint(spmul(S,2));
1265  list S1=list(ideal(-1/6,1/6),intvec(1,1));
1266  spprint(S1);
1267  list S2=list(ideal(-1/3,0,1/3),intvec(1,2,1));
1268  spprint(S2);
1269  spprint(spmul(list(S1,S2),intvec(1,2)));
1270}
1271///////////////////////////////////////////////////////////////////////////////
1272
1273proc spissemicont(list S,list #)
1274"USAGE:   spissemicont(S[,opt]); list S, int opt
1275RETURN:
1276@format
1277int k=
1278if opt==0:
1279  1, if sum of spectrum S over all intervals [a,a+1) is positive
1280  0, if sum of spectrum S over some interval [a,a+1) is negative
1281if opt==1:
1282  1, if sum of spectrum S over all intervals [a,a+1) and (a,a+1) is positive
1283  0, if sum of spectrum S over some interval [a,a+1) or (a,a+1) is negative
1284default: opt=0
1285@end format
1286EXAMPLE: example spissemicont; shows examples
1287"
1288{
1289  int opt=0;
1290  if(size(#)>0)
1291  {
1292    if(typeof(#[1])=="int")
1293    {
1294      opt=1;
1295    }
1296  }
1297  int i,j,k=1,1,0;
1298  while(j<=size(S[2]))
1299  {
1300    while(j+1<=size(S[2])&&S[1][j]<S[1][i]+1)
1301    {
1302      k=k+S[2][j];
1303      j++;
1304    }
1305    if(j==size(S[2])&&S[1][j]<S[1][i]+1)
1306    {
1307      k=k+S[2][j];
1308      j++;
1309    }
1310    if(k<0)
1311    {
1312      return(0);
1313    }
1314    k=k-S[2][i];
1315    if(k<0&&opt==1)
1316    {
1317      return(0);
1318    }
1319    i++;
1320  }
1321  return(1);
1322}
1323example
1324{ "EXAMPLE:"; echo=2;
1325  ring R=0,(x,y),ds;
1326  list S1=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1327  spprint(S1);
1328  list S2=list(ideal(-1/6,1/6),intvec(1,1));
1329  spprint(S2);
1330  spissemicont(spsub(S1,spmul(S2,5)));
1331  spissemicont(spsub(S1,spmul(S2,5)),1);
1332  spissemicont(spsub(S1,spmul(S2,6)));
1333}
1334///////////////////////////////////////////////////////////////////////////////
1335
1336proc spsemicont(list S0,list S,list #)
1337"USAGE:   spsemicont(S,k[,opt]); list S0, list S, int opt
1338RETURN:  list of intvecs l:
1339         spissemicont(sub(S0,spmul(S,k)),opt)==1 iff k<=l[i] for some i
1340NOTE:    if the spectra S occur with multiplicities k in a deformation
1341         of the [quasihomogeneous] spectrum S0 then
1342         spissemicont(sub(S0,spmul(S,k))[,1])==1
1343EXAMPLE: example spsemicont; shows examples
1344"
1345{
1346  list l,l0;
1347  int i,j,k;
1348  while(spissemicont(S0,#))
1349  {
1350    if(size(S)>1)
1351    {
1352      l0=spsemicont(S0,list(S[1..size(S)-1]));
1353      for(i=1;i<=size(l0);i++)
1354      {
1355        if(size(l)>0)
1356        {
1357          j=1;
1358          while(j<size(l)&&l[j]!=l0[i])
1359          {
1360            j++;
1361          }
1362          if(l[j]==l0[i])
1363          {
1364            l[j][size(S)]=k;
1365          }
1366          else
1367          {
1368            l0[i][size(S)]=k;
1369            l=l+list(l0[i]);
1370          }
1371        }
1372        else
1373        {
1374          l=l0;
1375        }
1376      }
1377    }
1378    S0=spsub(S0,S[size(S)]);
1379    k++;
1380  }
1381  if(size(S)>1)
1382  {
1383    return(l);
1384  }
1385  else
1386  {
1387    return(list(intvec(k-1)));
1388  }
1389}
1390example
1391{ "EXAMPLE:"; echo=2;
1392  ring R=0,(x,y),ds;
1393  list S0=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1394  spprint(S0);
1395  list S1=list(ideal(-1/6,1/6),intvec(1,1));
1396  spprint(S1);
1397  list S2=list(ideal(-1/3,0,1/3),intvec(1,2,1));
1398  spprint(S2);
1399  list S=S1,S2;
1400  list l=spsemicont(S0,S);
1401  l;
1402  spissemicont(spsub(S0,spmul(S,l[1])));
1403  spissemicont(spsub(S0,spmul(S,l[1]-1)));
1404  spissemicont(spsub(S0,spmul(S,l[1]+1)));
1405}
1406///////////////////////////////////////////////////////////////////////////////
1407
1408proc spmilnor(list S)
1409"USAGE:   spmilnor(S); list S
1410RETURN:  int: Milnor number of spectrum S
1411EXAMPLE: example spmilnor; shows examples
1412"
1413{
1414  return(sum(S[2]));
1415}
1416example
1417{ "EXAMPLE:"; echo=2;
1418  ring R=0,(x,y),ds;
1419  list S=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1420  spprint(S);
1421  spmilnor(S);
1422}
1423///////////////////////////////////////////////////////////////////////////////
1424
1425proc spgeomgenus(list S)
1426"USAGE:   spgeomgenus(S); list S
1427RETURN:  int: geometrical genus of spectrum S
1428EXAMPLE: example spgeomgenus; shows examples
1429"
1430{
1431  int g=0;
1432  int i=1;
1433  while(i+1<=size(S[2])&&number(S[1][i])<=number(0))
1434  {
1435    g=g+S[2][i];
1436    i++;
1437  }
1438  if(i==size(S[2])&&number(S[1][i])<=number(0))
1439  {
1440    g=g+S[2][i];
1441  }
1442  return(g);
1443}
1444example
1445{ "EXAMPLE:"; echo=2;
1446  ring R=0,(x,y),ds;
1447  list S=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1448  spprint(S);
1449  spgeomgenus(S);
1450}
1451///////////////////////////////////////////////////////////////////////////////
1452
1453proc spgamma(list S)
1454"USAGE:   spgamma(S); list S
1455RETURN:  number: gamma invariant of spectrum S
1456EXAMPLE: example spgamma; shows examples
1457"
1458{
1459  int i,j;
1460  number g=0;
1461  for(i=1;i<=ncols(S[1]);i++)
1462  {
1463    for(j=1;j<=S[2][i];j++)
1464    {
1465      g=g+(number(S[1][i])-number(nvars(basering)-2)/2)^2;
1466    }
1467  }
1468  g=-g/4+sum(S[2])*number(S[1][ncols(S[1])]-S[1][1])/48;
1469  return(g);
1470}
1471example
1472{ "EXAMPLE:"; echo=2;
1473  ring R=0,(x,y),ds;
1474  list S=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1475  spprint(S);
1476  spgamma(S);
1477}
1478///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.