source: git/Singular/LIB/elim.lib @ 0b59f5

fieker-DuValspielwiese
Last change on this file since 0b59f5 was 212d09, checked in by Hans Schönemann <hannes@…>, 25 years ago
*hannes: system("random") -> system("--random") git-svn-id: file:///usr/local/Singular/svn/trunk@3636 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 10.4 KB
Line 
1// $Id: elim.lib,v 1.8 1999-09-21 17:32:15 Singular Exp $
2// (GMG, last modified 22.06.96)
3///////////////////////////////////////////////////////////////////////////////
4
5version="$Id: elim.lib,v 1.8 1999-09-21 17:32:15 Singular Exp $";
6info="
7LIBRARY:  elim.lib      PROCEDURES FOR ELIMINATIOM, SATURATION AND BLOWING UP
8
9PROCEDURES:
10 blowup0(j[,s1,s2]);    create presentation of blownup ring of ideal j
11 elim(id,n,m);          variable n..m eliminated from id (ideal/module)
12 elim1(id,p);           p=product of vars to be eliminated from id
13 nselect(id,n[,m]);     select generators not containing nth [..mth] variable
14 sat(id,j);             saturated quotient of ideal/module id by ideal j
15 select(id,n[,m]);      select generators containing all variables n...m
16 select1(id,n[,m]);     select generators containing one variable n...m
17           (parameters in square brackets [] are optional)
18";
19
20LIB "inout.lib";
21LIB "general.lib";
22LIB "poly.lib";
23///////////////////////////////////////////////////////////////////////////////
24
25proc blowup0 (ideal j,list #)
26"USAGE:   blowup0(j[,s1,s2]); j ideal, s1,s2 nonempty strings
27CREATE:  Create a presentation of the blowup ring of j
28RETURN:  no return value
29NOTE:    s1 and s2 are used to give names to the blownup ring and the blownup
30         ideal (default: s1=\"j\", s2=\"A\")
31         Assume R = char,x(1..n),ord is the basering of j, and s1=\"j\", s2=\"A\"
32         then the procedure creates a new ring with name Bl_jR
33         (equal to R[A,B,...])
34               Bl_jR = char,(A,B,...,x(1..n)),(dp(k),ord)
35         with k=ncols(j) new variables A,B,... and ordering wp(d1..dk) if j is
36         homogeneous with deg(j[i])=di resp. dp otherwise for these vars.
37         If k>26 or size(s2)>1, say s2=\"A()\", the new vars are A(1),...,A(k).
38         Let j_ be the kernel of the ring map Bl_jR -> R defined by A(i)->j[i],
39         x(i)->x(i), then the quotient ring Bl_jR/j_ is the blowup ring of j
40         in R (being isomorphic to R+j+j^2+...). Moreover the procedure creates
41         a std basis of j_ with name j_ in Bl_jR.
42         This proc uses 'execute' or calls a procedure using 'execute'.
43DISPLAY: printlevel >=0: explain created objects (default)
44EXAMPLE: example blowup0; shows examples
45"{
46   string bsr = nameof(basering);
47   def br = basering;
48   string cr,vr,o = charstr(br),varstr(br),ordstr(br);
49   int n,k,i = nvars(br),ncols(j),0;
50   int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
51//---------------- create coordinate ring of blown up space -------------------
52   if( size(#)==0 ) { #[1] = "j"; #[2] = "A"; }
53   if( size(#)==1 ) { #[2] = "A"; }
54   if( k<=26 and size(#[2])==1 ) { string nv = A_Z(#[2],k)+","; }
55   else { string nv = (#[2])[1]+"(1.."+string(k)+"),"; }
56   if( is_homog(j) )
57   {
58      intvec v=1;
59      for( i=1; i<=k; i=i+1) { v[i+1]=deg(j[i]); }
60      string nor = "),(wp(v),";
61   }
62   else { string nor = "),(dp(1+k),";}
63   execute("ring Bl=("+cr+"),(t,"+nv+vr+nor+o+");");
64//---------- map to new ring, eliminate and create blown up ideal -------------
65   ideal j=imap(br,j);
66   for( i=1; i<=k; i=i+1) { j[i]=var(1+i)-t*j[i]; }
67   j=eliminate(j,t);
68   v=v[2..size(v)];
69   execute("ring Bl_"+#[1]+bsr+"=("+cr+"),("+nv+vr+nor+o+");");
70   ideal `#[1]+"_"`=imap(Bl,j);
71   export basering;
72   export `#[1]+"_"`;
73   //keepring basering;
74   setring br;
75//------------------- some comments about usage and names  --------------------
76dbprint(p,"",
77"// The proc created the ring Bl_"+#[1]+bsr+" (equal to "+bsr+"["+nv[1,size(nv)-1]+"])",
78"// it contains the ideal "+#[1]+"_ , such that",
79"//             Bl_"+#[1]+bsr+"/"+#[1]+"_ is the blowup ring",
80"// show(Bl_"+#[1]+bsr+"); shows this ring.",
81"// Make Bl_"+#[1]+bsr+" the basering and see "+#[1]+"_ by typing:",
82"   setring Bl_"+#[1]+bsr+";","   "+#[1]+"_;");
83   return();
84}
85example
86{ "EXAMPLE:"; echo = 2;
87   ring R=0,(x,y),dp;
88   poly f=y2+x3; ideal j=jacob(f);
89   blowup0(j);
90   show(Bl_jR);
91   setring Bl_jR;
92   j_;"";
93   ring r=32003,(x,y,z),ds;
94   blowup0(maxideal(1),"m","T()");
95   show(Bl_mr);
96   setring Bl_mr;
97   m_;
98   kill Bl_jR, Bl_mr;
99}
100///////////////////////////////////////////////////////////////////////////////
101
102proc elim (id, int n, int m)
103"USAGE:   elim(id,n,m);  id ideal/module, n,m integers
104RETURNS: ideal/module obtained from id by eliminating variables n..m
105NOTE:    no special monomial ordering is required, result is a SB with
106         respect to ordering dp (resp. ls) if the first var not to be
107         eliminated belongs to a -p (resp. -s) blockordering
108         This proc uses 'execute' or calls a procedure using 'execute'.
109EXAMPLE: example elim; shows examples
110"
111{
112//---- get variables to be eliminated and create string for new ordering ------
113   int ii; poly vars=1;
114   for( ii=n; ii<=m; ii=ii+1 ) { vars=vars*var(ii); }
115   if( n>1 ) { poly p = 1+var(1); }
116   else { poly p = 1+var(m+1); }
117   if( ord(p)==0 ) { string ordering = "),ls;"; }
118   if( ord(p)>0 ) { string ordering = "),dp;"; }
119//-------------- create new ring and map objects to new ring ------------------
120   def br = basering;
121   string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering;
122   execute(str);
123   def i = imap(br,id);
124   poly vars = imap(br,vars);
125//---------- now eliminate in new ring and map back to old ring ---------------
126   i = eliminate(i,vars);
127   setring br;
128   return(imap(@newr,i));
129}
130example
131{ "EXAMPLE:"; echo = 2;
132   ring r=0,(x,y,u,v,w),dp;
133   ideal i=x-u,y-u2,w-u3,v-x+y3;
134   elim(i,3,4);
135   module m=i*gen(1)+i*gen(2);
136   m=elim(m,3,4);show(m);
137}
138///////////////////////////////////////////////////////////////////////////////
139
140proc elim1 (id, poly vars)
141"USAGE:   elim1(id,poly); id ideal/module, poly=product of vars to be eliminated
142RETURN:  ideal/module obtained from id by eliminating vars occuring in poly
143NOTE:    no special monomial ordering is required, result is a SB with
144         respect to ordering dp (resp. ls) if the first var not to be
145         eliminated belongs to a -p (resp. -s) blockordering
146         This proc uses 'execute' or calls a procedure using 'execute'.
147EXAMPLE: example elim1; shows examples
148"
149{
150//---- get variables to be eliminated and create string for new ordering ------
151   int ii;
152   for( ii=1; ii<=nvars(basering); ii=ii+1 )
153   {
154      if( vars/var(ii)==0 ) { poly p = 1+var(ii); break;}
155   }
156   if( ord(p)==0 ) { string ordering = "),ls;"; }
157   if( ord(p)>0 ) { string ordering = "),dp;"; }
158//-------------- create new ring and map objects to new ring ------------------
159   def br = basering;
160   string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering;
161   execute(str);
162   def id = fetch(br,id);
163   poly vars = fetch(br,vars);
164//---------- now eliminate in new ring and map back to old ring ---------------
165   id = eliminate(id,vars);
166   setring br;
167   return(imap(@newr,id));
168}
169example
170{ "EXAMPLE:"; echo = 2;
171   ring r=0,(x,y,t,s,z),dp;
172   ideal i=x-t,y-t2,z-t3,s-x+y3;
173   elim1(i,ts);
174   module m=i*gen(1)+i*gen(2);
175   m=elim1(m,st); show(m);
176}
177///////////////////////////////////////////////////////////////////////////////
178
179proc nselect (id, int n, list#)
180"USAGE:   nselect(id,n[,m]); id a module or ideal, n, m integers
181RETURN:  generators of id not containing the variable n [up to m]
182EXAMPLE: example nselect; shows examples
183"{
184   int j,k;
185   if( size(#)==0 ) { #[1]=n; }
186   for( k=1; k<=ncols(id); k=k+1 )
187   {  for( j=n; j<=#[1]; j=j+1 )
188      {  if( size(id[k]/var(j))!=0) { id[k]=0; break; }
189      }
190   }
191   return(simplify(id,2));
192}
193example
194{ "EXAMPLE:"; echo = 2;
195   ring r=0,(x,y,t,s,z),(c,dp);
196   ideal i=x-y,y-z2,z-t3,s-x+y3;
197   nselect(i,3);
198   module m=i*(gen(1)+gen(2));
199   show(m);
200   show(nselect(m,3,4));
201}
202///////////////////////////////////////////////////////////////////////////////
203
204proc sat (id, ideal j)
205"USAGE:   sat(id,j);  id=ideal/module, j=ideal
206RETURN:  list of an ideal/module [1] and an integer [2]:
207         [1] = saturation of id with respect to j (= union_(k=1...) of id:j^k)
208         [2] = saturation exponent (= min( k | id:j^k = id:j^(k+1) ))
209NOTE:    [1] is a standard basis in the basering
210DISPLAY: saturation exponent during computation if printlevel >=1
211EXAMPLE: example sat; shows an example
212"{
213   int ii,kk;
214   def i=id;
215   id=std(id);
216   int p = printlevel-voice+3;  // p=printlevel+1 (default: p=1)
217   while( ii<=size(i) )
218   {
219      dbprint(p-1,"// compute quotient "+string(kk+1));
220      i=quotient(id,j);
221      for( ii=1; ii<=size(i); ii=ii+1 )
222      {
223         if( reduce(i[ii],id,1)!=0 ) break;
224      }
225      id=std(i); kk=kk+1;
226   }
227   dbprint(p-1,"// saturation becomes stable after "+string(kk-1)+" iteration(s)","");
228   list L = id,kk-1;
229   return (L);
230}
231example
232{ "EXAMPLE:"; echo = 2;
233   int p      = printlevel;
234   ring r     = 2,(x,y,z),dp;
235   poly F     = x5+y5+(x-y)^2*xyz;
236   ideal j    = jacob(F);
237   sat(j,maxideal(1));
238   printlevel = 2;
239   sat(j,maxideal(2));
240   printlevel = p;
241}
242///////////////////////////////////////////////////////////////////////////////
243
244proc select (id, int n, list#)
245"USAGE:   select(id,n[,m]); id ideal/module, n, m integers
246RETURN:  generators of id containing the variable n [all variables up to m]
247NOTE:    use 'select1' for selecting generators containing at least one of the
248         variables between n and m
249EXAMPLE: example select; shows examples
250"{
251   if( size(#)==0 ) { #[1]=n; }
252   int j,k;
253   for( k=1; k<=ncols(id); k=k+1 )
254   {  for( j=n; j<=#[1]; j=j+1 )
255      {   if( size(id[k]/var(j))==0) { id[k]=0; break; }
256      }
257   }
258   return(simplify(id,2));
259}
260example
261{ "EXAMPLE:"; echo = 2;
262   ring r=0,(x,y,t,s,z),(c,dp);
263   ideal i=x-y,y-z2,z-t3,s-x+y3;
264   ideal j=select(i,1);
265   j;
266   module m=i*(gen(1)+gen(2));
267   m;
268   select(m,1,2);
269}
270///////////////////////////////////////////////////////////////////////////////
271
272proc select1 (id, int n, list#)
273"USAGE:   select(id,n[,m]); id ideal/module, n, m integers
274RETURN:  generators of id containing the variable n
275         [at least one of the variables up to m]
276NOTE:    use 'select' for selecting generators containing all the
277         variables between n and m
278EXAMPLE: example select1; shows examples
279"{
280   if( size(#)==0 ) { #[1]=n; }
281   int j,k;
282   execute (typeof(id)+" I;");
283   for( k=1; k<=ncols(id); k=k+1 )
284   {  for( j=n; j<=#[1]; j=j+1 )
285      {   
286         if( size(subst(id[k],var(j),0)) != size(id[k]) )
287         { I=I,id[k]; break; }
288      }
289   }
290   return(simplify(I,2));
291}
292example
293{ "EXAMPLE:"; echo = 2;
294   ring r=0,(x,y,t,s,z),(c,dp);
295   ideal i=x-y,y-z2,z-t3,s-x+y3;
296   ideal j=select1(i,1);
297   j;
298   module m=i*(gen(1)+gen(2));
299   m;
300   select1(m,1,2);
301}
302///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.