source: git/Singular/LIB/noether.lib @ 0dd77c2

spielwiese
Last change on this file since 0dd77c2 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: 28.1 KB
Line 
1// AH last modified:  01.07.2007
2//////////////////////////////////////////////////////////////////////////////
3version = "$Id$";
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' (presented in ASCM 2007)
18
19This library computes also Castelnuovo-Mumford regularity and satiety of an
20ideal.  A modular version of these algorithms is also provided.
21The procedures are based on a paper of Amir Hashemi 'Computation of
22Castelnuovo-Mumford regularity and satiety' (preprint 2008)
23
24
25PROCEDURES:
26 NPos_test(id);  checks whether monomial ideal id is in Noether position
27 modNpos_test(id); the same as above using modular methods
28 NPos(id);       Noether normalization of ideal id
29 modNPos(id);      Noether normalization of ideal id by modular methods
30 nsatiety(id); Satiety of ideal id
31 modsatiety(id)  Satiety of ideal id by modular methods
32 regCM(id);    Castelnuovo-Mumford regularity of ideal id
33 modregCM(id); Castelnuovo-Mumford regularity of ideal id by modular methods
34";
35LIB "elim.lib";
36LIB "algebra.lib";
37LIB "poly.lib";
38LIB "ring.lib";
39LIB "presolve.lib";
40
41///////////////////////////////////////////////////////////////////////////////
42
43proc NPos_test (ideal I)
44"
45USAGE:  NPos_test (I); I monomial ideal
46RETURN: A list whose first element is 1, if i is in Noether position,
47        0 otherwise. The second element of this list is a list of variables ordered
48        such that those variables are listed first, of which a power belongs to the
49        initial ideal of i. If i is in Noether position, the method returns furthermore
50        the dimension of i.
51ASSUME: i is a nonzero monomial ideal.
52"
53{
54//--------------------------- initialisation ---------------------------------
55   int  time,ii,j,k,l,d,t,jj;
56   intvec v;
57   def r0 = basering;
58   int n = nvars(r0)-1;
59   list L,Y,P1,P2,P3;
60   if (I[1]==1)
61   {
62     print("The ideal is 1");return(1);
63   }
64   for ( ii = 1; ii <= n+1; ii++ )
65   {
66     L[ii]=0;
67   }
68   for ( ii = 1; ii <= size(I); ii++ )
69   {
70     Y=findvars(I[ii],1)[1];
71     l=rvar(Y[1][1]);
72     if (size(Y[1])==1)
73     {
74       L[l]=1;
75       P1=insert(P1,Y[1][1]);
76     }
77     if (L[l]==0)
78     {
79       L[l]=-1;
80     }
81   }
82   t=size(P1);
83   if (t==0)
84   {
85     for ( jj = 1; jj <= n+1; jj++ )
86     {
87       P3=insert(P3,varstr(jj));
88     }
89   }
90   else
91   {
92     P2=findvars(ideal(P1[1..t]),1)[3];
93     for ( jj = 1; jj <= size(P2[1]); jj++ )
94     {
95       P3=insert(P3,P2[1][jj]);
96     }
97   }
98   if (L[n+1]==-1)
99   {
100     return(list(0,P1+P3));
101   }
102   for ( ii = 1; ii <= n; ii++ )
103   {
104     if (L[ii]==-1)
105     {
106       return(list(0,P1+P3));
107     }
108     if (L[ii]==0 and L[ii+1]==1)
109     {
110       return(list(0,P1+P3));
111     }
112   }
113   d=n+1-sum(L);
114   print("The dimension of the ideal is:");print(d);
115   return(list(1,P1+P3));
116}
117//////////////////////////////////////////
118proc modNpos_test (ideal i)
119"USAGE: modNpos_test(i); i an ideal
120RETURN: 1 if i is in Noether position 0  otherwise.
121NOTE:   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).
122"
123{
124  "// WARNING:
125// The procedure is probabilistic and  it computes the initial of the ideal modulo the prime number 2147483647";
126  int p;
127  def br=basering;
128  setring br;
129  ideal I;
130  list #;
131  option(redSB);
132  p=2147483647;
133  #=ringlist(br);
134  #[1]=p;
135  def oro=ring(#);
136  setring oro;
137  ideal sbi,lsbi;
138  sbi=fetch(br,i);
139  lsbi=lead(std(sbi));
140  setring br;
141  I=fetch(oro,lsbi);
142  I=simplify(I,1);
143  attrib(I,"isSB",1);
144  return(NPos_test(I));
145}
146
147
148///////////////////////////////////////////////////////////////////////////////
149proc NPos (ideal i)
150"USAGE:  NPos(i); i ideal
151RETURN:  A linear map phi such that  phi(i) is in Noether position
152"
153{
154//--------------------------- initialisation ---------------------------------
155  int ii,jj,d,time,n,nl;
156  intmat ran;
157  def r0 = basering;
158  ideal K,chcoord;
159  n = nvars(r0)-1;
160  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
161  execute(s);
162  ideal i,sbi,I,K,chcoord,m,L;
163  list #;
164  poly P;
165  map phi;
166  i = fetch(r0,i);
167  time=rtimer;
168  system("--ticks-per-sec",10);
169  i=std(i);
170  sbi=sort(lead(i))[1];
171  #=NPos_test(sbi);
172  if ( #[1]== 1 )
173  {
174    return ("The ideal is in Noether position and the time of this computation is:",rtimer-time,"/10 sec.");
175  }
176  else
177  {
178    L=maxideal(1);
179    chcoord=maxideal(1);
180    for ( ii = 1; ii<=n+1; ii++ )
181    {
182      chcoord[rvar(#[2][ii])]=L[ii];
183    }
184    phi=r1,chcoord;
185    sbi=phi(sbi);
186    if ( NPos_test(sbi)[1] == 1 )
187    {
188      setring r0;
189      chcoord=fetch(r1,chcoord);
190      return (chcoord,"and the time of this computation is:",rtimer-time,"/10 sec.");
191    }
192  }
193  while ( nl < 30 )
194  {
195    nl=nl+1;
196    I=i;
197    L=maxideal(1);
198    for ( ii = n; ii>=0; ii-- )
199    {
200      chcoord=select1(maxideal(1),1..ii);
201      ran=random(100,1,ii);
202      ran=intmat(ran,1,ii+1);
203      ran[1,ii+1]=1;
204      m=select1(maxideal(1),1..(ii+1));
205      for ( jj = 1; jj<=ii+1; jj++ )
206      {
207        P=P+ran[1,jj]*m[jj];
208      }
209      chcoord[ii+1]=P;
210      L[ii+1]=P;
211      P=0;
212      phi=r1,chcoord;
213      I=phi(I);
214      if ( NPos_test(sort(lead(std(I)))[1])[1] == 1 )
215      {
216        K=x(ii..n);
217        setring r0;
218        K=fetch(r1,K);
219        ideal L=fetch(r1,L);
220        return (L,"and the time of this computation is:",rtimer-time,"/10 sec.");
221      }
222    }
223  }
224  "// WARNING:
225// The procedure has entered in more than 30 loops: in your example
226// the method may enter an infinite loop over a finite field!";
227  return (-1);
228}
229///////////////////////////////////////////////////////////////////////////////
230proc modNPos (ideal i)
231"USAGE:  modNPos(i); i ideal
232RETURN:  A linear map phi such that  phi(i) is in Noether position
233NOTE:    It uses the procedure  modNPos_test to test Noether position.
234"
235{
236//--------------------------- initialisation ---------------------------------
237   int ii,jj,d,time,n,nl;
238   intmat ran;
239   def r0 = basering;
240   ideal K,chcoord;
241   n = nvars(r0)-1;
242   string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
243   execute(s);
244   ideal i,sbi,I,K,chcoord,m,L;
245   poly P;
246   list #;
247   map phi;
248   i = fetch(r0,i);
249   time=rtimer;
250   system("--ticks-per-sec",10);
251   #=modNPos_test(i);
252   if ( #[1]== 1 )
253   {
254     return ("The ideal is in Noether position and the time of this computation is:",rtimer-time,"/10 sec.");
255   }
256   else
257   {
258     L=maxideal(1);
259     chcoord=maxideal(1);
260     for ( ii = 1; ii<=n+1; ii++ )
261     {
262       chcoord[rvar(#[2][ii])]=L[ii];
263     }
264     phi=r1,chcoord;
265     I=phi(i);
266     if ( modNPos_test(I)[1] == 1 )
267     {
268       setring r0;
269       chcoord=fetch(r1,chcoord);
270       return (chcoord,"and the time of this computation is:",rtimer-time,"/10 sec.");
271     }
272   }
273   while ( nl < 30 )
274   {
275     nl=nl+1;
276     I=i;
277     L=maxideal(1);
278     for ( ii = n; ii>=0; ii-- )
279     {
280       chcoord=select1(maxideal(1),1..ii);
281       ran=random(100,1,ii);
282       ran=intmat(ran,1,ii+1);
283       ran[1,ii+1]=1;
284       m=select1(maxideal(1),1..(ii+1));
285       for ( jj = 1; jj<=ii+1; jj++ )
286       {
287         P=P+ran[1,jj]*m[jj];
288       }
289       chcoord[ii+1]=P;
290       L[ii+1]=P;
291       P=0;
292       phi=r1,chcoord;
293       I=phi(I);
294       if ( modNPos_test(I)[1] == 1 )
295       {
296         K=x(ii..n);
297         setring r0;
298         K=fetch(r1,K);
299         ideal L=fetch(r1,L);
300         return (L,"and the time of this computation is:",rtimer-time,"/10 sec.");
301       }
302     }
303   }
304   "// WARNING:
305// The procedure has entered in more than 30 loops: in your example
306// the method may enter an infinite loop over a finite field!";
307   return (-1);
308}
309
310////////////////////////////////////////////////////////////////////////////////////
311proc Test (ideal i)
312"USAGE:   Test (i); i a monomial ideal,
313RETURN:  1 if the last variable is in generic position for i and 0 otherwise.
314THEORY:  The last variable is in generic position if the quotient of the ideal
315         with respect to this variable is equal to the quotient of the ideal with respect to the maximal ideal.
316"
317{
318//--------------------------- initialisation ---------------------------------
319  int n,ret;
320  def r0 = basering;
321  n = nvars(r0)-1;
322  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
323  execute(s);
324  ideal I,i;
325  i = fetch(r0,i);
326  attrib(i,"isSB",1);
327  I=quotient(select(i,n+1),x(n));
328  I=I*maxideal(1);
329  ret=1;
330  if (size(reduce(I,i)) <> 0)
331  {
332    ret=0;
333  }
334  return(ret);
335}
336
337
338////////////////////////////////////////////////////////////////////////////////////
339proc nsatiety (ideal i)
340"USAGE:   nsatiety (i); i ideal,
341RETURN:  an integer, the satiety of i.
342         (returns -1 if i is not homogeneous)
343ASSUME:  i is a homogeneous ideal of the basering R=K[x(0)..x(n)].
344THEORY:  The satiety, or saturation index, of a homogeneous ideal i is the
345         least integer s such that, for all d>=s, the degree d part of the
346         ideals i and isat=sat(i,maxideal(1))[1] coincide.
347"
348{
349//--------------------------- initialisation ---------------------------------
350  int e,ii,jj,h,d,time,lastv,nl,ret;
351  intmat ran;
352  def r0 = basering;
353  int n = nvars(r0)-1;
354  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
355  execute(s);
356  ideal i,sbi,I,K,chcoord,m,L;
357  poly P;
358  map phi;
359  i = fetch(r0,i);
360  time=rtimer;
361  system("--ticks-per-sec",100);
362  sbi=std(i);
363//----- Check ideal homogeneous
364  if ( homog(sbi) == 0 )
365  {
366    dbprint(2,"The ideal is not homogeneous, and time for this test is: " + string(rtimer-time) + "/100sec.");
367    return ();
368  }
369  I=simplify(lead(sbi),1);
370  attrib(I,"isSB",1);
371  K=select(I,n+1);
372  if (size(K) == 0)
373  {
374    dbprint(2,"sat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
375    return();
376  }
377  if (Test(I) == 1 )
378  {
379    dbprint(2,"sat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
380    return();
381  }
382  while ( nl < 5 )
383  {
384    nl=nl+1;
385    chcoord=select1(maxideal(1),1..n);
386    ran=random(100,1,n);
387    ran=intmat(ran,1,n+1);
388    ran[1,n+1]=1;
389    m=select1(maxideal(1),1..(n+1));
390    for ( jj = 1; jj<=n+1; jj++ )
391    {
392      P=P+ran[1,jj]*m[jj];
393    }
394    chcoord[n+1]=P;
395    P=0;
396    phi=r1,chcoord;
397    L=std(phi(i));
398    I=simplify(lead(L),1);
399    attrib(I,"isSB",1);
400    K=select(I,n+1);
401    if (size(K) == 0)
402    {
403      dbprint(2,"sat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
404      return();
405    }
406    if (Test(I) == 1 )
407    {
408      dbprint(2,"sat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
409      return();
410    }
411  }
412}
413
414
415//////////////////////////////////////////////////////////////////////////////
416proc modsatiety (ideal i)
417"USAGE:   modsatiety(i); i ideal,
418RETURN:  an integer, the satiety of i.
419         (returns -1 if i is not homogeneous)
420ASSUME:  i is a homogeneous ideal of the basering R=K[x(0)..x(n)].
421THEORY:  The satiety, or saturation index, of a homogeneous ideal i is the
422         least integer s such that, for all d>=s, the degree d part of the
423         ideals i and isat=sat(i,maxideal(1))[1] coincide.
424NOTE:    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).
425"
426{
427//--------------------------- initialisation ---------------------------------
428  "// WARNING: The characteristic of base field must be zero.
429// The procedure is probabilistic and  it computes the
430//initial ideals modulo the prime number 2147483647.";
431  int e,ii,jj,h,d,time,lastv,nl,ret,s1,d1,siz,j,si,u,k,p;
432  intvec v1;
433  intmat ran;
434  def r0 = basering;
435  int n = nvars(r0)-1;
436  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
437  execute(s);
438  ideal i,sbi,I,K,chcoord,m,L,sbi1,lsbi1,id1;
439  vector V1;
440  list #,LL,PL,Gb1,VGb1,Gb2,VGb2,Res1,Res2;
441  poly P;
442  map phi;
443  time=rtimer;
444  system("--ticks-per-sec",100);
445  i = fetch(r0,i);
446//----- Check ideal homogeneous
447  if ( homog(i) == 0 )
448  {
449    "// WARNING: The ideal is not homogeneous.";
450    dbprint(2,"Time for this test is: " + string(rtimer-time) + "/100sec.");
451    return ();
452  }
453  option(redSB);
454  p=2147483647;
455  list r2=ringlist(r1);
456  r2[1]=p;
457  def oro=ring(r2);
458  setring oro;
459  ideal sbi=fetch(r1,i);
460  sbi=std(sbi);
461  setring r1;
462  sbi=fetch(oro,sbi);
463  kill oro;
464  I=simplify(lead(sbi),1);
465  attrib(I,"isSB",1);
466  K=select(I,n+1);
467  if (size(K) == 0)
468  {
469    dbprint(2,"msat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
470    return();
471  }
472  if (Test(I) == 1 )
473  {
474    dbprint(2,"msat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
475    return();
476  }
477  while ( nl < 30 )
478  {
479    nl=nl+1;
480    chcoord=select1(maxideal(1),1..n);
481    ran=random(100,1,n);
482    ran=intmat(ran,1,n+1);
483    ran[1,n+1]=1;
484    m=select1(maxideal(1),1..(n+1));
485    for ( jj = 1; jj<=n+1; jj++ )
486    {
487      P=P+ran[1,jj]*m[jj];
488    }
489    chcoord[n+1]=P;
490    P=0;
491    phi=r1,chcoord;
492    sbi=phi(i);
493    list r2=ringlist(r1);
494    r2[1]=p;
495    def oro=ring(r2);
496    setring oro;
497    ideal sbi=fetch(r1,sbi);
498    sbi=std(sbi);
499    setring r1;
500    sbi=fetch(oro,sbi);
501    kill oro;
502    lsbi1=lead(sbi);
503    attrib(lsbi1,"isSB",1);
504    K=select(lsbi1,n+1);
505    if (size(K) == 0)
506    {
507      dbprint(2,"msat(i)=0 and the time of this computation: " + string(rtimer-time) + "/100sec.");
508      return();
509    }
510    if (Test(lsbi1) == 1 )
511    {
512      dbprint(2,"msat(i)=" + string(maxdeg1(K)) + " and the time of this computation: " + string(rtimer-time) + "/100sec.");
513      return();
514    }
515  }
516}
517
518//////////////////////////////////////////////////////////////////////////////
519//
520proc reg (ideal i)
521"USAGE:  reg (i); i ideal
522RETURN:  the Castelnuovo-Mumford regularity of i.
523         (returns -1 if i is not homogeneous)
524ASSUME:  i is a homogeneous ideal.
525"
526{
527//--------------------------- initialisation ---------------------------------
528  int e,ii,jj,H,h,d,time,nl;
529  def r0 = basering;
530  int n = nvars(r0)-1;
531  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
532  execute(s);
533  ideal i,sbi,I,J,K,L;
534  list #;
535  poly P;
536  map phi;
537  i = fetch(r0,i);
538  time=rtimer;
539  system("--ticks-per-sec",100);
540  sbi=std(i);
541//----- Check ideal homogeneous
542  if ( homog(sbi) == 0 )
543  {
544    "// The ideal is not homogeneous!";
545    return (-1);
546  }
547  I=simplify(lead(sbi),1);
548  attrib(I,"isSB",1);
549  d=dim(I);
550  if (char(r1) > 0 and d == 0)
551  {
552    def r2=changechar("0",r1);
553    setring r2;
554    ideal sbi,I,i,K,T;
555    map phi;
556    I = fetch(r1,I);
557    i=I;
558    attrib(I,"isSB",1);
559  }
560  else
561  {
562    def r2=changechar(charstr(r1),r1);
563    setring r2;
564    ideal sbi,I,i,K,T,ic,Ic;
565    map phi;
566    I = imap(r1,I);
567    Ic=I;
568    attrib(I,"isSB",1);
569    i = imap(r1,i);
570    ic=i;
571  }
572  K=select(I,n+1);
573  if (size(K) == 0)
574  {
575    h=0;
576  }
577  else
578  {
579    if (Test(I) == 1)
580    {
581      h=maxdeg1(K);
582    }
583    else
584    {
585      while ( nl < 30 )
586      {
587        nl=nl+1;
588        phi=r2,randomLast(100);
589        T=phi(i);
590        I=simplify(lead(std(T)),1);
591        attrib(I,"isSB",1);
592        K=select(I,n+1);
593        if (size(K) == 0)
594        {
595          h=0;break;
596        }
597        if (Test(I) == 1 )
598        {
599          h=maxdeg1(K);break;
600        }
601      }
602      i=T;
603    }
604  }
605  for ( ii = n; ii>=n-d+1; ii-- )
606  {
607    i=subst(i,x(ii),0);
608    s = "ring mr = ",charstr(r1),",x(0..ii-1),dp;";
609    execute(s);
610    ideal i,sbi,I,J,K,L,T;
611    poly P;
612    map phi;
613    i=imap(r2,i);
614    I=simplify(lead(std(i)),1);
615    attrib(I,"isSB",1);
616    K=select(I,ii);
617    if (size(K) == 0)
618    {
619      H=0;
620    }
621    else
622    {
623      if (Test(I) == 1)
624      {
625        H=maxdeg1(K);
626      }
627      else
628      {
629        while ( nl < 30 )
630        {
631          nl=nl+1;
632          phi=mr,randomLast(100);
633          T=phi(i);
634          I=simplify(lead(std(T)),1);
635          attrib(I,"isSB",1);
636          K=select(I,ii);
637          if (size(K) == 0)
638          {
639            H=0;break;
640          }
641          if (Test(I) == 1 )
642          {
643            H=maxdeg1(K);break;
644          }
645        }
646        setring r2;
647        i=imap(mr,T);
648        kill mr;
649      }
650    }
651    if (H > h)
652    {
653      h=H;
654    }
655  }
656  if (nl < 30)
657  {
658    dbprint(2,"reg(i)=" + string(h) + " and the time of this computation: " + string(rtimer-time) + " sec./100");
659    return();
660  }
661  else
662  {
663    I=Ic;
664    attrib(I,"isSB",1);
665    i=ic;
666    K=subst(select(I,n+1),x(n),1);
667    K=K*maxideal(maxdeg1(I));
668    if (size(reduce(K,I)) <> 0)
669    {
670      nl=0;
671      while ( nl < 30 )
672      {
673        nl=nl+1;
674        phi=r1,randomLast(100);
675        sbi=phi(i);
676        I=simplify(lead(std(sbi)),1);
677        attrib(I,"isSB",1);
678        K=subst(select(I,n+1),x(n),1);
679        K=K*maxideal(maxdeg1(I));
680        if (size(reduce(K,I)) == 0)
681        {
682          break;
683        }
684      }
685    }
686    h=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1;
687    for ( ii = n; ii> n-d+1; ii-- )
688    {
689      sbi=subst(sbi,x(ii),0);
690      s = "ring mr = ",charstr(r0),",x(0..ii-1),dp;";
691      execute(s);
692      ideal sbi,I,L,K,T;
693      map phi;
694      sbi=imap(r1,sbi);
695      I=simplify(lead(std(sbi)),1);
696      attrib(I,"isSB",1);
697      K=subst(select(I,ii),x(ii-1),1);
698      K=K*maxideal(maxdeg1(I));
699      if (size(reduce(K,I)) <> 0)
700      {
701        nl=0;
702        while ( nl < 30 )
703        {
704          nl=nl+1;
705          L=randomLast(100);
706          phi=mr,L;
707          T=phi(sbi);
708          I=simplify(lead(std(T)),1);
709          attrib(I,"isSB",1);
710          K=subst(select(I,ii),x(ii-1),1);
711          K=K*maxideal(maxdeg1(I));
712          if (size(reduce(K,I)) == 0)
713          {
714            sbi=T;
715            break;
716          }
717        }
718      }
719      H=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1;
720      if (H > h)
721      {
722        h=H;
723      }
724      setring r1;
725      sbi=fetch(mr,sbi);
726      kill mr;
727    }
728    sbi=subst(sbi,x(n-d+1),0);
729    s = "ring mr = ",charstr(r0),",x(0..n-d),dp;";
730    execute(s);
731    ideal sbi,I,L,K,T;
732    map phi;
733    sbi=imap(r1,sbi);
734    I=simplify(lead(std(sbi)),1);
735    attrib(I,"isSB",1);
736    H=maxdeg1(simplify(reduce(quotient(I,maxideal(1)),I),2))+1;
737    if (H > h)
738    {
739      h=H;
740    }
741    dbprint(2,"reg(i)=" + string(h) + " and the time of this computation: " + string(rtimer-time) + " sec./100");
742    return();
743  }
744}
745
746//////////////////////////////////////////////////////////////////////////////
747//
748proc modregCM(ideal i)
749"USAGE:  modregCM(i); i ideal
750RETURN:  an integer, the Castelnuovo-Mumford regularity of i.
751         (returns -1 if i is not homogeneous)
752ASSUME:  i is a homogeneous ideal and the characteristic of base field is zero..
753NOTE:    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).
754"
755{
756//--------------------------- initialisation ---------------------------------
757  "// WARNING: The characteristic of base field musr be zero.
758// This procedure is probabilistic and  it computes the initial
759//ideals modulo the prime number 2147483647";
760  int e,ii,jj,H,h,d,time,p,nl;
761  def r0 = basering;
762  int n = nvars(r0)-1;
763  string s = "ring r1 = ",charstr(r0),",x(0..n),dp;";
764  execute(s);
765  ideal i,sbi,I,J,K,L,lsbi1,lsbi2;
766  list #;
767  poly P;
768  map phi;
769  i = fetch(r0,i);
770  time=rtimer;
771  system("--ticks-per-sec",100);
772//----- Check ideal homogeneous
773  if ( homog(i) == 0 )
774  {
775    "// The ideal is not homogeneous!";
776    return (-1);
777  }
778  option(redSB);
779  p=2147483647;
780  #=ringlist(r1);
781  #[1]=p;
782  def oro=ring(#);
783  setring oro;
784  ideal sbi,lsbi;
785  sbi=fetch(r1,i);
786  lsbi=lead(std(sbi));
787  setring r1;
788  lsbi1=fetch(oro,lsbi);
789  lsbi1=simplify(lsbi1,1);
790  attrib(lsbi1,"isSB",1);
791  kill oro;
792  I=lsbi1;
793  d=dim(I);
794  K=select(I,n+1);
795  if (size(K) == 0)
796  {
797    h=0;
798  }
799  else
800  {
801    if (Test(I) == 1)
802    {
803      h=maxdeg1(K);
804    }
805    else
806    {
807      while ( nl < 30 )
808      {
809        nl=nl+1;
810        phi=r1,randomLast(100);
811        sbi=phi(i);
812        #=ringlist(r1);
813        #[1]=p;
814        def oro=ring(#);
815        setring oro;
816        ideal sbi,lsbi;
817        sbi=fetch(r1,sbi);
818        lsbi=lead(std(sbi));
819        setring r1;
820        lsbi1=fetch(oro,lsbi);
821        lsbi1=simplify(lsbi1,1);
822        attrib(lsbi1,"isSB",1);
823        kill oro;
824        I=lsbi1;
825        K=select(I,n+1);
826        if (size(K) == 0)
827        {
828          h=0;break;
829        }
830        if (Test(I) == 1 )
831        {
832          h=maxdeg1(K);break;
833        }
834      }
835      i=sbi;
836    }
837  }
838  for ( ii = n; ii>=n-d+1; ii-- )
839  {
840    i=subst(i,x(ii),0);
841    s = "ring mr = ","0",",x(0..ii-1),dp;";
842    execute(s);
843    ideal i,sbi,I,J,K,L,lsbi1;
844    poly P;
845    list #;
846    map phi;
847    i=imap(r1,i);
848    #=ringlist(mr);
849    #[1]=p;
850    def oro=ring(#);
851    setring oro;
852    ideal sbi,lsbi;
853    sbi=fetch(mr,i);
854    lsbi=lead(std(sbi));
855    setring mr;
856    lsbi1=fetch(oro,lsbi);
857    lsbi1=simplify(lsbi1,1);
858    attrib(lsbi1,"isSB",1);
859    kill oro;
860    I=lsbi1;
861    K=select(I,ii);
862    if (size(K) == 0)
863    {
864      H=0;
865    }
866    else
867    {
868      if (Test(I) == 1)
869      {
870        H=maxdeg1(K);
871      }
872      else
873      {
874        nl=0;
875        while ( nl < 30 )
876        {
877          nl=nl+1;
878          phi=mr,randomLast(100);
879          sbi=phi(i);
880          #=ringlist(mr);
881          #[1]=p;
882          def oro=ring(#);
883          setring oro;
884          ideal sbi,lsbi;
885          sbi=fetch(mr,sbi);
886          lsbi=lead(std(sbi));
887          setring mr;
888          lsbi1=fetch(oro,lsbi);
889          lsbi1=simplify(lsbi1,1);
890          kill oro;
891          I=lsbi1;
892          attrib(I,"isSB",1);
893          K=select(I,ii);
894          if (size(K) == 0)
895          {
896            H=0;break;
897          }
898          if (Test(I) == 1 )
899          {
900            H=maxdeg1(K);break;
901          }
902        }
903        setring r1;
904        i=imap(mr,sbi);
905        kill mr;
906      }
907    }
908    if (H > h)
909    {
910      h=H;
911    }
912  }
913  dbprint(2,"mreg(i)=" + string(h) + " and the time of this computation: " + string(rtimer-time) + "sec./100");
914  return();
915}
916/*
917//////////////////////////////////////////////////////////////
918example
919{ "EXAMPLE:"; echo = 2;
920ring r=0,(X,Y,a,b),dp;
921poly f=X^8+a*Y^4-Y;
922poly g=Y^8+b*X^4-X;
923poly h=diff(f,X)*diff(g,Y)-diff(f,Y)*diff(g,X);
924ideal i=f,g,h;
925}
926example
927{ "EXAMPLE:"; echo = 2;
928ring r=0,(x,y,z,a,b),dp;
929ideal 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;
930}
931example
932{ "EXAMPLE:"; echo = 2;
933ring r=0,(t,a,b,c,d),dp;
934ideal 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;
935}
936example
937{ "EXAMPLE:"; echo = 2;
938ring r=0,(a,b,c,d,e),dp;
939ideal 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;
940}
941example
942{ "EXAMPLE:"; echo = 2;
943ring r=0,(c,b,d,p,q),dp;
944ideal 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);
945}
946example
947{ "EXAMPLE:"; echo = 2;
948ring r=0,(a,b,c,d,e,f),dp;
949ideal 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;
950}
951example
952{ "EXAMPLE:"; echo = 2;
953ring r=0,(x,y,z,t,u,v,w),dp;
954ideal 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;
955}
956example
957{ "EXAMPLE:"; echo = 2;
958ring r=0,(a,b,c,d,x,w,u,v),dp;
959ideal 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;
960}
961example
962{ "EXAMPLE:"; echo = 2;
963ring r=0,(b,x,y,z,s,t,u,v,w),dp;
964ideal i=su+bv, tu+bw,tv+sw,sx+by,tx+bz,ty+sz,vx+uy,wx+uz,wy+vz;
965}
966example
967{ "EXAMPLE:"; echo = 2;
968ring r=0,(t,a,b,c,d,e,f,g,h),dp;
969ideal 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;
970}
971example
972{ "EXAMPLE:"; echo = 2;
973ring r=0,(a,b,c,d,e,f,g,h,k,l),dp;
974ideal 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;
975}
976example
977{ "EXAMPLE:"; echo = 2;
978ring r=0,(b,c,d,e,f,g,h,j,k,l),dp;
979ideal 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;
980}
981example
982{ "EXAMPLE:"; echo = 2;
983ring r=0,x(0..10),dp;
984ideal 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);
985}
986example
987{ "EXAMPLE:"; echo = 2;
988ring r=0,(a,b,c,d,e,f,g,h,j,k,l,m,n,o,p,q,s),dp;
989ideal 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;
990}
991example
992{ "EXAMPLE:"; echo = 2;
993ring r=0,(a,b,c,d,e,f,g,h,v,w,k,l,m,n,o,p,q,s,t,u),dp;
994ideal 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;
995}
996*/
Note: See TracBrowser for help on using the repository browser.