source: git/Singular/LIB/teachstd.lib @ c7c5ef

spielwiese
Last change on this file since c7c5ef was c7c5ef, checked in by Hans Schönemann <hannes@…>, 18 years ago
*hannes: doc fixes git-svn-id: file:///usr/local/Singular/svn/trunk@9155 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 23.0 KB
Line 
1// $Id:
2//GMG, last modified 28.9.01
3///////////////////////////////////////////////////////////////////////////////
4version="$Id: teachstd.lib,v 1.3 2006-05-19 11:50:35 Singular Exp $";
5category="Teaching";
6info="
7LIBRARY:  teachstd.lib   Procedures for teaching standard bases
8AUTHOR:                  G.-M. Greuel, greuel@mathematik.uni-kl.de
9
10PROCEDURES:
11 ecart(f);              ecart of f
12 tail(f);               tail of f
13 sameComponent(f,g);    test for same module component of lead(f) and lead(g)
14 leadmonomial(f);       leading monomial as poly (also for vectors)
15 monomialLcm(m,n);      lcm of monomials m and n as poly (also for vectors)
16 spoly(f[,1]);          s-polynomial of f [symmetric form]
17 minEcart(T,h);         element g from T of minimal ecart s.t. LM(g)|LM(h)
18 NFMora(i);             normal form of i w.r.t Mora algorithm
19 prodcrit(f,g);         test for product criterion
20 chaincrit(f,g,h);      test for chain criterion
21 pairset(G);            pairs form G neither satifying prodcrit nor chaincrit
22 updatePairs(P,S,h);    pairset P enlarded by not useless pairs (h,f), f in S
23 standard(id);          standard basis of ideal/module
24 localstd(id);          local standard basis of id using Lazard's method
25              [parameters in square brackets are optional]
26
27 NOTE: The library is intended to be used for teaching purposes but not
28       for serious computations. Sufficiently high printlevel allows to
29       control each step, thus illustrating the algorithms at work.
30       The procedures are implemented exatly as described in the book
31       'A SINGULAR Introduction to Commutative Algebra' by G.-M. Greuel and
32       G. Pfister (Springer 2002).
33";
34
35LIB "poly.lib";
36
37///////////////////////////////////////////////////////////////////////////////
38proc ecart(f)
39"USAGE:   ecart(f); f poly or vector
40RETURN:  the ecart e of f of type int
41EXAMPLE: example ecart; shows an example
42"
43{
44  int e = maxdeg1(f)-maxdeg1(lead(f));
45  return(e);
46}   
47example
48{ "EXAMPLE:"; echo = 2;
49   ring r=0,(x,y,z),ls;
50   ecart((y+z+x+xyz)**2);
51   ring s=0,(x,y,z),dp;
52   ecart((y+z+x+xyz)**2); 
53
54///////////////////////////////////////////////////////////////////////////////
55proc leadmonomial(f)
56"USAGE:   leadmonomial(f); f poly or vector
57RETURN:  the leading monomial of f of type poly
58NOTE:    if f is of type poly, leadmonomial(f)=leadmonom(f), if f is of type
59         vector and if leadmonom(f)=m*gen(i) then leadmonomial(f)=m
60EXAMPLE: example leadmonomial; shows an example
61"
62{
63  int e;
64  poly m;
65  if(typeof(f) == "vector")
66  {
67    e=leadexp(f)[nvars(basering)+1];
68    m=leadmonom(f)[e,1];
69  }
70  if(typeof(f) == "poly")
71  {
72    m=leadmonom(f);
73  } 
74  return(m);
75}   
76example
77{ "EXAMPLE:"; echo = 2;
78   ring s=0,(x,y,z),(c,dp);
79   leadmonomial((y+z+x+xyz)**2);
80   leadmonomial([(y+z+x+xyz)**2,xyz5]);
81}
82///////////////////////////////////////////////////////////////////////////////
83proc tail(f)
84"USAGE:   tail(f); f poly or vector
85RETURN:  f-lead(f), the tail of f of type poly
86EXAMPLE: example tail; shows an example
87"
88{
89  def t = f-lead(f);
90  return(t);
91}   
92example
93{ "EXAMPLE:"; echo = 2;
94   ring r=0,(x,y,z),ls;
95   tail((y+z+x+xyz)**2);
96   ring s=0,(x,y,z),dp;
97   tail((y+z+x+xyz)**2); 
98
99///////////////////////////////////////////////////////////////////////////////
100proc sameComponent(f,g)
101"USAGE:   sameComponent(f,g); f,g poly or vector
102RETURN:  1 if f and g are of type poly or if f and g are of type vector and
103         their leading monomials involve the same module component,
104         0 if not
105EXAMPLE: example sameComponent; shows an example
106"
107{
108  if(typeof(f) != typeof(g))
109  {
110    ERROR("** arguments must be of same type");
111  }
112  if(typeof(f) == "vector")
113  {   
114     if( leadexp(f)[nvars(basering)+1] !=  leadexp(g)[nvars(basering)+1] )
115     {
116       return(0);
117     }
118  }
119  return(1);
120}   
121example
122{ "EXAMPLE:"; echo = 2;
123   ring r=0,(x,y,z),dp;
124   sameComponent([y+z+x,xyz],[z2,xyz]);
125   sameComponent([y+z+x,xyz],[z4,xyz]);
126   sameComponent(y+z+x+xyz, xy+z5); 
127
128///////////////////////////////////////////////////////////////////////////////
129proc monomialLcm(m,n)
130"USAGE:   monomialLcm(m,n); m,n of type poly or vector
131RETURN:  least common multiple of leading monomials of m and n, of type poly
132NOTE:    if m = (x1...xr)^(a1,...,ar)*gen(i) (gen(i)=1 if m is of type poly)
133         and n = (x1...xr)^(b1,...,br)*gen(j), then the proc returns
134         (x1,...,xr)^(max(a1,b1),...,max(ar,br)) if i=j and 0 if i!=j.
135EXAMPLE: example monomialLcm; shows an example
136"
137{
138  if(typeof(n) != typeof(m))
139  {
140    ERROR("** arguments must be of same type");
141  }
142
143  poly u ;
144  if(sameComponent(m,n) == 0)   //leading term of vectors involve
145  {                             //different module components
146     return(u);
147  }
148   
149  intvec v = leadexp(m);        //now start to compute lcm
150  intvec w = leadexp(n);
151  u=1;
152  int i;
153  for (i=1; i<=nvars(basering); i++)
154  {
155      if(v[i]>=w[i])
156      {
157         u = u*var(i)**v[i];
158      }
159      else
160      {
161         u = u*var(i)**w[i];
162      }
163   }
164   return(u);       
165}   
166example
167{ "EXAMPLE:"; echo = 2;
168   ring r=0,(x,y,z),ds;
169   monomialLcm(xy2,yz3);
170   monomialLcm([xy2,xz],[yz3]);
171   monomialLcm([xy2,xz3],[yz3]);
172
173///////////////////////////////////////////////////////////////////////////////
174proc spoly(f,g,list #)
175"USAGE:   spoly(f,g[,s]); f,g poly or vector, s int
176RETURN:  the s-polynomial of f and g, of type poly or vector
177         if s!=0 the symmetric s-polynomial (without division) is returned
178EXAMPLE: example spoly; shows an example
179"
180{
181  if(typeof(f) != typeof(g))
182  {
183    ERROR("** arguments must be of same type");
184  } 
185  if(size(#) == 0)
186  {
187     #[1]=0;
188  }
189
190  int e;
191  poly o = monomialLcm(f,g); 
192  if( o == 0)                    //can only happen, if vectors f and g involve
193  {                              //different module components
194    vector sp;
195    return(sp);
196  }
197 
198  poly m=leadmonomial(f);         //compute the leading monomial as poly
199  poly n=leadmonomial(g);
200
201  if (#[1]==0)                    //the asymmetric s-poly
202  {
203    def sp = (o/m)*f - (leadcoef(f)/leadcoef(g))*(o/n)*g;
204  }
205  else                            //the symmetric s-poly, avoiding division
206  {
207    def sp = leadcoef(g)*(o/m)*f - leadcoef(f)*(o/n)*g;
208  }   
209  return(sp);
210}   
211example
212{ "EXAMPLE:"; echo = 2;
213   ring r=0,(x,y,z),ls;
214   spoly(2x2+x2y,3y3+xyz);
215   ring s=0,(x,y,z),(c,dp);
216   spoly(2x2+x2y,3y3+xyz);
217   spoly(2x2+x2y,3y3+xyz,1);             //symmetric s-poly without division
218   spoly([5x2+x2y,z5],[x2,y3,y4]);       //s-poly for vectors
219
220///////////////////////////////////////////////////////////////////////////////
221proc minEcart(T,h)
222"USAGE:   minEcart(T,h); T ideal or module, h poly or vector
223RETURN:  element g from T such that leadmonom(g) divides leadmonom(h)
224         ecart(g) is minimal with this property (if T != 0);
225         return 0 if T is 0 or h = 0
226EXAMPLE: example minEcart; shows an example
227"
228{
229  int i,k,e;
230  if (size(T)==0 or h==0 )       //trivial cases
231  {
232     h = 0;
233     return(h);
234  }
235//---- check whether some element in T has the same module component as h ----
236  int v;
237  intvec w;
238  T = simplify(T,2);
239 
240  if (typeof(h) == "vector")   
241  {
242     e=1;
243     v = leadexp(h)[nvars(basering)+1];
244     for( i=1; i<=size(T); i++)
245     {
246       w[i]=leadexp(T[i])[nvars(basering)+1];
247       if(v == w[i])
248       {
249         e=0;         //some element in T involves the same component as h
250       }
251     }
252  }
253  if ( e == 1 )       //no element in T involves the same component as h
254  {
255     h = 0;
256     return(h);
257  }
258
259  if (typeof(h) == "poly")   //for polys v=w[i] for all i
260  {
261    v = 1;
262    w[size(T)]=0;
263    w=w+1;
264  }
265 
266//------ check whether for some g in T leadmonom(g) divides leadmonom(h) -----
267  def g = T[1];
268  poly f = leadmonomial(h);
269
270  for( i=1; i<=size(T); i++)
271  {
272    if( f/leadmonomial(T[i]) != 0 and v==w[i] )
273    {
274       g=T[i];
275       k=i;
276       break;
277    }
278  }
279  if (k == 0)        //no leadmonom(g) divides leadmonom(h)   
280  {
281     g = 0;
282     return(g);
283  }
284//--look for T[i] with minimal ecart s.t.leadmonom(T[i]) divides leadmonom(h)--
285
286  for( i=k+1; i<=size(T); i++)
287  {
288    if( f/leadmonomial(T[i]) != 0 and v==w[i] )
289    {
290       if (ecart(T[i]) < ecart(g))
291       {
292         g=T[i];
293        }
294     }
295  }
296  return(g);
297}   
298example
299{ "EXAMPLE:"; echo = 2;
300   ring R=0,(x,y,z),dp;
301   ideal T = x2y+x2,y3+xyz,xyz2+z4;
302   poly h = x2y2z2+x5+yx3+z6;
303   minEcart(T,h);"";
304   ring S=0,(x,y,z),(c,ds);
305   module T = [x2+x2y,y2],[y3+xyz,x3-z3],[x3y+z4,0,x2];
306   vector h = [x3y+x5+x2y2z2+z6,x3];
307   minEcart(T,h);
308
309///////////////////////////////////////////////////////////////////////////////
310proc NFMora(f,G,list #)
311"USAGE:   NFMora(f,G[,s]); f poly or vector,G ideal or module, s int
312RETURN:  the Mora normal form of f w.r.t. G, same type as f
313         if s!=0 the symmetric s-polynomial (without division) is used
314NOTE:    Show comments if printlevel > 0, pauses computation if printlevel > 1
315EXAMPLE: example NFMora; shows an example
316"
317{
318  if(size(#) == 0)
319  {
320     #[1]=0;
321  }
322
323  int y = printlevel - voice + 2;
324  if( f==0 or size(G) ==0 )
325  {
326     if (y>0)
327     {
328        "// 1st or 2nd argument 0";
329     }
330     return(f);
331  }
332
333  int i,e;
334  def h = f;
335  def T = G;
336// -------------------- start with f to be reduced by G --------------------
337  if (y>0)
338  {"";
339   "// Input for NFMora is (f,T):";
340   "// f:"; f;
341   "// T:"; T;
342   "// Reduce f with T, eventually enlarging T for local ordering";
343  }
344
345// ----------------------- enter the reduction loop ------------------------
346  def g = minEcart(T,h);
347  while (h!=0 and g!=0)
348  {
349     if (y>0)
350     {  "";
351        "//                Reduction-step in NFMora:",i;
352        "// h = (f after",i,"reductions) reduction with g from T:";
353        "// g = element of minimal ecart in T s.t. LM(g)|LM(h):";
354        "// h:";h;
355        "// g:";g;     
356     }
357     if (y>1)
358     {
359        pause("press <return> to continue");
360        "// T, set used for reduction:"; T;
361        pause("press <return> to continue");
362     }
363     e=0;
364     if( ecart(g) > ecart(h) )
365     {
366        T=T,h;  e=1;
367     }
368     if (y>0 )
369     {
370        "// T-set enlarged for next reduction? (yes/no = 1/0):  ", e;
371        if( e==1 )
372        {
373          "// T-set for next reduction got enlarged by h:";
374          "// h:";h;
375          if (y>1)
376          {
377             pause("press <return> to continue");
378          }
379        }
380     }
381     h = spoly(h,g,#[1]);
382     g = minEcart(T,h);
383     i=i+1;
384  }
385  if(y>0)
386  { "";
387    "// normal form is:";
388  }
389  return(h);
390}   
391example
392{ "EXAMPLE:"; echo = 2;
393   ring r=0,(x,y,z),dp;
394   poly f = x2y2z2+x5+yx3+z6-3y3;
395   ideal G = x2y+x2,y3+xyz,xyz2+z6;
396   NFMora(f,G);"";
397   ring s=0,(x,y,z),ds;
398   poly f = x3y+x5+x2y2z2+z6;
399   ideal G = x2+x2y,y3+xyz,x3y2+z4;
400   NFMora(f,G);"";
401   vector v = [f,x2+x2y];
402   module M = [x2+x2y,f],[y3+xyz,y3],[x3y2+z4,z2];
403   NFMora(v,M);
404
405///////////////////////////////////////////////////////////////////////////////
406proc prodcrit(f,g)
407"USAGE:   prodcrit(f,g); f,g poly or vector
408RETURN:  1 if product criterion applies in the same module component,
409         2 if lead(f) and lead(g) involve different components, 0 else
410NOTE:    if product criterion applies we can delete (f,g) from pairset
411EXAMPLE: example prodcrit; shows an example
412"
413{
414  if(typeof(f)=="poly")    //product criterion for polynomials
415  {
416    if( monomialLcm(f,g)==leadmonom(f)*leadmonom(g))
417    {
418      return(1);
419    }
420    return(0);
421  }
422// ------------------- product criterion for modules --------------------- 
423  if(sameComponent(f,g)==1)
424  {
425     if( monomialLcm(f,g)==leadmonomial(f)*leadmonomial(g) )
426     {
427         int c = leadexp(f)[nvars(basering)+1];  //component involving lead(f)
428         if((f-f[c]*gen(c))-(g-g[c]*gen(c))==0)  //other components are 0
429         {
430           return(1);
431         }
432     }
433     return(0);
434  }
435  return(2);
436}
437example
438{ "EXAMPLE:"; echo = 2;
439   ring r=0,(x,y,z),dp;
440   poly f = y3z3+x5+yx3+z6;
441   poly g = x5+yx3;
442   prodcrit(f,g);
443   vector v = x3z2*gen(1)+x3y*gen(1)+x2y*gen(2);
444   vector w = y4*gen(1)+y3*gen(2)+xyz*gen(1);
445   prodcrit(v,w);
446}
447///////////////////////////////////////////////////////////////////////////////
448proc chaincrit(f,g,h)
449"USAGE:   chaincrit(f,g,h); f,g,h poly or module
450RETURN:  1 if chain criterion applies, 0 else
451NOTE:    if chain criterion applies to f,g,h we can delete (g,h) from pairset
452EXAMPLE: example chaincrit; shows an example
453"
454{
455  if(sameComponent(f,g) and sameComponent(f,h))
456  {
457    if( monomialLcm(g,h)/leadmonomial(f) !=0 )
458    {
459      return(1);
460    }
461  }
462  return(0);
463}
464example
465{ "EXAMPLE:"; echo = 2;
466   ring r=0,(x,y,z),dp;
467   poly f = x2y2z2+x5+yx3+z6;
468   poly g = x5+yx3;
469   poly h = y2z5+x5+yx3;
470   chaincrit(f,g,h);
471   vector u = [x2y3-z2,x2y];
472   vector v = [x2y2+z2,x2-y2];
473   vector w = [x2y4+z3,x2+y2];
474   chaincrit(u,v,w);
475}
476///////////////////////////////////////////////////////////////////////////////
477proc pairset(G)
478"USAGE:   pairset(G); G ideal or module
479RETURN:  list L,
480         L[1] = the pairset of G as list (not containing pairs for
481         which the product or the chain criterion applies)
482         L[2] = intvec v, v[1]= # product criterion, v[2]= # chain criterion
483EXAMPLE: example pairset; shows an example
484"
485{
486   int i,j,k,s,c,ccrit,pcrit,pr;
487   int y = printlevel - voice + 2;
488   G = simplify(G,10);
489   def g = G;
490   ideal pair;
491   list P,I;      //P=pairlist of G, I=list of corresponding indices of pairs
492   for (i=1; i<=size(G); i++)
493   {
494      for(j = i+1; j<=size(G); j++)
495      {
496         pr = prodcrit(G[i],G[j]);       //check first product criterion
497         if( pr != 0 )
498         {
499            pcrit=pcrit+(pr==1);
500         }
501         else
502         {
503            s = size(P);                //now check chain criterion
504            for(k=1; k<=s; k++)
505            {
506              if( i==I[k][2] )
507              {
508                if ( chaincrit(P[k][1],P[k][2],G[j]) )
509                {                     //need not include (G[i],G[j]) in P
510                  c=1; ccrit=ccrit+1; 
511                  break;
512                }
513              }
514              if( j==I[k][1] and c==0 )
515              {
516                "########### enter pairset2 #############";
517                if ( chaincrit(G[i],P[k][1],P[k][2]) )
518                {                     //can delete P[k]=(P[k][1],P[k][2])
519                  ccrit=ccrit+1;
520                  P = delete(P,k);
521                  s = s-1;
522                }
523              }
524            }
525            if ( c==0 )
526            {
527               g = G[i],G[j];
528               P[s+1]=g;
529               I[s+1]=intvec(i,j);
530            }
531            c=0;
532         }
533      }
534   }
535   if (y>0)
536   {  "";
537      "// product criterion:",pcrit," chain criterion:",ccrit;
538   }
539   intvec v = pcrit,ccrit;
540   P=P,v;
541   return(P);
542}
543example
544{ "EXAMPLE:"; echo = 2;
545   ring r=0,(x,y,z),dp;
546   ideal G = x2y+x2,y3+xyz,xyz2+z4;
547   pairset(G);"";
548   module T = [x2y3-z2,x2y],[x2y2+z2,x2-y2],[x2y4+z3,x2+y2];
549   pairset(T);
550
551///////////////////////////////////////////////////////////////////////////////
552proc updatePairs(P,S,h)
553"USAGE:   updatePairs(P,S,h); P list, S ideal or module, h poly or vector
554         P a list of pairs of polys or vectors (obtained from pairset)
555RETURN:  list Q,
556         Q[1] = the pairset P enlarged  by all pairs (f,h), f from S,
557         without pairs for which the product or the chain criterion applies
558         Q[2] = intvec v, v[1]= # product criterion, v[2]= # chain criterion
559EXAMPLE: example updatePairs; shows an example
560"
561{
562   int i,j,k,s,r,c,ccrit,pcrit,pr;
563   int y = printlevel - voice + 2;
564   ideal pair;
565   list Q = P;           //Q will become enlarged pairset
566   s = size(P);
567   r = size(Q);          //r will grow with Q
568   list R;
569   def g = S;            //give g the correct type ideal/module
570   for (i=1; i<=size(S); i++)
571   {
572      pr =  prodcrit(h,S[i]);
573      if( pr != 0 )     //check product criterion
574      {
575        pcrit=pcrit+(pr==1);       //count product criterion in same component
576      }
577      else
578      {                 //prodcrit did not apply, check for chaincrit
579         r=size(Q);
580         for(k=1; k<=r; k++)
581         {
582           if( Q[k][2]==S[i] )    //S[i]=Q[k][2]
583           {
584             if( chaincrit(Q[k][1],S[i],h) )
585             {                   //can forget (S[i],h)
586                c=1; ccrit=ccrit+1;
587                break;
588             }
589           }
590         }
591         if ( c==0 )
592         {
593            g = S[i],h;        //add pair (S[i],h)
594            Q[r+1] = g;
595         }
596         c=0;
597      }
598   }
599   if (y>0)
600   {  "";;
601      "// product criterion:",pcrit," chain criterion:",ccrit;
602   }
603   intvec v = pcrit,ccrit;
604   Q = Q,v;
605   return(Q);
606}
607example
608{ "EXAMPLE:"; echo = 2;
609   ring R1=0,(x,y,z),(c,dp);
610   ideal S = x2y+x2,y3+xyz;
611   poly h = x2y+xyz;
612   list P = pairset(S)[1];
613   P;"";
614   updatePairs(P,S,h);"";
615   module T = [x2y3-z2,x2y],[x2y4+z3,x2+y2];
616   P = pairset(T)[1];
617   P;"";
618   updatePairs(P,T,[x2+x2y,y3+xyz]);
619
620///////////////////////////////////////////////////////////////////////////////
621proc standard(id, list #)
622"USAGE:   standard(i[,s]); id ideal or module, s int
623RETURN:  a standard basis of id, using generalized Mora's algorithm
624         which is Buchberger's algorithm for global monomial orderings.
625         If s!=0 the symmetric s-polynomial (without division) is used
626NOTE:    Show comments if printlevel > 0, pauses computation if printlevel > 1
627EXAMPLE: example standard; shows an example
628"
629{
630  if(size(#) == 0)
631  {
632     #[1]=0;
633  }
634
635   def S = id;                 //S will become the standard basis of id
636   def h = S[1];
637   int i,z;
638   int y = printlevel - voice + 2;
639   if(y>0)
640   {  "";
641      "// the set S, to become a standard basis:"; S;
642      if(y>1)
643      {
644         "// create pairset, i.e. pairs from S,";
645         "// after application of product and chain criterion";
646      }
647   }   
648   list P = pairset(S);        //create pairset of S=id
649   intvec v = P[2];
650   P = P[1];
651//-------------------------- Main loop in SB lgorithm ----------------------
652   while (size(P) !=0)
653   {  z=z+1;
654      if(y>0)
655      {  "";
656         "//              Enter NFMora for next pair, count",z;
657         "// size of partial standard basis S:    (",size(S),")";
658         "// number of pairs of S after updating: (",size(P),")";
659         if(y>1)
660         {
661            "// 1st pair of new pairset:"; P[1];
662            "// set T=S used for reduction:";S;
663            "// apply NFMora to (spoly,S), spoly = spoly(1st pair)";
664         }
665      }
666      //-------------------- apply NFMora = Mora's normal form -------------
667      h = spoly(P[1][1],P[1][2],#[1]);
668      if(y>1)
669      { 
670         "// spoly:";h;
671      }
672      h = NFMora(h,S,#[1]);
673      if(h==0)           //normal form is 0
674      {
675         if(y==1)
676         {
677            "// pair has reduced to 0";
678         }
679          if(y>1)
680         { h;"";
681           pause("press <return> to continue");
682         }           
683     }
684      P = delete(P,1);   //spoly of pair reduced to 0, pair can be deleted
685      //--- spoly of pair did not reduce to 0, update S and paiset of S ----
686      if( h != 0)       
687      {
688         if(y==1)
689         {
690            "// ** new spoly in degree **:", deg(h);
691         }
692         if(y>1)
693         { h;"";
694           pause("press <return> to continue");
695           "// update pairset";
696         }           
697        P=updatePairs(P,S,h);    //update P (=paisert of S)
698        v=v+P[2];                //with useful pairs (g,h), g from S
699         P=P[1];
700         S=S,h;                  //update S, will become the standard basis
701      }
702   }
703//------------------------------ finished ---------------------------------
704   if( find(option(),"prot") or y>0 )
705   {  "";                //show how often prodcrit and chaincrit applied
706      "// product criterion:",v[1]," chain criterion:",v[2];
707      "";
708      "// Final standard basis:";
709   }       
710   return(S);
711}
712example
713{ "EXAMPLE:"; echo = 2;
714   ring r=0,(x,y,z),dp;
715   ideal G = x2y+x2,y3+xyz,xyz2+z4;
716   standard(G);"";
717   ring s=0,(x,y,z),(c,ds);
718   ideal G = 2x2+x2y,y3+xyz,3x3y+z4;
719   standard(G);"";
720   standard(G,1);"";           //use symmetric s-poly without division
721   module M = [2x2,x3y+z4],[3y3+xyz,y3],[5z4,z2];
722   standard(M);
723
724///////////////////////////////////////////////////////////////////////////////
725proc localstd (id)
726"USAGE:   localstd (id); id = ideal
727RETURN:  A standard basis for a local degree ordering, using Lazard's method.
728NOTE:    The procedure homogenizes id w.r.t. a new 1st variable local@t,
729         computes a SB wrt (dp(1),dp) and substitutes local@t by 1.
730         Hence the result is a SB with respect to an ordering which sorts
731         first w.r.t. the subdegree of the original variables and then refines
732         it with dp. This is the local degree ordering ds.
733         localstd may be used in order to avoid cancellation of units and thus
734         to be able to use option(contentSB) also for local orderings.
735EXAMPLE: example localstd; shows an example
736"
737{
738  int ii;
739  def bas = basering;
740  execute("ring  @r_locstd
741     =("+charstr(bas)+"),(local@t,"+varstr(bas)+"),(dp(1),dp);");
742  ideal id = imap(bas,id);
743  ideal hid = homog(id,local@t);
744  hid = std(hid);
745  hid = subst(hid,local@t,1);
746  setring bas;
747  def hid = imap(@r_locstd,hid);
748  attrib(hid,"isSB",1);
749  kill @r_locstd;
750  return(hid); 
751}
752example
753{ "EXAMPLE:"; echo = 2;
754   ring R = 0,(x,y,z),ds;
755   ideal i  = xyz+z5,2x2+y3+z7,3z5+y5;
756   localstd(i);
757}   
758///////////////////////////////////////////////////////////////////////////////
759
760/*
761// some examples:
762LIB"teachstd.lib";
763option(prot); printlevel=3;
764ring r0 = 0,(t,x,y),lp;
765ideal i = x-t2,y-t3;
766standard(i);
767
768printlevel=1;
769standard(i);
770
771option(prot); printlevel =1;
772ring r1 = (0,a,b),(x,y,z),(c,ds);
773module M = [ax2,bx3y+z4],[a3y3+xyz,by3],[5az4,(a+b)*z2];
774module N1= std(M);
775module N2 = standard(M,1);
776NF(lead(N2),lead(N1));
777NF(lead(N1),lead(N2));rom T
778ring r2 = 0,(x,y,z),dp;
779ideal I = x2y+x2,y3+xyz,xyz2+z4;
780option(prot);
781int tt = timer;
782ideal J = standard(I);
783timer -tt;                 //4sec, product criterion: 9  chain criterion: 6
784ideal J1 = std(I);
785NF(lead(J),lead(J1));
786NF(lead(J1),lead(J));
787
788ring r3 = 0,(x,y,z),ds;
789poly f = x3*y4+z5+xyz;
790ideal I = f,jacob(f);
791option(prot);
792int tt = timer;
793ideal J = standard(I);
794timer -tt;                 //3sec, product criterion: 1  chain criterion: 3
795ideal J1 = std(I);
796NF(lead(J),lead(J1));
797NF(lead(J1),lead(J));
798 
799//Becker:
800ring r4 = 32003,(x,y,z),lp;
801ideal I = x3-1, y3-1,
802-27x3-243x2y+27x2z-729xy2+162xyz-9xz2-729y3+243y2z-27yz2+z3-27;
803option(prot);
804int tt = timer;
805ideal J = standard(I);
806timer -tt;                 //201sec, product criterion: 42  chain criterion: 33
807ideal J1 = std(I);
808NF(lead(J),lead(J1));
809NF(lead(J1),lead(J));
810 
811//Alex
812ring r5 = 32003,(x,y,z,t),dp;
813ideal I =
8142t3xy2z+x2ty+2x2y,
8152tz+y3x2t+z2t3y2x;
816option(prot); printlevel =1;
817ideal J1 = std(I);
818int tt = timer;
819ideal J = standard(I);
820timer -tt;                 //15sec product criterion: 0  chain criterion: 12
821NF(lead(J),lead(J1));
822NF(lead(J1),lead(J));
823
824ring r6 = 32003,(x,y,z,t),dp; //is already SB for ds, for dp too long
825ideal I=
8269x8+y7t3z4+5x4y2t2+2xy2z3t2,
8279y8+7xy6t+2x5y4t2+2x2yz3t2,
8289z8+3x2y3z2t4;
829option(prot);
830int tt = timer;
831ideal J = standard(I);
832timer -tt;                 //0sec, product criterion: 3  chain criterion: 0
833ideal J1 = std(I);
834NF(lead(J),lead(J1));
835NF(lead(J1),lead(J));
836
837
838*/
839
Note: See TracBrowser for help on using the repository browser.