source: git/Singular/LIB/spcurve.lib @ 96ec6c9

spielwiese
Last change on this file since 96ec6c9 was 96ec6c9, checked in by Olaf Bachmann <obachman@…>, 25 years ago
* changed name of monromy.lib to monodrom.lib (name may not be longer than 8 letters) * added spcurve.lib git-svn-id: file:///usr/local/Singular/svn/trunk@3016 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 34.3 KB
Line 
1// $Id: spcurve.lib,v 1.1 1999-04-30 16:56:19 obachman Exp $
2// (anne, last modified 20.7.98)
3/////////////////////////////////////////////////////////////////////////////
4
5version="$Id: spcurve.lib,v 1.1 1999-04-30 16:56:19 obachman Exp $";
6info="
7LIBRARY: spcurve.lib    PROCEDURES FOR CM CODIMENSION 2 SINGULARITIES
8
9 isCMcod2(i);            presentation matrix of the ideal i
10 CMtype(i);              Cohen-Macaulay type of the ideal i
11 matrixT1(M,n);          T1 in matrix description
12 semi(M,t1);             semiuniversal deformation
13 discr(sem,n);           discriminant given the semiuniversal
14                         deformation (not a powerful algorithm)
15 qhmatrix(M);            weights if M is quasihomogeneous
16 relweight(N,W,a);       relative matrix weight
17 posweight(M,t1,i);      perturbation of non-negative weight
18 kod_ker(M,a);           kernel of the Kodaira-Spencer map using eliminate
19 kod_noelim(M);          kernel of the Kodaira-Spencer map (weighted
20                         elimination)
21";
22         
23LIB "elim.lib";
24LIB "homolog.lib";
25LIB "inout.lib";
26LIB "poly.lib";
27/////////////////////////////////////////////////////////////////////////////
28
29proc isCMcod2(ideal kurve)
30USAGE:   isCMcod2(i);
31         where i is an ideal
32RETURN:  presentation matrix of i, if i is Cohen-Macaulay of codimension2
33         a zero matrix otherwise
34EXAMPLE: example isCMcod2; shows an example
35{
36  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
37//---------------------------------------------------------------------------
38// Compute a minimal free resolution of the ideal and check if the
39// resolution has the expected structure
40//---------------------------------------------------------------------------
41  list kurveres=mres(kurve,0);
42  matrix M=kurveres[2];
43  if ((size(kurveres)>3) &&
44         ((size(kurveres[3])>1) ||
45          ((size(kurveres[3])<=1) && (kurveres[3][1,1]!=0))))
46  {
47    dbprint(p,"//not Cohen-Macaulay, codim 2");
48    matrix ret=0;
49    return(ret);
50  }
51  return(M);
52}
53example
54{ "EXAMPLE:"; echo=2;
55  ring r=32003,(x,y,z),ds;
56  ideal i=xz,yz,x^3-y^4;
57  print(isCMcod2(i));
58}
59/////////////////////////////////////////////////////////////////////////////
60
61proc CMtype(ideal kurve)
62USAGE:   CMtype(i);
63         where i is an ideal, Cohen-Macaulay of codimension 2
64RETURN:  Cohen-Macaulay type of i (integer)
65         (-1, if i is not Cohen-Macaulay of codimension 2)
66EXAMPLE: example CMtype; shows an example
67{
68  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
69  int gt = -1;
70//---------------------------------------------------------------------------
71// Compute a minimal free resolution of the ideal and check if the
72// resolution has the expected structure
73//---------------------------------------------------------------------------
74  list kurveres;
75  kurveres=mres(kurve,0);
76  if (size(kurveres)>3)
77  {
78    dbprint(p,"//not Cohen-Macaulay, codim 2");
79    return(gt);
80  }
81//---------------------------------------------------------------------------
82// Return the Cohen-Macaulay type of i
83//---------------------------------------------------------------------------
84  matrix M = matrix(kurveres[2]);
85  gt = ncols(M);
86  return(gt);
87}
88example
89{ "EXAMPLE:"; echo=2;
90  ring r=32003,(x,y,z),ds;
91  ideal i=xy,xz,yz;
92  CMtype(i);
93}
94/////////////////////////////////////////////////////////////////////////////
95
96proc matrixT1(matrix M ,int n)
97USAGE:   matrixT1(M,n);
98         where M is a presentation matrix of an ideal,
99         Cohen-Macaulay of codimension 2
100         and n determines the number of variables used as variables, not as
101         parameters ( variables are assumed to precede parameters in the
102         definition of the basering )
103RETURN:  T1 of i as a quotient of the module of matrices of the same
104         size as M with polynomial entries
105EXAMPLE: example matrixT1; shows an example
106{
107  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
108//--------------------------------------------------------------------------
109// Initialization and sanity checks
110//--------------------------------------------------------------------------
111  int nr=nrows(M);
112  int nc=ncols(M);
113  if ( nr < nc )
114  {
115    M=transpose(M);
116    temp=nc;
117    nc=nr;
118    nr=temp;
119    tra=1;
120  }
121  if ( nr != (nc+1) )
122  {
123    dbprint(p,"//not a k x (k+1) matrix");
124    return("ERROR");
125  }
126//---------------------------------------------------------------------------
127// Construct the denominator - step by step
128// step 1: initialization
129//---------------------------------------------------------------------------
130  int gt=nc;
131  int i,j;
132  ideal m = M;
133  ideal dx;
134  ideal rv;
135  ideal lv;
136  matrix R[gt][gt]=0;
137  matrix L[gt+1][gt+1]=0;
138  matrix T1[n+gt*gt+(gt+1)*(gt+1)][gt*(gt+1)] = 0;
139//---------------------------------------------------------------------------
140// step 2: the derivatives of the matrix are generators of the denominator
141//---------------------------------------------------------------------------
142  for( i=1; i<= n; i++ )
143  {
144    dx=diff(m,var(i));
145    T1[i,1..gt*(gt+1)] = dx;
146  }
147//---------------------------------------------------------------------------
148// step 3: M*R is a generator as well
149//---------------------------------------------------------------------------
150  for( i=1; i <= gt; i++ )
151  {
152    for ( j=1 ; j <= gt ; j++ )
153    {
154      R[i,j]=1;
155      rv = M * R;
156      T1[n+(i-1)*gt+j,1..gt*(gt+1)] = rv;
157      R[i,j]=0;
158    }
159  }
160//---------------------------------------------------------------------------
161// step 4: so is L*M
162//---------------------------------------------------------------------------
163  for( i=1; i <= (gt+1); i++)
164  {
165    for( j=1 ; j <= (gt+1);j++ )
166    {
167      L[i,j]=1;
168      lv = L * M;
169      T1[n+gt*gt+(i-1)*(gt+1)+j,1..gt*(gt+1)] = lv;
170      L[i,j]=0;
171    }
172  }
173//---------------------------------------------------------------------------
174// Compute the vectorspace basis of T1
175//---------------------------------------------------------------------------
176  module t1 = module(transpose(T1));
177  list result=M,t1;
178  return(result);
179}
180example
181{ "EXAMPLE:"; echo = 2;
182  ring r=32003,(x(1),x(2),x(3)),dp;
183  ideal curve=x(1)*x(2),x(1)*x(3),x(2)*x(3);
184  matrix M=isCMcod2(curve);
185  matrixT1(M,3);
186}
187/////////////////////////////////////////////////////////////////////////////
188
189proc semi(matrix M, module t1)
190USAGE:   semi(M,t1);
191         where M is a presentation matrix of a Cohen-Macaulay codimension 2
192         ideal and t1 is its T1 space in matrix notation
193         The current basering should not contain any variables named
194         A(i) where i is some integer!
195RETURN:  after a change to a new basering
196         ring rneu=char(basering),(var(1),..,var(nvars(basering)),
197                    A(1),..,A(vdim(t1))),(dp nvars(basering),dp vdim(t1));
198         an ideal describing the semiuniversal deformation is returned
199EXAMPLE: example semi; shows an example
200{
201//---------------------------------------------------------------------------
202// Initialization
203//---------------------------------------------------------------------------
204  module t1erz=kbase(t1);
205  int tau=vdim(t1);
206  int gt=ncols(M);
207  int i;
208  def r=basering;
209  if(size(M)!=gt*(gt+1))
210  {
211    gt=gt-1;
212  }
213//---------------------------------------------------------------------------
214// Definition of the new ring and the image of M and t1 in the new ring
215//---------------------------------------------------------------------------
216  ring rtemp=0,(A(1..tau)),dp;
217  def rneu=r+rtemp;
218  setring rneu;
219  matrix M=imap(r,M);
220  ideal m=M;
221  module t1erz=imap(r,t1erz);
222//---------------------------------------------------------------------------
223// Construction of the presentation matrix of the versal deformation
224//---------------------------------------------------------------------------
225  matrix N=matrix(m);
226  matrix Mtemp[gt*(gt+1)][1];
227  for( i=1; i<=tau; i++)
228  {
229    Mtemp=t1erz[i];
230    N=N+A(i)*transpose(Mtemp);
231  }
232  ideal n=N;
233  matrix O[gt+1][gt]=n;
234//---------------------------------------------------------------------------
235// Construction of the return value
236//---------------------------------------------------------------------------
237  ideal result=minor(O,gt);
238  export rneu;
239  keepring rneu;
240  return(result);
241}
242example
243{ "EXAMPLE:"; echo=2;
244  ring r=32003,(x(1),x(2),x(3)),dp;
245  ideal curve=x(1)*x(2),x(1)*x(3),x(2)*x(3);
246  matrix M=isCMcod2(curve);
247  list l=matrixT1(M,3);
248  semi(l[1],std(l[2]));
249}
250/////////////////////////////////////////////////////////////////////////////
251
252proc discr(ideal kurve, int n)
253USAGE:   discr(sem,n)
254         where sem is the versal deformation of an ideal
255         and the first n variables of the ring are treated as variables
256         all the others as parameters
257RETURN:  ideal describing the discriminant
258EXAMPLE: example discr; shows an example
259{
260//---------------------------------------------------------------------------
261// some sanity checks and initialization
262//---------------------------------------------------------------------------
263  int i;
264  ideal sem=std(kurve);
265  ideal semdiff;
266  ideal J2;
267  int ncol=ncols(matrix(sem));
268  matrix Jacob[n][ncol];
269//---------------------------------------------------------------------------
270// compute the Jacobian
271//---------------------------------------------------------------------------
272  for ( i=1; i<=n; i++)
273  {
274    semdiff=diff(sem,var(i));
275    Jacob[i,1..ncol]=semdiff;
276  }
277//---------------------------------------------------------------------------
278// eliminate the first n variables in the ideal generated by
279// the versal deformation and the 2x2 minors of the Jacobian
280//---------------------------------------------------------------------------
281  semdiff=minor(Jacob,2);
282  J2=sem,semdiff;
283  J2=std(J2);
284  poly eli=1;
285  for( i=1; i<=n; i++)
286  {
287    eli=eli*var(i);
288  }
289  ideal dis=eliminate(J2,eli);
290  return(dis);
291}
292example
293{ "EXAMPLE:"; echo=2;
294  ring r=32003,(x(1),x(2),x(3)),dp;
295  ideal curve=x(1)*x(2),x(1)*x(3),x(2)*x(3);
296  matrix M=isCMcod2(curve);
297  list l=matrixT1(M,3);
298  def sem=semi(l[1],std(l[2]));
299  basering;
300  discr(sem,3);
301}
302/////////////////////////////////////////////////////////////////////////////
303
304proc qhmatrix(matrix M)
305USAGE:   qhmatrix(M);
306         where M is a matrix with polynomial entries of size k x (k+1)
307RETURN:  list consisting of an integer vector containing the weights of
308         the variables of the basering and an integer matrix giving the
309         weights of the entries
310         integer vector and integer matrix both contain only 0, if the
311         matrix is not quasihomogeneous, i.e. does not allow row and
312         column weights
313EXAMPLE: example qhmatrix; shows an example
314{
315  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
316//---------------------------------------------------------------------------
317// Initialization and sanity checks
318//---------------------------------------------------------------------------
319  def r=basering;
320  int i,j,temp;
321  int tra=0;
322  int nr=nrows(M);
323  int nc=ncols(M);
324  if ( nr > nc )
325  {
326    M=transpose(M);
327    temp=nc;
328    nc=nr;
329    nr=temp;
330    tra=1;
331  }
332  if ( nc != (nr+1) )
333  {
334    dbprint(p,"//not a k x (k+1) matrix");
335    return("ERROR");
336  }
337  ideal m=minor(M,nr);
338//---------------------------------------------------------------------------
339// get the weight using the fact that the matrix is quasihomogeneous, if
340// its maximal minors are, and check, whether M is really quasihomogeneous
341//---------------------------------------------------------------------------
342  intvec a=weight(m);
343  string tempstr="ring rneu=" + charstr(r) + ",(" + varstr(r) + "),ws(" + string(a) + ");";
344  execute(tempstr);
345  def M=imap(r,M);
346  int difset=0;
347  list l;
348  int dif;
349  int donttest=0;
350  int comprow=0;
351  intmat W[nr][nc];
352//---------------------------------------------------------------------------
353// find a row not containing a 0
354//---------------------------------------------------------------------------
355  for(i=1; i<=nr; i++)
356  {
357    if(comprow==0)
358    {
359      comprow=i;
360      for(j=1; j<=nc; j++)
361      {
362        if(M[i,j]==0)
363        {
364          comprow=0;
365          break;
366        }
367      }
368    }
369  }
370//---------------------------------------------------------------------------
371// get the weights of the comprow'th row or use emergency exit
372//--------------------------------------------------------------------------- 
373  if(comprow==0)
374  {
375    intvec v=0;
376    intmat V=0
377    list ret=v,V;
378    return(ret);
379  }
380  else
381  {
382    for(j=1; j<=nc; j++)
383    {
384      l[j]=deg(lead(M[comprow,j]));
385    }
386  }
387//---------------------------------------------------------------------------
388// do the checks
389//---------------------------------------------------------------------------
390  for(i=1; i<=nr; i++)
391  {
392    if ( i==comprow )
393    {
394// this row should not be tested against itself
395      donttest=1;
396    }
397    else
398    {
399// initialize the difference of the rows, but ignore 0-entries
400      if (M[i,1]!=0)
401      {
402        dif=deg(lead(M[i,1]))-l[1];
403        difset=1;
404      }
405      else
406      {
407        list memo;
408        memo[1]=1;
409      }
410    }
411// check column by column
412    for(j=1; j<=nc; j++)
413    {
414      if(M[i,j]==0)
415      {
416        if(defined(memo)!=0)
417        {
418          memo[size(memo)+1]=j;
419        }
420        else
421        {
422          list memo;
423          memo[1]=j;
424        }
425      }
426      temp=deg(lead(M[i,j]));
427      if((difset!=1) && (donttest!=1) && (M[i,j]!=0))
428      {
429// initialize the difference of the rows, if necessary - still ignore 0s
430        dif=deg(lead(M[i,j]))-l[j];
431        difset=1;
432      }
433// is M[i,j] quasihomogeneous - else emergency exit
434      if(M[i,j]!=jet(M[i,j],temp,a)-jet(M[i,j],temp-1,a))
435      {
436        intvec v=0;
437        intmat V=0;
438        list ret=v,V;
439        return(ret);
440      }
441      if(donttest!=1)
442      {
443// check row and column weights - else emergency exit
444        if(((temp-l[j])!=dif) && (M[i,j]!=0) && (difset==1))
445        {
446          intvec v=0;
447          intmat V=0;
448          list ret=v,V;
449          return(ret);
450        }
451      }
452// set the weight matrix entry
453      W[i,j]=temp;
454    }
455// clean up the 0's we left out
456    if((difset==1) && (defined(memo)!=0))
457    {
458      for(j=1; j<=size(memo); j++)
459      {
460        W[i,memo[j]]=dif+l[memo[j]];
461      }
462      kill memo;
463    }
464    donttest=0;
465  }
466//---------------------------------------------------------------------------
467// transpose, if M was transposed during initialization, and return the list
468//---------------------------------------------------------------------------
469  if ( tra==1 )
470  {
471    W=transpose(W);
472  }
473  setring r;
474  list ret=a,W;
475  return(ret);
476}
477example
478{ "EXAMPLE:"; echo=2;
479  ring r=0,(x,y,z),ds;
480  matrix M[3][2]=z,0,y,x,x^3,y;
481  qhmatrix(M);
482  pmat(M);
483}
484/////////////////////////////////////////////////////////////////////////////
485
486proc relweight(matrix N, intmat W, intvec a)
487USAGE:   relweight(N,W);
488         where N is a non-zero matrix with polynomial entries, W is a
489         matrix with integer entries of the same size and the entries
490         of a give the weight of the variables of the basering
491RETURN:  maximum of weight_a(N_\{ij\})-W_\{ij\}
492         string "ERROR" is sizes do not match
493EXAMPLE: example relweight; shows an example
494{
495  int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
496//---------------------------------------------------------------------------
497// Initialization and sanity checks
498//---------------------------------------------------------------------------
499  if ((size(N)!=size(W)) || (ncols(N)!=ncols(W)))
500  {
501    dbprint(p,"//matrix size does not match");
502    return("ERROR");
503  }
504  if (size(a)!=nvars(basering))
505  {
506    dbprint(p,"//length of weight vector != number of variables");
507    return("ERROR");
508  }
509  int i,j,temp;
510  def r=basering;
511//---------------------------------------------------------------------------
512// Comparision entry by entry
513//---------------------------------------------------------------------------
514  for(i=1; i<=nrows(N); i++)
515  {
516    for(j=1; j<=ncols(N); j++)
517    {
518      if (N[i,j]!=0)
519      {
520        temp=mindeg1(N[i,j],a)-W[i,j];
521        if (defined(ret))
522        {
523          if(temp > ret)
524          {
525            ret=temp;
526          }
527        }
528        else
529        {
530          int ret=temp;
531        }
532      }
533    }
534  }
535  return(ret);
536}
537example
538{ "EXAMPLE:"; echo=2;
539  ring r=32003,(x,y,z),ds;
540  matrix N[2][3]=z,0,y,x,x^3,y;
541  intmat W[2][3]=1,1,1,1,1,1;
542  intvec a=1,1,1;
543  relweight(N,W,a);
544}
545/////////////////////////////////////////////////////////////////////////////
546
547proc posweight(matrix M, module t1,int choose)
548USAGE:   posweight(M,t1,choose);
549         where M is a presentation matrix of a Cohen-Macaulay codimension 2
550         ideal and t1 is its T1 space in matrix notation
551         The current basering should not contain any variables named
552         T(i) where i is some integer!
553         choose==0 => all perturbations of non-negative weight
554         choose==1 => only those which do not change the CM-type
555         choose==2 => all perturbations of positive weight
556RETURN:  after a change to a new basering
557         ring rneu=char(basering),(var(1),..,var(nvars(basering)),
558                    T(1),..,T(k),(dp nvars(basering),dp k);
559         a presentation matrix describing the deformation given by the
560         generators of T1 of non-negative weight is returned as the first
561         list element, followed by the weight vector for the new variables
562EXAMPLE: example posweight; shows an example
563{
564//---------------------------------------------------------------------------
565// Initialization and sanity checks
566//---------------------------------------------------------------------------
567  if (attrib(t1,"isSB"))
568  {
569    module t1erz=kbase(t1);
570    int tau=vdim(t1);
571  }
572  else
573  { module t1erz=kbase(std(t1));
574    int tau=vdim(std(t1));
575  }
576  for(int i=1; i<=size(t1erz); i++)
577  {
578    if(rvar(T(i)))
579    {
580      int jj=-1;
581    }
582  }
583  kill i;
584  if (defined(jj))
585  {
586    if (jj==-1)
587    {
588      "Your ring contains a variable T(" +string(i)+")!";
589      return("ERROR");
590    }
591  }
592  int pw=0;
593  int i;
594  def r=basering;
595  list l=qhmatrix(M);
596  int gt=ncols(M);
597  if(size(M)!=gt*(gt+1))
598  {
599    gt=gt-1;
600  }
601  matrix erzmat[gt+1][gt];
602  list erz;
603  if ((size(l[1])==1) && (l[1][1]==0) && (size(l[2])==1) && (l[2][1,1]==0))
604  {
605    return("ERROR");
606  }
607//---------------------------------------------------------------------------
608// Find the generators of T1 of non-negative weight
609//---------------------------------------------------------------------------
610  int relw;
611  list rlw;
612  for(i=1; i<=tau; i++)
613  {
614    erzmat=t1erz[i];
615    kill relw;
616    def relw=relweight(erzmat,l[2],l[1]);
617    if(typeof(relw)=="int")
618    {
619      if (((choose==0) && (relw>=0))
620           || ((choose==1) && (relw>=0) && (CMtype(minor(M+erzmat,gt))==gt))
621           || ((choose==2) && (relw > 0)))
622      {
623        pw++;
624        rlw[pw]=relw;
625        erz[pw]=erzmat;
626      }
627    }
628    else
629    {
630      return("ERROR");
631    }
632  }
633//---------------------------------------------------------------------------
634// Definition of the new ring and the image of M and erz in the new ring
635//---------------------------------------------------------------------------
636  if(size(rlw)==0)
637  {
638    return("ERROR");
639  }
640  intvec iv=rlw[1..size(rlw)];
641  ring rtemp=0,(T(1..pw)),dp;
642  def rneu=r+rtemp;
643  setring rneu;
644  matrix M=imap(r,M);
645  ideal m=M;
646// we cannot imap erz, if its size=0
647  if(pw==0)
648  {
649    list erz1;
650  }
651  else
652  {
653    list erz1=imap(r,erz);
654  }
655//---------------------------------------------------------------------------
656// Construction of the presentation matrix of the deformation
657//---------------------------------------------------------------------------
658  matrix N=matrix(m);
659  ideal mtemp;
660  matrix Mtemp[gt*(gt+1)][1];
661  for( i=1; i<=pw; i++)
662  {
663    mtemp=erz1[i];
664    Mtemp=mtemp;
665    N=N+T(i)*transpose(Mtemp);
666  }
667  ideal n=N;
668  matrix O[gt+1][gt]=n;
669//---------------------------------------------------------------------------
670// Keep the ring and return the matrix
671//---------------------------------------------------------------------------
672  export rneu;
673  keepring rneu;
674  list ret=O,iv;
675  return(ret);
676}
677example
678{ "EXAMPLE:"; echo=2;
679  ring r=32003,(x(1),x(2),x(3)),dp;
680  ideal curve=(x(3)-x(1)^2)*x(3),(x(3)-x(1)^2)*x(2),x(2)^2-x(1)^7*x(3);
681  matrix M=isCMcod2(curve);
682  list l=matrixT1(M,3);
683  list li=posweight(l[1],std(l[2]),0);
684  pmat(li[1]);
685  li[2];
686}
687/////////////////////////////////////////////////////////////////////////////
688
689proc kod_ker(matrix Mat, intvec a);
690USAGE:   kod_ker(Mat,a);
691         where Mat and a are the return values of posweight,
692         i.e. Mat is a k x (k+1) matrix perturbed by all generators of T1
693         of relative weight >= 0 and -a is the weight vector of the
694         corresponding parameters
695RETURN:  module K, a presentation of the kernel of the Kodaira-Spencer
696         mapping
697EXAMPLE: example kod_ker; shows examples
698{
699//---------------------------------------------------------------------------
700// Initialization and sanity checks
701//---------------------------------------------------------------------------
702  intvec optvec=option(get);
703  int i,j;
704  int gt=ncols(Mat);
705  int first=nvars(basering)-size(a);
706  int last=size(a);
707  intvec iv;
708  poly p=1;
709  def baser=basering;
710  if (nrows(Mat)!=gt+1)
711  {
712    if (nrows(Mat)!=gt-1)
713    {
714      return("ERROR");
715    }
716    else
717    {
718      gt=gt-1;
719
720    }
721  }
722  list l=matrixT1(Mat,first);
723  matrix t1=l[2];
724  matrix kod[gt*(gt+1)][last];
725  for(i=1;i<=last;i++)
726  {
727    kod[1..gt*(gt+1),i]=diff(l[1],var(first+i));
728  }
729
730  module ker=std(modulo(kod,t1));
731  option(redTail);
732  ker=std(ker);
733
734  for(j=1;j<=first;j++)
735  {
736    p=p*var(j);
737  }
738  for(i=1;i<=size(ker);i++)
739  {
740    matrix testlead=coef(lead(ker[i]),p);
741    if((size(testlead)==2) && (testlead[1,1]=1))
742    {
743      if((ker[i]/lead(ker[i]))*lead(ker[i])==ker[i])
744      {
745          ker[i]=lead(ker[i]);
746      }
747    }
748    kill testlead;
749  } 
750  ker=eliminate(interred(ker),p);
751  option(set,optvec);
752  return(ker);
753}
754example
755{"EXAMPLE";   // echo=2;
756  ring r=0,(x,y,z),(c,ds);
757  matrix M[3][2]=z-x^4,0,y,z,x^12,y;
758  list l=matrixT1(M,3);
759  list posw=posweight(l[1],std(l[2]),1);
760  posw;
761  kod_ker(posw[1],posw[2]);
762}
763/////////////////////////////////////////////////////////////////////////////
764
765proc kod_noelim(matrix M)
766USAGE:     kod_noelim(M);
767           where M is a quasihomogeneous n x (n+1) matrix defining an
768           isolated space curve singularity
769NOTE:      the initial basering should not contain variables with name
770           e(i) or T(i), since those variable names will be internally
771           used by the script
772RETURN:    coefficient matrix representing the kernel of the Kodaira-
773           Spencer map of the family of non-negative perturbations
774           having the given singularity as special fibre
775EXAMPLE:   example kod_noelim; shows an example
776{
777//---------------------------------------------------------------------------
778// Initialization and sanity checks
779//---------------------------------------------------------------------------
780  intvec optvec=option(get);
781  option(redTail);
782  if (nvars(basering) != 3 )
783  {
784    "It should be a curve in 3 space";
785    return("ERROR");
786  }
787  def rt=basering;
788  list wl=qhmatrix(M);
789  if ((size(wl)!=2) || ((wl[1]==0) && (wl[2]==0)))
790  {
791    "The matrix was not n x (n+1) or not quasihomogenous";
792    return("ERROR");
793  }
794  string ringre=" ring r=" + charstr(rt) + ",(x,y,z), ws(" + string(wl[1]) + ");";
795  execute ringre;
796  matrix M=imap(rt,M);
797  int ne=size(M);
798  intvec iv=1..ne; 
799  list l=matrixT1(M,3);
800  if (dim(std(l[2])) != 0)
801  {
802    "The matrix does not define an isolated space curve singularity";
803    return("ERROR");
804  }
805  module t1qh=l[2];
806//--------------------------------------------------------------------------
807// Passing to a new ring with extra variables e(i) corresponding to
808// the module generators gen(i) for weighted standard basis computation
809// accepting weights for the gen(i)
810//--------------------------------------------------------------------------
811  for(int i=1; i<=ne; i++)
812  {
813    if(rvar(e(i)))
814    {
815      int jj=-1;
816    }
817  }
818  if (defined(jj))
819  {
820    if (jj==-1)
821    {
822      "Your ring contains a variable e(" +string(i)+")!";
823      return("ERROR");
824    }
825  }
826  ringre="ring re=" + charstr(r) +",(e(1.." + string(ne) + "),"+ varstr(basering)
827                        + "),ws(" + string((-1)*intvec(wl[2])) + ","
828                        + string(wl[1]) + ");";
829  execute ringre;
830  module temp=imap(r,t1qh);
831  ideal t1qh=mod2id(temp,iv);
832  if (defined(Debug))
833  {
834    option(prot);
835  }
836  ideal t1qhs=std(t1qh);
837  if (defined(Debug))
838  {
839    option(noprot);
840  }
841  ideal t1qhsl=lead(t1qhs);
842  module mo=id2mod(t1qhsl,iv);
843//--------------------------------------------------------------------------
844// Return to the initial ring to compute the kbase and noether there
845// (in the new ring t1qh is of course not of dimension 0 but of dimension 3
846// so we have to go back)
847//--------------------------------------------------------------------------
848  setring r;
849  module mo=imap(re,mo);
850  attrib(mo,"isSB",1);                // mo is monomial ==> SB
851  attrib(mo,"isHomog",intvec(wl[2])); // highcorner has to respect the weights
852  vector noe=highcorner(mo);
853  if (defined(Debug))
854  {
855    wl;
856    mo;
857    noe;
858  }
859//--------------------------------------------------------------------------
860// Define the family of curves with the same quasihomogeneous initial
861// matrix M, compute T1 and pass again to the ring with the variables e(i)
862//--------------------------------------------------------------------------
863  list li=posweight(M,mo,0);
864  if (size(li)<=1)
865  {
866    return("ERROR")
867  }
868  if (defined(Debug))
869  {
870    li;
871  }
872  list li2=matrixT1(li[1],3);
873  module Mpert=transpose(matrix(ideal(li2[1])));
874  module t1pert=li2[2];
875  int nv=nvars(rneu)-nvars(r);
876  ring rtemp=0,(T(1..nv)),wp(li[2]);
877  def reneu=re+rtemp;
878  setring reneu;
879  module noe=matrix(imap(r,noe));
880  ideal noet=mod2id(noe,iv);
881  module temp=imap(rneu,t1pert);
882  ideal t1pert=mod2id(temp,iv);
883//--------------------------------------------------------------------------
884// Compute the standard basis and select those generators with leading term
885// divisible by some T(i)
886//--------------------------------------------------------------------------
887  noether=noet[size(noet)];
888  if (defined(Debug))
889  {
890    noether;
891    option(prot);
892  }
893  ideal t1perts=std(t1pert);
894  noether=noet[size(noet)];
895  t1perts=interred(t1perts);
896  if (defined(Debug))
897  {
898    option(noprot);
899  }
900  ideal templ=lead(t1perts);
901  for(int j=1;j<=nv;j++)
902  {
903    templ=subst(templ,T(j),0);
904  }
905  ideal mx;
906  ideal mt;
907  for(j=1;j<=size(t1perts);j++)
908  {
909    if(templ[j]!=0)
910    {
911      mx=mx,t1perts[j];
912    }
913    else
914    {
915      mt=mt,t1perts[j];
916    }
917  }
918//--------------------------------------------------------------------------
919// multiply by the initial ring variables to shift the generators with
920// leading term divisible by some T(i) and reduce afterwards
921//--------------------------------------------------------------------------
922  attrib(mx,"isSB",1); // This is obviously no SB, but we have to reduce by   
923                       // it and setting isSB suppresses error messages
924  noether=noet[size(noet)];
925  ideal ker_gen=reduce(mt,mx);
926  ideal ovar=var(ne+1),var(ne+2),var(ne+3);
927  ideal tvar=ovar;
928  j=1;
929  noether=noet[size(noet)];
930  if (defined(Debug))
931  {
932    mt;
933    noether;
934  }
935  int zeros;
936  templ=ker_gen;
937  while(zeros==0)
938  {
939    zeros=1;
940    templ=templ*ovar;
941    templ=reduce(templ,mx);
942//    for(i=1;i<=size(tvar);i++)
943//    {
944//      templ=tvar[i]*mt;
945//      templ=reduce(templ,mx);
946    if(defined(Debug))
947    {
948      if(Debug > 2)
949      {
950//          tvar[i];
951      templ;
952//          ~;
953      }
954    }
955      if (size(templ)!= 0)
956      {
957        zeros=0;
958        ker_gen=ker_gen,templ;
959      }
960//    }
961//    tvar=tvar*ovar;
962  }
963//-------------------------------------------------------------------------
964// kill zero entries, keep only one of identical entries and
965// return the result
966//-------------------------------------------------------------------------
967  ovar=var(1);
968  for(i=2;i<=ne;i++)
969  {
970    ovar=ovar,var(i);
971  }
972  ker_gen=ker_gen,ovar^2;
973  noether=noet[size(noet)];
974  ker_gen=simplify(ker_gen,10);
975//-------------------------------------------------------------------------
976// interreduce ker_gen as a k[T]-module
977//-------------------------------------------------------------------------
978  intvec mgen=1..(ne+3);
979  ideal Mpert=mod2id(imap(rneu,Mpert),iv);
980  templ=0;
981  for(i=1;i<=nv;i++)
982  {
983    templ[i]=diff(Mpert[size(Mpert)],T(i));
984  }
985  templ=templ,ovar^2;
986  ker_gen=subrInterred(templ,ker_gen,mgen);
987  module ret=id2mod(ker_gen,iv);
988  option(set,optvec);
989  export reneu;
990  keepring reneu;
991  return(ret);
992}
993example
994{ "EXAMPLE:"; echo=2;
995  ring r=0,(x,y,z),ds;
996  matrix M[3][2]=z,0,y,z-x^3,x^14,y;
997  kod_noelim(M);
998}
999///////////////////////////////////////////////////////////////////////////
1000static
1001proc mod2id(matrix M,intvec vpos)
1002USAGE:     mod2id(M,vpos);
1003           where M is a matrix and vpos is an integer vector such that
1004           gen(i) will correspond to var(vpos[i])
1005NOTE:      this procedure should be used in the following situation:
1006           one wants to pass to a ring with new variables which stand
1007           for the generators of the module and consider the module as
1008           an ideal
1009RETURN:    ideal i in which each gen(i) from the module is replaced by
1010           var(vpos[i]) and all monomials var(vpos[i])*var(vpos[j]) have
1011           been added to the generating set of i
1012EXAMPLE:   example mod2id; shows an example
1013{
1014//----------------------------------------------------------------------
1015// define the ideal generated by the var(vpos[i]) and set up the matrix
1016// for the multiplication
1017//----------------------------------------------------------------------
1018  ideal vars=var(vpos[1]);
1019  for(int i=2;i<=size(vpos);i++)
1020  {
1021    vars=vars,var(vpos[i]);
1022  }
1023  matrix varm[1][size(vpos)]=vars;
1024  if (size(vpos) > nrows(M))
1025  {
1026    matrix Mt[size(vpos)][ncols(M)];
1027    Mt[1..nrows(M),1..ncols(M)]=M;
1028    kill M;
1029    matrix M=Mt;
1030  }
1031//----------------------------------------------------------------------
1032// define the desired ideal
1033//----------------------------------------------------------------------
1034  ideal ret=vars^2,varm*M;
1035  return(ret);
1036}
1037example
1038{ "EXAMPLE:"; echo=2;
1039  ring r=0,(e(1),e(2),x,y,z),(dp(2),ds(3));
1040  module mo=x*gen(1)+y*gen(2);
1041  intvec iv=2,1;
1042  mod2id(mo,iv);
1043}
1044////////////////////////////////////////////////////////////////////////
1045static
1046proc id2mod(ideal i,intvec vpos)
1047USAGE:     id2mod(I,vpos);
1048           where I is an ideal and vpos is an integer vector such that
1049           gen(i) will correspond to var(vpos[i])
1050NOTE:      * use this procedure only makes sense if the ideal contains
1051             all var(vpos[i])*var(vpos[j]) as monomial generators and
1052             all other generators are linear combinations of the
1053             var(vpos[i]) over the ring in the other variables
1054           * this is the inverse procedure to mod2id
1055RETURN:    module corresponding to the ideal by replacing var(vpos[i]) by
1056           gen(i) and omitting all generators var(vpos[i])*var(vpos[j])
1057EXAMPLE:   example id2mod; shows an example;
1058{
1059//---------------------------------------------------------------------
1060// Initialization
1061//---------------------------------------------------------------------
1062  int n=size(i);
1063  int v=size(vpos);
1064  matrix tempmat;
1065  matrix mm[v][n];
1066//---------------------------------------------------------------------
1067// Conversion
1068//---------------------------------------------------------------------
1069  for(int j=1;j<=v;j++)
1070  {
1071    tempmat=coeffs(i,var(vpos[j]));
1072    mm[j,1..n]=tempmat[2,1..n];
1073  }
1074  for(j=1;j<=v;j++)
1075  {
1076    mm=subst(mm,var(vpos[j]),0);
1077  }
1078  module ret=simplify(mm,10);
1079  return(ret);
1080}
1081example
1082{ "EXAMPLE:"; echo=2;
1083  ring r=0,(e(1),e(2),x,y,z),(dp(2),ds(3));
1084  ideal i=e(2)^2,e(1)*e(2),e(1)^2,e(1)*y+e(2)*x;
1085  intvec iv=2,1;
1086  id2mod(i,iv);
1087}
1088///////////////////////////////////////////////////////////////////////
1089static
1090proc subrInterred(ideal mon, ideal sm, intvec iv)
1091USAGE:    subrInterred(mon,sm);
1092          sm ideal in a ring r with n + s variables,
1093          e.g. x_1,..,x_n and t_1,..,t_s
1094          mon ideal with monomial generators (not divisible by
1095          one of the t_i) such that sm is contained in the module
1096          k[t_1,..,t_s]*mon
1097          iv intvec listing the variables which are supposed to be used
1098          as x_i
1099RETURN:   interreduced system of generators of sm seen as a submodule
1100          of k[t_1,..,t_s]*mon
1101EXAMPLE:  example subrInterred; shows an example
1102{
1103//-----------------------------------------------------------------------
1104// check that mon is really generated by monomials
1105// and sort its generators with respect to the monomial ordering
1106//-----------------------------------------------------------------------
1107  int err;
1108  for(int i=1;i<=ncols(mon);i++)
1109  {
1110    if ( size(mon[i]) > 1 )
1111    {
1112      err=1;
1113    }
1114  }
1115  if (err==1)
1116  {
1117    "mon has to be generated by monomials";
1118    return("ERROR");
1119  }
1120  intvec sv=sortvec(mon);
1121  ideal mons;
1122  for(i=1;i<=size(sv);i++)
1123  {
1124    mons[i]=mon[sv[i]];
1125  }
1126  ideal itemp=maxideal(1);
1127  for(i=1;i<=size(iv);i++)
1128  {
1129    itemp=subst(itemp,var(iv[i]),0);
1130  }
1131  itemp=simplify(itemp,10);
1132  def r=basering;
1133  string tempstr="ring rtemp=" + charstr(basering) + ",(" + string(itemp)
1134                               + "),(C,dp);";
1135//-----------------------------------------------------------------------
1136// express m in terms of the generators of mon and check whether m
1137// can be considered as a submodule of k[t_1,..,t_n]*mon
1138//-----------------------------------------------------------------------
1139  module motemp;
1140  motemp[ncols(sm)]=0;
1141  poly ptemp;
1142  int j;
1143  for(i=1;i<=ncols(mons);i++)
1144  {
1145    for(j=1;j<=ncols(sm);j++)
1146    {
1147      ptemp=sm[j]/mons[i];
1148      motemp[j]=motemp[j]+ptemp*gen(i);
1149    }
1150  }
1151  for(i=1;i<=size(iv);i++)
1152  {
1153    motemp=subst(motemp,var(iv[i]),0);
1154  }
1155  matrix monmat[1][ncols(mons)]=mons;
1156  ideal dummy=monmat*motemp;
1157  for(i=1;i<=size(sm);i++)
1158  {
1159    if(sm[i]-dummy[i]!=0)
1160    {
1161      "the second argument is not a submodule of the assumed structure";
1162      return("ERROR");
1163    }
1164  }
1165//----------------------------------------------------------------------
1166// do the interreduction and convert back
1167//----------------------------------------------------------------------
1168  execute tempstr;
1169  def motemp=imap(r,motemp);
1170  motemp=interred(motemp);
1171  setring r;
1172  kill motemp;
1173  def motemp=imap(rtemp,motemp);
1174  ideal ret=monmat*motemp;
1175  for(i=1;i<=ncols(ret);i++)
1176  {
1177    ret[i]=cleardenom(ret[i]);
1178  }
1179  return(ret);
1180}
1181example
1182{ "EXAMPLE:"; echo=2;
1183  ring r=0,(x,y,z),dp;
1184  ideal i=x^2+x*y^2,x*y+x^2*y,z;
1185  ideal j=x^2+x*y^2,x*y,z;
1186  ideal mon=x^2,z,x*y;
1187  intvec iv=1,3;
1188  subrInterred(mon,i,iv);
1189  subrInterred(mon,j,iv);
1190}
1191////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.