source: git/Singular/LIB/sagbigrob.lib

spielwiese
Last change on this file was 20e0447, checked in by Hans Schoenemann <hannes@…>, 3 years ago
agbigrob.lib: avoid redefine in example
  • Property mode set to 100644
File size: 9.1 KB
Line 
1/////// Procedure to compute Sagbi-Groebner Bases //////
2version="version sagbi.lib 4.2.1.1 Sep_2021 "; // $Id$
3category="Commutative Algebra";
4info="
5LIBRARY: sagbigrob.lib  Compute Sagbi-Groebner basis of an ideal of a subalgebra
6AUTHORS:
7 Nazish Kanwal, Lecturer of Mathematics, School of Mathematics and
8        Computer Science, Institute of Business Administration,
9        Karachi, Pakistan
10 Junaid Alam Khan,  Associate Professor of Mathematics, School of
11        Mathematics and Computer Science, Institute of Business
12        Administration,
13        Karachi, Pakistan
14
15PROCEDURES:
16 LTGS(I,A);                  leading terms for syzygies of I over subalgebra A
17 SGNF(f,I,A);                normalform of f wrt. I in subalgebra A
18 SPOLY(I,A);                 S-polynomials of ideal I over subalgebra A
19 SGB(I,A);                   Sagbi-Groebner basis of ideal I over subalgebra A
20
21SEE ALSO: sagbi_lib
22";
23
24LIB "algebra.lib";
25LIB "sagbi.lib";
26LIB "grobcov.lib";
27
28////////////////////////////////////////
29
30////////// Procedure to compute normal form ////////
31
32// For a polynomial f of subalgebra A and a finite set of polynomials I ,
33// the following procedure compute a normal form of f with respect to I over subalgebra A.
34
35proc SGNF(poly f,ideal I, ideal A)
36"USAGE: SGNF(f,I,A); f polynomial, I ideal of subalgebra
37                   A, A ideal (which is a finite Sagbi bases).
38RETURN: a polynomial h: the normalform of f wrt. I in A
39"
40{
41   A=sagbi(A);
42   ideal G=I ;
43   poly h=f ;
44   poly h1,j,m,c;
45   list L ;
46   map psi ;
47   int i,k;
48
49   while(h!=0 && h1!=h)
50   {
51     for(i=1;i<=size(G);i++)
52     {
53       m=lead(h)/lead(G[i]);
54       if(m!=0)
55       {
56         L= algebra_containment(m,lead(A),1);
57         if (L[1]==1)
58         { k=1;
59           def s= L[2] ;
60           psi= s,maxideal(1),A ;
61           j= psi(check) ;
62           c=leadcoef(h)/(leadcoef(j)*leadcoef(G[i]));
63           h1=h;
64           h=h-(c*j*G[i]);
65           kill s;
66         }
67       }
68     }
69     if(k==0)
70     {
71       return(h);
72     }
73     k=0;
74   }
75   return(h);
76}
77example
78{
79  "EXAMPLE:"; echo = 2;
80  ring r=0,(x,y),Dp;
81  ideal A=x2,xy;
82  ideal I=x3y+x2,x4+x2y2,-x3y3-x2y2;
83  poly f=x6y6+x2;
84  poly g=x12+x6y6-x8+x5y;
85  SGNF(f,I,A);
86  SGNF(g,I,A);
87}
88
89//////// Leading term generating set for syzygies //////
90
91// This is a procedure for computing generating set for syzygies of
92// leading of ideal I over subalgebra A.
93
94// For this procedure we required two more procedures.
95
96// This procedure compute the elements of lead(I) in the power products
97// of leading elements of subalgebra A.
98
99proc SGGS(ideal I,ideal A)
100"USAGE: SGGS(I,A); I ideal of subalgebra, A subalgebra(which is finite sagbi basis).
101RETURN: a list M."
102{
103  A=sagbi(A);
104  def bsr=R1;
105  ideal B=lead(A);
106  int i;
107  ideal vars = maxideal(1) ;
108  int n=nvars(r) ;
109  int m=size(I) ;
110  ideal Q;
111  list M,Li;
112  poly ji;
113  for(i=1;i<=m;i++)
114  {
115     Li=algebra_containment(lead(I[i]),B,1);
116     if (Li[1]==1)
117     {
118       if (defined(Si)) { kill Si; }
119       def Si=Li[2];
120       setring Si;
121       poly ji=check;
122       setring bsr;
123     }
124     ji=imap(Si,ji);
125     M[i]=ji;
126  }
127  return(M);
128}
129
130/////////////////////////////////////
131
132// This procedure provide the syzygies of lead(I) by using
133// Groebner technique.
134
135// Here ideal G=SGGS(I,A);
136proc SYZ(ideal G)
137"USAGE: SYZ(G); G=SGGS(I,A), I ideal of subalgebra A, A is a subalgebra(which is finite sagbi basis).
138RETURN: a list T."
139{
140  int i,j;
141  int l=size(G);
142  list T,S;
143  poly gij;
144  vector vij;
145  for(i=1;i<=l-1;i++)
146  {
147    S=list();
148    for(j=i+1;j<=l;j++)
149    {
150        gij=lcm(G[i],G[j]);
151        vij=(gij/G[i])*gen(i)-(gij/G[j])*gen(j);
152        S[j]=vij;
153    }
154    T[i]=S;
155  }
156  return(T);
157}
158//////////////////////////////////////////
159
160// This procedure provide the leading term generating set for syzygies of
161// lead(I) over subalgebra A.
162
163proc LTGS(ideal I,ideal A)
164"USAGE: LTGS(I,A); I ideal of subalgebra A, A subalgebra (which is a finite sagbi basis).
165RETURN: a module M."
166{
167  def r=basering;
168  A=sagbi(A);
169  ideal F=lead(I);
170  ideal B=lead(A);
171  ideal vars = maxideal(1) ;
172  int n=nvars(r) ;
173  int m=ncols(A) ;
174  int k ;
175  ideal Q1 ;
176  if(I==0)
177  {
178    return(Q1) ;
179  }
180  else
181  {
182    execute("ring R1=("+charstr(r)+"),(y(1..m),"+varstr(r)+"),(dp(m),dp(n));");
183    ideal I=imap(r,I);
184    ideal A=imap(r,A);
185    ideal B=lead(A);
186    list P=SGGS(I,A);
187    int a=size(P);
188    ideal G;
189    for(k=1;k<=a;k++)
190    {
191      G[k]=P[k];
192    }
193    ideal H=std(G);
194    list N=SYZ(G);
195    execute("ring R=("+charstr(r)+"),(y(1..m)),(dp(m));");
196    setring r;
197    map phi= R,B;
198    setring R;
199    ideal T=kernel(r,phi);
200    setring R1;
201    ideal T=imap(R,T);
202    ideal J=intersect(H,T);
203    list Q;
204    int b=size(J);
205    int c=size(H);
206    if(b!=0)
207    {
208      int d,e;
209      list D;
210      vector qd,pde;
211      poly gd;
212      list td;
213      for(d=1;d<=b;d++)
214      {
215        qd=0;
216        gd=J[d];
217        td=pdivi(gd,H);
218        for(e=1;e<=c;e++)
219        {
220          pde=td[2][e]*gen(e);
221          qd=qd+pde;
222        }
223        D[d]=qd;
224      }
225      Q=N,D;
226    }
227    else
228    {
229      Q=N,0;
230    }
231    setring r;
232    map psi=R1,A,maxideal(1);
233    list W=psi(Q);
234    int nn=size(I);
235    int i,j,l,t;
236    module M,Z;
237    vector vij;
238    t=1;
239    for(i=1;i<=nn-1;i++)
240    {
241      Z=0;
242      for(j=i+1;j<=nn;j++)
243      {
244        vij=W[t][i][j];
245        Z[j-i]=vij;
246      }
247      if(M!=0)
248      {
249        M=M,Z;
250      }
251      else
252      {
253        M=Z;
254      }
255    }
256    t=t+1;
257    vector vt;
258    for(l=1;l<=size(W[2]);l++)
259    {
260      vt=W[t][l];
261      if(vt!=0)
262      {
263        M=M,vt;
264      }
265    }
266    return(M);
267  }
268}
269example
270{
271  "EXAMPLE:"; echo = 2;
272// Example 1:
273   ring r=ZZ,(x,y),Dp;
274   ideal A=2x2+xy,2y2,3xy;
275   ideal I=4x2y2+2xy3,18x2y4,36xy5;
276   LTGS(I,A);
277
278// Example 2:
279   ring r2=QQ,(x,y),Dp;
280   ideal A=x2,xy;
281   ideal I=x3y+x2,x4+x2y2,-x3y3-x2y2;
282   LTGS(I,A);
283}
284
285////////// S-Polynomials of ideal I over subalgebra //////////////
286
287// This procedure compute S-polynomials of ideal I over subalgebra A.
288
289// Here we use LTGS(I,A) for computing S-polynomial.
290
291proc SPOLY(ideal I,ideal A)
292"USAGE: SPOLY(I,A); I ideal of subalgebra A, A subalgebra (which is a finite sagbi basis).
293RETURN: an ideal S: S-polynomials of ideal I
294"
295{
296  int i,j;
297  module P=LTGS(I,A);
298  ideal S;
299  poly pij,hj;
300  vector Vj;
301  for(j=1;j<=size(P);j++)
302  {
303    Vj=P[j];
304    hj=0;
305    for(i=1;i<=size(I);i++)
306    {
307      pij = Vj[i]*I[i];
308      hj=hj+pij;
309    }
310    S=S+hj;
311  }
312  return(S);
313}
314example
315{
316  "EXAMPLE:"; echo = 2;
317  // Example 1:
318  ring r=ZZ,(x,y),Dp;
319  ideal A=2x2+xy,2y2,3xy;
320  ideal I=4x2y2+2xy3,18x2y4;
321  SPOLY(I,A);
322  // Example 2:
323  ring r2=QQ,(x,y),Dp;
324  ideal A=x2,xy;
325  ideal I=x3y+x2,x4+x2y2,-x3y3-x2y2;
326  SPOLY(I,A);
327}
328
329//////// SAGBI-GROEBNER Bases Construction //////////
330
331// This procedure give Sagbi Groebner bases of
332// ideal I over subalgebra A.
333
334// We used ideal T=SPOLY(I,A);
335
336proc SGB(ideal I,ideal A)
337"USAGE: SGB(I,A); I ideal of subalgebra A, A subalgebra (which is a finite sagbi basis).
338RETURN: an ideal SB."
339{
340  ideal SB,oldSB;
341  poly Red ;
342  ideal T ;
343  int k,l ;
344  SB=I ;
345  while( size(SB)!=size(oldSB))
346  {
347    A=sagbi(A);
348    T=SPOLY(SB,A);
349    l=size(T);
350    if(l==0)
351    {
352      oldSB=SB;
353    }
354    else
355    {
356      for (k=1; k<=l;k++)
357      {
358        Red=T[k] ;
359        Red=SGNF(Red,SB,A);
360        Red;
361        oldSB=SB ;
362        SB=SB+Red ;
363      }
364    }
365  }
366  return(SB);
367}
368example
369{
370  "EXAMPLE:"; echo = 2;
371  // Example 1:
372  ring r=ZZ,(x,y),Dp;
373  ideal A=2x2+xy,2y2,3xy;
374  ideal I=4x2y2+2xy3,18x2y4;
375  SGB(I,A);
376
377  // Example 2:
378  ring r2=QQ,(w,x,y,z),lp;
379  ideal A=wxy+2z2, y2-4z, x+3y;
380  ideal I= wxy-y2+2z2+4z, x+y2+3y-4z, x2+6xy+9y2;
381  SGB(I,A);
382}
383/*
384// SINGULAR EXAMPLE #01 for all Procedures:
385
386// ring r=integer,(x,y,z),dp;
387// ideal A=2x2+xz,2y2,3yz;
388// ideal I=4x2y2+2xy2z,6x2yz+3xyz2,4x4-4y4+4x3z+x2z2,27y3z3;
389
390// LTGS(I,A);
391
392_[1]=-2y2*gen(2)+3yz*gen(1)
393_[2]=2x2*gen(1)-2y2*gen(3)+xz*gen(1)
394_[3]=27y3z3*gen(1)-4x2y2*gen(4)-2xy2z*gen(4)
395_[4]=2x2*gen(2)+xz*gen(2)-3yz*gen(3)
396_[5]=9y2z2*gen(2)-2x2*gen(4)-xz*gen(4)
397_[6]=27y3z3*gen(3)-4x4*gen(4)-4x3z*gen(4)-x2z2*gen(4)
398
399// SPOLY(I,A);
400
401_[1]=8y6
402_[2]=12y5z
403_[3]=-108y7z3
404
405// SGB(I,A);
406
407_[1]=4x2y2+2xy2z
408_[2]=6x2yz+3xyz2
409_[3]=4x4-4y4+4x3z+x2z2
410_[4]=27y3z3
411_[5]=8y6
412_[6]=12y5z
413
414// SINGULAR EXAMPLE #02 for all Procedures:
415
416// ring r=0,(x,y),lp;
417// ideal A=x3y2+y2, x3-y, y2+y;
418// ideal I=x3y2+x3y-y3-y2, x3+y2, x3y2-y;
419
420// LTGS(I,A);
421
422_[1]=-x3y2*gen(2)+x3*gen(1)-y2*gen(2)-y*gen(1)
423_[2]=-gen(3)+gen(1)
424_[3]=x3y2*gen(2)-x3*gen(3)+y2*gen(2)+y*gen(3)
425_[4]=y2*gen(1)+y*gen(1)-gen(2)
426_[5]=2x3y4*gen(1)+3x3y3*gen(1)+x3y2*gen(1)-y6*gen(1)-4y5*gen(1)-4y4*gen(1)-y3*gen(1)
427_[6]=x6y4*gen(1)-x6y2*gen(2)+2x3y4*gen(2)+2x3y4*gen(1)+4x3y3*gen(2)-y6*gen(2)-4y5*gen(2)-4y4*gen(2)+y4*gen(1)
428_[7]=x6y3*gen(2)-2x3y6*gen(2)-6x3y5*gen(2)-6x3y4*gen(2)+y8*gen(2)+5y7*gen(2)+8y6*gen(2)+4y5*gen(2)-y4*gen(2)
429
430// SPOLY(I,A);
431
432_[1]=x6y-x3y4-2x3y3-3x3y2+y3
433_[2]=x3y-y3-y2+y
434_[3]=x3y4+x3y3+x3y2+x3y+y4-y2
435_[4]=x3y4+2x3y3+x3y2-x3-y5-2y4-y3-y2
436_[5]=2x6y6+5x6y5+4x6y4+x6y3-x3y8-7x3y7-13x3y6-9x3y5-2x3y4+y9+5y8+8y7+5y6+y5
437_[6]=x9y6+x9y5-x9y2-x6y7+x6y6+2x6y5+x6y4+4x6y3-2x3y7+x3y5-4x3y4-y8-5y7-5y6
438_[7]=x9y3-2x6y6-5x6y5-6x6y4-x3y8-x3y7+2x3y6+4x3y5-x3y4+y10+5y9+8y8+4y7-y6
439
440// SGB(I,A);
441
442_[1]=x3y2+x3y-y3-y2
443_[2]=x3+y2
444_[3]=x3y2-y
445_[4]=-x3y3-x3y2+y5+2y4-y2
446_[5]=x3y-y3-y2+y
447_[6]=y4+2y3+y2
448
449*/
Note: See TracBrowser for help on using the repository browser.