source: git/Singular/LIB/spcurve.lib @ f34c37c

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