source: git/Singular/LIB/noether.lib @ 67b4f7

spielwiese
Last change on this file since 67b4f7 was 67b4f7, checked in by Hans Schönemann <hannes@…>, 16 years ago
*amir.hashemi: references git-svn-id: file:///usr/local/Singular/svn/trunk@10669 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 28.1 KB
Line 
1// AH last modified:  01.07.2007
2//////////////////////////////////////////////////////////////////////////////
3version = "$Id: noether.lib,v 1.10 2008-04-11 14:04:40 Singular Exp $";
4category="Commutative Algebra";
5info="
6LIBRARY: noether.lib   Noether normalization of an ideal (not nessecary
7                       homogeneous)
8AUTHORS: A. Hashemi,  Amir.Hashemi@lip6.fr
9
10
11OVERVIEW:
12A library for computing the Noether normalization of an ideal that DOES NOT
13require the computation of the dimension of the ideal.
14It checks whether an ideal is in Noether position.  A modular version of
15these algorithms is also provided.
16The procedures are based on a paper of Amir Hashemi 'Efficient Algorithms for
17Computing Noether Normalization'
18(presented in ASCM 2007)
19
20This library computes also Castelnuovo-Mumford regularity and satiety of an
21ideal.  A modular version of these algorithms is also provided.
22The procedures are based on a paper of Amir Hashemi 'Computation of
23Castelnuovo-Mumford regularity and satiety'
24(preprint 2008)
25
26
27PROCEDURES:
28 NPos_test(id);  checks whether monomial ideal id is in Noether position
29 modNpos_test(id); the same as above using modular methods
30 NPos(id);       Noether normalization of ideal id
31 modNPos(id);      Noether normalization of ideal id by modular methods
32 nsatiety(id); Satiety of ideal id
33 modsatiety(id)  Satiety of ideal id by modular methods
34 regCM(id);    Castelnuovo-Mumford regularity of ideal id
35 modregCM(id); Castelnuovo-Mumford regularity of ideal id by modular methods
36";
37LIB "elim.lib";
38LIB "algebra.lib";
39LIB "poly.lib";
40LIB "ring.lib";
41LIB "presolve.lib";
42
43///////////////////////////////////////////////////////////////////////////////
44
45proc NPos_test (ideal I)
46"
47USAGE:  NPos_test (I); I monomial ideal
48RETURN: A list which first element is 1 if i is in Noether position
49        0  otherwise. The second element of this list is the list of variable which
50        its first part is the variable such that a power of this varaibles belong to the initial of i.
51        It return also the dimension of i if i is in Noether position
52ASSUME: i is a nonzero monomial ideal.
53"
54{
55//--------------------------- initialisation ---------------------------------
56   int  time,ii,j,k,l,d,t,jj;
57   intvec v;
58   def r0 = basering;
59   int n = nvars(r0)-1;
60   list L,Y,P1,P2,P3;
61   if (I[1]==1)
62   {
63     print("The ideal is 1");return(1);
64   }
65   for ( ii = 1; ii <= n+1; ii++ )
66   {
67     L[ii]=0;
68   }
69   for ( ii = 1; ii <= size(I); ii++ )
70   {
71     Y=findvars(I[ii],1)[1];
72     l=rvar(Y[1][1]);
73     if (size(Y[1])==1)
74     {
75       L[l]=1;
76       P1=insert(P1,Y[1][1]);
77     }
78     if (L[l]==0)
79     {
80       L[l]=-1;
81     }
82   }
83   t=size(P1);
84   if (t==0)
85   {
86     for ( jj = 1; jj <= n+1; jj++ )
87     {
88       P3=insert(P3,varstr(jj));
89     }
90   }
91   else
92   {
93     P2=findvars(ideal(P1[1..t]),1)[3];
94     for ( jj = 1; jj <= size(P2[1]); jj++ )
95     {
96       P3=insert(P3,P2[1][jj]);
97     }
98   }
99   if (L[n+1]==-1)
100   {
101     return(list(0,P1+P3));
102   }
103   for ( ii = 1; ii <= n; ii++ )
104   {
105     if (L[ii]==-1)
106     {
107       return(list(0,P1+P3));
108     }
109     if (L[ii]==0 and L[ii+1]==1)
110     {
111       return(list(0,P1+P3));
112     }
113   }
114   d=n+1-sum(L);
115   print("The dimension of the ideal is:");print(d);
116   return(list(1,P1+P3));
117}
118//////////////////////////////////////////
119proc modNpos_test (ideal i)
120"USAGE: modNpos_test(i); i an ideal
121RETURN: 1 if i is in Noether position 0  otherwise.
122NOTE:   This test is a probabilistic test, and it computes the initial of the ideal modulo the prime number 2147483647 (the biggest prime less than 2^31).
123"
124{
125  "// WARNING:
126// The procedure is probabilistic and  it computes the initial of the ideal modulo the prime number 2147483647";
127  int p;
128  def br=basering;
129  setring br;
130  ideal I;
131  list #;
132  option(redSB);
133  p=2147483647;
134  #=ringlist(br);
135  #[1]=p;
136  def oro=ring(#);
137  setring oro;
138  ideal sbi,lsbi;
139  sbi=fetch(br,i);
140  lsbi=lead(std(sbi));
141  setring br;
142  I=fetch(oro,lsbi);
143  I=simplify(I,1);
144  attrib(I,"isSB",1);
145  return(NPos_test(I));
146}
147
148
149///////////////////////////////////////////////////////////////////////////////
150proc NPos (ideal i)
151"USAGE:  NPos(i); i ideal
152RETURN:  A linear map phi such that  phi(i) is in Noether position
153"
154{
155//--------------------------- initialisation ---------------------------------
156  int ii,jj,d,time,n,nl;
157  intmat ran;
158  def r0 = basering;
159  ideal K,chcoord;
160  n = nvars(r0)-1;
161  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
162  execute(s);
163  ideal i,sbi,I,K,chcoord,m,L;
164  list #;
165  poly P;
166  map phi;
167  i = fetch(r0,i);
168  time=rtimer;
169  system("--ticks-per-sec",10);
170  i=std(i);
171  sbi=sort(lead(i))[1];
172  #=NPos_test(sbi);
173  if ( #[1]== 1 )
174  {
175    return ("The ideal is in Noether position and the time of this computation is:",rtimer-time,"/10 sec.");
176  }
177  else
178  {
179    L=maxideal(1);
180    chcoord=maxideal(1);
181    for ( ii = 1; ii<=n+1; ii++ )
182    {
183      chcoord[rvar(#[2][ii])]=L[ii];
184    }
185    phi=r1,chcoord;
186    sbi=phi(sbi);
187    if ( NPos_test(sbi)[1] == 1 )
188    {
189      setring r0;
190      chcoord=fetch(r1,chcoord);
191      return (chcoord,"and the time of this computation is:",rtimer-time,"/10 sec.");
192    }
193  }
194  while ( nl < 30 )
195  {
196    nl=nl+1;
197    I=i;
198    L=maxideal(1);
199    for ( ii = n; ii>=0; ii-- )
200    {
201      chcoord=select1(maxideal(1),1,(ii));
202      ran=random(100,1,ii);
203      ran=intmat(ran,1,ii+1);
204      ran[1,ii+1]=1;
205      m=select1(maxideal(1),1,(ii+1));
206      for ( jj = 1; jj<=ii+1; jj++ )
207      {
208        P=P+ran[1,jj]*m[jj];
209      }
210      chcoord[ii+1]=P;
211      L[ii+1]=P;
212      P=0;
213      phi=r1,chcoord;
214      I=phi(I);
215      if ( NPos_test(sort(lead(std(I)))[1])[1] == 1 )
216      {
217        K=x(ii..n);
218        setring r0;
219        K=fetch(r1,K);
220        ideal L=fetch(r1,L);
221        return (L,"and the time of this computation is:",rtimer-time,"/10 sec.");
222      }
223    }
224  }
225  "// WARNING:
226// The procedure has entered in more than 30 loops: in your example
227// the method may enter an infinite loop over a finite field!";
228  return (-1);
229}
230///////////////////////////////////////////////////////////////////////////////
231proc modNPos (ideal i)
232"USAGE:  modNPos(i); i ideal
233RETURN:  A linear map phi such that  phi(i) is in Noether position
234NOTE:    It uses the procedure  modNPos_test to test Noether position.
235"
236{
237//--------------------------- initialisation ---------------------------------
238   int ii,jj,d,time,n,nl;
239   intmat ran;
240   def r0 = basering;
241   ideal K,chcoord;
242   n = nvars(r0)-1;
243   string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
244   execute(s);
245   ideal i,sbi,I,K,chcoord,m,L;
246   poly P;
247   list #;
248   map phi;
249   i = fetch(r0,i);
250   time=rtimer;
251   system("--ticks-per-sec",10);
252   #=modNPos_test(i);
253   if ( #[1]== 1 )
254   {
255     return ("The ideal is in Noether position and the time of this computation is:",rtimer-time,"/10 sec.");
256   }
257   else
258   {
259     L=maxideal(1);
260     chcoord=maxideal(1);
261     for ( ii = 1; ii<=n+1; ii++ )
262     {
263       chcoord[rvar(#[2][ii])]=L[ii];
264     }
265     phi=r1,chcoord;
266     I=phi(i);
267     if ( modNPos_test(I)[1] == 1 )
268     {
269       setring r0;
270       chcoord=fetch(r1,chcoord);
271       return (chcoord,"and the time of this computation is:",rtimer-time,"/10 sec.");
272     }
273   }
274   while ( nl < 30 )
275   {
276     nl=nl+1;
277     I=i;
278     L=maxideal(1);
279     for ( ii = n; ii>=0; ii-- )
280     {
281       chcoord=select1(maxideal(1),1,(ii));
282       ran=random(100,1,ii);
283       ran=intmat(ran,1,ii+1);
284       ran[1,ii+1]=1;
285       m=select1(maxideal(1),1,(ii+1));
286       for ( jj = 1; jj<=ii+1; jj++ )
287       {
288         P=P+ran[1,jj]*m[jj];
289       }
290       chcoord[ii+1]=P;
291       L[ii+1]=P;
292       P=0;
293       phi=r1,chcoord;
294       I=phi(I);
295       if ( modNPos_test(I)[1] == 1 )
296       {
297         K=x(ii..n);
298         setring r0;
299         K=fetch(r1,K);
300         ideal L=fetch(r1,L);
301         return (L,"and the time of this computation is:",rtimer-time,"/10 sec.");
302       }
303     }
304   }
305   "// WARNING:
306// The procedure has entered in more than 30 loops: in your example
307// the method may enter an infinite loop over a finite field!";
308   return (-1);
309}
310
311////////////////////////////////////////////////////////////////////////////////////
312proc Test (ideal i)
313"USAGE:   Test (i); i a monomial ideal,
314RETURN:  1 if the last variable is in generic position for i and 0 otherwise.
315THEORY:  The last variable is in generic position if the quotient of the ideal
316         with respect to this variable is equal to the quotient of the ideal with respect to the maximal ideal.
317"
318{
319//--------------------------- initialisation ---------------------------------
320  int n,ret;
321  def r0 = basering;
322  n = nvars(r0)-1;
323  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
324  execute(s);
325  ideal I,i;
326  i = fetch(r0,i);
327  attrib(i,"isSB",1);
328  I=quotient(select(i,n+1),x(n));
329  I=I*maxideal(1);
330  ret=1;
331  if (size(reduce(I,i)) <> 0)
332  {
333    ret=0;
334  }
335  return(ret);
336}
337
338
339////////////////////////////////////////////////////////////////////////////////////
340proc nsatiety (ideal i)
341"USAGE:   nsatiety (i); i ideal,
342RETURN:  an integer, the satiety of i.
343         (returns -1 if i is not homogeneous)
344ASSUME:  i is a homogeneous ideal of the basering R=K[x(0)..x(n)].
345THEORY:  The satiety, or saturation index, of a homogeneous ideal i is the
346         least integer s such that, for all d>=s, the degree d part of the
347         ideals i and isat=sat(i,maxideal(1))[1] coincide.
348"
349{
350//--------------------------- initialisation ---------------------------------
351  int e,ii,jj,h,d,time,lastv,nl,ret;
352  intmat ran;
353  def r0 = basering;
354  int n = nvars(r0)-1;
355  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
356  execute(s);
357  ideal i,sbi,I,K,chcoord,m,L;
358  poly P;
359  map phi;
360  i = fetch(r0,i);
361  time=rtimer;
362  system("--ticks-per-sec",100);
363  sbi=std(i);
364//----- Check ideal homogeneous
365  if ( homog(sbi) == 0 )
366  {
367    dbprint(2,"The ideal is not homogeneous, and time for this test is: " + string(rtimer-time) + "/100sec.");
368    return ();
369  }
370  I=simplify(lead(sbi),1);
371  attrib(I,"isSB",1);
372  K=select(I,n+1);
373  if (size(K) == 0)
374  {
375    dbprint(2,"sat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
376    return();
377  }
378  if (Test(I) == 1 )
379  {
380    dbprint(2,"sat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
381    return();
382  }
383  while ( nl < 5 )
384  {
385    nl=nl+1;
386    chcoord=select1(maxideal(1),1,(n));
387    ran=random(100,1,n);
388    ran=intmat(ran,1,n+1);
389    ran[1,n+1]=1;
390    m=select1(maxideal(1),1,(n+1));
391    for ( jj = 1; jj<=n+1; jj++ )
392    {
393      P=P+ran[1,jj]*m[jj];
394    }
395    chcoord[n+1]=P;
396    P=0;
397    phi=r1,chcoord;
398    L=std(phi(i));
399    I=simplify(lead(L),1);
400    attrib(I,"isSB",1);
401    K=select(I,n+1);
402    if (size(K) == 0)
403    {
404      dbprint(2,"sat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
405      return();
406    }
407    if (Test(I) == 1 )
408    {
409      dbprint(2,"sat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
410      return();
411    }
412  }
413}
414
415
416//////////////////////////////////////////////////////////////////////////////
417proc modsatiety (ideal i)
418"USAGE:   modsatiety(i); i ideal,
419RETURN:  an integer, the satiety of i.
420         (returns -1 if i is not homogeneous)
421ASSUME:  i is a homogeneous ideal of the basering R=K[x(0)..x(n)].
422THEORY:  The satiety, or saturation index, of a homogeneous ideal i is the
423         least integer s such that, for all d>=s, the degree d part of the
424         ideals i and isat=sat(i,maxideal(1))[1] coincide.
425NOTE:    This is a probabilistic procedure, and it computes the initial of the ideal modulo the prime number 2147483647 (the biggest prime less than 2^31).
426"
427{
428//--------------------------- initialisation ---------------------------------
429  "// WARNING: The characteristic of base field must be zero.
430// The procedure is probabilistic and  it computes the
431//initial ideals modulo the prime number 2147483647.";
432  int e,ii,jj,h,d,time,lastv,nl,ret,s1,d1,siz,j,si,u,k,p;
433  intvec v1;
434  intmat ran;
435  def r0 = basering;
436  int n = nvars(r0)-1;
437  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
438  execute(s);
439  ideal i,sbi,I,K,chcoord,m,L,sbi1,lsbi1,id1;
440  vector V1;
441  list #,LL,PL,Gb1,VGb1,Gb2,VGb2,Res1,Res2;
442  poly P;
443  map phi;
444  time=rtimer;
445  system("--ticks-per-sec",100);
446  i = fetch(r0,i);
447//----- Check ideal homogeneous
448  if ( homog(i) == 0 )
449  {
450    "// WARNING: The ideal is not homogeneous.";
451    dbprint(2,"Time for this test is: " + string(rtimer-time) + "/100sec.");
452    return ();
453  }
454  option(redSB);
455  p=2147483647;
456  list r2=ringlist(r1);
457  r2[1]=p;
458  def oro=ring(r2);
459  setring oro;
460  ideal sbi=fetch(r1,i);
461  sbi=std(sbi);
462  setring r1;
463  sbi=fetch(oro,sbi);
464  kill oro;
465  I=simplify(lead(sbi),1);
466  attrib(I,"isSB",1);
467  K=select(I,n+1);
468  if (size(K) == 0)
469  {
470    dbprint(2,"msat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
471    return();
472  }
473  if (Test(I) == 1 )
474  {
475    dbprint(2,"msat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
476    return();
477  }
478  while ( nl < 30 )
479  {
480    nl=nl+1;
481    chcoord=select1(maxideal(1),1,(n));
482    ran=random(100,1,n);
483    ran=intmat(ran,1,n+1);
484    ran[1,n+1]=1;
485    m=select1(maxideal(1),1,(n+1));
486    for ( jj = 1; jj<=n+1; jj++ )
487    {
488      P=P+ran[1,jj]*m[jj];
489    }
490    chcoord[n+1]=P;
491    P=0;
492    phi=r1,chcoord;
493    sbi=phi(i);
494    list r2=ringlist(r1);
495    r2[1]=p;
496    def oro=ring(r2);
497    setring oro;
498    ideal sbi=fetch(r1,sbi);
499    sbi=std(sbi);
500    setring r1;
501    sbi=fetch(oro,sbi);
502    kill oro;
503    lsbi1=lead(sbi);
504    attrib(lsbi1,"isSB",1);
505    K=select(lsbi1,n+1);
506    if (size(K) == 0)
507    {
508      dbprint(2,"msat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
509      return();
510    }
511    if (Test(lsbi1) == 1 )
512    {
513      dbprint(2,"msat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
514      return();
515    }
516  }
517}
518
519//////////////////////////////////////////////////////////////////////////////
520//
521proc reg (ideal i)
522"USAGE:  reg (i); i ideal
523RETURN:  the Castelnuovo-Mumford regularity of i.
524         (returns -1 if i is not homogeneous)
525ASSUME:  i is a homogeneous ideal.
526"
527{
528//--------------------------- initialisation ---------------------------------
529  int e,ii,jj,H,h,d,time,nl;
530  def r0 = basering;
531  int n = nvars(r0)-1;
532  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
533  execute(s);
534  ideal i,sbi,I,J,K,L;
535  list #;
536  poly P;
537  map phi;
538  i = fetch(r0,i);
539  time=rtimer;
540  system("--ticks-per-sec",100);
541  sbi=std(i);
542//----- Check ideal homogeneous
543  if ( homog(sbi) == 0 )
544  {
545    "// The ideal is not homogeneous!";
546    return (-1);
547  }
548  I=simplify(lead(sbi),1);
549  attrib(I,"isSB",1);
550  d=dim(I);
551  if (char(r1) > 0 and d == 0)
552  {
553    def r2=changechar("0",r1);
554    setring r2;
555    ideal sbi,I,i,K,T;
556    map phi;
557    I = fetch(r1,I);
558    i=I;
559    attrib(I,"isSB",1);
560  }
561  else
562  {
563    def r2=changechar(charstr(r1),r1);
564    setring r2;
565    ideal sbi,I,i,K,T,ic,Ic;
566    map phi;
567    I = imap(r1,I);
568    Ic=I;
569    attrib(I,"isSB",1);
570    i = imap(r1,i);
571    ic=i;
572  }
573  K=select(I,n+1);
574  if (size(K) == 0)
575  {
576    h=0;
577  }
578  else
579  {
580    if (Test(I) == 1)
581    {
582      h=maxdeg1(K);
583    }
584    else
585    {
586      while ( nl < 30 )
587      {
588        nl=nl+1;
589        phi=r2,randomLast(100);
590        T=phi(i);
591        I=simplify(lead(std(T)),1);
592        attrib(I,"isSB",1);
593        K=select(I,n+1);
594        if (size(K) == 0)
595        {
596          h=0;break;
597        }
598        if (Test(I) == 1 )
599        {
600          h=maxdeg1(K);break;
601        }
602      }
603      i=T;
604    }
605  }
606  for ( ii = n; ii>=n-d+1; ii-- )
607  {
608    i=subst(i,x(ii),0);
609    s = "ring mr = ",charstr(r1),",x(0..ii-1),dp;";
610    execute(s);
611    ideal i,sbi,I,J,K,L,T;
612    poly P;
613    map phi;
614    i=imap(r2,i);
615    I=simplify(lead(std(i)),1);
616    attrib(I,"isSB",1);
617    K=select(I,ii);
618    if (size(K) == 0)
619    {
620      H=0;
621    }
622    else
623    {
624      if (Test(I) == 1)
625      {
626        H=maxdeg1(K);
627      }
628      else
629      {
630        while ( nl < 30 )
631        {
632          nl=nl+1;
633          phi=mr,randomLast(100);
634          T=phi(i);
635          I=simplify(lead(std(T)),1);
636          attrib(I,"isSB",1);
637          K=select(I,ii);
638          if (size(K) == 0)
639          {
640            H=0;break;
641          }
642          if (Test(I) == 1 )
643          {
644            H=maxdeg1(K);break;
645          }
646        }
647        setring r2;
648        i=imap(mr,T);
649        kill mr;
650      }
651    }
652    if (H > h)
653    {
654      h=H;
655    }
656  }
657  if (nl < 30)
658  {
659    dbprint(2,"reg(i)=" + string(h) + " and the time of this computation: " + string(rtimer-time) + " sec./100");
660    return();
661  }
662  else
663  {
664    I=Ic;
665    attrib(I,"isSB",1);
666    i=ic;
667    K=subst(select(I,n+1),x(n),1);
668    K=K*maxideal(maxdeg1(I));
669    if (size(reduce(K,I)) <> 0)
670    {
671      nl=0;
672      while ( nl < 30 )
673      {
674        nl=nl+1;
675        phi=r1,randomLast(100);
676        sbi=phi(i);
677        I=simplify(lead(std(sbi)),1);
678        attrib(I,"isSB",1);
679        K=subst(select(I,n+1),x(n),1);
680        K=K*maxideal(maxdeg1(I));
681        if (size(reduce(K,I)) == 0)
682        {
683          break;
684        }
685      }
686    }
687    h=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1;
688    for ( ii = n; ii> n-d+1; ii-- )
689    {
690      sbi=subst(sbi,x(ii),0);
691      s = "ring mr = ",charstr(r0),",x(0..ii-1),dp;";
692      execute(s);
693      ideal sbi,I,L,K,T;
694      map phi;
695      sbi=imap(r1,sbi);
696      I=simplify(lead(std(sbi)),1);
697      attrib(I,"isSB",1);
698      K=subst(select(I,ii),x(ii-1),1);
699      K=K*maxideal(maxdeg1(I));
700      if (size(reduce(K,I)) <> 0)
701      {
702        nl=0;
703        while ( nl < 30 )
704        {
705          nl=nl+1;
706          L=randomLast(100);
707          phi=mr,L;
708          T=phi(sbi);
709          I=simplify(lead(std(T)),1);
710          attrib(I,"isSB",1);
711          K=subst(select(I,ii),x(ii-1),1);
712          K=K*maxideal(maxdeg1(I));
713          if (size(reduce(K,I)) == 0)
714          {
715            sbi=T;
716            break;
717          }
718        }
719      }
720      H=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1;
721      if (H > h)
722      {
723        h=H;
724      }
725      setring r1;
726      sbi=fetch(mr,sbi);
727      kill mr;
728    }
729    sbi=subst(sbi,x(n-d+1),0);
730    s = "ring mr = ",charstr(r0),",x(0..n-d),dp;";
731    execute(s);
732    ideal sbi,I,L,K,T;
733    map phi;
734    sbi=imap(r1,sbi);
735    I=simplify(lead(std(sbi)),1);
736    attrib(I,"isSB",1);
737    H=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1;
738    if (H > h)
739    {
740      h=H;
741    }
742    dbprint(2,"reg(i)=" + string(h) + " and the time of this computation: " + string(rtimer-time) + " sec./100");
743    return();
744  }
745}
746
747//////////////////////////////////////////////////////////////////////////////
748//
749proc modregCM(ideal i)
750"USAGE:  modregCM(i); i ideal
751RETURN:  an integer, the Castelnuovo-Mumford regularity of i.
752         (returns -1 if i is not homogeneous)
753ASSUME:  i is a homogeneous ideal and the characteristic of base field is zero..
754NOTE:    This is a probabilistic procedure, and it computes the initial of the ideal modulo the prime number 2147483647 (the biggest prime less than 2^31).
755"
756{
757//--------------------------- initialisation ---------------------------------
758  "// WARNING: The characteristic of base field musr be zero.
759// This procedure is probabilistic and  it computes the initial
760//ideals modulo the prime number 2147483647";
761  int e,ii,jj,H,h,d,time,p,nl;
762  def r0 = basering;
763  int n = nvars(r0)-1;
764  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
765  execute(s);
766  ideal i,sbi,I,J,K,L,lsbi1,lsbi2;
767  list #;
768  poly P;
769  map phi;
770  i = fetch(r0,i);
771  time=rtimer;
772  system("--ticks-per-sec",100);
773//----- Check ideal homogeneous
774  if ( homog(i) == 0 )
775  {
776    "// The ideal is not homogeneous!";
777    return (-1);
778  }
779  option(redSB);
780  p=2147483647;
781  #=ringlist(r1);
782  #[1]=p;
783  def oro=ring(#);
784  setring oro;
785  ideal sbi,lsbi;
786  sbi=fetch(r1,i);
787  lsbi=lead(std(sbi));
788  setring r1;
789  lsbi1=fetch(oro,lsbi);
790  lsbi1=simplify(lsbi1,1);
791  attrib(lsbi1,"isSB",1);
792  kill oro;
793  I=lsbi1;
794  d=dim(I);
795  K=select(I,n+1);
796  if (size(K) == 0)
797  {
798    h=0;
799  }
800  else
801  {
802    if (Test(I) == 1)
803    {
804      h=maxdeg1(K);
805    }
806    else
807    {
808      while ( nl < 30 )
809      {
810        nl=nl+1;
811        phi=r1,randomLast(100);
812        sbi=phi(i);
813        #=ringlist(r1);
814        #[1]=p;
815        def oro=ring(#);
816        setring oro;
817        ideal sbi,lsbi;
818        sbi=fetch(r1,sbi);
819        lsbi=lead(std(sbi));
820        setring r1;
821        lsbi1=fetch(oro,lsbi);
822        lsbi1=simplify(lsbi1,1);
823        attrib(lsbi1,"isSB",1);
824        kill oro;
825        I=lsbi1;
826        K=select(I,n+1);
827        if (size(K) == 0)
828        {
829          h=0;break;
830        }
831        if (Test(I) == 1 )
832        {
833          h=maxdeg1(K);break;
834        }
835      }
836      i=sbi;
837    }
838  }
839  for ( ii = n; ii>=n-d+1; ii-- )
840  {
841    i=subst(i,x(ii),0);
842    s = "ring mr = ","0",",x(0..ii-1),dp;";
843    execute(s);
844    ideal i,sbi,I,J,K,L,lsbi1;
845    poly P;
846    list #;
847    map phi;
848    i=imap(r1,i);
849    #=ringlist(mr);
850    #[1]=p;
851    def oro=ring(#);
852    setring oro;
853    ideal sbi,lsbi;
854    sbi=fetch(mr,i);
855    lsbi=lead(std(sbi));
856    setring mr;
857    lsbi1=fetch(oro,lsbi);
858    lsbi1=simplify(lsbi1,1);
859    attrib(lsbi1,"isSB",1);
860    kill oro;
861    I=lsbi1;
862    K=select(I,ii);
863    if (size(K) == 0)
864    {
865      H=0;
866    }
867    else
868    {
869      if (Test(I) == 1)
870      {
871        H=maxdeg1(K);
872      }
873      else
874      {
875        nl=0;
876        while ( nl < 30 )
877        {
878          nl=nl+1;
879          phi=mr,randomLast(100);
880          sbi=phi(i);
881          #=ringlist(mr);
882          #[1]=p;
883          def oro=ring(#);
884          setring oro;
885          ideal sbi,lsbi;
886          sbi=fetch(mr,sbi);
887          lsbi=lead(std(sbi));
888          setring mr;
889          lsbi1=fetch(oro,lsbi);
890          lsbi1=simplify(lsbi1,1);
891          kill oro;
892          I=lsbi1;
893          attrib(I,"isSB",1);
894          K=select(I,ii);
895          if (size(K) == 0)
896          {
897            H=0;break;
898          }
899          if (Test(I) == 1 )
900          {
901            H=maxdeg1(K);break;
902          }
903        }
904        setring r1;
905        i=imap(mr,sbi);
906        kill mr;
907      }
908    }
909    if (H > h)
910    {
911      h=H;
912    }
913  }
914  dbprint(2,"mreg(i)=" + string(h) + " and the time of this computation: " + string(rtimer-time) + "sec./100");
915  return();
916}
917/*
918//////////////////////////////////////////////////////////////
919example
920{ "EXAMPLE:"; echo = 2;
921ring r=0,(X,Y,a,b),dp;
922poly f=X^8+a*Y^4-Y;
923poly g=Y^8+b*X^4-X;
924poly h=diff(f,X)*diff(g,Y)-diff(f,Y)*diff(g,X);
925ideal i=f,g,h;
926}
927example
928{ "EXAMPLE:"; echo = 2;
929ring r=0,(x,y,z,a,b),dp;
930ideal i=2*y^2*(y^2+x^2)+(b^2-3*a^2)*y^2-2*b*y^2*(x+y)+2*a^2*b*(y+x)-a^2*x^2+a^2*(a^2-b^2),4*y^3+4*y*(y^2+x^2)-2*b*y^2-4*b*y*(y+x)+2*(b^2-3*a^2)*y+2*a^2*b,4*x*y^2-2*b*y^2-2*a^2*x+2*a^2*b;
931}
932example
933{ "EXAMPLE:"; echo = 2;
934ring r=0,(t,a,b,c,d),dp;
935ideal i=b4-a3d, ab3-a3c, bc4-ac3d-bcd3+ad4, c6-bc3d2-c3d3+bd5, ac5-b2c3d-ac2d3+b2d4, a2c4-a3d3+b3d3-a2cd3, b3c3-a3d3, ab2c3-a3cd2+b3cd2-ab2d3, a2bc3-a3c2d+b3c2d-a2bd3, a3c3-a3bd2, a4c2-a3b2d;
936}
937example
938{ "EXAMPLE:"; echo = 2;
939ring r=0,(a,b,c,d,e),dp;
940ideal i=6*b4*c3+21*b4*c2*d+15b4cd2+9b4d3-8b2c2e-28b2cde+36b2d2e-144b2c-648b2d-120, 9b4c4+30b4c3d+39b4c2d2+18b4cd3-24b2c3e-16b2c2de+16b2cd2e+24b2d3e-432b2c2-720b2cd-432b2d2+16c2e2-32cde2+16d2e2+576ce-576de-240c+5184,-15b2c3e+15b2c2de-81b2c2+216b2cd-162b2d2+40c2e2-80cde2+40d2e2+1008ce-1008de+5184, -4b2c2+4b2cd-3b2d2+22ce-22de+261;
941}
942example
943{ "EXAMPLE:"; echo = 2;
944ring r=0,(c,b,d,p,q),dp;
945ideal i=2*(b-1)^2+2*(q-p*q+p^2)+c^2*(q-1)^2-2*b*q+2*c*d*(1-q)*(q-p)+2*b*p*q*d*(d-c)+b^2*d^2*(1-2*p)+2*b*d^2*(p-q)+2*b*d*c*(p-1)+2*b*p*q*(c+1)+(b^2-2*b)*p^2*d^2+2*b^2*p^2+4*b*(1-b)*p+d^2*(p-q)^2,d*(2*p+1)*(q-p)+c*(p+2)*(1-q)+b*(b-2)*d+b*(1-2*b)*p*d+b*c*(q+p-p*q-1)+b*(b+1)*p^2*d, -b^2*(p-1)^2+2*p*(p-q)-2*(q-1),b^2+4*(p-q*q)+3*c^2*(q-1)*(q-1)-3*d^2*(p-q)^2+3*b^2*d^2*(p-1)^2+b^2*p*(p-2)+6*b*d*c*(p+q+q*p-1);
946}
947example
948{ "EXAMPLE:"; echo = 2;
949ring r=0,(a,b,c,d,e,f),dp;
950ideal i=2adef+3be2f-cef2,4ad2f+5bdef+cdf2,2abdf+3b2ef-bcf2,4a2df+5abef+acf2,4ad2e+3bde2+7cdef, 2acde+3bce2-c2ef, 4abde+3b2e2-4acdf+2bcef-c2f2, 4a2de+3abe2+7acef, 4acd2+5bcde+c2df, 4abd2+3b2de+7bcdf, 16a2d2-9b2e2+32acdf-18bcef+7c2f2, 2abcd+3b2ce-bc2f, 4a2cd+5abce+ac2f, 4a2bd+3ab2e+7abcf, abc2f-cdef2, ab2cf-bdef2, 2a2bcf+3be2f2-cef3, ab3f-3bdf3, 2a2b2f-4adf3+3bef3-cf4, a3bf+4aef3, 3ac3e-cde3, 3b2c2e-bc3f+2cd2ef, abc2e-cde2f, 6a2c2e-4ade3-3be4+ce3f, 3b3ce-b2c2f+2bd2ef, 2a2bce+3be3f-ce2f2, 3a3ce+4ae3f, 4bc3d+cd3e, 4ac3d-3bc3e-2cd2e2+c4f, 8b2c2d-4ad4-3bd3e-cd3f, 4b3cd+3bd3f, 4ab3d+3b4e-b3cf-6bd2f2, 4a4d+3a3be+a3cf-8ae2f2;
951}
952example
953{ "EXAMPLE:"; echo = 2;
954ring r=0,(x,y,z,t,u,v,w),dp;
955ideal i=2tw+2wy-wz,2uw2-10vw2+20w3-7tu+35tv-70tw, 6tw2+2w2y-2w2z-21t2-7ty+7tz, 2v3-4uvw-5v2w+6uw2+7vw2-15w3-42vy, 6tw+9wy+2vz-3wz-21x, 9uw3-45vw3+135w4+14tv2-70tuw+196tvw-602tw2-14v2z+28uwz+14vwz-28w2z+147ux-735vx+2205wx-294ty+98tz+294yz-98z2, 36tw3+6w3y-9w3z-168t2w-14v2x+28uwx+14vwx-28w2x-28twy+42twz+588tx+392xy-245xz, 2uvw-6v2w-uw2+13vw2-5w3-28tw+14wy, u2w-3uvw+5uw2-28tw+14wy, tuw+tvw-11tw2-2vwy+8w2y+uwz-3vwz+5w2z-21wx, 5tuw-17tvw+33tw2-7uwy+22vwy-39w2y-2uwz+6vwz-10w2z+63wx, 20t2w-12uwx+30vwx-15w2x-10twy-8twz+4wyz, 4t2w-6uwx+12vwx-6w2x+2twy-2wy2-2twz+wyz, 8twx+8wxy-4wxz;
956}
957example
958{ "EXAMPLE:"; echo = 2;
959ring r=0,(a,b,c,d,x,w,u,v),dp;
960ideal i=a+b+c+d,u+v+w+x, 3ab+3ac+3bc+3ad+3bd+3cd+2,bu+cu+du+av+cv+dv+aw+bw+dw+ax+bx+cx,bcu+bdu+cdu+acv+adv+cdv+abw+adw+bdw+abx+acx+bcx,abc+abd+acd+bcd,bcdu+acdv+abdw+abcx;
961}
962example
963{ "EXAMPLE:"; echo = 2;
964ring r=0,(b,x,y,z,s,t,u,v,w),dp;
965ideal i=su+bv, tu+bw,tv+sw,sx+by,tx+bz,ty+sz,vx+uy,wx+uz,wy+vz;
966}
967example
968{ "EXAMPLE:"; echo = 2;
969ring r=0,(t,a,b,c,d,e,f,g,h),dp;
970ideal i=a+c+d-e-h,2df+2cg+2eh-2h2-h-1,3df2+3cg2-3eh2+3h3+3h2-e+4h, 6bdg-6eh2+6h3-3eh+6h2-e+4h, 4df3+4cg3+4eh3-4h4-6h3+4eh-10h2-h-1, 8bdfg+8eh3-8h4+4eh2-12h3+4eh-14h2-3h-1, 12bdg2+12eh3-12h4+12eh2-18h3+8eh-14h2-h-1, -24eh3+24h4-24eh2+36h3-8eh+26h2+7h+1;
971}
972example
973{ "EXAMPLE:"; echo = 2;
974ring r=0,(a,b,c,d,e,f,g,h,k,l),dp;
975ideal i=f2h-1,ek2-1,g2l-1, 2ef2g2hk2+f2g2h2k2+2ef2g2k2l+2f2g2hk2l+f2g2k2l2+ck2, 2e2fg2hk2+2efg2h2k2+2e2fg2k2l+4efg2hk2l+2fg2h2k2l+2efg2k2l2+2fg2hk2l2+2bfh, 2e2f2ghk2+2ef2gh2k2+2e2f2gk2l+4ef2ghk2l+2f2gh2k2l+2ef2gk2l2+2f2ghk2l2+2dgl, e2f2g2k2+2ef2g2hk2+2ef2g2k2l+2f2g2hk2l+f2g2k2l2+bf2, 2e2f2g2hk+2ef2g2h2k+2e2f2g2kl+4ef2g2hkl+2f2g2h2kl+2ef2g2kl2+2f2g2hkl2+2cek, e2f2g2k2+2ef2g2hk2+f2g2h2k2+2ef2g2k2l+2f2g2hk2l+dg2, -e2f2g2hk2-ef2g2h2k2-e2f2g2k2l-2ef2g2hk2l-f2g2h2k2l-ef2g2k2l2-f2g2hk2l2+a2;
976}
977example
978{ "EXAMPLE:"; echo = 2;
979ring r=0,(b,c,d,e,f,g,h,j,k,l),dp;
980ideal i=-k9+9k8l-36k7l2+84k6l3-126k5l4+126k4l5-84k3l6+36k2l7-9kl8+l9, -bk8+8bk7l+k8l-28bk6l2-8k7l2+56bk5l3+28k6l3-70bk4l4-56k5l4+56bk3l5+70k4l5-28bk2l6-56k3l6+8bkl7+28k2l7-bl8-8kl8+l9, ck7-7ck6l-k7l+21ck5l2+7k6l2-35ck4l3-21k5l3+35ck3l4+35k4l4-21ck2l5-35k3l5+7ckl6+21k2l6-cl7-7kl7+l8, -dk6+6dk5l+k6l-15dk4l2-6k5l2+20dk3l3+15k4l3-15dk2l4-20k3l4+6dkl5+15k2l5-dl6-6kl6+l7, ek5-5ek4l-k5l+10ek3l2+5k4l2-10ek2l3-10k3l3+5ekl4+10k2l4-el5-5kl5+l6, -fk4+4fk3l+k4l-6fk2l2-4k3l2+4fkl3+6k2l3-fl4-4kl4+l5, gk3-3gk2l-k3l+3gkl2+3k2l2-gl3-3kl3+l4, -hk2+2hkl+k2l-hl2-2kl2+l3, jk-jl-kl+l2;
981}
982example
983{ "EXAMPLE:"; echo = 2;
984ring r=0,x(0..10),dp;
985ideal i=x(1)*x(0),x(1)*x(2),x(2)*x(3),x(3)*x(4),x(4)*x(5),x(5)*x(6),x(6)*x(7),x(7)*x(8),x(8)*x(9),x(9)*x(10),x(10)*x(0);
986}
987example
988{ "EXAMPLE:"; echo = 2;
989ring r=0,(a,b,c,d,e,f,g,h,j,k,l,m,n,o,p,q,s),dp;
990ideal i=ag,gj+am+np+q,bl,nq,bg+bk+al+lo+lp+b+c,ag+ak+jl+bm+bn+go+ko+gp+kp+lq+a+d+f+h+o+p,gj+jk+am+an+mo+no+mp+np+gq+kq+e+j+q+s-1,jm+jn+mq+nq,jn+mq+2nq,gj+am+2an+no+np+2gq+kq+q+s,2ag+ak+bn+go+gp+lq+a+d,bg+al, an+gq, 2jm+jn+mq, gj+jk+am+mo+2mp+np+e+2j+q, jl+bm+gp+kp+a+f+o+2p,lp+b,jn+mq,gp+a;
991}
992example
993{ "EXAMPLE:"; echo = 2;
994ring r=0,(a,b,c,d,e,f,g,h,v,w,k,l,m,n,o,p,q,s,t,u),dp;
995ideal i=af+bg+ch+dv+ew-1/2, a2f+b2g+c2h+d2v+e2w-1/3,tdw+agk+ahl+bhm+avn+bvo+cvp+awq+bwu+cws-1/6, a3f+b3g+c3h+d3v+e3w-1/4, tdew+abgk+achl+bchm+advn+bdvo+cdvp+aewq+bewu+cews-1/8, td2w+a2gk+a2hl+b2hm+a2vn+b2vo+c2vp+a2wq+b2wu+c2ws-1/12, ahkm+tawn+tbwo+avko+tcwp+avlp+bvmp+awku+awls+bwms-1/24, a4f+b4g+c4h+d4v+e4w-1/5, tde2w+ab2gk+ac2hl+bc2hm+ad2vn+bd2vo+cd2vp+ae2wq+be2wu+ce2ws-1/10, td2ew+a2bgk+a2chl+b2chm+a2dvn+b2dvo+c2dvp+a2ewq+b2ewu+c2ews-1/15,achkm+taewn+tbewo+advko+tcewp+advlp+bdvmp+aewku+aewls+bewms-1/30,t2d2w+a2gk2+a2hl2+2abhlm+b2hm2+a2vn2+2abvno+b2vo2+2acvnp+2bcvop+c2vp2+2tadwq+a2wq2+2tbdwu+2abwqu+b2wu2+2tcdws+2acwqs+2bcwus+c2ws2-1/20,td3w+a3gk+a3hl+b3hm+a3vn+b3vo+c3vp+a3wq+b3wu+c3ws-1/20,abhkm+tadwn+tbdwo+abvko+tcdwp+acvlp+bcvmp+abwku+acwls+bcwms-1/40,a2hkm+ta2wn+tb2wo+a2vko+tc2wp+a2vlp+b2vmp+a2wku+a2wls+b2wms-1/60,tawko+tawlp+tbwmp+avkmp+awkms-1/20;
996}
997*/
Note: See TracBrowser for help on using the repository browser.