Changeset e801fe in git for Singular/LIB/primdec.lib


Ignore:
Timestamp:
Feb 16, 1998, 1:07:04 PM (26 years ago)
Author:
Gerhard Pfister <pfister@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'fc741b6502fd8a97288eaa3eba6e5220f3c3df87')
Children:
1e7d8d9fbdaf1094cc869ca3a6be98b9e1fbfc9a
Parents:
437e2c21158af6efe6402cc1da62ee40760c03e0
Message:
* updated invar.lib normal.lib, merged prim_dec.lib with primdec.lib


git-svn-id: file:///usr/local/Singular/svn/trunk@1145 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/primdec.lib

    r437e2c2 re801fe  
    1 // $Id: primdec.lib,v 1.8 1998-01-27 18:51:23 Singular Exp $
     1// $Id: primdec.lib,v 1.9 1998-02-16 12:07:04 pfister Exp $
    22///////////////////////////////////////////////////////
    33// primdec.lib
     
    55// the ideas of Gianni,Trager,Zacharias
    66// written by Gerhard Pfister
     7//
     8// algorithms for primary decomposition based on
     9// the ideas of Shimoyama/Yokoyama
     10// written by Wolfram Decker and Hans Schoenemann
    711//////////////////////////////////////////////////////
    812
     
    1216  //computes the minimal associated primes of the ideal I
    1317
    14   decomp (ideal I)
     18  primdecGTZ (ideal I)
    1519  // Computes a complete primary decomposition via Gianni,Trager,Zacharias
    1620
     
    2428  //computes the radicals of the equidimensional parts of I
    2529
     30  min_ass_prim_charsets (ideal I, int choose)
     31  // minimal associated primes via the  characteristic set
     32  // package written by Michael Messollen.
     33  // The integer choose must be either 0 or 1.
     34  // If choose=0, the given ordering of the variables is used.
     35  // If choose=1, the system tries to find an "optimal ordering",
     36  // which in some cases may considerably speed up the algorithm
     37
     38  // You may also may want to try one of the algorithms for
     39  // minimal associated primes in the the library
     40  // primdec.lib, written by Gerhard Pfister.
     41  // These algorithms are variants of the algorithm
     42  // of Gianni-Trager-Zacharias
     43
     44  primdecSY (ideal I, int choose)
     45
     46  // Computes a complete primary decomposition via
     47  // a variant of the pseudoprimary approach of
     48  // Shimoyama-Yokoyama.
     49  // The integer choose must be either 0, 1, 2 or 3.
     50  // If choose=0, min_ass_prim_charsets with the given
     51  // ordering of the variables is used.
     52  // If choose=1, min_ass_prim_charsets with the "optimized"
     53  // ordering of the variables is used.
     54  // If choose=2, minAssPrimes from primdec.lib is used
     55  // If choose=3, minAssPrimes+factorizing Buchberger from primdec.lib is used
     56
     57LIB "general.lib";
     58LIB "elim.lib";
     59LIB "poly.lib";
    2660LIB "random.lib";
    27 LIB "elim.lib";
    2861///////////////////////////////////////////////////////////////////////////////
    2962
     
    6295   if(ordstr(basering)[1,2]!="dp")
    6396   {
    64       execute "ring @Phelp=("+charstr(@P)+"),("+varstr(@P)+"),dp;";
     97      execute "ring @Phelp=("+charstr(@P)+"),("+varstr(@P)+"),(C,dp);";
    6598      ideal inew=std(imap(@P,id));
    6699      ideal  @h=imap(@P,h);
     
    175208   ideal fac=tsil[2];
    176209   poly f=tsil[3];
    177 
     210   
    178211   ideal star=quotient(laedi,f);
    179 
    180212   action=1;
    181213
     
    190222      {
    191223        g=1;
     224        verg=laedi;
     225       
    192226         for(j=1;j<=size(fac);j++)
    193227         {
     
    198232         }
    199233         verg=quotient(laedi,g);
     234         
    200235         if(specialIdealsEqual(verg,star)==1)
    201236         {
     
    211246      }
    212247   }
    213    l=star,fac,f;
     248   l=star,fac,f;   
    214249   return(l);
    215250}
    216 
    217251
    218252////////////////////////////////////////////////////////////////////////////////
    219253proc testFactor(list act,poly p)
    220254{
     255  poly keep=p;
     256 
    221257   int i;
    222258   poly q=act[1][1]^act[2][1];
     
    230266   {
    231267      "ERROR IN FACTOR";
     268      basering;
     269     
    232270      act;
     271      keep;
     272      pause;
     273     
    233274      p;
    234275      q;
     
    274315     return(@l);
    275316  }
    276   @l=factorize(p,2);
    277   if(npars(basering)>0)
    278   {
     317//  @l=factorize(p,2);
     318  @l=factorize(p);
     319  // if(npars(basering)>0)
     320  // {
    279321     for(@j=1;@j<=size(@l[1]);@j++)
    280322     {
     
    320362        }
    321363     }
    322   }
     364     // }
    323365  return(@l);
    324366}
     
    381423      }
    382424      attrib(k2,"isSB",1);
    383       if(size(reduce(k1,k2))==0)
     425      if(size(reduce(k1,k2,1))==0)
    384426      {
    385427         return(1);
     
    514556         m=m-1;
    515557      }
    516       //check whether i[m] =(c*var(n)+h)^e modulo prm for some
     558      //check whether i[m] =(c*var(n)+h)^e modulo prm for some 
    517559      //h in K[var(n+1),...,var(nvars(basering))], c in K
    518560      //if not (0) is returned, else var(n)+h is added to prm
     
    524566         i[m]=poly(e)^e*leadcoef(i[m])^(e-1)*i[m];
    525567
    526          if (reduce(i[m]-t^e,prm) !=0)
     568         if (reduce(i[m]-t^e,prm,1) !=0)
    527569         {
    528570           return(ideal(0));
     
    606648   {
    607649      i++;
    608       if((size(ser)>0)&&(size(reduce(ser,l[2*i-1]))==0))
     650      if((size(ser)>0)&&(size(reduce(ser,l[2*i-1],1))==0))
    609651      {
    610652         l[2*i-1]=ideal(1);
     
    736778   for(i=1;i<=size(l)/2;i++)
    737779   {
    738       if((size(l[2*i])==0)&&(specialIdealsEqual(keepprime[i],l[2*i-1])!=1))
     780     attrib(l[2*i-1],"isSB",1);
     781     
     782     if((size(ser)>0)&&(size(reduce(ser,l[2*i-1],1))==0)&&(deg(l[2*i-1][1])>0))
     783     {
     784       "Achtung in split";
     785       
     786         l[2*i-1]=ideal(1);
     787         l[2*i]=ideal(1);
     788     }
     789     if((size(l[2*i])==0)&&(specialIdealsEqual(keepprime[i],l[2*i-1])!=1))
    739790      {
    740791         keepprime[i]=std(keepprime[i]);
     
    782833  def   @P = basering;
    783834  int nva = nvars(basering);
    784   int @k,@s,@n,@k1;
    785   list primary,lres,act,@lh,@wh;
    786   map phi,psi;
    787   ideal jmap,helpprim,@qh,@qht;
     835  int @k,@s,@n,@k1,zz;
     836  list primary,lres,lres1,act,@lh,@wh;
     837  map phi,psi,phi1,psi1;
     838  ideal jmap,jmap1,jmap2,helpprim,@qh,@qht,ser1;
    788839  intvec @vh,@hilb;
    789840  string @ri;
     
    796847     return(primary);
    797848  }
    798   j=interred(j);
     849 
     850  j=interred(j); 
    799851  attrib(j,"isSB",1);
    800852  if(vdim(j)==deg(j[1]))
    801   {
    802      if((size(ser)>0)&&(size(reduce(ser,j))==0))
    803      {
    804           primary[1]=ideal(1);
    805           primary[2]=ideal(1);
    806           return(primary);
    807      }
     853  {   
    808854     act=factor(j[1]);
    809855     for(@k=1;@k<=size(act[1]);@k++)
     
    822868       @qh[1]=act[1][@k];
    823869       primary[2*@k]=interred(@qh);
    824      }
    825         return(primary);
     870       attrib( primary[2*@k-1],"isSB",1);
     871       
     872       if((size(ser)>0)&&(size(reduce(ser,primary[2*@k-1],1))==0))
     873       {
     874          primary[2*@k-1]=ideal(1);
     875          primary[2*@k]=ideal(1);         
     876       }
     877     }
     878     return(primary);
    826879  }
    827880
     
    829882  {
    830883     primary[1]=j;
    831      if((size(ser)>0)&&(size(reduce(ser,j))==0))
     884     if((size(ser)>0)&&(size(reduce(ser,j,1))==0))
    832885     {
    833886          primary[1]=ideal(1);
     
    894947  }
    895948  else
    896   {
     949  { 
    897950     primary[1]=j;
    898951     if((size(#)>0)&&(act[2][1]>1))
     
    913966  if(size(#)==0)
    914967  {
     968   
    915969     primary=splitPrimary(primary,ser,@wr,act);
     970     
    916971  }
    917972
     
    922977
    923978  @k=0;
    924   int zz;
    925979  while(@k<(size(primary)/2))
    926980  {
     
    937991    }
    938992  }
     993   
    939994  @k=0;
     995  ideal keep;
    940996  while(@k<(size(primary)/2))
    941997  {
     
    943999    if (size(primary[2*@k])==0)
    9441000    {
    945 //      "the univariat polynomials";
    946 //       int qwe=timer;
    947 //       system("finduni",primary[2*@k-1]);
    9481001
    9491002       jmap=randomLast(100);
    950 //       timer-qwe;
    951 //       primary[2*@k-1];
    952 //       pause;
     1003       jmap1=maxideal(1);
     1004       jmap2=maxideal(1);
     1005       @qht=primary[2*@k-1];
     1006
    9531007       for(@n=2;@n<=size(primary[2*@k-1]);@n++)
    9541008       {
    9551009          if(deg(lead(primary[2*@k-1][@n]))==1)
    9561010          {
     1011             for(zz=1;zz<=nva;zz++)
     1012             {
     1013                if(lead(primary[2*@k-1][@n])/var(zz)!=0)
     1014                {
     1015                   jmap1[zz]=-1/leadcoef(primary[2*@k-1][@n])*primary[2*@k-1][@n]
     1016                   +2/leadcoef(primary[2*@k-1][@n])*lead(primary[2*@k-1][@n]);
     1017                    jmap2[zz]=primary[2*@k-1][@n];
     1018                    @qht[@n]=var(zz);
     1019                     
     1020                }
     1021             }
    9571022             jmap[nva]=subst(jmap[nva],lead(primary[2*@k-1][@n]),0);
    9581023          }
    9591024       }
     1025       if(size(subst(jmap[nva],var(1),0)-var(nva))!=0)
     1026       {
     1027          jmap[nva]=subst(jmap[nva],var(1),0);
     1028       }
     1029       phi1=@P,jmap1;
    9601030       phi=@P,jmap;
    961        jmap[nva]=-(jmap[nva]-2*var(nva));
     1031 
     1032       for(@n=1;@n<=nva;@n++)
     1033       {
     1034          jmap[@n]=-(jmap[@n]-2*var(@n));
     1035       }
    9621036       psi=@P,jmap;
    963        @qht=primary[2*@k-1];
     1037       psi1=@P,jmap2;
     1038
    9641039       @qh=phi(@qht);
     1040       
    9651041       if(npars(@P)>0)
    9661042       {
    9671043          @ri= "ring @Phelp ="
    968                   +string(char(@P))+",("+varstr(@P)+","+parstr(@P)+",@t),dp;";
     1044                  +string(char(@P))+",
     1045                   ("+varstr(@P)+","+parstr(@P)+",@t),(C,dp);";
    9691046       }
    9701047       else
    9711048       {
    9721049          @ri= "ring @Phelp ="
    973                   +string(char(@P))+",("+varstr(@P)+",@t),dp;";
     1050                  +string(char(@P))+",("+varstr(@P)+",@t),(C,dp);";
    9741051       }
    9751052       execute(@ri);
     
    9791056       @hilb=hilb(@qh1,1);
    9801057       @ri= "ring @Phelp1 ="
    981                   +string(char(@P))+",("+varstr(@Phelp)+"),lp;";
     1058                  +string(char(@P))+",("+varstr(@Phelp)+"),(C,lp);";
    9821059       execute(@ri);
    9831060       ideal @qh=homog(imap(@P,@qh),@t);
     
    9891066       kill @Phelp1;
    9901067       @qh=clearSB(@qh);
    991        attrib(@qh,"isSB",1);
    992 
    993        @lh=zero_decomp (@qh,psi(ser),@wr);
    994 
     1068       attrib(@qh,"isSB",1);       
     1069       ser1=phi1(ser);
     1070       @lh=zero_decomp (@qh,phi(ser1),@wr);
     1071//       @lh=zero_decomp (@qh,psi(ser),@wr);
     1072       
     1073       
    9951074       kill lres;
    9961075       list lres;
     
    9991078          helpprim=@lh[2];
    10001079          lres[1]=primary[2*@k-1];
    1001           lres[2]=psi(helpprim);
    1002           if(size(reduce(lres[2],lres[1]))==0)
     1080          ser1=psi(helpprim);
     1081          lres[2]=psi1(ser1);
     1082          if(size(reduce(lres[2],lres[1],1))==0)
    10031083          {
    10041084             primary[2*@k]=primary[2*@k-1];
     
    10141094             {
    10151095                @f=act[1][@n]^act[2][@n];
    1016                 lres[2*@n-1]=interred(primary[2*@k-1]+psi(@f));
     1096                ser1=psi(@f);
     1097                lres[2*@n-1]=interred(primary[2*@k-1]+psi1(ser1));
    10171098                helpprim=@lh[2*@n];
    1018                 lres[2*@n]=psi(helpprim);
     1099                ser1=psi(helpprim);
     1100                lres[2*@n]=psi1(ser1);
    10191101             }
    10201102          }
    10211103          else
    10221104          {
    1023              lres=psi(@lh);
     1105             lres1=psi(@lh);
     1106             lres=psi1(lres1);
    10241107          }
    10251108       }
     
    10271110       {
    10281111          @ri= "ring @Phelp ="
    1029                   +string(char(@P))+",("+varstr(@P)+","+parstr(@P)+",@t),dp;";
     1112                  +string(char(@P))+",
     1113                   ("+varstr(@P)+","+parstr(@P)+",@t),(C,dp);";
    10301114       }
    10311115       else
    10321116       {
    10331117          @ri= "ring @Phelp ="
    1034                   +string(char(@P))+",("+varstr(@P)+",@t),dp;";
     1118                  +string(char(@P))+",("+varstr(@P)+",@t),(C,dp);";
    10351119       }
    10361120       execute(@ri);
     
    10691153       }
    10701154       @ri= "ring @Phelp1 ="
    1071                   +string(char(@P))+",("+varstr(@Phelp)+"),lp;";
     1155                  +string(char(@P))+",("+varstr(@Phelp)+"),(C,lp);";
    10721156       execute(@ri);
    10731157       list @lr=imap(@Phelp,@lr);
     
    11561240        return(1)
    11571241     }
    1158      p=gcd(p,i[k]);
     1242     p=GCD(p,i[k]);
    11591243     if(deg(p)==0)
    11601244     {
     
    12041288   def bsr= basering;
    12051289   string @id=string(h);
    1206    execute "ring @r=0,("+@pa+","+varstr(bsr)+"),dp;";
     1290   execute "ring @r=0,("+@pa+","+varstr(bsr)+"),(C,dp);";
    12071291   execute "ideal @i="+@id+";";
    12081292   poly @p=lcmP(@i);
     
    12501334     if(deg(i[k])!=0)
    12511335     {
    1252         q=gcd(p,i[k]);
     1336        q=GCD(p,i[k]);
    12531337        if(deg(q)==0)
    12541338        {
     
    15141598    @jh=@jh+var(@n);
    15151599  }
    1516   quotring=quotring+"),lp;";
     1600  quotring=quotring+"),(C,lp);";
    15171601
    15181602  return(quotring);
     
    15771661   #[1]=1;
    15781662   def @P=basering;
     1663   list qr=simplifyIdeal(i);
     1664   map phi=@P,qr[2];
     1665   i=qr[1];
     1666   
    15791667   execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),("
    15801668             +ordstr(basering)+");";
     
    15931681      setring @P;
    15941682      list @res=imap(gnir,tluser);
    1595       return(@res);
     1683      return(phi(@res));
    15961684   }
    15971685   list @res,empty;
     
    16061694         setring @P;
    16071695         list @res=maxideal(1);
    1608          return(@res);
     1696         return(phi(@res));
    16091697      }
    16101698      if(dim(@pr[1])>1)
    16111699      {
    16121700         setring @P;
    1613          kill gnir;
    1614          execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),lp;";
     1701        // kill gnir;
     1702         execute "ring gnir1 = ("+charstr(basering)+"),
     1703                              ("+varstr(basering)+"),(C,lp);";
    16151704         ideal i=fetch(@P,i);
    16161705         list @pr=facstd(i);
    1617          ideal ser;
    1618       }
    1619    }
    1620    option(noredSB);
     1706        // ideal ser;
     1707         setring gnir;
     1708         @pr=fetch(gnir1,@pr);
     1709         kill gnir1;
     1710      }
     1711   }
     1712    option(noredSB);
    16211713   int j,k,odim,ndim,count;
    16221714   attrib(@pr[1],"isSB",1);
     
    16621754     for(j=1;j<=size(@pr);j++)
    16631755     {
    1664          @res[j]=decomp(@pr[j],2);
    1665  //      @res[j]=decomp(@pr[j],2,@pr[j],ser);
    1666  //      for(k=1;k<=size(@res[j]);k++)
    1667  //      {
    1668  //         ser=intersect1(ser,@res[j][k]);
    1669  //      }
     1756//@pr[j];
     1757//pause;
     1758        @res[j]=decomp(@pr[j],2);
     1759//       @res[j]=decomp(@pr[j],2,@pr[j],ser);
     1760//       for(k=1;k<=size(@res[j]);k++)
     1761//       {
     1762//          ser=intersect(ser,@res[j][k]);
     1763//       }
    16701764     }
    16711765   }
     
    16741768   setring @P;
    16751769   list @res=imap(gnir,@res);
    1676    return(@res);
     1770   return(phi(@res));
    16771771}
    16781772example
     
    16961790  def P=basering;
    16971791
    1698   execute "ring ir = ("+charstr(basering)+"),("+varstr(basering)+"),lp;";
     1792  execute "ring ir = ("+charstr(basering)+"),("+varstr(basering)+"),(C,lp);";
    16991793  list l=fetch(P,li);
    17001794  list @erg;
     
    17351829        if(size(reduce(i1,i2,1))==0)
    17361830        {
    1737            if(size(reduce(@erg[i],@erg[k]))==0)
     1831           if(size(reduce(@erg[i],@erg[k],1))==0)
    17381832           {
    17391833              @erg[k]=ideal(1);
     
    17431837        if(size(reduce(i2,i1,1))==0)
    17441838        {
    1745            if(size(reduce(@erg[k],@erg[i]))==0)
     1839           if(size(reduce(@erg[k],@erg[i],1))==0)
    17461840           {
    17471841              break;
     
    17801874   return(radical(i,1));
    17811875}
     1876
    17821877///////////////////////////////////////////////////////////////////////////////
    1783 proc decomp (ideal i,list #)
     1878proc decomp(ideal i,list #)
    17841879USAGE:   decomp(i); i ideal  (for primary decomposition)   (resp.
    17851880         decomp(i,1);        (for the minimal associated primes) )
     
    17931888  list primary,indep,ltras;
    17941889  intvec @vh,isat;
    1795   int @wr,@k,@n,@m,@n1,@n2,@n3,homo;
     1890  int @wr,@k,@n,@m,@n1,@n2,@n3,homo,seri,keepdi;
    17961891  ideal peek=i;
    17971892  ideal ser,tras;
    17981893
    1799   int @aa=timer;
    1800 
    1801   homo=homog(i);
    18021894  if(size(#)>0)
    18031895  {
     
    18071899        if(size(#)>1)
    18081900        {
     1901          seri=1;
    18091902          peek=#[2];
    18101903          ser=#[3];
     
    18131906      else
    18141907      {
    1815          peek=#[1];
    1816          ser=#[2];
    1817       }
    1818   }
    1819 
     1908        seri=1;
     1909        peek=#[1];
     1910        ser=#[2];
     1911      }
     1912  }
     1913 
     1914  homo=homog(i);
     1915 
    18201916  if(homo==1)
    18211917  {
    1822      ltras=mstd(i);
    1823      attrib(ltras[1],"isSB",1);
    1824      tras=ltras[1];
    1825      if(dim(tras)==0)
    1826      {
     1918    if(attrib(i,"isSB")!=1)
     1919    {
     1920      ltras=mstd(i);
     1921      attrib(ltras[1],"isSB",1);
     1922    }
     1923    else
     1924    {
     1925      ltras=i,i;
     1926    }
     1927    tras=ltras[1];
     1928    if(dim(tras)==0)
     1929    {
    18271930        primary[1]=ltras[2];
    18281931        primary[2]=maxideal(1);
     
    18361939        return(primary);
    18371940     }
    1838       intvec @hilb=hilb(tras,1);
     1941     intvec @hilb=hilb(tras,1);
     1942     intvec keephilb=@hilb;
    18391943  }
    18401944
     
    18531957  //----------------------------------------------------------------
    18541958
    1855   execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),lp;";
    1856 
     1959  execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),(C,lp);";
    18571960  option(redSB);
    1858   ideal ser=fetch(@P,ser);
    1859   ideal peek=std(fetch(@P,peek));
    1860   homo=homog(peek);
     1961
     1962  ideal ser=fetch(@P,ser); 
    18611963
    18621964  if(homo==1)
    18631965  {
    1864      if(ordstr(@P)[1,2]!="lp")
    1865      {
    1866         ideal @j=std(fetch(@P,i),@hilb);
     1966     if((ordstr(@P)[1]!="(C,lp)")&&(ordstr(@P)[3]!="(C,lp)"))
     1967     {
     1968       ideal @j=std(fetch(@P,i),@hilb);
    18671969     }
    18681970     else
     
    18761978     ideal @j=std(fetch(@P,i));
    18771979  }
    1878 
     1980  option(noredSB);
     1981  if(seri==1)
     1982  {
     1983    ideal peek=fetch(@P,peek);
     1984    attrib(peek,"isSB",1);
     1985  }
     1986  else
     1987  {
     1988    ideal peek=@j;
     1989  }
     1990  if(size(ser)==0)
     1991  {
     1992    ideal fried;
     1993    @n=size(@j);
     1994    for(@k=1;@k<=@n;@k++)
     1995    {
     1996      if(deg(lead(@j[@k]))==1)
     1997      {
     1998        fried[size(fried)+1]=@j[@k];
     1999        @j[@k]=0;
     2000      }
     2001    }
     2002    if(size(fried)>0)
     2003    {
     2004       @j=simplify(@j,2);
     2005       attrib(@j,"isSB",1);
     2006       list pr=decomp(@j);
     2007       for(@k=1;@k<=size(pr);@k++)
     2008       {
     2009         @j=pr[@k]+fried;
     2010         pr[@k]=@j;
     2011       }
     2012       setring @P;
     2013       return(fetch(gnir,pr));
     2014    }
     2015  }
     2016 
    18792017  //----------------------------------------------------------------
    18802018  //j is the ring
     
    18832021  if (dim(@j)==-1)
    18842022  {
    1885      setring @P;
    1886      option(noredSB);
    1887      return(ideal(0));
     2023    setring @P;
     2024    return(ideal(0));
    18882025  }
    18892026
     
    19112048     }
    19122049     setring @P;
    1913      option(noredSB);
    19142050     primary=fetch(gnir,gprimary);
    19152051
    19162052     return(primary);
    19172053  }
    1918 
     2054 
    19192055 //------------------------------------------------------------------
    19202056 //the zero-dimensional case
     
    19232059  if (dim(@j)==0)
    19242060  {
    1925       list gprimary= zero_decomp(@j,ser,@wr);
    1926 
    1927       setring @P;
    1928       option(noredSB);
    1929       primary=fetch(gnir,gprimary);
    1930       if(size(ser)>0)
    1931       {
    1932          primary=cleanPrimary(primary);
    1933       }
    1934       return(primary);
    1935    }
     2061    option(redSB);
     2062    list gprimary= zero_decomp(@j,ser,@wr);
     2063    option(noredSB);
     2064    setring @P;
     2065    primary=fetch(gnir,gprimary);
     2066    if(size(ser)>0)
     2067    {
     2068      primary=cleanPrimary(primary);
     2069    }
     2070    return(primary);
     2071  }
    19362072
    19372073  poly @gs,@gh,@p;
     
    19412077  int jdim=dim(@j);
    19422078  list fett;
    1943   int lauf,di;
     2079  int lauf,di,newtest;
    19442080  //------------------------------------------------------------------
    19452081  //search for a maximal independent set indep,i.e.
     
    19702106      indep=maxIndependSet(@j);
    19712107   }
    1972 
     2108 
    19732109  ideal jkeep=@j;
    19742110
     
    19792115  else
    19802116  {
    1981      execute "ring @Phelp=("+charstr(gnir)+"),("+varstr(gnir)+"),dp;";
    1982   }
    1983   ideal jwork=std(imap(gnir,@j));
     2117     execute "ring @Phelp=("+charstr(gnir)+"),("+varstr(gnir)+"),(C,dp);";
     2118  }
     2119
     2120  if(homo==1)
     2121  {
     2122    if((ordstr(@P)[3]=="d")||(ordstr(@P)[1]=="d")||(ordstr(@P)[1]=="w")
     2123       ||(ordstr(@P)[3]=="w"))
     2124    {
     2125      ideal jwork=imap(@P,tras);
     2126      attrib(jwork,"isSB",1);
     2127    }
     2128    else
     2129    {
     2130      ideal jwork=std(imap(gnir,@j),@hilb);
     2131    }
     2132   
     2133  }
     2134  else
     2135  {
     2136    ideal jwork=std(imap(gnir,@j));
     2137  }
     2138  list hquprimary;
    19842139  poly @p,@q;
    1985   ideal @h,fac;
     2140  ideal @h,fac,ser;
    19862141  di=dim(jwork);
     2142  keepdi=di;
     2143 
    19872144  setring gnir;
    19882145  for(@m=1;@m<=size(indep);@m++)
     
    19902147     isat=0;
    19912148     @n2=0;
     2149     option(redSB);
    19922150     if((indep[@m][1]==varstr(basering))&&(@m==1))
    19932151     //this is the good case, nothing to do, just to have the same notations
     
    19982156        ideal @j=fetch(gnir,@j);
    19992157        attrib(@j,"isSB",1);
     2158        ideal ser=fetch(gnir,ser);
     2159       
    20002160     }
    20012161     else
     
    20132173          ideal @j=std(phi(@j));
    20142174        }
    2015       }
     2175        ideal ser=phi(ser);
     2176       
     2177     }
     2178     option(noredSB);     
    20162179     if((deg(@j[1])==0)||(dim(@j)<jdim))
    20172180     {
     
    20502213    // @j considered in the quotientring
    20512214     ideal @j=imap(gnir1,@j);
    2052      ideal ser=imap(gnir,ser);
     2215     ideal ser=imap(gnir1,ser);
    20532216
    20542217     kill gnir1;
     
    20692232        }
    20702233        //the primary decomposition of j*K(var(nnp+1),..,var(nva))[..the rest..]
    2071 
     2234        option(redSB);       
    20722235        list uprimary= zero_decomp(@j,ser,@wr);
    2073 
     2236        option(noredSB);
    20742237     }
    20752238     else
    20762239     {
    20772240       list uprimary;
     2241       uprimary[1]=ideal(1);
    20782242       uprimary[2]=ideal(1);
    2079        uprimary[1]=ideal(1);
    20802243     }
    20812244
     
    21302293     //here the intersection with the polynomialring
    21312294     //mentioned above is really computed
    2132 
    2133     for(@n=@n3/2+1;@n<=@n2/2;@n++)
    2134      {
     2295     for(@n=@n3/2+1;@n<=@n2/2;@n++)
     2296     {       
    21352297        if(specialIdealsEqual(quprimary[2*@n-1],quprimary[2*@n]))
    21362298        {
     
    21472309        }
    21482310     }
     2311   
    21492312     if(size(@h)>0)
    21502313     {
     
    21552318        @h=imap(gnir,@h);
    21562319        if(@wr!=1)
    2157 //        if(@wr==0)
    2158         {
    2159            @q=minSat(jwork,@h)[2];
     2320        {
     2321          @q=minSat(jwork,@h)[2];   
    21602322        }
    21612323        else
     
    21772339        }
    21782340        jwork=std(jwork,@q);
    2179         if(dim(jwork)<di)
     2341        keepdi=dim(jwork);       
     2342        if(keepdi<di)
    21802343        {
    21812344           setring gnir;
     
    21952358  {
    21962359     @j=ideal(1);
     2360     quprimary[1]=ideal(1);
    21972361     quprimary[2]=ideal(1);
    2198      quprimary[1]=ideal(1);
    2199   }
    2200 
     2362  }
     2363  if((size(quprimary)==0))
     2364  {
     2365    keepdi=di-1;
     2366  } 
    22012367  //---------------------------------------------------------------
    22022368  //notice that j=sat(j,gh) intersected with (j,gh^n)
     
    22052371  if((deg(@j[1])!=0)&&(@wr!=1))
    22062372  {
    2207      int uq=size(quprimary);
    2208      if(uq>0)
    2209      {
     2373     if(size(quprimary)>0)
     2374     {
     2375        setring @Phelp;
     2376        ser=imap(gnir,ser);
     2377        hquprimary=imap(gnir,quprimary);
    22102378        if(@wr==0)
    22112379        {
    2212            ideal htest=quprimary[1];
    2213 
    2214            for (@n1=2;@n1<=size(quprimary)/2;@n1++)
     2380           ideal htest=hquprimary[1];
     2381           for (@n1=2;@n1<=size(hquprimary)/2;@n1++)
    22152382           {
    2216               htest=intersect(htest,quprimary[2*@n1-1]);
     2383              htest=intersect(htest,hquprimary[2*@n1-1]);
    22172384           }
    22182385        }
    22192386        else
    22202387        {
    2221            ideal htest=quprimary[2];
    2222 
    2223            for (@n1=2;@n1<=size(quprimary)/2;@n1++)
     2388           ideal htest=hquprimary[2];
     2389
     2390           for (@n1=2;@n1<=size(hquprimary)/2;@n1++)
    22242391           {
    2225               htest=intersect(htest,quprimary[2*@n1]);
     2392              htest=intersect(htest,hquprimary[2*@n1]);
    22262393           }
    22272394        }
     2395
    22282396        if(size(ser)>0)
    2229         {
    2230            htest=intersect(htest,ser);
    2231         }
    2232         ser=std(htest);
    2233      }
    2234      //we are not ready yet
    2235      if (specialIdealsEqual(ser,peek)!=1)
    2236      {
     2397        {
     2398           ser=intersect(htest,ser);
     2399        }
     2400        else
     2401        {
     2402          ser=htest;
     2403        }
     2404        setring gnir;
     2405        ser=imap(@Phelp,ser);
     2406     }
     2407     if(size(reduce(ser,peek,1))!=0)
     2408     {       
    22372409        for(@m=1;@m<=size(restindep);@m++)
    22382410        {
     2411         // if(restindep[@m][3]>=keepdi)
     2412         // {
    22392413           isat=0;
    22402414           @n2=0;
     2415           option(redSB);
     2416           
    22412417           if(restindep[@m][1]==varstr(basering))
    22422418           //this is the good case, nothing to do, just to have the same notations
     
    22562432              if(homo==1)
    22572433              {
    2258                  ideal @j=std(phi(jkeep),@hilb);
     2434                 ideal @j=std(phi(jkeep),keephilb);
    22592435              }
    22602436              else
     
    22622438                ideal @j=std(phi(jkeep));
    22632439              }
     2440              ideal ser=phi(ser);
    22642441           }
    2265 
     2442           option(noredSB);
     2443           
    22662444           for (lauf=1;lauf<=size(@j);lauf++)
    22672445           {
     
    22952473           // @j considered in the quotientring
    22962474           ideal @j=imap(gnir1,@j);
    2297            ideal ser=imap(gnir,ser);
     2475           ideal ser=imap(gnir1,ser);
    22982476
    22992477           kill gnir1;
     
    23122490           }
    23132491           //the primary decomposition of j*K(var(nnp+1),..,var(nva))[..the rest..]
    2314 
    2315             list uprimary= zero_decomp(@j,ser,@wr);
    2316 
     2492           
     2493           option(redSB);
     2494           list uprimary= zero_decomp(@j,ser,@wr);
     2495           option(noredSB);
     2496           
     2497           
    23172498           //we need the intersection of the ideals in the list quprimary with the
    23182499           //polynomialring, i.e. let q=(f1,...,fr) in the quotientring such an ideal
     
    23492530           @n2=size(quprimary);
    23502531           @n3=@n2;
    2351 
     2532           
    23522533           for(@n1=1;@n1<=size(collectprimary)/2;@n1++)
    23532534           {
     
    23622543              }
    23632544           }
    2364 
     2545           
     2546           
    23652547           //here the intersection with the polynomialring
    23662548           //mentioned above is really computed
     
    23802562                 }
    23812563                 quprimary[2*@n]=sat2(quprimary[2*@n],lnew[2*@n])[1];
    2382              }
    2383              if(@wr==0)
    2384              {
    2385                 ser=std(intersect(ser,quprimary[2*@n-1]));
    2386              }
    2387              else
    2388              {
    2389                 ser=std(intersect(ser,quprimary[2*@n]));
    2390              }
     2564              }
    23912565           }
    2392         }
    2393         //we are not ready yet
    2394         if (specialIdealsEqual(ser,peek)!=1)
     2566           if(@n2>=@n3+2)
     2567           {
     2568              setring @Phelp;
     2569              ser=imap(gnir,ser);
     2570              hquprimary=imap(gnir,quprimary);
     2571              for(@n=@n3/2+1;@n<=@n2/2;@n++)
     2572              {
     2573                if(@wr==0)
     2574                {
     2575                   ser=intersect(ser,hquprimary[2*@n-1]);
     2576                }
     2577                else
     2578                {
     2579                   ser=intersect(ser,hquprimary[2*@n]);
     2580                }
     2581              }
     2582              setring gnir;
     2583              ser=imap(@Phelp,ser);
     2584           }
     2585           
     2586         // }
     2587        }             
     2588        if(size(reduce(ser,peek,1))!=0)
    23952589        {
    23962590           if(@wr>0)
     
    24042598           // here we collect now both results primary(sat(j,gh))
    24052599           // and primary(j,gh^n)
    2406 
    24072600           @n=size(quprimary);
    24082601           for (@k=1;@k<=size(htprimary);@k++)
     
    24122605        }
    24132606     }
     2607     
    24142608   }
    24152609  //------------------------------------------------------------
     
    24172611  //the final result: primary
    24182612  //------------------------------------------------------------
     2613 
    24192614  setring @P;
    24202615  primary=imap(gnir,quprimary);
    2421 
    2422   option(noredSB);
    24232616  return(primary);
    24242617}
     
    24382631
    24392632///////////////////////////////////////////////////////////////////////////////
     2633proc primdecGTZ(ideal i)
     2634{
     2635   return(decomp(i));
     2636}
     2637///////////////////////////////////////////////////////////////////////////////
     2638proc primdecSY(ideal i,int j)
     2639{
     2640   return(prim_dec(i,j));
     2641}
     2642///////////////////////////////////////////////////////////////////////////////
     2643
    24402644proc radical(ideal i,list #)
    24412645{
     
    24442648   if(size(#)>0)
    24452649   {
    2446      il=#[1];
     2650     il=#[1]; 
    24472651   }
    24482652   ideal re=1;
    24492653   option(redSB);
     2654   list qr=simplifyIdeal(i);
     2655   map phi=@P,qr[2];
     2656   i=qr[1];
     2657   
    24502658   list pr=facstd(i);
    24512659
     
    24562664      {
    24572665         ideal @res=maxideal(1);
    2458          return(@res);
     2666         return(phi(@res));
    24592667      }
    24602668      if(dim(pr[1])>1)
    24612669      {
    2462          execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+"),lp;";
     2670         execute "ring gnir = ("+charstr(basering)+"),
     2671                              ("+varstr(basering)+"),(C,lp);";
    24632672         ideal i=fetch(@P,i);
    24642673         list @pr=facstd(i);
     
    24692678   option(noredSB);
    24702679   int s=size(pr);
     2680
    24712681   if(s==1)
    24722682   {
    2473       return(radicalEHV(i,ideal(1),il));
     2683     i=radicalEHV(i,ideal(1),il);
     2684     return(phi(i));
    24742685   }
    24752686   intvec pos;
    24762687   pos[s]=0;
    2477 
    24782688   if(il==1)
    24792689   {
     
    24822692     int odim=dim(pr[1]);
    24832693     int count=1;
    2484 
     2694   
    24852695     for(j=2;j<=s;j++)
    24862696     {
     
    25022712     }
    25032713   }
    2504 
    25052714   for(j=1;j<=s;j++)
    25062715   {
    25072716      if(pos[j]==0)
    25082717      {
    2509          re=intersect1(re,radicalEHV(pr[s+1-j],re,il));
    2510       }
    2511    }
    2512    return(re);
     2718         re=intersect(re,radicalEHV(pr[s+1-j],re,il));
     2719      }
     2720   }
     2721   return(phi(re));
    25132722}
    25142723
     
    25162725{
    25172726   def R=basering;
    2518    execute "ring gnir = ("+charstr(basering)+"),("+varstr(basering)+",@t),dp;";
     2727   execute "ring gnir = ("+charstr(basering)+"),
     2728                        ("+varstr(basering)+",@t),(C,dp);";
    25192729   ideal i=var(nvars(basering))*imap(R,i)+(var(nvars(basering))-1)*imap(R,j);
    25202730   ideal j=eliminate(i,var(nvars(basering)));
     
    25232733   return(phi(j));
    25242734}
    2525 
     2735 
    25262736
    25272737///////////////////////////////////////////////////////////////////////////////
     
    25442754      return(ideal(0));
    25452755   }
    2546 
     2756   
    25472757   def  @P = basering;
    25482758   list indep,allindep,restindep,fett,@mu;
     
    25522762   ideal rad=ideal(1);
    25532763   ideal te=ser;
     2764
    25542765   poly @p,@q;
    25552766   string @va,quotring;
     
    25632774   @j1=m[2];
    25642775   int jdim=dim(@j);
    2565    if(size(reduce(ser,@j))==0)
     2776   if(size(reduce(ser,@j,1))==0)
    25662777   {
    25672778      return(ser);
     
    25952806   {
    25962807      fac=factorize(@j[1],1);
    2597       poly @p=1;
     2808      @p=1;
    25982809      for(@k=1;@k<=size(fac);@k++)
    25992810      {
     
    26032814
    26042815      return(ideal(@p));
    2605    }
     2816   }   
    26062817   //------------------------------------------------------------------
    26072818   //the case of a complete intersection
     
    26192830   if (jdim==0)
    26202831   {
    2621       @j1=system("finduni",@j);
     2832      @j1=system("finduni",@j); 
    26222833      for(@k=1;@k<=size(@j1);@k++)
    26232834      {
     
    26342845      return(@j);
    26352846   }
    2636 
     2847 
    26372848   //------------------------------------------------------------------
    26382849   //search for a maximal independent set indep,i.e.
     
    26432854
    26442855   indep=maxIndependSet(@j);
    2645 
     2856 
    26462857   di=dim(@j);
    26472858
     
    27722983      {
    27732984         fac=ideal(0);
    2774          for(lauf=1;lauf<=ncols(@h);lauf++)
     2985         for(lauf=1;lauf<=ncols(@h);lauf++)   
    27752986         {
    27762987            if(deg(@h[lauf])>0)
     
    27862997         }
    27872998
    2788 
     2999       
    27893000         @mu=mstd(quotient(@j+ideal(@q),rad));
    27903001         @j=@mu[1];
    27913002         attrib(@j,"isSB",1);
    2792 
     3003       
    27933004      }
    27943005      if((deg(rad[1])>0)&&(deg(collectrad[1])>0))
    27953006      {
    2796 int xyz=timer;
    2797 "bei collecterad";
    27983007         rad=intersect(rad,collectrad);
    2799 timer-xyz;
    28003008      }
    28013009      else
     
    28083016
    28093017      te=simplify(reduce(te*rad,@j),2);
    2810 
     3018 
    28113019      if((dim(@j)<di)||(size(te)==0))
    28123020      {
     
    28223030   {
    28233031      return(rad);
    2824    }
    2825    ideal tes=radicalKL(@mu,rad,@wr);
    2826 int sml=timer;
    2827 "bei rad";
    2828    rad=intersect(rad,tes);
    2829 timer-sml;
    2830   // rad=intersect(rad,radicalKL(@mu,ideal(1),@wr));
     3032   }   
     3033  // rad=intersect(rad,radicalKL(@mu,rad,@wr));
     3034   rad=intersect(rad,radicalKL(@mu,ideal(1),@wr));
    28313035
    28323036
     
    28493053      il=#[1];
    28503054   }
     3055   
    28513056   option(redSB);
    28523057   list m=mstd(i);
    28533058        I=m[2];
    28543059   option(noredSB);
    2855    if(size(reduce(re,m[1]))==0)
     3060   if(size(reduce(re,m[1],1))==0)
    28563061   {
    28573062      return(re);
    28583063   }
    28593064   int cod=nvars(basering)-dim(m[1]);
    2860    if(nvars(basering)<9)
     3065   if((nvars(basering)<=5)&&(size(m[2])<=5))
    28613066   {
    28623067      if(cod==size(m[2]))
    28633068      {
    2864          J=minor(jacob(I),cod);
    2865          return(quotient(I,J));
    2866       }
    2867 
     3069        J=minor(jacob(I),cod);
     3070        return(quotient(I,J));
     3071      }
     3072   
    28683073      for(l=1;l<=cod;l++)
    28693074      {
     
    28773082         radI1=quotient(radI0,L);
    28783083
    2879          if(size(reduce(radI1,m[1]))==0)
     3084         if(size(reduce(radI1,m[1],1))==0)
    28803085         {
    28813086            return(I);
     
    28833088         if(il==1)
    28843089         {
     3090     
    28853091            return(radI1);
    28863092         }
     
    28923098            return(radI1);
    28933099         }
    2894          return(intersect(radI1,radicalEHV(I2,re,il)));
     3100         return(intersect(radI1,radicalEHV(I2,re,il)));       
    28953101      }
    28963102   }
     
    29013107{
    29023108  M=prune(M);  //to obtain a small embedding
    2903   return(quotient(M,freemodule(nrows(M))));
     3109  ideal ann=quotient1(M,freemodule(nrows(M)));
     3110  return(ann);
    29043111}
    29053112
     
    29193126  }
    29203127  return(ann);
    2921 }
    2922 
     3128} 
     3129 
    29233130//computes all equidimensional parts of the ideal i
    29243131proc prepareAss(ideal i)
     
    29373144  {
    29383145     list re=mres(i,0);             //fehler in sres
    2939   }
     3146  } 
    29403147  for(e=cod;e<=nvars(basering);e++)
    29413148  {
    29423149     ann=AnnExt_R(e,re);
     3150
    29433151     if(nvars(basering)-dim(std(ann))==e)
    29443152     {
     
    29473155  }
    29483156  return(er);
    2949 }
     3157} 
    29503158
    29513159//computes the annihilator of Ext^n(R/i,R) with given resolution re
     
    29583166     module k=res(f,2)[2];             //the kernel
    29593167     matrix g=transpose(re[n]);        //the image of Hom(_,R)
     3168
    29603169     ideal ann=quotient(g,k);           //the anihilator
    29613170  }
     
    29643173     ideal ann=Ann(transpose(re[n]));
    29653174  }
    2966   return(ann);
    2967 }
    2968 
     3175  return(ann);           
     3176}
     3177
     3178proc quotient1(module a,module b)
     3179{
     3180   int i;
     3181   ideal re=quotient(a,module(b[1]));
     3182   for(i=2;i<=size(b);i++)
     3183   {
     3184      re=intersect1(re,quotient(a,module(b[i])));
     3185   }
     3186   return(re);   
     3187}
     3188
     3189
     3190
     3191proc analyze(list pr)
     3192{
     3193   int ii,jj;
     3194   for(ii=1;ii<=size(pr)/2;ii++)
     3195   {
     3196      dim(std(pr[2*ii]));
     3197      idealsEqual(pr[2*ii-1],pr[2*ii]);
     3198      "===========================";
     3199   }
     3200
     3201   for(ii=size(pr)/2;ii>1;ii--)
     3202   {
     3203      for(jj=1;jj<ii;jj++)
     3204      {
     3205         if(size(reduce(pr[2*jj],std(pr[2*ii],1)))==0)
     3206         {
     3207            "eingebette Komponente";
     3208            jj;
     3209            ii;
     3210         }
     3211      }
     3212   }   
     3213}
     3214
     3215
     3216proc simplifyIdeal(ideal i)
     3217{
     3218  def r=basering;
     3219 
     3220  int j,k;
     3221  map phi;
     3222  poly p;
     3223 
     3224  ideal iwork=i;
     3225  ideal imap1=maxideal(1);
     3226  ideal imap2=maxideal(1);
     3227 
     3228
     3229  for(j=1;j<=nvars(basering);j++)
     3230  {
     3231    for(k=1;k<=size(i);k++)
     3232    {
     3233      if(deg(iwork[k]/var(j))==0)
     3234      {
     3235        p=-1/leadcoef(iwork[k]/var(j))*iwork[k];
     3236        imap1[j]=p+2*var(j);
     3237        phi=r,imap1;
     3238        iwork=phi(iwork);
     3239        iwork=subst(iwork,var(j),0);
     3240        iwork[k]=var(j);
     3241        imap1=maxideal(1);
     3242        imap2[j]=-p;       
     3243        break;
     3244      }
     3245    }
     3246  }
     3247  return(iwork,imap2);
     3248}
     3249
     3250       
     3251///////////////////////////////////////////////////////
     3252// ini_mod
     3253// input: a polynomial p
     3254// output: the initial term of p as needed
     3255// in the context of characteristic sets
     3256//////////////////////////////////////////////////////
     3257
     3258proc ini_mod(poly p)
     3259{
     3260  if (p==0)
     3261  {
     3262    return(0);
     3263  }
     3264  int n; matrix m;
     3265  for( n=nvars(basering); n>0; n=n-1)
     3266  {
     3267    m=coef(p,var(n));
     3268    if(m[1,1]!=1)
     3269    {
     3270      p=m[2,1];
     3271      break;
     3272    }
     3273  }
     3274  if(deg(p)==0)
     3275  {
     3276    p=0;
     3277  }
     3278  return(p);
     3279}
     3280///////////////////////////////////////////////////////
     3281// min_ass_prim_charsets
     3282// input: generators of an ideal PS and an integer cho
     3283// If cho=0, the given ordering of the variables is used.
     3284// Otherwise, the system tries to find an "optimal ordering",
     3285// which in some cases may considerably speed up the algorithm
     3286// output: the minimal associated primes of PS
     3287// algorithm: via characteriostic sets
     3288//////////////////////////////////////////////////////
     3289
     3290
     3291proc min_ass_prim_charsets (ideal PS, int cho)
     3292{
     3293  if((cho<0) and (cho>1))
     3294    {
     3295      "ERROR: <int> must be 0 or 1"
     3296      return();
     3297    }
     3298  if(system("version")>933)
     3299  {
     3300    option(notWarnSB);
     3301  }
     3302  if(cho==0)
     3303  {
     3304    return(min_ass_prim_charsets0(PS));
     3305  }
     3306  else
     3307  {
     3308     return(min_ass_prim_charsets1(PS));
     3309  }
     3310}
     3311///////////////////////////////////////////////////////
     3312// min_ass_prim_charsets0
     3313// input: generators of an ideal PS
     3314// output: the minimal associated primes of PS
     3315// algorithm: via characteristic sets
     3316// the given ordering of the variables is used
     3317//////////////////////////////////////////////////////
     3318
     3319
     3320proc min_ass_prim_charsets0 (ideal PS)
     3321{
     3322
     3323  matrix m=char_series(PS);  // We compute an irreducible
     3324                             // characteristic series
     3325  int i,j,k;
     3326  list PSI;
     3327  list PHI;  // the ideals given by the characteristic series
     3328  for(i=nrows(m);i>=1; i--)
     3329  {
     3330     PHI[i]=ideal(m[i,1..ncols(m)]);
     3331  }
     3332  // We compute the radical of each ideal in PHI
     3333  ideal I,JS,II;
     3334  int sizeJS, sizeII;
     3335  for(i=size(PHI);i>=1; i--)
     3336  {
     3337     I=0;
     3338     for(j=size(PHI[i]);j>0;j=j-1)
     3339     {
     3340       I=I+ini_mod(PHI[i][j]);
     3341     }
     3342     JS=std(PHI[i]);
     3343     sizeJS=size(JS);
     3344     for(j=size(I);j>0;j=j-1)
     3345     {
     3346       II=0;
     3347       sizeII=0;
     3348       k=0;
     3349       while(k<=sizeII)                  // successive saturation
     3350       {
     3351         option(returnSB);
     3352         II=quotient(JS,I[j]);
     3353         option(noreturnSB);
     3354//std
     3355//         II=std(II);
     3356         sizeII=size(II);
     3357         if(sizeII==sizeJS)
     3358         {
     3359            for(k=1;k<=sizeII;k++)
     3360            {
     3361              if(leadexp(II[k])!=leadexp(JS[k])) break;
     3362            }
     3363         }
     3364         JS=II;
     3365         sizeJS=sizeII;
     3366       }
     3367    }
     3368    PSI=insert(PSI,JS);
     3369  }
     3370  int sizePSI=size(PSI);
     3371  // We eliminate redundant ideals
     3372  for(i=1;i<sizePSI;i++)
     3373  {
     3374    for(j=i+1;j<=sizePSI;j++)
     3375    {
     3376      if(size(PSI[i])!=0)
     3377      {
     3378        if(size(PSI[j])!=0)
     3379        {
     3380          if(size(NF(PSI[i],PSI[j],1))==0)
     3381          {
     3382            PSI[j]=ideal(0);
     3383          }
     3384          else
     3385          {
     3386            if(size(NF(PSI[j],PSI[i],1))==0)
     3387            {
     3388              PSI[i]=ideal(0);
     3389            }
     3390          }
     3391        }
     3392      }
     3393    }
     3394  }
     3395  for(i=sizePSI;i>=1;i--)
     3396  {
     3397    if(size(PSI[i])==0)
     3398    {
     3399      PSI=delete(PSI,i);
     3400    }
     3401  }
     3402  return (PSI);
     3403}
     3404
     3405///////////////////////////////////////////////////////
     3406// min_ass_prim_charsets1
     3407// input: generators of an ideal PS
     3408// output: the minimal associated primes of PS
     3409// algorithm: via characteristic sets
     3410// input: generators of an ideal PS and an integer i
     3411// The system tries to find an "optimal ordering" of
     3412// the variables
     3413//////////////////////////////////////////////////////
     3414
     3415
     3416proc min_ass_prim_charsets1 (ideal PS)
     3417{
     3418  def oldring=basering;
     3419  string n=system("neworder",PS);
     3420  execute "ring r="+charstr(oldring)+",("+n+"),dp;";
     3421  ideal PS=imap(oldring,PS);
     3422  matrix m=char_series(PS);  // We compute an irreducible
     3423                             // characteristic series
     3424  int i,j,k;
     3425  ideal I;
     3426  list PSI;
     3427  list PHI;    // the ideals given by the characteristic series
     3428  list ITPHI;  // their initial terms
     3429  for(i=nrows(m);i>=1; i--)
     3430  {
     3431     PHI[i]=ideal(m[i,1..ncols(m)]);
     3432     I=0;
     3433     for(j=size(PHI[i]);j>0;j=j-1)
     3434     {
     3435       I=I,ini_mod(PHI[i][j]);
     3436     }
     3437      I=I[2..ncols(I)];
     3438      ITPHI[i]=I;
     3439  }
     3440  setring oldring;
     3441  matrix m=imap(r,m);
     3442  list PHI=imap(r,PHI);
     3443  list ITPHI=imap(r,ITPHI);
     3444  // We compute the radical of each ideal in PHI
     3445  ideal I,JS,II;
     3446  int sizeJS, sizeII;
     3447  for(i=size(PHI);i>=1; i--)
     3448  {
     3449     I=0;
     3450     for(j=size(PHI[i]);j>0;j=j-1)
     3451     {
     3452       I=I+ITPHI[i][j];
     3453     }
     3454     JS=std(PHI[i]);
     3455     sizeJS=size(JS);
     3456     for(j=size(I);j>0;j=j-1)
     3457     {
     3458       II=0;
     3459       sizeII=0;
     3460       k=0;
     3461       while(k<=sizeII)                  // successive iteration
     3462       {
     3463         option(returnSB);
     3464         II=quotient(JS,I[j]);
     3465         option(noreturnSB);
     3466//std
     3467//         II=std(II);
     3468         sizeII=size(II);
     3469         if(sizeII==sizeJS)
     3470         {
     3471            for(k=1;k<=sizeII;k++)
     3472            {
     3473              if(leadexp(II[k])!=leadexp(JS[k])) break;
     3474            }
     3475         }
     3476         JS=II;
     3477         sizeJS=sizeII;
     3478       }
     3479    }
     3480    PSI=insert(PSI,JS);
     3481  }
     3482  int sizePSI=size(PSI);
     3483  // We eliminate redundant ideals
     3484  for(i=1;i<sizePSI;i++)
     3485  {
     3486    for(j=i+1;j<=sizePSI;j++)
     3487    {
     3488      if(size(PSI[i])!=0)
     3489      {
     3490        if(size(PSI[j])!=0)
     3491        {
     3492          if(size(NF(PSI[i],PSI[j],1))==0)
     3493          {
     3494            PSI[j]=ideal(0);
     3495          }
     3496          else
     3497          {
     3498            if(size(NF(PSI[j],PSI[i],1))==0)
     3499            {
     3500              PSI[i]=ideal(0);
     3501            }
     3502          }
     3503        }
     3504      }
     3505    }
     3506  }
     3507  for(i=sizePSI;i>=1;i--)
     3508  {
     3509    if(size(PSI[i])==0)
     3510    {
     3511      PSI=delete(PSI,i);
     3512    }
     3513  }
     3514  return (PSI);
     3515}
     3516
     3517
     3518/////////////////////////////////////////////////////
     3519// proc prim_dec
     3520// input:  generators of an ideal I and an integer choose
     3521// If choose=0, min_ass_prim_charsets with the given
     3522// ordering of the variables is used.
     3523// If choose=1, min_ass_prim_charsets with the "optimized"
     3524// ordering of the variables is used.
     3525// If choose=2, minAssPrimes from primdec.lib is used
     3526// If choose=3, minAssPrimes+factorizing Buchberger from primdec.lib is used
     3527// output: a primary decomposition of I, i.e., a list
     3528// of pairs consisting of a standard basis of a primary component
     3529// of I and a standard basis of the corresponding associated prime.
     3530// To compute the minimal associated primes of a given ideal
     3531// min_ass_prim_l is called, i.e., the minimal associated primes
     3532// are computed via characteristic sets.
     3533// In the homogeneous case, the performance of the procedure
     3534// will be improved if I is already given by a minimal set of
     3535// generators. Apply minbase if necessary.
     3536//////////////////////////////////////////////////////////
     3537
     3538
     3539proc prim_dec(ideal I, int choose)
     3540{
     3541   if((choose<0) or (choose>3))
     3542   {
     3543     "ERROR: <int> must be 0 or 1 or 2 or 3";
     3544      return();
     3545   }
     3546   if(system("version")>933)
     3547   {
     3548      option(notWarnSB);
     3549    }
     3550  ideal H=1; // The intersection of the primary components
     3551  list U;    // the leaves of the decomposition tree, i.e.,
     3552             // pairs consisting of a primary component of I
     3553             // and the corresponding associated prime
     3554  list W;    // the non-leaf vertices in the decomposition tree.
     3555             // every entry has 6 components:
     3556                // 1- the vertex itself , i.e., a standard bais of the
     3557                //    given ideal I (type 1), or a standard basis of a
     3558                //    pseudo-primary component arising from
     3559                //    pseudo-primary decomposition (type 2), or a
     3560                //    standard basis of a remaining component arising from
     3561                //    pseudo-primary decomposition or extraction (type 3)
     3562                // 2- the type of the vertex as indicated above
     3563                // 3- the weighted_tree_depth of the vertex
     3564                // 4- the tester of the vertex
     3565                // 5- a standard basis of the associated prime
     3566                //    of a vertex of type 2, or 0 otherwise
     3567                // 6- a list of pairs consisting of a standard
     3568                //    basis of a minimal associated prime ideal
     3569                //    of the father of the vertex and the
     3570                //    irreducible factors of the "minimal
     3571                //    divisor" of the seperator or extractor
     3572                //    corresponding to the prime ideal
     3573                //    as computed by the procedure minsat,
     3574                //    if the vertex is of type 3, or
     3575                //    the empty list otherwise
     3576  ideal SI=std(I);
     3577  int ncolsSI=ncols(SI);
     3578  int ncolsH=1;
     3579  W[1]=list(I,1,0,poly(1),ideal(0),list()); // The root of the tree
     3580  int weighted_tree_depth;
     3581  int i,j;
     3582  int check;
     3583  list V;  // current vertex
     3584  list VV; // new vertex
     3585  list QQ;
     3586  list WI;
     3587  ideal Qi,SQ,SRest,fac;
     3588  poly tester;
     3589
     3590  while(1)
     3591  {
     3592    i=1;
     3593    while(1)
     3594    {
     3595      while(i<=size(W)) // find vertex V of smallest weighted tree-depth
     3596      {
     3597        if (W[i][3]<=weighted_tree_depth) break;
     3598        i++;
     3599      }
     3600      if (i<=size(W)) break;
     3601      i=1;
     3602      weighted_tree_depth++;
     3603    }
     3604    V=W[i];
     3605    W=delete(W,i); // delete V from W
     3606
     3607    // now proceed by type of vertex V
     3608
     3609    if (V[2]==2)  // extraction needed
     3610    {
     3611      SQ,SRest,fac=extraction(V[1],V[5]);
     3612                        // standard basis of primary component,
     3613                        // standard basis of remaining component,
     3614                        // irreducible factors of
     3615                        // the "minimal divisor" of the extractor
     3616                        // as computed by the procedure minsat,
     3617      check=0;
     3618      for(j=1;j<=ncolsH;j++)
     3619      {
     3620        if (NF(H[j],SQ,1)!=0) // Q is not redundant
     3621        {
     3622          check=1;
     3623          break;
     3624        }
     3625      }
     3626      if(check==1)             // Q is not redundant
     3627      {
     3628        QQ=list();
     3629        QQ[1]=list(SQ,V[5]);  // primary component, associated prime,
     3630                              // i.e., standard bases thereof
     3631        U=U+QQ;
     3632        H=intersect(H,SQ);
     3633        H=std(H);
     3634        ncolsH=ncols(H);
     3635        check=0;
     3636        if(ncolsH==ncolsSI)
     3637        {
     3638          for(j=1;j<=ncolsSI;j++)
     3639          {
     3640            if(leadexp(H[j])!=leadexp(SI[j]))
     3641            {
     3642              check=1;
     3643              break;
     3644            }
     3645          }
     3646        }
     3647        else
     3648        {
     3649          check=1;
     3650        }
     3651        if(check==0) // H==I => U is a primary decomposition
     3652        {
     3653          return(U);
     3654        }
     3655      }
     3656      if (SRest[1]!=1)        // the remaining component is not
     3657                              // the whole ring
     3658      {
     3659        if (rad_con(V[4],SRest)==0) // the new vertex is not the
     3660                                    // root of a redundant subtree
     3661        {
     3662          VV[1]=SRest;     // remaining component
     3663          VV[2]=3;         // pseudoprimdec_special
     3664          VV[3]=V[3]+1;    // weighted depth
     3665          VV[4]=V[4];      // the tester did not change
     3666          VV[5]=ideal(0);
     3667          VV[6]=list(list(V[5],fac));
     3668          W=insert(W,VV,size(W));
     3669        }
     3670      }
     3671    }
     3672    else
     3673    {
     3674      if (V[2]==3) // pseudo_prim_dec_special is needed
     3675      {
     3676        QQ,SRest=pseudo_prim_dec_special_charsets(V[1],V[6],choose);
     3677                         // QQ = quadruples:
     3678                         // standard basis of pseudo-primary component,
     3679                         // standard basis of corresponding prime,
     3680                         // seperator, irreducible factors of
     3681                         // the "minimal divisor" of the seperator
     3682                         // as computed by the procedure minsat,
     3683                         // SRest=standard basis of remaining component
     3684      }
     3685      else     // V is the root, pseudo_prim_dec is needed
     3686      {
     3687        QQ,SRest=pseudo_prim_dec_charsets(I,SI,choose);
     3688                         // QQ = quadruples:
     3689                         // standard basis of pseudo-primary component,
     3690                         // standard basis of corresponding prime,
     3691                         // seperator, irreducible factors of
     3692                         // the "minimal divisor" of the seperator
     3693                         // as computed by the procedure minsat,
     3694                         // SRest=standard basis of remaining component
     3695
     3696      }
     3697//check
     3698      for(i=size(QQ);i>=1;i--)
     3699      //for(i=1;i<=size(QQ);i++)
     3700      {
     3701        tester=QQ[i][3]*V[4];
     3702        Qi=QQ[i][2];
     3703        if(NF(tester,Qi,1)!=0)  // the new vertex is not the
     3704                                // root of a redundant subtree
     3705        {
     3706          VV[1]=QQ[i][1];
     3707          VV[2]=2;
     3708          VV[3]=V[3]+1;
     3709          VV[4]=tester;      // the new tester as computed above
     3710          VV[5]=Qi;          // QQ[i][2];
     3711          VV[6]=list();
     3712          W=insert(W,VV,size(W));
     3713        }
     3714      }
     3715      if (SRest[1]!=1)        // the remaining component is not
     3716                              // the whole ring
     3717      {
     3718        if (rad_con(V[4],SRest)==0) // the vertex is not the root
     3719                                    // of a redundant subtree
     3720        {
     3721          VV[1]=SRest;
     3722          VV[2]=3;
     3723          VV[3]=V[3]+2;
     3724          VV[4]=V[4];      // the tester did not change
     3725          VV[5]=ideal(0);
     3726          WI=list();
     3727          for(i=1;i<=size(QQ);i++)
     3728          {
     3729            WI=insert(WI,list(QQ[i][2],QQ[i][4]));
     3730          }
     3731          VV[6]=WI;
     3732          W=insert(W,VV,size(W));
     3733        }
     3734      }
     3735    }
     3736  }
     3737}
     3738
     3739//////////////////////////////////////////////////////////////////////////
     3740// proc pseudo_prim_dec_charsets
     3741// input: Generators of an arbitrary ideal I, a standard basis SI of I,
     3742// and an integer choo
     3743// If choo=0, min_ass_prim_charsets with the given
     3744// ordering of the variables is used.
     3745// If choo=1, min_ass_prim_charsets with the "optimized"
     3746// ordering of the variables is used.
     3747// If choo=2, minAssPrimes from primdec.lib is used
     3748// If choo=3, minAssPrimes+factorizing Buchberger from primdec.lib is used
     3749// output: a pseudo primary decomposition of I, i.e., a list
     3750// of pseudo primary components together with a standard basis of the
     3751// remaining component. Each pseudo primary component is
     3752// represented by a quadrupel: A standard basis of the component,
     3753// a standard basis of the corresponding associated prime, the
     3754// seperator of the component, and the irreducible factors of the
     3755// "minimal divisor" of the seperator as computed by the procedure minsat,
     3756// calls  proc pseudo_prim_dec_i
     3757//////////////////////////////////////////////////////////////////////////
     3758
     3759
     3760proc pseudo_prim_dec_charsets (ideal I, ideal SI, int choo)
     3761{
     3762  list L;          // The list of minimal associated primes,
     3763                   // each one given by a standard basis
     3764  if((choo==0) or (choo==1))
     3765    {
     3766       L=min_ass_prim_charsets(I,choo);
     3767    }
     3768  else
     3769    {
     3770      if(choo==2)
     3771      {
     3772        L=minAssPrimes(I);
     3773      }
     3774      else
     3775      {
     3776        L=minAssPrimes(I,1);
     3777      }
     3778      for(int i=size(L);i>=1;i=i-1)
     3779        {
     3780          L[i]=std(L[i]);
     3781        }
     3782    }
     3783  return (pseudo_prim_dec_i(SI,L));
     3784}
     3785
     3786////////////////////////////////////////////////////////////////
     3787// proc pseudo_prim_dec_special_charsets
     3788// input: a standard basis of an ideal I whose radical is the
     3789// intersection of the radicals of ideals generated by one prime ideal
     3790// P_i together with one polynomial f_i, the list V6 must be the list of
     3791// pairs (standard basis of P_i, irreducible factors of f_i),
     3792// and an integer choo
     3793// If choo=0, min_ass_prim_charsets with the given
     3794// ordering of the variables is used.
     3795// If choo=1, min_ass_prim_charsets with the "optimized"
     3796// ordering of the variables is used.
     3797// If choo=2, minAssPrimes from primdec.lib is used
     3798// If choo=3, minAssPrimes+factorizing Buchberger from primdec.lib is used
     3799// output: a pseudo primary decomposition of I, i.e., a list
     3800// of pseudo primary components together with a standard basis of the
     3801// remaining component. Each pseudo primary component is
     3802// represented by a quadrupel: A standard basis of the component,
     3803// a standard basis of the corresponding associated prime, the
     3804// seperator of the component, and the irreducible factors of the
     3805// "minimal divisor" of the seperator as computed by the procedure minsat,
     3806// calls  proc pseudo_prim_dec_i
     3807////////////////////////////////////////////////////////////////
     3808
     3809
     3810proc pseudo_prim_dec_special_charsets (ideal SI,list V6, int choo)
     3811{
     3812  int i,j,l;
     3813  list m;
     3814  list L;
     3815  int sizeL;
     3816  ideal P,SP; ideal fac;
     3817  int dimSP;
     3818  for(l=size(V6);l>=1;l--)   // creates a list of associated primes
     3819                             // of I, possibly redundant
     3820  {
     3821    P=V6[l][1];
     3822    fac=V6[l][2];
     3823    for(i=ncols(fac);i>=1;i--)
     3824    {
     3825      SP=P+fac[i];
     3826      SP=std(SP);
     3827      if(SP[1]!=1)
     3828      {
     3829        if((choo==0) or (choo==1))
     3830        {
     3831          m=min_ass_prim_charsets(SP,choo);  // a list of SB
     3832        }
     3833        else
     3834        {
     3835          if(choo==2)
     3836          {
     3837            m=minAssPrimes(SP);
     3838          }
     3839          else
     3840          {
     3841            m=minAssPrimes(SP,1);
     3842          }
     3843          for(j=size(m);j>=1;j=j-1)
     3844            {
     3845              m[j]=std(m[j]);
     3846            }
     3847        }
     3848        dimSP=dim(SP);
     3849        for(j=size(m);j>=1; j--)
     3850        {
     3851          if(dim(m[j])==dimSP)
     3852          {
     3853            L=insert(L,m[j],size(L));
     3854          }
     3855        }
     3856      }
     3857    }
     3858  }
     3859  sizeL=size(L);
     3860  for(i=1;i<sizeL;i++)     // get rid of redundant primes
     3861  {
     3862    for(j=i+1;j<=sizeL;j++)
     3863    {
     3864      if(size(L[i])!=0)
     3865      {
     3866        if(size(L[j])!=0)
     3867        {
     3868          if(size(NF(L[i],L[j],1))==0)
     3869          {
     3870            L[j]=ideal(0);
     3871          }
     3872          else
     3873          {
     3874            if(size(NF(L[j],L[i],1))==0)
     3875            {
     3876              L[i]=ideal(0);
     3877            }
     3878          }
     3879        }
     3880      }
     3881    }
     3882  }
     3883  for(i=sizeL;i>=1;i--)
     3884  {
     3885    if(size(L[i])==0)
     3886    {
     3887      L=delete(L,i);
     3888    }
     3889  }
     3890  return (pseudo_prim_dec_i(SI,L));
     3891}
     3892
     3893
     3894////////////////////////////////////////////////////////////////
     3895// proc pseudo_prim_dec_i
     3896// input: A standard basis of an arbitrary ideal I, and standard bases
     3897// of the minimal associated primes of I
     3898// output: a pseudo primary decomposition of I, i.e., a list
     3899// of pseudo primary components together with a standard basis of the
     3900// remaining component. Each pseudo primary component is
     3901// represented by a quadrupel: A standard basis of the component Q_i,
     3902// a standard basis of the corresponding associated prime P_i, the
     3903// seperator of the component, and the irreducible factors of the
     3904// "minimal divisor" of the seperator as computed by the procedure minsat,
     3905////////////////////////////////////////////////////////////////
     3906
     3907
     3908proc pseudo_prim_dec_i (ideal SI, list L)
     3909{
     3910  list Q;
     3911  if (size(L)==1)               // one minimal associated prime only
     3912                                // the ideal is already pseudo primary
     3913  {
     3914    Q=SI,L[1],1;
     3915    list QQ;
     3916    QQ[1]=Q;
     3917    return (QQ,ideal(1));
     3918  }
     3919
     3920  poly f0,f,g;
     3921  ideal fac;
     3922  int i,j,k,l;
     3923  ideal SQi;
     3924  ideal I'=SI;
     3925  list QP;
     3926  int sizeL=size(L);
     3927  for(i=1;i<=sizeL;i++)
     3928  {
     3929    fac=0;
     3930    for(j=1;j<=sizeL;j++)           // compute the seperator sep_i
     3931                                    // of the i-th component
     3932    {
     3933      if (i!=j)                       // search g not in L[i], but L[j]
     3934      {
     3935        for(k=1;k<=ncols(L[j]);k++)
     3936        {
     3937          if(NF(L[j][k],L[i],1)!=0)
     3938          {
     3939            break;
     3940          }
     3941        }
     3942        fac=fac+L[j][k];
     3943      }
     3944    }
     3945    // delete superfluous polynomials
     3946    fac=simplify(fac,8);
     3947    // saturation
     3948    SQi,f0,f,fac=minsat_ppd(SI,fac);
     3949    I'=I',f;
     3950    QP=SQi,L[i],f0,fac;
     3951             // the quadrupel:
     3952             // a standard basis of Q_i,
     3953             // a standard basis of P_i,
     3954             // sep_i,
     3955             // irreducible factors of
     3956             // the "minimal divisor" of the seperator
     3957             //  as computed by the procedure minsat,
     3958    Q[i]=QP;
     3959  }
     3960  I'=std(I');
     3961  return (Q, I');
     3962                   // I' = remaining component
     3963}
     3964
     3965
     3966////////////////////////////////////////////////////////////////
     3967// proc extraction
     3968// input: A standard basis of a pseudo primary ideal I, and a standard
     3969// basis of the unique minimal associated prime P of I
     3970// output: an extraction of I, i.e., a standard basis of the primary
     3971// component Q of I with associated prime P, a standard basis of the
     3972// remaining component, and the irreducible factors of the
     3973// "minimal divisor" of the extractor as computed by the procedure minsat
     3974////////////////////////////////////////////////////////////////
     3975
     3976
     3977proc extraction (ideal SI, ideal SP)
     3978{
     3979  list indsets=system("indsetall",SP,0);
     3980  poly f;
     3981  if(size(indsets)!=0)      //check, whether dim P != 0
     3982  {
     3983    intvec v;               // a maximal independent set of variables
     3984                            // modulo P
     3985    string U;               // the independent variables
     3986    string A;               // the dependent variables
     3987    int j,k;
     3988    int a;                  //  the size of A
     3989    int degf;
     3990    ideal g;
     3991    list polys;
     3992    int sizepolys;
     3993    list newpoly;
     3994    def R=basering;
     3995    //intvec hv=hilb(SI,1);
     3996    for (k=1;k<=size(indsets);k++)
     3997    {
     3998      v=indsets[k];
     3999      for (j=1;j<=nvars(R);j++)
     4000      {
     4001        if (v[j]==1)
     4002        {
     4003          U=U+varstr(j)+",";
     4004        }
     4005        else
     4006        {
     4007          A=A+varstr(j)+",";
     4008          a++;
     4009        }
     4010      }
     4011
     4012      U[size(U)]=")";           // we compute the extractor of I (w.r.t. U)
     4013      execute "ring RAU="+charstr(basering)+",("+A+U+",(dp("+string(a)+"),dp);";
     4014      ideal I=imap(R,SI);
     4015      //I=std(I,hv);            // the standard basis in (R[U])[A]
     4016      I=std(I);            // the standard basis in (R[U])[A]
     4017      A[size(A)]=")";
     4018      execute "ring Rloc=("+charstr(basering)+","+U+",("+A+",dp;";
     4019      ideal I=imap(RAU,I);
     4020      //"std in lokalisierung:"+newline,I;
     4021      ideal h;
     4022      for(j=ncols(I);j>=1;j--)
     4023      {
     4024        h[j]=leadcoef(I[j]);  // consider I in (R(U))[A]
     4025      }
     4026      setring R;
     4027      g=imap(Rloc,h);
     4028      kill RAU,Rloc;
     4029      U="";
     4030      A="";
     4031      a=0;
     4032      f=lcm(g);
     4033      newpoly[1]=f;
     4034      polys=polys+newpoly;
     4035      newpoly=list();
     4036    }
     4037    f=polys[1];
     4038    degf=deg(f);
     4039    sizepolys=size(polys);
     4040    for (k=2;k<=sizepolys;k++)
     4041    {
     4042      if (deg(polys[k])<degf)
     4043      {
     4044        f=polys[k];
     4045        degf=deg(f);
     4046      }
     4047    }
     4048  }
     4049  else
     4050  {
     4051    f=1;
     4052  }
     4053  poly f0,h0; ideal SQ; ideal fac;
     4054  if(f!=1)
     4055  {
     4056    SQ,f0,h0,fac=minsat(SI,f);
     4057    return(SQ,std(SI+h0),fac);
     4058             // the tripel
     4059             // a standard basis of Q,
     4060             // a standard basis of remaining component,
     4061             // irreducible factors of
     4062             // the "minimal divisor" of the extractor
     4063             // as computed by the procedure minsat
     4064  }
     4065  else
     4066  {
     4067    return(SI,ideal(1),ideal(1));
     4068  }
     4069}
     4070
     4071/////////////////////////////////////////////////////
     4072// proc minsat
     4073// input:  a standard basis of an ideal I and a polynomial p
     4074// output: a standard basis IS of the saturation of I w.r. to p,
     4075// the maximal squarefree factor f0 of p,
     4076// the "minimal divisor" f of f0 such that the saturation of
     4077// I w.r. to f equals the saturation of I w.r. to f0 (which is IS),
     4078// the irreducible factors of f
     4079//////////////////////////////////////////////////////////
     4080
     4081
     4082proc minsat(ideal SI, poly p)
     4083{
     4084  ideal fac=factorize(p,1);       //the irreducible factors of p
     4085  fac=sort(fac)[1];
     4086  int i,k;
     4087  poly f0=1;
     4088  for(i=ncols(fac);i>=1;i--)
     4089  {
     4090    f0=f0*fac[i];
     4091  }
     4092  poly f=1;
     4093  ideal iold;
     4094  list quotM;
     4095  quotM[1]=SI;
     4096  quotM[2]=fac;
     4097  quotM[3]=f0;
     4098  // we deal seperately with the first quotient;
     4099  // factors, which do not contribute to this one,
     4100  // are omitted
     4101  iold=quotM[1];
     4102  quotM=minquot(quotM);
     4103  fac=quotM[2];
     4104  if(quotM[3]==1)
     4105    {
     4106      return(quotM[1],f0,f,fac);
     4107    }
     4108  while(special_ideals_equal(iold,quotM[1])==0)
     4109    {
     4110      f=f*quotM[3];
     4111      iold=quotM[1];
     4112      quotM=minquot(quotM);
     4113    }
     4114  return(quotM[1],f0,f,fac);           // the quadrupel ((I:p),f0,f, irr. factors of f)
     4115}
     4116
     4117/////////////////////////////////////////////////////
     4118// proc minsat_ppd
     4119// input:  a standard basis of an ideal I and a polynomial p
     4120// output: a standard basis IS of the saturation of I w.r. to p,
     4121// the maximal squarefree factor f0 of p,
     4122// the "minimal divisor" f of f0 such that the saturation of
     4123// I w.r. to f equals the saturation of I w.r. to f0 (which is IS),
     4124// the irreducible factors of f
     4125//////////////////////////////////////////////////////////
     4126
     4127
     4128proc minsat_ppd(ideal SI, ideal fac)
     4129{
     4130  fac=sort(fac)[1];
     4131  int i,k;
     4132  poly f0=1;
     4133  for(i=ncols(fac);i>=1;i--)
     4134  {
     4135    f0=f0*fac[i];
     4136  }
     4137  poly f=1;
     4138  ideal iold;
     4139  list quotM;
     4140  quotM[1]=SI;
     4141  quotM[2]=fac;
     4142  quotM[3]=f0;
     4143  // we deal seperately with the first quotient;
     4144  // factors, which do not contribute to this one,
     4145  // are omitted
     4146  iold=quotM[1];
     4147  quotM=minquot(quotM);
     4148  fac=quotM[2];
     4149  if(quotM[3]==1)
     4150    {
     4151      return(quotM[1],f0,f,fac);
     4152    }
     4153  while(special_ideals_equal(iold,quotM[1])==0)
     4154  {
     4155    f=f*quotM[3];
     4156    iold=quotM[1];
     4157    quotM=minquot(quotM);
     4158    k++;
     4159  }
     4160  return(quotM[1],f0,f,fac);           // the quadrupel ((I:p),f0,f, irr. factors of f)
     4161}
     4162/////////////////////////////////////////////////////////////////
     4163// proc minquot
     4164// input: a list with 3 components: a standard basis
     4165// of an ideal I, a set of irreducible polynomials, and
     4166// there product f0
     4167// output: a standard basis of the ideal (I:f0), the irreducible
     4168// factors of the "minimal divisor" f of f0 with (I:f0) = (I:f),
     4169// the "minimal divisor" f
     4170/////////////////////////////////////////////////////////////////
     4171
     4172proc minquot(list tsil)
     4173{
     4174   int i,j,k,action;
     4175   ideal verg;
     4176   list l;
     4177   poly g;
     4178   ideal laedi=tsil[1];
     4179   ideal fac=tsil[2];
     4180   poly f=tsil[3];
     4181
     4182//std
     4183//   ideal star=quotient(laedi,f);
     4184//   star=std(star);
     4185   option(returnSB);
     4186   ideal star=quotient(laedi,f);
     4187   option(noreturnSB);
     4188   if(special_ideals_equal(laedi,star)==1)
     4189     {
     4190       return(laedi,ideal(1),1);
     4191     }
     4192   action=1;
     4193   while(action==1)
     4194   {
     4195      if(size(fac)==1)
     4196      {
     4197         action=0;
     4198         break;
     4199      }
     4200      for(i=1;i<=size(fac);i++)
     4201      {
     4202        g=1;
     4203         for(j=1;j<=size(fac);j++)
     4204         {
     4205            if(i!=j)
     4206            {
     4207               g=g*fac[j];
     4208            }
     4209         }
     4210//std
     4211//         verg=quotient(laedi,g);
     4212//         verg=std(verg);
     4213         option(returnSB);
     4214         verg=quotient(laedi,g);
     4215         option(noreturnSB);
     4216         if(special_ideals_equal(verg,star)==1)
     4217         {
     4218            f=g;
     4219            fac[i]=0;
     4220            fac=simplify(fac,2);
     4221            break;
     4222         }
     4223         if(i==size(fac))
     4224         {
     4225            action=0;
     4226         }
     4227      }
     4228   }
     4229   l=star,fac,f;
     4230   return(l);
     4231}
     4232/////////////////////////////////////////////////
     4233// proc special_ideals_equal
     4234// input: standard bases of ideal k1 and k2 such that
     4235// k1 is contained in k2, or k2 is contained ink1
     4236// output: 1, if k1 equals k2, 0 otherwise
     4237//////////////////////////////////////////////////
     4238
     4239proc special_ideals_equal( ideal k1, ideal k2)
     4240{
     4241   int j;
     4242   if(size(k1)==size(k2))
     4243   {
     4244      for(j=1;j<=size(k1);j++)
     4245      {
     4246         if(leadexp(k1[j])!=leadexp(k2[j]))
     4247         {
     4248            return(0);
     4249         }
     4250      }
     4251      return(1);
     4252   }
     4253   return(0);
     4254}
     4255       
     4256       
     4257 
Note: See TracChangeset for help on using the changeset viewer.