source: git/Singular/LIB/lejeune.lib @ 341696

spielwiese
Last change on this file since 341696 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 17.0 KB
Line 
1
2//-*- mode:C++;-*-
3// $Id$
4
5
6info="
7LIBRARY: lejeune.lib     Arc space computations
8AUTHOR:  Nadine Cremer,  nadine.cremer@gmx.de
9PROCEDURES:
10    fgset(f,H);          returns simultaneously the sets F and G corresponding
11                         to H as described by M. Lejeune
12    trunc(f,i);          returns the set Tr(i) as described by M. Lejeune
13    ";
14
15
16LIB "ring.lib";
17LIB "general.lib";
18LIB "primdec.lib";
19LIB "standard.lib";
20LIB "sing.lib";
21
22
23
24//////////////////////////////////////////////////////////////////////
25proc trunc (poly f, int i)
26"USAGE:   trunc(f,i); (f polynomial, i integer)
27 CREATE:  list, contains lists, each one consisting of two ideals:
28          the first one giving equations, the second one giving
29          inequations for a part of Tr(i). All of them together give a
30          complete description of Tr(i)
31 RETURN:  ring, corresponds to f and i, i.e. plugging in a polynomial
32          in t of degree i for each variable of f yields a ring whose
33          variables are the original variables of f, t and the
34          according t-coefficients
35 EXAMPLE: example trunc; shows an example"
36{
37 def r=basering;
38
39 // we make sure that we obtain Tr(i), which requires
40 // computations up to m*i, where m is minimal s.th.
41 // x(j)^m in J(f) for each variable x(j) involved in f
42 int m=minpower(f);
43 int mi=m*i;
44 int k;
45 int l=order(f);
46 int s0=mi+1;
47 int s=l*(mi+1);
48 int z1=nvars(r)*(i+1)+2;
49 int z2=nvars(r)*k+1;
50 intvec H=l;
51
52 // initialization of an intvec H of size m*i
53 for(k=1;k<=mi;k++)
54 {
55   H[k+1]=1;
56 }
57 // this is the ring in which result lies
58 def R1=ringchange(i);
59 setring R1;
60 ideal I,J;
61 list intersec=I,J;
62
63 // will save the results:
64 list fresult,gresult;
65 list result;
66
67 // consider all possible H's
68 while(sum(H)<=s)
69 {
70   setring r;
71   def tmp=fgset(f,H);
72   setring R1;
73   intersec=imap(tmp,fgresult);
74   kill tmp;
75
76   // simplifications
77   intersec[1]=simplifymodd(interred(intersec[1]));
78   intersec[2]=simplifymodd(interred(intersec[2]));
79   //option(redSB);
80   //intersec[1]=std(intersec[1]);
81   //intersec[2]=std(intersec[2]);
82   intersec[1]=simplifymodd(intersec[1]);
83   intersec[2]=simplifymodd(intersec[2]);
84   intersec[1]=simplifymodd(intersec[1]);
85   intersec[2]=simplifymodd(intersec[2]);
86
87   // remove lists which contain
88   // the same ideal twice and
89   // therefore define the empty
90   // set
91   if(equalitytest(intersec[1],intersec[2])==1)
92     {
93       H=Hnew(H);
94       continue;
95   }
96   intersec[1]=radical(intersec[1]);
97   intersec[2]=radical(intersec[2]);
98
99   // remove lists which contain
100   // the same ideal twice and
101   // therefore define the empty
102   // set
103   if(equalitytest(intersec[1],intersec[2])==1)
104     {
105       H=Hnew(H);
106       continue;
107     }
108   result=insert(result,intersec);
109   H=Hnew(H);
110 }
111 // output:
112 int u=size(result);
113 newline;
114 " We obtain the following sets of equations
115 and inequations for Tr(" +string(i)+"). In order to be
116 contained in Tr(" +string(i)+"), a point has to fulfill
117 the conditions of one of those set, i.e. it has to be
118 in the zero-set of the first ideal without
119 the zero-set of the second ideal.";
120 newline;
121 string ending;
122
123 for(k=1;k<=u;k++)
124 {
125   if((k mod 10==1) && (k mod 100!=11))
126   {ending="st";}
127   else
128   {
129     if((k mod 10==2) && (k mod 100!=12))
130     {ending="nd";}
131     else
132     {
133       if((k mod 10==3) && (k mod 100!=13))
134       {ending="rd";}
135       else
136       {ending="th";}
137     }
138   }
139   print(string(k)+ending+" set of equations:"+newline);
140   print(result[k]);
141   newline;
142 }
143 // return the ring
144 return(R1);
145}
146
147example
148{
149  "EXAMPLE:"; echo=2;
150  def r=basering;
151  poly f=y2-x3;
152  def R=trunc(f,3);
153  setring R;
154  print(result);
155  setring r;
156  def R1=trunc(f,6);
157  setring R1;
158  print(result);
159}
160
161
162
163
164
165//////////////////////////////////////////////////////////////////////
166//                                                                  //
167//             COMPUTATION OF F AND G SIMULTANEOUSLY                //
168//                                                                  //
169//////////////////////////////////////////////////////////////////////
170
171//////////////////////////////////////////////////////////////////////
172proc fgset (poly f,intvec H)
173"USAGE:   fgset(f,H);  f polynomial, H integer vector
174 CREATE:  list, consists two ideals, the first one giving equations,
175          the second one giving inequations to be satisfied by the set
176          corresponding to H
177 RETURN:  ring, corresponds to f and size(H)-1, i.e. plugging in a
178          polynomial in t of degree size(H)-1 for each variable of f
179          yields a ring whose variables are the original variables of f,
180          t and the according t-coefficients
181 EXAMPLE: example fgset; shows an example"
182{
183  def r=basering;
184  int p;
185  int m0=order(f);
186  int b=size(H);
187  if(H[1]!=m0)                       // input admissible?!
188    {
189      ERROR("H[1]=ord(f) necessary");
190    }
191  for(p=1;p<b;p++)
192    {
193      if(H[p]<H[p+1])
194      {
195        ERROR("Inadmissible input, H[1]<=...<=H[b] necessary");
196      }
197    }
198
199  def R=ringchange(b-1);
200  setring R;
201  list l;
202  ideal fresult,gresult;
203  list fgresult;
204  for(p=2;p<=b;p++)
205  {
206    setring r;
207    def tmp=formaldiff(f,intvec(H[1..p]));
208    setring R;
209    l=imap(tmp,resultdiff);
210    kill tmp;
211    fresult=fresult,l[1];
212  }
213  gresult=fresult;                     // use computation of f for g
214
215  setring r;                           // last step, special for G
216  def tmp=formaldiff(f,H);;
217  setring R;
218  l=imap(tmp,resultdiff);
219  kill tmp;
220  gresult=gresult,l[2];
221  fresult=simplify(fresult,6);
222  gresult=simplify(gresult,6);
223  fgresult=fresult,gresult;
224  export(fgresult);
225  //fgresult;
226  return(R);
227}
228example
229{
230  "EXAMPLE:"; echo=2;
231  def r= basering;
232  poly f=y2-x3;
233  intvec H1=2,2,2;
234  intvec H2=2,2,2,1;
235  def R1=fgset(f,H1);
236  def R2=fgset(f,H2);
237  setring R1;
238  print(fgresult);
239  setring R2;
240  print(fgresult);
241}
242
243
244
245//////////////////////////////////////////////////////////////////////
246//                                                                  //
247//      PREPARATORY WORK: PLUGGING IN AND DIFFERENTIATING           //
248//                                                                  //
249//////////////////////////////////////////////////////////////////////
250
251
252//////////////////////////////////////////////////////////////////////
253static proc plugincoeffs (poly f,int i)
254"USAGE:   plugincoeffs(f,i); f polynomial, i integer
255 CREATE:  matrix, the t-coefficients obtained by plugging in a
256          polynomial in t of degree i in each variable of f
257 RETURN:  ring, corresponds to f and i, i.e. plugging in a polynomial
258          in t of degree i for each variable of f yields a ring whose
259          variables are the original variables of f, t and the
260          according t-coefficients"
261
262{
263  int startvar=nvars(basering);
264  def r=basering;
265  def R=ringchange(i);              // changes the ring
266  setring R;                        // makes it new basering;
267  ideal I=tpolys(i,startvar);
268  poly g=imap(r,f);                 // maps f to new basering
269  export(g);                        // export it
270  map h=r,I;                        // define map according to our purpose
271  ideal J=h(f);                     // gives f with power series plugged in
272  export(h);
273  matrix resultplug=coeffs(J[1],t); // gives the t-coefficients
274  export resultplug;                // export it i.o. to use it later on
275  return(R);                        // return ring (ring change!)
276}
277
278
279
280//////////////////////////////////////////////////////////////////////
281static proc tpolys (int i,int k)
282"USAGE:   tpolys(i,i); i,k integer
283 RETURN:  ideal, generated by k general polynomials in t of degree i
284          without constant term
285 NOTE:    called from plugincoeffs"
286
287{                                     // has to be called from pluin_coeffs
288  int s,t;                            // loop variables
289  int v;
290  poly sum;
291  ideal I;
292  for(t=1;t<=k;t++)
293   {
294     v=(t-1)*i;
295     for(s=1;s<=i;s++)
296      {
297        sum=sum+var(1+k+v+s)*var(k+1)^s;    // clumsy: working with "var(1)",
298      }                                     // depends on form of basering
299     I[t]=sum;
300     sum=0;
301   }
302  return(I);
303}
304
305
306
307//////////////////////////////////////////////////////////////////////
308static proc formaldiff (poly f,intvec H)
309"USAGE:   formaldiff(f,H); f polynomial, H integer vector
310 CREATE:  list, containing two ideals. Polynomials in t of
311          degree size(H)-1 are plugged into f. H defines, if and how
312          often we differentiate each t-coefficient. We distinguish
313          two different cases, the only difference being that we
314          diffentiate more often in the second case (this is still
315          defined by H). This leads to two systems of equations,
316          each one defining a Zariski-closed set and the second one
317          being contained in the first one
318 RETURN:  ring, corresponds to f and size(H)-1, i.e. plugging in a
319          polynomial in t of degree size(H)-1 for each variable of f
320          yields a ring whose variables are the original variables of f,
321          t and the according t-coefficients"
322{
323  int startvar=nvars(basering);
324  int s,t,v;                          // loop variables
325  int u;
326  int i=size(H)-1;
327  int c=sum(H,1..i);
328  int k=H[i+1];
329  def R=plugincoeffs(f,i);           // plugs the power series in...
330  setring R;                          // changes the ring
331  matrix coe=resultplug;            // gives the t-coeff. after plugging in
332  poly fkv;                           // need this stuff for the following
333  ideal step=diffidealstep(i,startvar);
334  list resultdiff;
335  ideal m,power,diffstep,J,gresultdiff,fresultdiff;
336  for(v=1;v<=k;v++)                   // consider the different t-coeff.
337    {
338     if(c+v>nrows(coe))
339     {
340       fkv=0;
341     }
342     else
343     {
344       fkv=coe[c+v,1];
345     }
346     m=fkv;
347     J=fkv;
348     for(s=1;s<=k-v+1;s++)           // "s<=k-v+1" special for G, ONLY DIFF.!
349       {
350         if(s==k-v+1)                // equations for F!
351         {
352           fresultdiff=fresultdiff,J;
353         }
354         power=step^s;
355         u=size(power);
356         for(t=1;t<=u;t++)
357          {
358            diffstep=contract(power[t],m);     // actual differentiation
359            J=J,diffstep;
360          }
361
362       }
363     gresultdiff=gresultdiff,J;
364   }
365  resultdiff=fresultdiff,gresultdiff;
366  export(resultdiff);                 // exports the result
367  return(R);                           // return the ring
368}
369
370
371
372
373//////////////////////////////////////////////////////////////////////
374//                                                                  //
375//                   CONSTRUCTING THE NEW RING                      //
376//                                                                  //
377//////////////////////////////////////////////////////////////////////
378
379//////////////////////////////////////////////////////////////////////
380static proc ringchange (int i)
381"USAGE:   ringchange(i); i integer
382 RETURN:  ring, extends basering by variables t and
383          #(variables of basering)*i new variables"
384
385{
386  def R=changevar(""+varstr(basering)+",t,"+variables(nvars(basering),i)+"");
387  return(R);
388}
389
390
391//////////////////////////////////////////////////////////////////////
392static proc variables (int k,int i)
393"USAGE:   variables(k,i); k,i integer
394 RETURN:  string of the names of the additional variables
395 NOTE:    called from ringchange, we use this procedure to obtain
396          a convenient shape of the ring created in ringchange"
397{
398  list l;
399  int s,u;                              // loop variables
400  string str;
401  for (u=1;u<=k;u++)
402   {
403     for (s=1;s<=i;s++)
404     {
405       str=""+atoz(u)+"("+string(s)+")"; // creates new variables
406       l[(u-1)*i+s]=str;                // saves them in a list
407     }
408   }
409  string str1=string(l);                // makes the list into a string,
410  return(str1);                         // (needed for ring change)
411}
412
413
414//////////////////////////////////////////////////////////////////////
415static proc atoz (int n)
416"USAGE:   atoz(n); n integer
417 RETURN:  string, the nth letter of the alphabet"
418
419{
420  if(1>n>26)
421   {
422     ERROR("n must range between 1 and 26!");
423   }
424  string s="ring r=0,("+A_Z("a",n)+"),ds;";
425  execute(s);
426  return (string(var(n)));
427}
428
429
430
431//////////////////////////////////////////////////////////////////////
432//                                                                  //
433//                  AUXILIARY PROCEDURES                            //
434//                                                                  //
435//////////////////////////////////////////////////////////////////////
436
437//////////////////////////////////////////////////////////////////////
438static proc diffidealstep (int i, int N)
439"USAGE:   diffidealstep(i,N); i,N integer
440 RETURN:  ideal, generated by variables specified by i,N
441 NOTE:    called from formaldiff, gives the variables by which is
442          differentiated in a certain step"
443{
444  ideal I=var(N+1+i);
445  int j;
446  for(j=2;j<=N;j++)
447   {
448     I=I,var(N+1+j*i);
449   }
450return(I);
451}
452
453
454//////////////////////////////////////////////////////////////////////
455static proc order (poly f)
456"USAGE:   order(f); f polynomial
457 RETURN:  int, the multiplicity of V(f) in 0
458 NOTE:    this order partly directs the differentiation in formaldiff
459          and, together with minpower, gives the size of the
460          integer vector in fgset"
461{
462  poly g=homog(f,var(1));
463  int k=deg(g);
464  int i;
465  for(i=1;i<=k;i++)
466    {
467      if(jet(f,i)!=0)
468        {
469          return(i);
470        }
471    }
472}
473
474
475//////////////////////////////////////////////////////////////////////
476static proc simplifyvar (ideal I)
477"USAGE:   simplifyvar(I); I ideal
478 RETURN:  ideal defining the same zeroset as I: if any generator
479          of I is a power of one single variable, replace it by the
480          variable
481 NOTE:    this procedure is supposed to simplify and clarify the
482          output of the calculations made in fgset, trunc a.o.
483          without using radical"
484{
485  int i,j;
486  int divisornumber=0;
487  int pos;
488  I=simplify(I,6);
489  for(j=1;j<=ncols(I);j++)
490  {
491    if(size(I[j])==1)
492    {
493       for(i=1;i<=nvars(basering);i++)
494       {
495          if(modd(I[j],var(i))==0)
496          {
497             divisornumber++;
498             pos=i;
499          }
500       }
501    }
502    if(divisornumber==1)
503      {
504        I[j]=var(pos);
505      }
506    divisornumber=0;
507  }
508  return(I);
509}
510
511
512//////////////////////////////////////////////////////////////////////
513static proc modd (poly f, poly g)
514"USAGE:   modd(f,g); f,g polynomials
515 RETURN:  poly, f mod g modulo operation in the polynomial ring
516 NOTE:    called from idealsimplify1 where it is used to simplify
517          a generating set of an ideal"
518
519{
520  poly result=f-(f/g)*g;
521  return(result);
522}
523
524
525//////////////////////////////////////////////////////////////////////
526static proc Hnew (intvec H)
527"USAGE:   Hnew(H); H integer vector
528 RETURN:  intvec, the vector needed in the following step of trunc"
529
530{
531  intvec H1=H;
532  int k;
533  int l=size(H);
534  for(k=0;k<=l-2;k++)
535  {
536    if(H[l-k]<H[l-k-1])
537    {
538      H[l-k]=H[l-k]+1;
539      break;
540    }
541  }
542  if(H==H1)
543  {
544    H[l]=H[l]+1;
545  }
546  return(intvec(H));
547}
548
549
550//////////////////////////////////////////////////////////////////////
551static proc simplifymodd (ideal I)
552"USAGE:   simplifymodd(I); I ideal
553 RETURN:  ideal defining the same zeroset as I: replace certain
554          generators of I by the generator modulo the other generators.
555 NOTE:    this procedure is supposed to simplify and clarify the
556          output of the calculations made in fgset, trunc a.o.
557          without using radical"
558{
559  int i,j;
560  I=simplify(I,6);
561  for(j=2;j<=ncols(I);j++)          // reduce with higher element
562  {
563    for(i=1;i<j;i++)
564    {
565      if(I[i]!=0)
566      {
567        I[j]=modd(I[j],I[i]);
568      }
569    }
570  }
571  for(j=ncols(I)-1;j>=1;j--)        // reduce with lower elements
572  {
573    for(i=ncols(I);i>j;i--)
574    {
575      if(I[i]!=0)
576      {
577        I[j]=modd(I[j],I[i]);
578      }
579    }
580  }
581  I=simplify(simplifyvar(I),6);
582  return(I);
583}
584
585
586//////////////////////////////////////////////////////////////////////
587static proc minpower (poly f)
588"USAGE:   minpower(f); f polynomial
589 RETURN:  int, the minimal z>=1 s.th. v^z in J(f) for each variable v
590          of the basering
591 NOTE:    called from trunc, gives; together with i, the size of the
592          integer vectors to be considered in trunc(f,i)"
593{
594 ideal J=jacob(f);
595 int s=ncols(J);
596 int control=0;                // control if conditions for ny are fulfilled
597 int control1=0;
598 int n=nvars(basering);
599 int ny=1;
600 int i,j;
601 while (control==0)           // while var(i)^ny not in J(f)...
602 {
603   for(i=1;i<=n;i++)          // consider all variables
604   {
605    control1=0;
606    for(j=1;j<=s;j++)         // consider all elements of J
607    {
608      if (modd(var(i)^ny,J[j])==0)  // var(i)^ny in J(f)?
609      {
610        control1=1;
611        break;
612      }
613    }
614    if (control1==0)          // increment ny if no var(i)^nt in J(f)
615    {
616      ny++;
617      break;
618    }
619   }
620   if (control1==1)           // if each step was successful...
621  {
622    control=1;
623  }
624 }
625 return(ny);
626}
627
628
629
630static proc equalitytest (ideal I,ideal J)
631"USAGE:   equalitytest(I,J); I,J ideals
632 RETURN:  1, if I=J, 0 else
633 NOTE:    we assume I contained in J already"
634{
635  int s=ncols(J);
636  int i;
637  int p=0;
638  I=std(I);
639  for(i=1;i<=s;i++)
640  {
641    if(reduce(J[i],I)!=0)
642    {
643      p=1;
644    }
645  }
646  if(p==1)
647  {
648    return(0);
649  }
650  else{return(1);}
651}
652
Note: See TracBrowser for help on using the repository browser.