Changeset e801fe in git


Ignore:
Timestamp:
Feb 16, 1998, 1:07:04 PM (26 years ago)
Author:
Gerhard Pfister <pfister@…>
Branches:
(u'spielwiese', '2fa36c576e6a4ddbb1093b43c7f8e9835e17e52a')
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
Location:
Singular/LIB
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/invar.lib

    r437e2c2 re801fe  
    1 // $Id: invar.lib,v 1.3 1997-09-18 09:58:24 Singular Exp $
     1// $Id: invar.lib,v 1.4 1998-02-16 12:07:01 pfister Exp $
    22///////////////////////////////////////////////////////
    33// invar.lib
     
    77//////////////////////////////////////////////////////
    88
    9 LIBRARY: invar.lib PROCEDURE FOR COMPUTING INVARIANTS UNDER (C,+)-ACTIONS
     9LIBRARY: invar.lib PROCEDURES FOR COMPUTING INVARIANTS OF (C,+)-ACTIONS
    1010
    1111  invariantRing(matrix m,poly p,poly q,int choose)
     
    142142
    143143
    144 proc reduction(poly p, ideal mo, list #)
    145 USAGE:   reduction(p,mo,q); p poly, mo ideal, q (optional) monomial
     144proc reduction(poly p, ideal dom, list #)
     145USAGE:   reduction(p,dom,q); p poly, dom ideal, q (optional) monomial
    146146RETURN:  poly= (p-H(f1,...,fr))/q^a, if Lt(p)=H(Lt(f1),...,Lt(fr)) for
    147147               some polynomial H in r variables over the base field,
    148148               a maximal such that q^a devides p-H(f1,...,fr),
    149                mo =(f1,...,fr)
     149               dom =(f1,...,fr)
    150150NOTE:   
    151151EXAMPLE: example reduction; shows an example
    152152{
    153153  int i;
    154   int z=size(mo);
     154  int z=size(dom);
    155155  def bsr=basering;
    156156 
     
    165165  execute "ring s="+charstr(basering)+",("+varstr(basering)+",@(0..z)),dp;";
    166166 
    167   //costructes the ideal mo=(p-@(0),mo[1]-@(1),...,mo[z]-@(z))
    168   ideal mo=imap(bsr,mo);
     167  //costructes the ideal dom=(p-@(0),dom[1]-@(1),...,dom[z]-@(z))
     168  ideal dom=imap(bsr,dom);
    169169  for (i=1;i<=z;i++)
    170170  {
    171     mo[i]=lead(mo[i])-var(nvars(bsr)+i+1);
    172   }
    173   mo=lead(imap(bsr,p))-@(0),mo;
     171    dom[i]=lead(dom[i])-var(nvars(bsr)+i+1);
     172  }
     173  dom=lead(imap(bsr,p))-@(0),dom;
    174174 
    175175  //eliminates the variables of the basering bsr
    176   //i.e. computes mo intersected with K[@(0),...,@(z)]
    177   ideal kern=eliminate(mo,imap(bsr,v));
     176  //i.e. computes dom intersected with K[@(0),...,@(z)]
     177  ideal kern=eliminate(dom,imap(bsr,v));
    178178
    179179  // test wether @(0)-h(@(1),...,@(z)) is in ker for some poly h
     
    186186     {
    187187        h=(1/h)*kern[i];
    188         // defines the map psi : s ---> bsr defined by @(i) ---> p,mo[i]
     188        // defines the map psi : s ---> bsr defined by @(i) ---> p,dom[i]
    189189        setring bsr;
    190         map psi=s,maxideal(1),p,mo;
     190        map psi=s,maxideal(1),p,dom;
    191191        poly re=psi(h);
    192192
     
    210210   ring q=0,(x,y,z,u,v,w),dp;
    211211   poly p=x2yz-x2v;
    212    ideal mo =x-w,u2w+1,yz-v;
    213    reduction(p,mo);
    214    reduction(p,mo,w);
    215 }
    216 
    217 ///////////////////////////////////////////////////////////////////////////////
    218 
    219 proc completeReduction(poly p, ideal mo, list #)
    220 USAGE:   completeReduction(p,mo,q); p poly, mo ideal,
     212   ideal dom =x-w,u2w+1,yz-v;
     213   reduction(p,dom);
     214   reduction(p,dom,w);
     215}
     216
     217///////////////////////////////////////////////////////////////////////////////
     218
     219proc completeReduction(poly p, ideal dom, list #)
     220USAGE:   completeReduction(p,dom,q); p poly, dom ideal,
    221221                                     q (optional) monomial
    222 RETURN:  poly= the polynomial p reduced with mo via the procedure
     222RETURN:  poly= the polynomial p reduced with dom via the procedure
    223223               reduction as long as possible
    224224NOTE:   
     
    226226{
    227227  poly p1=p;
    228   poly p2=reduction(p,mo,#);
     228  poly p2=reduction(p,dom,#);
    229229  while (p1!=p2)
    230230  {
    231231    p1=p2;
    232     p2=reduction(p1,mo,#);
     232    p2=reduction(p1,dom,#);
    233233  }
    234234  return(p2);
     
    238238   ring q=0,(x,y,z,u,v,w),dp;
    239239   poly p=x2yz-x2v;
    240    ideal mo =x-w,u2w+1,yz-v;
    241    completeReduction(p,mo);
    242    completeReduction(p,mo,w);
    243 }
    244 ///////////////////////////////////////////////////////////////////////////////
    245 
    246 proc inSubring(poly p, ideal mo)
    247 USAGE:   inSubring(p,mo); p poly, mo ideal
    248 RETURN:  list= 1,string(@(0)-h(@(1),...,@(size(mo)))) :if p = h(mo[1],...,mo[size(mo)])
    249               0,string(h(@(0),...,@(size(mo)))) :if there is only a nonlinear relation
    250               h(p,mo[1],...,mo[size(mo)])=0.
     240   ideal dom =x-w,u2w+1,yz-v;
     241   completeReduction(p,dom);
     242   completeReduction(p,dom,w);
     243}
     244///////////////////////////////////////////////////////////////////////////////
     245
     246proc inSubring(poly p, ideal dom)
     247USAGE:   inSubring(p,dom); p poly, dom ideal
     248RETURN:  list= 1,string(@(0)-h(@(1),...,@(size(dom)))) :if p = h(dom[1],...,dom[size(dom)])
     249              0,string(h(@(0),...,@(size(dom)))) :if there is only a nonlinear relation
     250              h(p,dom[1],...,dom[size(dom)])=0.
    251251NOTE:   
    252252EXAMPLE: example inSubring; shows an example
    253253{
    254   int z=size(mo);
     254  int z=size(dom);
    255255  int i;
    256256  def gnir=basering;
     
    262262  }
    263263  string eli=string(mile);
    264   // the intersection of ideal nett=(p-@(0),mo[1]-@(1),...)
     264  // the intersection of ideal nett=(p-@(0),dom[1]-@(1),...)
    265265  // with the ring k[@(0),...,@(n)] is computed, the result is ker
    266266  execute "ring r1="+charstr(basering)+",("+varstr(basering)+",@(0..z)),dp;";
    267   ideal nett=imap(gnir,mo);
     267  ideal nett=imap(gnir,dom);
    268268  poly p;
    269269  for (i=1;i<=z;i++)
     
    299299   ring q=0,(x,y,z,u,v,w),dp;
    300300   poly p=xyzu2w-1yzu2w2+u4w2-1xu2vw+u2vw2+xyz-1yzw+2u2w-1xv+vw+2;
    301    ideal mo =x-w,u2w+1,yz-v;
    302    inSubring(p,mo);
     301   ideal dom =x-w,u2w+1,yz-v;
     302   inSubring(p,dom);
    303303}
    304304
     
    478478     "                     ";
    479479     karl;
    480     pause;
     480    // pause;
    481481     "                     ";
    482482  }
     
    517517       "                                  ";
    518518       karl;
    519       pause;
     519      // pause;
    520520       "                                  ";
    521521    }
     
    643643 
    644644}
    645 ///////////////////////////////////////////////////////////////////////////////
  • Singular/LIB/normal.lib

    r437e2c2 re801fe  
    1 // $Id: normal.lib,v 1.1 1997-11-05 18:16:55 Singular Exp $
    21///////////////////////////////////////////////////////////////////////////////
    32// normal.lib
     
    109
    1110  normal(ideal I)
    12   // computes a set of rings such that their product is the
    13   // normalization of the reduced basering/I
    14 
    15 LIB "sing.lib";
     11  // computes a set of rings such that their product is the 
     12  // normalization of the reduced basering/I 
     13
     14LIB "sing.lib"; 
    1615LIB "primdec.lib";
    1716LIB "elim.lib";
     
    2726         p    = nonzero divisor of R
    2827RETURN:  1 if R = R:J, 0 if not
    29 EXAMPLE: example isR_HomJR;  shows an example
     28EXAMPLE: example isR_HomJR;  shows an example   
    3029{
    3130   int n, ii;
     
    4342   n=1;
    4443   for (ii=1; ii<=size(f); ii++ )
    45    {
    46       if ( reduce(f[ii],lp) != 0)
     44   { 
     45      if ( reduce(f[ii],lp) != 0) 
    4746      { n = 0; break; }
    4847   }
     
    7372NOTE:    This is useful when enlarging P but keeping the weights of the old
    7473         variables
    75 EXAMPLE: example extraweight;  shows an example
     74EXAMPLE: example extraweight;  shows an example   
    7675{
    7776   int ii,q,fi,fo,fia;
     
    8887      os = osP[fi+1,find(osP,")",fi)-fi-1];
    8988      if( find(os,",") )
    90       {
     89      { 
    9190         execute "nw = "+os+";";
    9291         if( size(nw) > ii )
     
    101100      {
    102101         execute "q = "+os+";";
    103          if( q > ii )
    104          {
     102         if( q > ii ) 
     103         { 
    105104            nw = 0; nw[q-ii] = 0;
    106105            nw = nw + 1;          //creates an intvec 1,...,1 of length q-ii
     
    114113   }
    115114//-------------- adjust weight vector to length = nvars(P)  -------------------
    116    if( fo > 1 )
     115   if( fo > 1 ) 
    117116   {                                            // case when weights were found
    118       rw = rw[2..size(rw)];
    119       if( size(rw) > nvars(P) )
    120       {
    121          rw = rw[1..nvars(P)];
    122       }
    123       if( size(rw) < nvars(P) )
    124       {
    125          nw=0; nw[nvars(P)-size(rw)]=0; nw=nw+1; rw=rw,nw;
    126       }
    127    }
    128    else
     117      rw = rw[2..size(rw)]; 
     118      if( size(rw) > nvars(P) ) 
     119      { 
     120         rw = rw[1..nvars(P)]; 
     121      }
     122      if( size(rw) < nvars(P) ) 
     123      { 
     124         nw=0; nw[nvars(P)-size(rw)]=0; nw=nw+1; rw=rw,nw; 
     125      }
     126   }
     127   else 
    129128   {                                         // case when no weights were found
    130       rw[nvars(P)]= 0; rw=rw+1;
     129      rw[nvars(P)]= 0; rw=rw+1; 
    131130   }
    132131   return(rw);
     
    158157         R is the quotient ring of P modulo the standard basis SBid
    159158RETURN:  a list of two objects
    160          _[1]: a polynomial ring, containing two ideals, 'endid' and 'endphi'
     159         _[1]: a polynomial ring, containing two ideals, 'endid' and 'endphi' 
    161160               s.t. _[1]/endid = Hom_R(J,J) and
    162161               endphi describes the canonical map R -> Hom_R(J,J)
    163162         _[2]: an integer which is 1 if phi is an isomorphism, 0 if not
    164 EXAMPLE: example HomJJ;  shows an example
     163EXAMPLE: example HomJJ;  shows an example   
    165164{
    166165//---------- initialisation ---------------------------------------------------
     
    180179
    181180//---- set attributes for special cases where algorithm can be simplified -----
    182    if( homo==1 )
    183    {
     181   if( homo==1 ) 
     182   { 
    184183      rw = extraweight(P);
    185184   }
     
    213212
    214213//---------- computation of p*Hom(J,J) as R-ideal -----------------------------
    215    f  = quotient(p*J,J);
    216    if(y==1)
    217    {
     214   f  = quotient(p*J,J); 
     215   if(y==1)     
     216   {               
    218217      "the module Hom(rad(J),rad(J)) presented by the values on";
    219218      "the non-zerodivisor";
     
    238237   rf = interred(reduce(f,f2));       // represents p*Hom(J,J)/p*R = Hom(J,J)/R
    239238   if ( size(rf) == 0 )
    240    {
     239   { 
    241240      if ( homog(f) && find(ordstr(basering),"s")==0 )
    242241      {
    243          ring newR1 = char(P),(X(1..nvars(P))),(a(rw),dp);
     242         ring newR1 = char(P),(X(1..nvars(P))),(a(rw),dp); 
    244243      }
    245244      else
    246245      {
    247          ring newR1 = char(P),(X(1..nvars(P))),dp;
     246         ring newR1 = char(P),(X(1..nvars(P))),dp; 
    248247      }
    249248      ideal endphi = maxideal(1);
    250       ideal endid = fetch(P,id);
     249      ideal endid = fetch(P,id); 
    251250      attrib(endid,"isCohenMacaulay",isCo);
    252251      attrib(endid,"isPrim",isPr);
     
    301300   q = size(f);
    302301   syzf = syz(f);
    303 
     302       
    304303   if ( homo==1 )
    305304   {
     
    307306      for ( ii=2; ii<=q; ii++ )
    308307      {
    309          rw  = rw, deg(f[ii])-deg(f[1]);
    310          rw1 = rw1, deg(f[ii])-deg(f[1]);
    311       }
    312       ring newR1 = char(R),(X(1..nvars(R)),T(1..q)),(a(rw1),dp);
     308         rw  = rw, deg(f[ii])-deg(f[1]);       
     309         rw1 = rw1, deg(f[ii])-deg(f[1]);       
     310      }
     311      ring newR1 = char(R),(X(1..nvars(R)),T(1..q)),(a(rw1),dp); 
    313312   }
    314313   else
    315314   {
    316       ring newR1 = char(R),(X(1..nvars(R)),T(1..q)),dp;
     315      ring newR1 = char(R),(X(1..nvars(R)),T(1..q)),dp; 
    317316   }
    318317
     
    320319   ideal SBid = psi1(SBid);
    321320   attrib(SBid,"isSB",1);
    322 
     321   
    323322 qring newR = std(SBid);
    324323   map psi = R,ideal(X(1..nvars(R)));
     
    331330
    332331//---------- computation of Hom(J,J) as ring ----------------------------------
    333 // determine kernel of: R[T1,...,Tq] -> J:J >-> R[1/p]=R[t]/(t*p-1),
     332// determine kernel of: R[T1,...,Tq] -> J:J >-> R[1/p]=R[t]/(t*p-1), 
    334333// Ti -> fi/p -> t*fi (p=f1=f[1]), to get ring structure. This is of course
    335334// the same as the kernel of R[T1,...,Tq] -> pJ:J >-> R, Ti -> fi.
     
    339338   pf = f[1]*f;
    340339   T = matrix(ideal(T(1..q)),1,q);
    341    Lin = ideal(T*syzf);
     340   Lin = ideal(T*syzf); 
    342341   if(y==1)
    343342   {
     
    374373   else
    375374   {
    376       ring newRing = char(R),(X(1..nvars(R)),T(2..q)),dp;
     375      ring newRing = char(R),(X(1..nvars(R)),T(2..q)),dp; 
    377376   }
    378377
     
    381380
    382381   map phi = basering,maxideal(1);
    383    list Le = elimpart(endid);
     382   list Le = elimpart(endid); 
    384383           //this proc and the next loop try to
    385384   q = size(Le[2]);                 //substitute as many variables as possible
    386    rw1 = 0;
     385   rw1 = 0;                     
    387386   rw1[nvars(basering)] = 0;
    388387   rw1 = rw1+1;
     
    395394      kill ps;
    396395
    397       for( ii=1; ii<=size(rw1); ii++ )
    398       {
    399          if( Le[4][ii]==0 )
    400          {
     396      for( ii=1; ii<=size(rw1); ii++ ) 
     397      { 
     398         if( Le[4][ii]==0 ) 
     399         { 
    401400            rw1[ii]=0;                             //look for substituted vars
    402401         }
     
    404403      Le=elimpart(endid);
    405404      q = q + size(Le[2]);
    406    }   
     405   }     
    407406   endphi = phi(endphi);
    408407
     
    412411
    413412   if (homo==1 && nvars(newRing)-q >1 && size(endid) >0 )
    414    {
     413   {                           
    415414      jj=1;
    416415      for( ii=2; ii<size(rw1); ii++)
    417       {
     416      { 
    418417         jj++;
    419          if( rw1[ii]==0 )
    420          {
     418         if( rw1[ii]==0 ) 
     419         { 
    421420            rw=rw[1..jj-1],rw[jj+1..size(rw)];
    422             jj=jj-1;
     421            jj=jj-1; 
    423422         }
    424423      }
     
    430429   else
    431430   {
    432       ring lastRing = char(R),(T(1..nvars(newRing)-q)),dp;
    433    }
    434 
    435    ideal lastmap;
     431      ring lastRing = char(R),(T(1..nvars(newRing)-q)),dp; 
     432   }
     433
     434   ideal lastmap; 
    436435   q = 1;
    437436   for(ii=1; ii<=size(rw1); ii++ )
     
    439438      if ( rw1[ii]==1 ) { lastmap[ii] = T(q); q=q+1; }
    440439      if ( rw1[ii]==0 ) { lastmap[ii] = 0; }
    441    }
     440   }     
    442441   map phi = newRing,lastmap;
    443442   ideal endid  = phi(endid);
     
    490489  list L   = HomJJ(Li);
    491490  def end = L[1];      // defines ring L[1], containing ideals endid and endphi
    492   setring end;         // makes end the basering
     491  setring end;         // makes end the basering 
    493492  end;
    494493  endid;               // end/endid is isomorphic to End(r/id) as ring
     
    496495  psi;
    497496
    498   ring r   = 32003,(x,y,z),dp;
     497  ring r   = 32003,(x,y,z),dp; 
    499498  ideal id = x2-xy-xz+yz;
    500499  ideal J =y-z,x-z;
     
    503502  list L   = HomJJ(Li,0);
    504503  def end = L[1];      // defines ring L[1], containing ideals endid and endphi
    505   setring end;         // makes end the basering
     504  setring end;         // makes end the basering 
    506505  end;
    507506  endid;               // end/endid is isomorphic to End(r/id) as ring
     
    528527      if( typeof(attrib(id,"isEquidimensional"))=="int" )
    529528      {
    530         if(attrib(id,"isEquidimensional")==1)
     529        if(attrib(id,"isEquidimensional")==1) 
    531530        {
    532            attrib(prim[1],"isEquidimensional",1);
     531           attrib(prim[1],"isEquidimensional",1); 
    533532        }
    534533      }
     
    539538      if( typeof(attrib(id,"isCompleteIntersection"))=="int" )
    540539      {
    541         if(attrib(id,"isCompleteIntersection")==1)
     540        if(attrib(id,"isCompleteIntersection")==1) 
    542541        {
    543            attrib(prim[1],"isCompleteIntersection",1);
     542           attrib(prim[1],"isCompleteIntersection",1); 
    544543        }
    545544      }
     
    548547         attrib(prim[1],"isCompleteIntersection",0);
    549548      }
    550 
     549     
    551550      if( typeof(attrib(id,"isPrim"))=="int" )
    552551      {
     
    559558      if( typeof(attrib(id,"isIsolatedSingularity"))=="int" )
    560559      {
    561          if(attrib(id,"isIsolatedSingularity")==1)
     560         if(attrib(id,"isIsolatedSingularity")==1) 
    562561             {attrib(prim[1],"isIsolatedSingularity",1); }
    563562      }
    564563      else
    565564      {
    566          attrib(prim[1],"isIsolatedSingularity",0);
     565         attrib(prim[1],"isIsolatedSingularity",0);       
    567566      }
    568567      if( typeof(attrib(id,"isCohenMacaulay"))=="int" )
    569568      {
    570          if(attrib(id,"isCohenMacaulay")==1)
     569         if(attrib(id,"isCohenMacaulay")==1) 
    571570           { attrib(prim[1],"isCohenMacaulay",1); }
    572571      }
    573572      else
    574573      {
    575          attrib(prim[1],"isCohenMacaulay",0);
     574         attrib(prim[1],"isCohenMacaulay",0);       
    576575      }
    577576      if( typeof(attrib(id,"isRegInCodim2"))=="int" )
     
    582581      else
    583582      {
    584           attrib(prim[1],"isRegInCodim2",0);
     583          attrib(prim[1],"isRegInCodim2",0);       
    585584      }
    586585      return(normalizationPrimes(prim[1],maxideal(1)));
     
    616615         if( typeof(attrib(id,"isEquidimensional"))=="int" )
    617616         {
    618            if(attrib(id,"isEquidimensional")==1)
     617           if(attrib(id,"isEquidimensional")==1) 
    619618           {
    620               attrib(prim[i],"isEquidimensional",1);
     619              attrib(prim[i],"isEquidimensional",1); 
    621620           }
    622621         }
     
    624623         {
    625624            attrib(prim[i],"isEquidimensional",0);
    626          }
     625         }     
    627626         if( typeof(attrib(id,"isIsolatedSingularity"))=="int" )
    628627         {
    629             if(attrib(id,"isIsolatedSingularity")==1)
     628            if(attrib(id,"isIsolatedSingularity")==1) 
    630629             {attrib(prim[i],"isIsolatedSingularity",1); }
    631630         }
    632631         else
    633632         {
    634             attrib(prim[i],"isIsolatedSingularity",0);
     633            attrib(prim[i],"isIsolatedSingularity",0);       
    635634         }
    636 
     635   
    637636         keepresult=normalizationPrimes(prim[i],maxideal(1));
    638637         for(j=1;j<=size(keepresult);j++)
     
    688687         ideal PP=fetch(BAS,ihp);
    689688         export PP;
    690          export KK;
     689         export KK;     
    691690         result=newR7;
    692691         setring BAS;
     
    859858  //    if((dim(SM[1]))==depth)
    860859  //    {
    861   //    attrib(SM[2],"isCohenMacaulay",1);
     860  //    attrib(SM[2],"isCohenMacaulay",1);   
    862861  //    "it is CohenMacaulay";
    863   //    }
     862  //    } 
    864863  // }
    865 
     864   
    866865   //compute the singular locus+lower dimensional components
    867866   if(((attrib(SM[2],"isIsolatedSingularity")==0)||(homog(SM[2])==0))
     
    946945            "                                  ";
    947946            maxideal(1);
    948             "                                  ";
     947            "                                  "; 
    949948            "                                  ";
    950949         }
     
    963962  //          export SB,MB;
    964963  //          result=BAS;
    965   //          return(result);
     964  //          return(result); 
    966965  //       }
    967966  //       timer-ti;
     
    972971         if(RR[2]==0)
    973972         {
    974             def newR=RR[1];
     973            def newR=RR[1];     
    975974            setring newR;
    976975            map psi=BAS,endphi;
     
    980979        //    timer-ti;
    981980            setring BAS;
    982             return(tluser);
     981            return(tluser); 
    983982         }
    984983         MB=SM[2];
     
    992991         setring BAS;
    993992         return(result);
    994 
     993 
    995994       }
    996995       else
     
    10261025       }
    10271026   }
    1028 
     1027   
    10291028   //test for non-normality
    10301029   //Hom(I,I)<>R
     
    10521051 //        export SB,MB;
    10531052 //        result=BAS;
    1054  //        return(result);
     1053 //        return(result); 
    10551054 //     }
    10561055 //     timer-ti;
     
    10581057 //     list  RR=SM[1],SM[2],JM[2],SL[1];
    10591058 //     ti=timer;
    1060       list RS;
     1059      list RS;   
    10611060 //   list RS=HomJJ(RR);
    10621061 //   timer-ti;
     
    10681067 //        list tluser=normalizationPrimes(SM);
    10691068 //        setring BAS;
    1070  //        return(tluser);
     1069 //        return(tluser); 
    10711070 //     }
    10721071
     
    10771076      }
    10781077//      ti=timer;
    1079 
     1078     
    10801079
    10811080      if((attrib(JM[2],"isRad")==0)&&(attrib(SM[2],"isEquidimensional")==0))
     
    10831082           //J=radical(JM[2]);
    10841083          J=radical(SM[2]+ideal(SL[1]));
    1085 
     1084         
    10861085          // evtl. test auf J=SM[2]+ideal(SL[1]) dann schon normal
    10871086      }
     
    11031102//    timer-ti;
    11041103
    1105       JM=J,J;
     1104      JM=J,J;       
    11061105
    11071106      //evtl. fuer SL[1] anderen Nichtnullteiler aus J waehlen
     
    11171116        //    keepresult1=insert(keepresult1,keepresult2[lauf]);
    11181117        // }
    1119         // return(keepresult1);
     1118        // return(keepresult1);   
    11201119      // }
    11211120      RR=SM[1],SM[2],JM[2],SL[1];
     
    11401139         export KK;
    11411140         setring BAS;
    1142         // return(RS[1]);
     1141        // return(RS[1]); 
    11431142         return(lastR);
    11441143      }
     
    11531152            // normalizationPrimes(endid);
    11541153      setring BAS;
    1155       return(tluser);
     1154      return(tluser); 
    11561155   }
    11571156   else
     
    11621161                      +ordstr(basering)+");";
    11631162      if(y==1)
    1164       {
     1163      {     
    11651164         "zero-divisor found";
    11661165      }
     
    11801179      }
    11811180      attrib(vid,"isCompleteIntersection",0);
    1182 
     1181   
    11831182      keepresult1=normalizationPrimes(vid,ihp);
    11841183
     
    11891188      execute "ring newR2="+charstr(basering)+",("+varstr(basering)+"),("
    11901189                      +ordstr(basering)+");";
    1191 
     1190 
    11921191      ideal vid=fetch(BAS,new2);
    11931192      ideal ihp=fetch(BAS,ihp);
     
    12131212         keepresult1=insert(keepresult1,keepresult2[lauf]);
    12141213      }
    1215       return(keepresult1);
    1216    }
     1214      return(keepresult1);   
     1215   }   
    12171216}
    12181217example
    12191218{ "EXAMPLE:";echo = 2;
     1219   LIB"normal.lib";
    12201220   //Huneke
    1221   ring qr=31991,(a,b,c,d,e),dp;
    1222   ideal i=
    1223   5abcde-a5-b5-c5-d5-e5,
    1224   ab3c+bc3d+a3be+cd3e+ade3,
    1225   a2bc2+b2cd2+a2d2e+ab2e2+c2de2,
    1226   abc5-b4c2d-2a2b2cde+ac3d2e-a4de2+bcd2e3+abe5,
    1227   ab2c4-b5cd-a2b3de+2abc2d2e+ad4e2-a2bce3-cde5,
    1228   a3b2cd-bc2d4+ab2c3e-b5de-d6e+3abcd2e2-a2be4-de6,
    1229   a4b2c-abc2d3-ab5e-b3c2de-ad5e+2a2bcde2+cd2e4,
    1230   b6c+bc6+a2b4e-3ab2c2de+c4d2e-a3cde2-abd3e2+bce5;
    1231  
    1232   list pr=normal(i);
    1233   def r1=pr[1];
    1234   setring r1;
    1235   KK;
     1221ring qr=31991,(a,b,c,d,e),dp;
     1222ideal i=
     12235abcde-a5-b5-c5-d5-e5,
     1224ab3c+bc3d+a3be+cd3e+ade3,
     1225a2bc2+b2cd2+a2d2e+ab2e2+c2de2,
     1226abc5-b4c2d-2a2b2cde+ac3d2e-a4de2+bcd2e3+abe5,
     1227ab2c4-b5cd-a2b3de+2abc2d2e+ad4e2-a2bce3-cde5,
     1228a3b2cd-bc2d4+ab2c3e-b5de-d6e+3abcd2e2-a2be4-de6,
     1229a4b2c-abc2d3-ab5e-b3c2de-ad5e+2a2bcde2+cd2e4,
     1230b6c+bc6+a2b4e-3ab2c2de+c4d2e-a3cde2-abd3e2+bce5;
     1231
     1232list pr=normal(i);
     1233def r1=pr[1];
     1234setring r1;
     1235KK;
    12361236}
     1237
     1238
     1239
     1240/////////////////////////////////////////////////////////////////////////////
     1241
     1242LIB"normal.lib";
     1243int aa=timer;list pr=normal(i);timer-aa;
     1244
     1245
     1246
     1247//Huneke
     1248ring qr=31991,(a,b,c,d,e),dp;
     1249ideal i=
     12505abcde-a5-b5-c5-d5-e5,
     1251ab3c+bc3d+a3be+cd3e+ade3,
     1252a2bc2+b2cd2+a2d2e+ab2e2+c2de2,
     1253abc5-b4c2d-2a2b2cde+ac3d2e-a4de2+bcd2e3+abe5,
     1254ab2c4-b5cd-a2b3de+2abc2d2e+ad4e2-a2bce3-cde5,
     1255a3b2cd-bc2d4+ab2c3e-b5de-d6e+3abcd2e2-a2be4-de6,
     1256a4b2c-abc2d3-ab5e-b3c2de-ad5e+2a2bcde2+cd2e4,
     1257b6c+bc6+a2b4e-3ab2c2de+c4d2e-a3cde2-abd3e2+bce5;
     1258
     1259
     1260//Vasconcelos
     1261ring r=32003,(x,y,z,w,t),dp;
     1262ideal i=
     1263x2+zw,
     1264y3+xwt,
     1265xw3+z3t+ywt2,
     1266y2w4-xy2z2t-w3t3;
     1267
     1268//Theo1
     1269ring r=32003,(x,y,z),wp(2,3,6);
     1270ideal i=zy2-zx3-x6;
     1271
     1272//Theo2
     1273ring r=32003,(x,y,z),wp(3,4,12);
     1274ideal i=z*(y3-x4)+x8;
     1275
     1276//Theo2a
     1277ring r=32003,(T(1..4)),wp(3,4,12,17);
     1278ideal i=
     1279T(1)^8-T(1)^4*T(3)+T(2)^3*T(3),
     1280T(1)^4*T(2)^2-T(2)^2*T(3)+T(1)*T(4),
     1281T(1)^7+T(1)^3*T(2)^3-T(1)^3*T(3)+T(2)*T(4),
     1282T(1)^6*T(2)*T(3)+T(1)^2*T(2)^4*T(3)+T(1)^3*T(2)^2*T(4)-T(1)^2*T(2)*T(3)^2+T(4)^2;
     1283
     1284//Theo3
     1285ring r=32003,(x,y,z),wp(3,5,15);
     1286ideal i=z*(y3-x5)+x10;
     1287
     1288
     1289//Theo4
     1290ring r=32003,(x,y,z),dp;
     1291ideal i=(x-y)*(x-z)*(y-z);
     1292
     1293//Theo5
     1294ring r=32003,(x,y,z),wp(2,1,2);
     1295ideal i=z3-xy4;
     1296
     1297//Theo6
     1298ring r=32003,(x,y,z),dp;
     1299ideal i=x2y2+x2z2+y2z2;
     1300
     1301ring r=32003,(a,b,c,d,e,f),dp;
     1302ideal i=
     1303bf,
     1304af,
     1305bd,
     1306ad;
     1307
     1308//Beispiel, wo vorher Primaerzerlegung schneller
     1309//ist CM
     1310//Sturmfels
     1311ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
     1312ideal i=
     1313bv+su,
     1314bw+tu,
     1315sw+tv,
     1316by+sx,
     1317bz+tx,
     1318sz+ty,
     1319uy+vx,
     1320uz+wx,
     1321vz+wy,
     1322bvz;
     1323
     1324//J S/Y
     1325ring r=32003,(x,y,z,t),dp;
     1326ideal i=
     1327x2z+xzt,
     1328xyz,
     1329xy2-xyt,
     1330x2y+xyt;
     1331
     1332//St_S/Y
     1333ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
     1334ideal i=
     1335wy-vz,
     1336vx-uy,
     1337tv-sw,
     1338su-bv,
     1339tuy-bvz;
     1340
     1341//dauert laenger
     1342//Horrocks:
     1343ring r=32003,(a,b,c,d,e,f),dp;
     1344ideal i=
     1345adef-16000be2f+16001cef2,
     1346ad2f+8002bdef+8001cdf2,
     1347abdf-16000b2ef+16001bcf2,
     1348a2df+8002abef+8001acf2,
     1349ad2e-8000bde2-7999cdef,
     1350acde-16000bce2+16001c2ef,
     1351a2de-8000abe2-7999acef,
     1352acd2+8002bcde+8001c2df,
     1353abd2-8000b2de-7999bcdf,
     1354a2d2+9603abde-10800b2e2-9601acdf+800bcef+11601c2f2,
     1355abde-8000b2e2-acdf-16001bcef-8001c2f2,
     1356abcd-16000b2ce+16001bc2f,
     1357a2cd+8002abce+8001ac2f,
     1358a2bd-8000ab2e-7999abcf,
     1359ab3f-3bdf3,
     1360a2b2f-2adf3-16000bef3+16001cf4,
     1361a3bf+4aef3,
     1362ac3e-10668cde3,
     1363a2c2e+10667ade3+16001be4+5334ce3f,
     1364a3ce+10669ae3f,
     1365bc3d+8001cd3e,
     1366ac3d+8000bc3e+16001cd2e2+8001c4f,
     1367b2c2d+16001ad4+4000bd3e+12001cd3f,
     1368b2c2e-10668bc3f-10667cd2ef,
     1369abc2e-cde2f,
     1370b3cd-8000bd3f,
     1371b3ce-10668b2c2f-10667bd2ef,
     1372abc2f-cdef2,
     1373a2bce-16000be3f+16001ce2f2,
     1374ab3d-8000b4e-8001b3cf+16000bd2f2,
     1375ab2cf-bdef2,
     1376a2bcf-16000be2f2+16001cef3,
     1377a4d-8000a3be+8001a3cf-2ae2f2;
     1378
     1379 
     1380ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
     1381
     1382ideal k=
     1383wy-vz,
     1384vx-uy,
     1385tv-sw,
     1386su-bv,
     1387tuy-bvz;
     1388ideal j=x2y2+x2z2+y2z2;
     1389ideal i=mstd(intersect(j,k))[2];
     1390
     1391//22
     1392ring r=32003,(b,s,t,u,v,w,x,y,z),dp;
     1393ideal i=
     1394wx2y3-vx2y2z+wx2yz2+wy3z2-vx2z3-vy2z3,
     1395vx3y2-ux2y3+vx3z2-ux2yz2+vxy2z2-uy3z2,
     1396tvx2y2-swx2y2+tvx2z2-swx2z2+tvy2z2-swy2z2,
     1397sux2y2-bvx2y2+sux2z2-bvx2z2+suy2z2-bvy2z2,
     1398tux2y3-bvx2y2z+tux2yz2+tuy3z2-bvx2z3-bvy2z3;
     1399
     1400
     1401//riemenschneider
     1402//33
     1403//normal+primary 3
     1404//primary 9
     1405//radical 1
     1406//minAssPrimes 2
     1407ring r=32000,(p,q,s,t,u,v,w,x,y,z),wp(1,1,1,1,1,1,2,1,1,1);
     1408ideal i=
     1409xz,
     1410vx,
     1411ux,
     1412su,
     1413qu,
     1414txy,
     1415stx,
     1416qtx,
     1417uv2z-uwz,
     1418uv3-uvw,
     1419puv2-puw;
     1420
     1421
  • 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.