source: git/Singular/LIB/resbinomial.lib @ 1e1ec4

spielwiese
Last change on this file since 1e1ec4 was 1e1ec4, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Updated LIBs according to master add: new LIBs from master fix: updated LIBs due to minpoly/(de)numerator changes fix: -> $Id$ fix: Fixing wrong rebase of SW on master (LIBs)
  • Property mode set to 100644
File size: 89.5 KB
Line 
1////////////////////////////////////////////////////////////////////////////
2version="$Id$";
3category="Resolution of singularities";
4info="
5LIBRARY: resbinomial.lib  Combinatorial algorithm of resolution of singularities
6                        of binomial ideals in arbitrary characteristic.
7                        Binomial resolution algorithm of Blanco
8
9AUTHORS:  R. Blanco,            mariarocio.blanco@uclm.es,
10@*        G. Pfister,           pfister@mathematik.uni-kl.de
11
12PROCEDURES:
13 BINresol(J);      computes a E-resolution of singularities of (J) (THE SECOND PART IS NOT IMPLEMENTED YET)
14
15 Eresol(J);                         computes a E-resolution of singularities of (J) in char 0
16 determinecenter(L1,L2,c,n,Y,a,mb,flag,control3);    computes the next blowing-up center
17 Blowupcenter(L1,id,m,L2,c,n,h);    makes the blowing-up
18 Nonhyp(Coef,expJ,sJ,n,flag,sums);  computes the ideal generated by the non hyperbolic generators of expJ
19
20 identifyvar();                     identifies status of variables
21 Edatalist(Coef,Exp,k,n,flag);      gives the E-order of each term in Exp
22 EOrdlist(Coef,Exp,k,n,flag);       computes the E-order of an ideal (giving in the language of lists)
23 maxEord(Coef,Exp,k,n,flag);        computes de maximum E-order of an ideal given by Coef and Exp
24 ECoef(Coef,expP,sP,V,auxc,n,flag); Computes a simplified version of the E-Coeff ideal. The E-orders are correct,
25                                    but tranformations of coefficients of the generators and powers of binomials
26                                    cannot be computed easily in terms of lists.
27 elimrep(L);                        removes repeated terms from a list
28 Emaxcont(Coef,Exp,k,n,flag);       computes a list of hypersurfaces of E-maximal contact
29 cleanunit(mon,n,flag);             clean the units in a monomial mon
30 resfunction(t,auxinv,nchart,n);    composes the E-resolution function
31 calculateI(Coef,J,c,n,Y,a,b,D);    computes the order of the non monomial part of an ideal J
32 Maxord(L,n);                       computes the maximum exponent of an exceptional monomial ideal
33 Gamma(L,c,n);                      computes the Gamma function for an exceptional monomial ideal given by L
34
35 convertdata(C,L,n,flag);           computes the ideal corresponding to C,L
36 lcmofall(nchart,mobile);           computes the lcm of the denominators of the E-orders for all the charts
37 computemcm(Eolist);                computes the lcm of the denominators of the E-orders for one chart
38
39 constructH(Hhist,n,flag);                construct the list of exceptional divisors accumulated at this chart
40 constructblwup(blwhist,n,chy,flag);      construct the ideal defining the map K[W] --> K[Wi],
41                                          which gives the composition map of all the blowing up leading to this chart
42 constructlastblwup(blwhist,n,chy,flag);  construct the ideal defining the last blowup leading to this chart
43
44 genoutput(chart,mobile,nchart,nsons,n,q,p);             generates the output for visualization
45 salida(idchart,chart,mobile,numson,previousa,n,q);      generates the output for one chart
46
47 iniD(n);                           creates a list of lists of zeros of size n
48 sumlist(L1,L2);                    sums two lists component to component
49 reslist(L1,L2);                    subtracts two lists component to component
50 multiplylist(L,a);                 multiplies a list by a number, component to component
51 dividelist(L1,L2);                 divides two lists component to component
52 createlist(L1,L2);                 creates a list of lists of two elements
53";
54// inidata(K,k);                      verifies input data, a binomial ideal K of k generators
55// data(K,k,n);                       transforms data on lists of length n
56// list0(n);                          creates a list of zeros of size n
57
58LIB "general.lib";
59LIB "qhmoduli.lib";
60LIB "inout.lib";
61LIB "poly.lib";
62LIB "resolve.lib";
63LIB "reszeta.lib";
64LIB "resgraph.lib";
65////////////////////////////////////////////////////////////////////////////
66
67static proc inidata(ideal K,int k)
68"USAGE: inidata(K,k); K any ideal, k integer (!=0)
69COMPUTE: Verifies the input data
70RETURN: flag indicating if the ideal is binomial or not
71EXAMPLE: example inidata; shows an example
72"
73{
74 int i;
75 for (i=1;i<=k; i++)
76 { if (size(K[i])>2){return(0);}
77 }
78return(1);
79}
80example
81{"EXAMPLE:"; echo = 2;
82  ring r = 0,(x(1..3)),dp;
83  ideal J1=x(1)^4*x(2)^2, x(1)^2+x(3)^3;
84  inidata(J1,2);
85
86  ideal J2=x(1)^4*x(2)^2, x(1)^2+x(2)^3+x(3)^5;
87  inidata(J2,2);
88}
89/////////////////////////////////////////////////////////////////////////////////
90
91proc changeoriginalvar()
92"USAGE: changeoriginalvar();
93COMPUTE: Change the name of the variables to x(1...n), only necessary at the beginning
94RETURN: the new ring with the suitable names
95EXAMPLE: example changeoriginalvar; shows an example
96"
97{
98int i,n,cont;
99
100n=nvars(basering);
101cont=0;
102def r=basering;
103
104// check the name of the variables
105
106for (i=1;i<=n; i++){if (varstr(i)[1]=="x" or varstr(i)[1]=="y"){cont=cont+1;}}
107
108// change them if there exists some variable different from x(i) or y(i)
109
110if (cont!=n or n<=2){
111             // making the change
112              def Rnew=changevar ("x()");
113              setring Rnew;
114                // print("INVERTIBLE VARIABLES NOT CONSIDERED AT THE BEGINNING");
115              return(Rnew,1);
116             }
117else{          // print("INVERTIBLE VARIABLES ALREADY CONSIDERED AT THE BEGINNING");
118     return(r,0);
119    }
120}
121example
122{"EXAMPLE:"; echo = 2;
123  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
124  changeoriginalvar();
125
126  ring r = 0,(x,y,z,w),dp;
127  changeoriginalvar();
128}
129
130/////////////////////////////////////////////////////////////////////////////////
131
132proc identifyvar()
133"USAGE: identifyvar();
134COMPUTE: Asign 0 to variables x and 1 to variables y, only necessary at the beginning
135RETURN: list, say l, of size the dimension of the basering
136        l[i] is: 0 if the i-th variable is x(i),
137                 1 if the i-th variable is y(i)
138EXAMPLE: example identifyvar; shows an example
139"
140{
141int i,n;
142list flaglist;
143
144n=nvars(basering);
145flaglist=list0(n);
146
147for (i=1;i<=n; i++){if (varstr(i)[1]=="y"){flaglist[i]=1;}}
148
149return(flaglist);
150}
151example
152{"EXAMPLE:"; echo = 2;
153  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
154  identifyvar();
155}
156/////////////////////////////////////////////////////////////////////////////////
157
158proc data(ideal K,int k,int n)
159"USAGE: data(K,k,n); K any ideal, k integer (!=0), n integer (!=0)
160COMPUTE: Construcs a list with the coefficients and exponents of one ideal
161RETURN: lists of coefficients and exponents of K
162EXAMPLE: example data; shows an example
163"
164{int i,j,lon;
165 number aa;
166 intvec cc;
167 list bb,dd,aux,ddaux,Coef,Exp;
168
169 for (i=1;i<=k; i++)
170 { lon=size(K[i]);
171
172// binomial
173if (lon==2){aa=leadcoef(K[i][1]);
174                   bb=aa;
175                   Coef[i]=bb;              // coefficients
176                   cc=leadexp(K[i][1]);     // exponents
177
178// cc is an intvec, transform cc in dd, a list of lists
179                   dd=cc[1..n];
180                   aux[1]=dd;
181// the same for the second term
182
183                   aa=leadcoef(K[i][2]);
184                   bb=aa;
185                   Coef[i]=Coef[i] + bb;  // all the coefficients of i-th generator of K
186                   cc=leadexp(K[i][2]);
187
188                   dd=cc[1..n];
189                   aux[2]=dd;
190                   Exp[i]=aux;}
191
192// monomial
193if (lon==1){aux=list();
194            aa=leadcoef(K[i][1]);
195            bb=aa;
196            Coef[i]=bb;
197            cc=leadexp(K[i][1]);
198            dd=cc[1..n];
199            aux[1]=dd;
200            Exp[i]=aux;}
201} //end for
202return(Coef,Exp);
203}
204example
205{"EXAMPLE:"; echo = 2;
206  ring r = 0,(x(1..3)),dp;
207  ideal J=x(1)^4*x(2)^2, x(1)^2-x(3)^3;
208  data(J,2,3);
209}
210//////////////////////////////////////////////////////
211
212proc Edatalist(list Coef,list Exp,int k,int n,list flaglist)
213"USAGE: Edatalist(Coef,Exp,k,n,flaglist);
214        Coef,Exp,flaglist lists, k,n, integers
215        Exp is a list of lists of exponents, k=size(Exp)
216COMPUTE: computes a list with the E-order of each term
217RETURN: a list with the E-order of each term
218EXAMPLE: example Edatalist; shows an example
219"
220{int i,j,lon,mm;
221 list dd,ss,sums;
222 number aux,aux1,aux2;
223
224 for (i=1;i<=k;i++){lon=size(Coef[i]);
225                    if (lon==1) { for (j=1;j<=n;j++){if (flaglist[j]==0){aux=aux+Exp[i][1][j];}}
226                                  ss=aux; aux=0;}            // monomial
227                    else { for (j=1;j<=n;j++){if (flaglist[j]==0){ aux1=aux1+Exp[i][1][j];
228                                                                   aux2=aux2+Exp[i][2][j];}}
229                           ss=aux1,aux2; aux1=0; aux2=0; }   // binomial
230                    sums[i]=ss;}
231return(sums);
232}
233example
234{"EXAMPLE:"; echo = 2;
235  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
236  list flag=identifyvar();
237  ideal J=x(1)^3*x(3)-y(2)*y(4)^2,x(5)*y(2)-x(7)*y(4)^2,x(6)^2*(1-y(4)*y(8)^5);
238  list L=data(J,3,8);
239  list EL=Edatalist(L[1],L[2],3,8,flag);
240  EL; // E-order of each term
241
242
243  ring r = 2,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
244  list flag=identifyvar();
245  ideal J=x(1)^3*x(3)-y(2)*y(4)^2,x(5)*y(2)-x(7)*y(4)^2,x(6)^2*(1-y(4)*y(8)^5);
246  list L=data(J,3,8);
247  list EL=Edatalist(L[1],L[2],3,8,flag);
248  EL; // E-order of each term IN CHAR 2, COMPUTATIONS NEED TO BE DONE IN CHAR 0
249
250
251  ring r = 0,(x(1..3)),dp;
252  list flag=identifyvar();
253  ideal J=x(1)^4*x(2)^2, x(1)^2-x(3)^3;
254  list L=data(J,2,3);
255  list EL=Edatalist(L[1],L[2],2,3,flag);
256  EL; // E-order of each term
257}
258///////////////////////////////////////////////////////////////////////////////////
259
260proc EOrdlist(list Coef,list Exp,int k,int n,list flaglist)
261"USAGE: EOrdlist(Coef,Exp,k,n,flaglist);
262        Coef,Exp,flaglist lists, k,n, integers
263        Exp is a list of lists of exponents, k=size(Exp)
264COMPUTE: computes de E-order of an ideal given by a list (Coef,Exp) and extra information
265RETURN: maximal E-order, and its position=number of generator and term
266EXAMPLE: example EOrdlist; shows an example
267"
268{int i,can,canpost,lon;
269 number canmin;
270 list sums;
271
272sums=Edatalist(Coef,Exp,k,n,flaglist);
273
274 canmin=sums[1][1];                            // inicializating, works also with a monomial
275for (i=1;i<=k; i++){lon=size(sums[i]);         // this is 2 for binomial and 1 for monomial generators
276                    if (sums[i][1]<=canmin and Coef[i][1]!=0){canmin=sums[i][1];
277                                                               can=i; canpost=1;}
278
279// if the generator is a binomial we check the second term
280
281                   if (lon==2) {if (sums[i][2]<canmin and Coef[i][2]!=0){canmin=sums[i][2];
282                                                                          can=i; canpost=2;}}
283}
284return(canmin,can,canpost);
285}
286example
287{"EXAMPLE:"; echo = 2;
288  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
289  list flag=identifyvar();
290  ideal J=x(1)^3*x(3)-y(2)*y(4)^2,x(5)*y(2)-x(7)*y(4)^2,x(6)^2*(1-y(4)*y(8)^5),x(7)^4*y(8)^2;
291  list L=data(J,4,8);
292  list Eo=EOrdlist(L[1],L[2],4,8,flag);
293  Eo[1]; // E-order
294  Eo[2]; // generator giving the E-order
295  Eo[3]; // term giving the E-order
296}
297
298//////////////////////////////////////////////////////
299
300proc maxEord(list Coef,list Exp,int k,int n,list flaglist)
301"USAGE: maxEord(Coef,Exp,k,n,flaglist);
302        Coef,Exp,flaglist lists, k,n, integers
303        Exp is a list of lists of exponents, k=size(Exp)
304RETURN: computes de maximal E-order of an ideal given by Coef,Exp
305EXAMPLE: example maxEord; shows an example
306"
307{
308int i,lon;
309number canmin;  // THE ASSIGNMENT IS NOT OK BECAUSE IT IS OF TYPE NUMBER
310list sums;
311
312sums=Edatalist(Coef,Exp,k,n,flaglist);
313
314canmin=sums[1][1];                             // inicializating, works also with a monomial
315for (i=1;i<=k; i++){lon=size(sums[i]);         // this is 2 for binomial and 1 for monomial generators
316                    if (sums[i][1]<=canmin and Coef[i][1]!=0){canmin=sums[i][1];}
317
318// if the generator is a binomial we check the second term
319
320                   if (lon==2) {if (sums[i][2]<canmin and Coef[i][2]!=0){canmin=sums[i][2];}}
321}
322return(canmin,sums);
323}
324example
325{"EXAMPLE:"; echo = 2;
326  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
327  list flag=identifyvar();
328  ideal J=x(1)^3*x(3)-y(2)*y(4)^2*x(3),x(5)*y(2)-x(7)*y(4)^2,x(6)^2*(1-y(4)*y(8)^5),x(7)^4*y(8)^2;
329  list L=data(J,4,8);
330  list M=maxEord(L[1],L[2],4,8,flag);
331  M[1];    // E-order
332}
333//////////////////////////////////////////////////////
334
335proc elimrep(list maxvar)
336"USAGE: elimrep(L); L is a list
337COMPUTE: Eliminate repeated terms from a list
338RETURN: the same list without repeated terms
339EXAMPLE: example elimrep; shows an example
340"
341{
342int i,j;
343list aux2;
344
345aux2=maxvar;
346for (i=1;i<=size(aux2); i++)
347{ for (j=i+1;j<=size(aux2); j++){if (aux2[i]==aux2[j] and i!=j){aux2=delete(aux2,j);}}
348}
349maxvar=aux2;
350return(maxvar);
351}
352example
353{"EXAMPLE:"; echo = 2;
354  ring r = 0,(x(1..3)),dp;
355  list L=4,5,2,5,7,8,6,3,2;
356  elimrep(L);
357}
358//////////////////////////////////////////////////////
359
360proc Emaxcont(list Coef,list Exp,int k,int n,list flag)
361"USAGE: Emaxcont(Coef,Exp,k,n,flag);
362        Coef,Exp,flag lists, k,n, integers
363        Exp is a list of lists of exponents, k=size(Exp)
364COMPUTE: Identify ALL the variables of E-maximal contact
365RETURN: a list with the indexes of the variables of E-maximal contact
366EXAMPLE: example Emaxcont; shows an example
367"
368{
369int i,j,lon;
370number maxEo;
371list L,sums,bx,maxvar;
372
373L=maxEord(Coef,Exp,k,n,flag);
374
375maxEo=L[1];
376sums=L[2];
377
378if (maxEo>0){
379
380for (i=1;i<=k; i++){lon=size(sums[i]);
381                   if (lon==2){if (sums[i][1]==maxEo)        // variables of the first term
382                              {for (j=1;j<=n; j++){if(Exp[i][1][j]!=0 and flag[j]==0){bx=j; maxvar=maxvar + bx;}}}
383
384                              if (sums[i][2]==maxEo)         // variables of the second term
385                              {for (j=1;j<=n; j++){if(Exp[i][2][j]!=0 and flag[j]==0){bx=j; maxvar=maxvar + bx;}}}}
386                   else {if (sums[i][1]==maxEo)
387                        {for (j=1;j<=n; j++){if(Exp[i][1][j]!=0 and flag[j]==0){bx=j; maxvar=maxvar + bx;}}}}
388
389                   }}
390else {maxvar=list();}
391
392// eliminating repeated terms
393maxvar=elimrep(maxvar);
394
395// It is necessary to check if flag[j]==0 in order to avoid the selection of y variables
396
397return(maxEo,maxvar);
398}
399example
400{"EXAMPLE:"; echo = 2;
401  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
402  list flag=identifyvar();
403  ideal J=x(1)^3*x(3)-y(2)*y(4)^2,x(5)*y(2)-x(7)*y(4)^2,x(6)^2*(1-y(4)*y(8)^5),x(7)^4*y(8)^2;
404  list L=data(J,4,8);
405  list hyp=Emaxcont(L[1],L[2],4,8,flag);
406  hyp[1]; // max E-order=0
407  hyp[2]; // There are no hypersurfaces of E-maximal contact
408
409  ring r = 0,(x(1),y(2),x(3),y(4),x(5..7),y(8)),dp;
410  list flag=identifyvar();
411  ideal J=x(1)^3*x(3)-y(2)*y(4)^2*x(3),x(5)*y(2)-x(7)*y(4)^2,x(6)^2*(1-y(4)*y(8)^5),x(7)^4*y(8)^2;
412  list L=data(J,4,8);
413  list hyp=Emaxcont(L[1],L[2],4,8,flag);
414  hyp[1]; // the E-order is 1
415  hyp[2]; // {x(3)=0},{x(5)=0},{x(7)=0} are hypersurfaces of E-maximal contact
416
417 }
418///////////////////////////////////////////////////////
419
420proc cleanunit(list mon,int n,list flaglist)
421"USAGE: cleanunit(mon,n,flaglist);
422        mon, flaglist lists, n integer
423COMPUTE: We clean (or forget) the units in a monomial, given by "y" variables
424RETURN: The list defining the monomial ideal already cleaned
425EXAMPLE: example cleanunit; shows an example
426"
427{
428int i;
429
430for (i=1;i<=n;i++){if (flaglist[i]==1){mon[i]=0;}}
431
432// coef[1]=coef[1]*y(i)^mon[i]; IS NOT ALLOWED because mon[i] can be a number
433// therefore, the coefficients remain constant
434
435return(mon);
436}
437example
438{"EXAMPLE:"; echo = 2;
439ring r = 0,(x(1),y(2),x(3),y(4)),dp;
440list flag=identifyvar();
441ideal J=x(1)^3*y(2)*x(3)^5*y(4)^8;
442list L=data(J,1,4);
443L[2][1][1];  // list of exponents of the monomial J
444list M=cleanunit(L[2][1][1],4,flag);
445M;           // new list without units
446}
447//////////////////////////////////////////////////////
448// Classification of the ideal E-Coeff_V(P):
449// ccase=1,    E-Coeff_V(P)=0
450//       2,3   Bold regular case
451//       4     P=1 monomial case (detected before)
452//       0     Otherwise
453
454proc ECoef(list Coef,list expP,int sP,int V,number auxc,int n,list flaglist)
455"USAGE: ECoef(Coef,expP,sP,V,auxc,n,flaglist);
456        Coef, expP, flaglist lists, sP, V, n integers, auxc number
457COMPUTE: The ideal E-Coeff_V(P), where V is a permissible hypersurface which belongs to the center
458RETURN: list of exponents, list of coefficients and classification of the ideal E-Coeff_V(P)
459EXAMPLE: example ECoef; shows an example
460"
461{
462int i,j,k,l,numg,ccase,cont2,cont3,val;
463number aa;
464list Eco,newcoef,auxexp,newL,rs,rs2,aux,aux2,aux3,aux4,L;
465
466auxexp=expP;
467
468l=1;
469for (i=1;i<=sP;i++)
470{rs[i]=size(Coef[i]);
471 if (rs[i]==2){                                   // binomials
472               if (auxexp[i][1][V]!=auxexp[i][2][V])  // no common factors for the variable in V
473
474                  {for (j=1;j<=2;j++){if (auxexp[i][j][V]<auxc){aa=auxc/(auxc-auxexp[i][j][V]);
475                                                              auxexp[i][j][V]=0;
476                                                              aux4[1]=multiplylist(auxexp[i][j],aa);
477                                                              Eco[l]=aux4;
478                                                            // newcoef[l]=Coef[i][j]^aa; IT IS NO ALLOWED!!!
479                                                              newcoef[l]=Coef[i][j]; // we leave it constant
480                                                              l=l+1;}}}
481
482               else                               // common factors for the variable in V, of zero in both terms
483
484                 {if (auxexp[i][1][V]<auxc){aa=auxc/(auxc-auxexp[i][1][V]);
485                                          auxexp[i][1][V]=0; auxexp[i][2][V]=0;
486
487                 // this generator is a power of a binomial
488                 // one possibility is Eco[l]=auxexp[i]; we leave it constant and add some extra number aa, or
489                 // define a binomial again. The E-order coincides!!!
490
491                                          aux=multiplylist(auxexp[i][1],aa);
492                                          aux2=multiplylist(auxexp[i][2],aa);
493                                          aux3[1]=aux;
494                                          aux3[2]=aux2;
495                                          Eco[l]=aux3;
496                                          newcoef[l]=Coef[i];
497                                          l=l+1;}}
498              }
499
500else                                               // monomials
501    {if (auxexp[i][1][V]<auxc){aa=auxc/(auxc-auxexp[i][1][V]);
502                             auxexp[i][1][V]=0;
503                             aux4=list();
504                             aux4[1]=multiplylist(auxexp[i][1],aa);
505                             Eco[l]=aux4;
506                             newcoef[l]=Coef[i];
507                             l=l+1;}}
508}
509
510// cleaning units from the monomial generators of Eco
511// If there are hyperbolic equations in Eco, such that Eco=1, we detect it later, computing the E-order
512
513 numg=size(Eco);
514 for (k=1;k<=numg;k++){ if (size(newcoef[k])==1){Eco[k][1]=cleanunit(Eco[k][1],n,flaglist);}}
515
516// checking Eco
517
518ccase=0;
519cont2=0;
520cont3=0;
521val=0;
522
523// CASE Eco=0: If Eco=empty list then as ideal Eco=0
524
525if (numg==0){ccase=1;}
526else
527{
528for (i=1;i<=numg;i++) {rs2[i]=size(newcoef[i]);
529                       if (rs2[i]==1){val=val+n;                                               // monomials
530                                      for (l=1;l<=n; l++) {if (Eco[i][1][l]==0) {cont2=cont2+1;}}
531                                      }
532                       else{val=val+(2*n);                                                     // binomials
533                            for (l=1;l<=n; l++) {if (Eco[i][1][l]==0) {cont2=cont2+1;}
534                                                 if (Eco[i][2][l]==0) {cont2=cont2+1;}}
535                            }
536                       }
537
538// If cont2=val then all the entries of Eco are zero!! As ideal Eco=1
539
540for (i=1;i<=sP;i++){if (rs[i]==2){                                                           // binomials
541                                  for (l=1;l<=n;l++) {if (expP[i][1][l]!=0) {cont3=cont3+1;}
542                                                      if (expP[i][2][l]!=0) {cont3=cont3+1;}}
543                                 }
544                    else{                                                                    // monomials
545                         for (l=1;l<=n;l++) {if (expP[i][1][l]!=0) {cont3=cont3+1;}}
546                        }
547                   }
548
549// If cont3=0 all the entries of expP are zero!! As ideal P=1 this is detected before
550// If cont3=1 then P is bold regular
551
552
553// CASE Eco=1
554
555if (cont2==val and cont3==1){ccase=2;}    // BOLD REGULAR CASE
556if (cont2==val and cont3>1){ccase=3;}     // CASE P=x^{\alpha},x^{\beta}, IN FACT, BOLD REGULAR
557if (cont2==val and cont3==0){ccase=4;}    // P=1, then I=1 monomial case
558
559// Case BOLD REGULAR P=x^{\alpha}*(1-\mu y^{\delta})
560// IT IS NON NECESSARY TO CHECK IT, Eco=empty list, already done!
561
562 L=maxEord(newcoef,Eco,numg,n,flaglist);         // L[1] is the E-order of Eco
563 if (L[1]==0){ccase=2; print("E-order zero!");}  // BOLD REGULAR CASE
564
565// we leave it to check the computations
566
567} // close else
568
569return(Eco,newcoef,ccase);
570}
571example
572{"EXAMPLE:"; echo = 2;
573ring r = 0,(x(1),y(2),x(3),y(4),x(5..7)),dp;
574list flag=identifyvar();
575ideal P=x(1)^2*x(3)^5-x(5)^7*y(4),x(6)^3*y(2)^5-x(7)^5,x(5)^3*x(6)-y(4)^3*x(1)^5;
576list L=data(P,3,7);
577list L2=ECoef(L[1],L[2],3,1,3,7,flag);
578L2[1];  // exponents of the E-Coefficient ideal respect to x(1)
579L2[2];  // its coefficients
580L2[3];  // classify the type of ideal obtained
581
582ring r = 0,(x(1),y(2),x(3),y(4)),dp;
583list flag=identifyvar();
584ideal J=x(1)^3*(1-2*y(2)*y(4)^2);  // Bold regular case
585list L=data(J,1,4);
586list L2=ECoef(L[1],L[2],1,1,3,4,flag);
587L2;
588
589ring r = 0,(x(1),y(2),x(3),y(4),x(5..7)),dp;
590list flag=identifyvar();
591ideal J=x(1)^3-x(3)^2*y(4)^2,x(1)*x(7)*y(2)-x(6)^3*x(5)*y(4)^3,x(5)^3-x(5)^3*y(2)^2;
592list L=data(J,3,7);
593list L2=ECoef(L[1],L[2],3,1,2,7,flag);
594L2;
595
596ring r = 3,(x(1),y(2),x(3),y(4),x(5..7)),dp;
597list flag=identifyvar();
598ideal J=x(1)^3-x(3)^2*y(4)^2,x(1)*x(7)*y(2)-x(6)^3*x(5)*y(4)^3,x(5)^3-x(5)^3*y(2)^2;
599list L=data(J,3,7);
600list L2=ECoef(L[1],L[2],3,1,2,7,flag);
601L2; // THE COMPUTATIONS ARE NOT CORRECT IN CHARACTERISTIC p>0
602    // because numbers are treated as 0 in assignments
603
604}
605////////////////////////////////////////////////////////////////////////////
606// The intvec a indicates the previous center
607// Hhist = intvec of exceptional divisors of the parent chart
608
609proc determinecenter(list Coef,list expJ,number c,int n,int Y,intvec a,list listmb,list flag,int control3,intvec Hhist)
610"USAGE: determinecenter(Coef,expJ,c,n,Y,a,listmb,flag,control3,Hhist);
611        Coef, expJ, listmb, flag lists, c number, n, Y, control3 integers, a, Hhist intvec
612COMPUTE: next center of blowing up and related information, see example
613RETURN: several lists defining the center and related information
614EXAMPLE: example determinecenter; shows an example
615"
616{int i,j,rstep,l,mm,cont,cont1,cont2,cont3,a4,sI,sP,V,V2,ccase,b,Mindx,tip,mval;
617 number auxc,a1,a2,ex,maxEo,aux;
618
619 list D,H,auxJ; // lists of D_n,D_n-1,...,D_1; H_n,H_n-1,...,H_1; J_n,J_n-1,...,J_1
620
621 list oldOlist,oldC,oldt,oldD,oldH,allH;  // information of the previous step
622
623 list Olist,C,t,Dstar,center,expI,expP,newJ,maxset;
624
625 list maxvar,auxlist,aux3,auxD,auxolist,auxdiv,auxaux,L,rs,auxgamma,auxg2,aux1;   // auxiliary lists
626 list auxinvlist,newcoef,EL,Ecoaux,Hplus,transH,Hsum,auxset,sumnewH;              // auxiliary lists
627 list auxcoefI,auxcent,center2;
628
629 intvec oldinfobo7,infobo7;
630 int infaux,leh,leh2,leh3;
631
632tip=listmb[1];   // It is not used in this procedure, it is used to compute the lcm of the denominators
633oldOlist=listmb[2];
634oldC=listmb[3];
635oldt=listmb[4];  // t= resolution function
636oldD=listmb[5];
637
638oldH=listmb[6];
639allH=listmb[7];
640
641oldinfobo7=listmb[8];  // auxiliary intvec, it is used to define BO[7]
642
643// inicializating lists
644 Olist=list();
645 C=list();
646 auxinvlist=list();
647
648 auxJ[1]=expJ;
649 rstep=n;             // we are in dimension rstep
650 auxc=c;
651 cont=1;
652
653if (Y==0) {D=iniD(n); H=iniD(n); infobo7=-1;} // first center, inicializate previous information
654
655 if (Y!=0 and rstep==n)           // In dimension n, D'_n is always of this form
656   { auxdiv=list0(n);
657     Dstar[1]=oldD[1];
658
659     b=size(a);
660     for (i=1;i<=n;i++) {for (j=1;j<=b;j++) {if (a[j]==i) {aux=aux+oldD[1][i];}}}
661     Dstar[1][Y]=aux;
662     aux=0;
663
664     auxdiv[Y]=oldOlist[1]-oldC[1];
665     D[1]=sumlist(Dstar[1],auxdiv);}  // list defining D_n
666
667// computing strict transforms of the exceptional divisors H
668
669if (Y!=0){transH=iniD(n);
670          for (i=1;i<=size(oldH);i++){transH[i]=oldH[i]; transH[i][Y]=0;}         // Note: size(oldH)<=n
671          allH[Y]=1;}                                                             // transform of |H|=H_nU...UH_1
672
673// We put here size(oldH) instead of n because maybe we have not
674// calculated all the dimensions in the previous step
675
676// STARTING THE LOOP
677
678 while (rstep>=1)
679  {
680    if (Y!=0 and rstep!=n) // transformation law of D_i for i<n
681    {
682      if (cont!=0)      // the resolution function did not drop in higher dimensions
683      {
684       if (oldt[n-rstep]==a1/a2 and c==oldC[1] and control3==0)
685        {auxD=list0(n);
686         auxD[Y]=oldOlist[n-rstep+1]-oldC[n-rstep+1];
687          Dstar[n-rstep+1]=oldD[n-rstep+1];
688
689           for (i=1;i<=n;i++) {for (j=1;j<=b;j++) {if (a[j]==i) {aux=aux+oldD[n-rstep+1][i];}}}
690           Dstar[n-rstep+1][Y]=aux;
691           aux=0;
692
693           D[n-rstep+1]=sumlist(Dstar[n-rstep+1],auxD);
694
695        }
696       else
697           {cont=0;
698            for (j=n-rstep+1;j<=n; j++){D[j]=list0(n);}
699           }
700      }
701    }
702
703// Factorizing J=M*I
704
705   cont1=0;
706   for (i=1;i<=n;i++) {if (D[n-rstep+1][i]==0) {cont1=cont1+1;}}  // if it fails write: listO(n)[i]
707
708   if (cont1==n) {expI=expJ;}    // D[n-rstep+1]=0 (is a list of zeros)
709   else {
710         for (i=1;i<=size(expJ);i++)
711         {rs[i]=size(Coef[i]);
712          if (rs[i]==2){ aux1=list();
713                         aux1[1]=reslist(expJ[i][1],D[n-rstep+1]);
714                         aux1[2]=reslist(expJ[i][2],D[n-rstep+1]);
715                         expI[i]=aux1;}                             // binomial
716          else {aux1=list();
717                aux1[1]=reslist(expJ[i][1],D[n-rstep+1]);
718                expI[i]=aux1;}}                                     // monomial
719        }
720
721// NOTE: coeficients of I = coeficients of J, because I and J differ in a monomial
722
723// Detecting errors, negative exponents in expI
724
725sI=size(expI);
726
727for (i=1;i<=sI;i++)
728{rs[i]=size(Coef[i]);
729 if (rs[i]==2){for (j=1;j<=2;j++){for (l=1;l<=n; l++)
730             {if (expI[i][j][l]<0) {print("ERROR, the BINOMIAL ideal I has negative components");
731        //   print("M ideal"); print(D[n-rstep+1]); print(expI); print("dimension"); print(rstep);
732        //                print("previous chart"); print(size(finalchart)); ~;
733 }}}}
734  else {for (l=1;l<=n; l++)
735  {if (expI[i][1][l]<0) {print("ERROR, the MONOMIAL ideal I has negative components");
736        //  print("M ideal"); print(D[n-rstep+1]); print(expI); print("dimension"); print(rstep);
737        //  print("previous chart"); print(size(finalchart)); ~;
738  }}}
739}
740
741// Compute the maximal E-order of I
742
743L=maxEord(Coef,expI,sI,n,flag);
744maxEo=L[1]; // E-order of I
745
746// Inicializating information
747
748   auxolist=maxEo;
749   a1=maxEo;
750   a2=auxc;
751   Olist=Olist+auxolist;  // list of new maximal E-orders o_n,o_{n-1},...o_1
752   aux3=auxc;
753   C=C+aux3;              // list of new critical values c=c_{n+1},c_{n},...c_2
754
755// It is necessary to check if the first coordinate of the invariant has dropped or not
756// NOTE: By construction, the first coordinate is always 1 !!
757// It has dropped is equivalent to: CURRENT C<c of the previous step
758
759// Calculate new H, this is done for every dimension
760
761if (Y!=0){a4=size(oldt);
762          if (n-rstep+1>a4){cont=0; oldt[n-rstep+1]=0; }            // VERIFICAR!!!!
763
764          if (cont!=0 and oldt[n-rstep+1]==a1/a2 and c==oldC[1] and control3==0){H[n-rstep+1]=transH[n-rstep+1];
765
766              // we fill now the value for BO[7]
767                    if (oldinfobo7[n-rstep+1]==-1){leh=size(Hhist);
768                                                   infobo7[n-rstep+1]=Hhist[leh];} // suitable index !!!
769                    else{ infaux=oldinfobo7[n-rstep+1];
770                          infobo7[n-rstep+1]=infaux;}      // the same as the previous step
771
772                                                                                }
773          else {
774                if (rstep<n) {sumnewH=list0(n);
775                              for (i=1;i<n-rstep+1;i++){sumnewH=sumlist(sumnewH,H[i]);}
776                              H[n-rstep+1]=reslist(allH,sumnewH);}
777                else {H[n-rstep+1]=allH;}
778
779                 // we fill the value for BO[7] too, we complete it at the end if necessary
780                infobo7[n-rstep+1]=-1;
781               }
782          }
783
784// It is necessary to detect the monomial case AFTER inicializate the information
785// OTHERWISE WE WILL HAVE EMPTY COMPONENTS IN THE RESOLUTION FUNCTION
786
787// If maxEo=0 but maxo!=0 MONOMIAL CASE (because E-Sing(J,c) still !=emptyset)
788// If maxEo=0 and maxo=0 then I=1, (real) monomial case, the same case for us
789// NOTE THAT IT DOESN'T MATTER IF THERE IS A p-TH POWER OF A HYPERBOLIC EQ, THE E-ORDER IS ZERO ANYWAY
790
791if (maxEo==0){auxgamma=Gamma(D[n-rstep+1],auxc,n); // Gamma gives (maxlist,gamma,center)
792              auxg2=auxgamma[3];
793              center=center+auxg2;
794              center=elimrep(center);
795              auxinvlist=auxgamma[2];
796
797// print("gamma"); print(auxg2);
798
799              break;}
800
801// Calculate P    // P=I+M^{o/(c-o)} with weight o
802
803if (maxEo>=auxc) {expP=expI; Mindx=0;}                 // The coefficients also remain constant
804   else {ex=maxEo/(auxc-maxEo);
805         auxlist=list();
806         Mindx=1;
807         auxlist[1]=multiplylist(D[n-rstep+1],ex);     // weighted monomial part: D[n-rstep+1]^ex;
808         expP=insert(expI,auxlist);                    // P=I+D[n-rstep+1]^ex;
809         auxcoefI=Coef;
810         Coef=insert(Coef,list(1));}                   // Adding the coefficient for M
811
812// NOTE: IT IS NECESSARY TO ADD COEFFICIENT 1 TO THE MONOMIAL PART M
813// E-ord(P_i)=E-ord(I_i) so to compute the E-order of P_i we can compute E-ord(I_i)
814
815// Calculate variables of E-maximal contact, ALWAYS WITH RESPECT TO THE IDEAL I !!
816
817sP=size(expP);     // Can be different from size(expI)
818
819if (Mindx==1){ maxvar=Emaxcont(auxcoefI,expI,sI,n,flag);}
820else{ maxvar=Emaxcont(Coef,expP,sP,n,flag);}
821
822auxc=maxvar[1];     // E-order of P, critical value for the next step, ALSO VALID auxc=maxEo;
823if (auxc!=maxEo){print("ERROR, the E-order is not well computed");}
824
825maxset=maxvar[2];
826
827// center=center + maxset;  // HACER DESPUES Y A?ADIR SOLO V!!!!!!
828// Cleaning the center: eliminating repeated variables
829// center=elimrep(center);
830
831// if (rstep==1) {break;}   // Induction finished, is not necessary to compute the rest
832
833// Calculate Hplus=set of non permissible hypersurfaces
834// RESET Hplus if c has dropped or we have eliminated hyperbolic generators
835
836// ES NECESARIO PONER CONDICION DE SI INVARIANTE BAJA O NO??? SI BAJA HPLUS NO SE USA...
837
838if (Y==0 or c<oldC[1] or control3==1) {Hplus=list0(n);}
839else {Hsum=list0(n);
840      Hplus=allH;
841      for (i=1;i<=n-rstep+1;i++){Hsum=sumlist(Hsum,H[i]);}
842      Hplus=reslist(Hplus,Hsum);                             // CHEQUEAR QUE NO SALEN -1'S
843     }
844
845// Taking into account variables of maxset outside of Hplus (so inside Hminus)
846
847if (Y==0 or c<oldC[1] or control3==1){V=maxset[1];                  // Hplus=0 so any variable is permissible
848                                      maxset=delete(maxset,1);}     // eliminating this variable V from maxset
849else{
850     // If the invariant remains constant V comes from the previous step
851
852    if (cont!=0 and oldt[n-rstep+1]==a1/a2 and c==oldC[1]){
853                                                           if (Mindx==1){
854//----------------------------USING HPLUS----------------------------------------
855// REMIND THAT IN THIS CASE maxset=HYPERSURFACES OF E-MAXIMAL CONTACT FOR I, INSTEAD OF P
856
857      V2=a[n-rstep+1];           // V can be different from the variable coming from the previous step
858// check that V2 belongs to maxset
859
860for (i=1;i<=size(maxset);i++){
861                              if (V2==maxset[i]){mval=1; break;}
862                              else{mval=0;}
863                             }
864
865      if (Hplus[V2]==0 and mval==1){V=V2;}   // V2 is permissible
866      else{
867                                                      cont2=1;
868                                                      cont3=1;
869                                                      auxset=maxset;
870                                                        while (cont2!=0){mm=auxset[1];
871                                                          if (Hplus[mm]!=0) {auxset=delete(auxset,1); cont3=cont3+1;}
872                                                               // eliminating non permissible variables from maxset
873                                                          else {cont2=0;}}
874                                                      V=maxset[cont3];        // first permissible variable
875                                                      maxset=delete(maxset,cont3);
876           }
877                                                                         }
878
879//-------------------------------------------------------------------------------
880                                                           else{ V=a[n-rstep+1];}
881                                                          }
882    else {V=maxset[1];     // Hplus=0 so any variable is permissible
883          maxset=delete(maxset,1);
884         }
885
886     }
887
888
889// if (V!=V2 and V2!=0){print(a); print(rstep); print(V); print(V2); print("num cartas"); print(size(finalchart)); ~;}
890
891V2=0;
892
893// Adding the new hypersurface of E-maximal contact to the center
894
895auxcent[1]=V;
896
897center=center + auxcent; // print("num cartas"); print(size(finalchart)); print(center); if (size(finalchart)==2){~~;}
898
899auxcent=list();
900
901// Cleaning the center: eliminating repeated variables CREO QUE NO HACE FALTA
902
903center2=elimrep(center);  // print(center2); print("-----------");
904
905// if (size(center2)!=size(center)){print("MAL");}
906
907// for (i=1;i<=size(center);i++){if (center2[i]!=center[i]){print("cambia");}}
908
909
910if (rstep==1) {break;}   // Induction finished, is not necessary to compute the rest
911
912
913// Calculate Eco=E-Coeff_V(P) where V is a permissible hypersurface which belongs to the center
914// Eco can have rational exponents
915
916Ecoaux=ECoef(Coef,expP,sP,V,auxc,n,flag);
917
918// SPECIAL CASES: BOLD REGULAR CASE
919//--------------------------------------------------------------------
920
921if (Ecoaux[3]==1){                      // Eco=EMPTY LIST, Eco=0 AS IDEAL
922                  aux1[1]=list0(n);
923                  newJ[1]=aux1;         // monomial with zero entries, newJ=1 as ideal
924                  newcoef[1]=list(1);   // the new coefficient is only 1
925                  auxaux=list();
926                  auxaux[1]=newJ;
927                  auxJ=auxJ+auxaux;     // auxJ list of ideals J_i
928                  auxinvlist=1;
929                  break;}
930
931//-----------------------------------------------------------
932// THIS CASE IS NOT GOING TO APPEAR, BUT WE LEAVE IT TO CHECK COMPUTATIONS
933
934if (Ecoaux[3]==2 or Ecoaux[3]==3){                     // Eco=0 LIST, Eco=1 AS IDEAL
935                                  aux1[1]=list0(n);
936                                  newJ[1]=aux1;
937                                  newcoef[1]=list(1); // print("Strange case happens"); ~;
938                                  auxaux=list();
939                                  auxaux[1]=newJ;
940                                  auxJ=auxJ + auxaux;  // auxJ list of ideals J_i
941                                  auxinvlist=1;
942                                  break;}
943//-----------------------------------------------------------
944// THIS CASE IS NOT GOING TO APPEAR, BUT WE LEAVE IT TO CHECK COMPUTATIONS
945
946// P=1 THIS CANNOT HAPPEN SINCE P=1 IFF I=1 (or I is equivalent to 1)
947// and this is the monomial case, already checked
948
949if (Ecoaux[3]==4){print("ERROR in ECoef"); break;}
950//-----------------------------------------------------------
951
952// If we are here Ecoaux[3]=0, then continue
953
954// Filling the list of "ideals", auxJ=J_n,J_{n-1},...
955
956 newJ=Ecoaux[1];
957 newcoef=Ecoaux[2];
958
959 auxJ=insert(auxJ,newJ,n-rstep+1); // newJ is inserted after n-rstep+1 position, so in position n-rstep+2
960
961// New input for the loop, if we are here newJ is different from 0
962
963   expJ=newJ;
964   Coef=newcoef;
965
966   newJ=list();
967   expI=list();
968   expP=list();
969   rstep=rstep-1;  // print(size(auxJ));
970}
971
972// EXIT LOOP "while"
973// we do NOT construct the center as an ideal because WE USE LISTS
974
975t=dividelist(Olist,C);    // resolution function t
976
977// Complete the intvec infobo7 if necessary
978
979if (control3==1){infobo7=-1;} // We reset the value after clean hyperbolic equations
980leh2=size(Olist);
981leh3=size(infobo7);
982if (leh3<leh2){for (j=leh3+1;j<=leh2; j++){infobo7[j]=-1;}}
983
984// Auxiliary list to complete the resolution function in special cases
985if (size(auxinvlist)==0) {auxinvlist[1]=0;}
986
987return(center,auxJ,Olist,C,t,D,H,allH,auxinvlist,infobo7);
988}
989example
990{"EXAMPLE:"; echo = 2;
991  ring r = 0,(x(1..4)),dp;
992  list flag=identifyvar();
993  ideal J=x(1)^2-x(2)^2*x(3)^5, x(1)*x(3)^3+x(4)^6;
994  list Lmb=1,list(0,0,0,0),list(0,0,0,0),list(0,0,0,0),iniD(4),iniD(4),list(0,0,0,0),-1;
995  list L=data(J,2,4);
996  list LL=determinecenter(L[1],L[2],2,4,0,0,Lmb,flag,0,-1); // Compute the first center
997  LL[1];  // index of variables in the center
998  LL[2];  // exponents of ideals J_4,J_3,J_2,J_1
999  LL[3];  // list of orders of J_4,J_3,J_2,J_1
1000  LL[4];  // list of critical values
1001  LL[5];  // components of the resolution function t
1002  LL[6];  // list of D_4,D_3,D_2,D_1
1003  LL[7];  // list of H_4,H_3,H_2,H_1 (exceptional divisors)
1004  LL[8];  // list of all exceptional divisors acumulated
1005  LL[9];  // auxiliary invariant
1006  LL[10]; // intvec pointing out the last step where the function t has dropped
1007
1008  ring r= 0,(x(1..4)),dp;
1009  list flag=identifyvar();
1010  ideal J=x(1)^3-x(2)^2*x(3)^5, x(1)*x(3)^3+x(4)^5;
1011  list Lmb=2,list(0,0,0,0),list(0,0,0,0),list(0,0,0,0),iniD(4),iniD(4),list(0,0,0,0),-1;
1012  list L2=data(J,2,4);
1013  list L3=determinecenter(L2[1],L2[2],2,4,0,0,Lmb,flag,0,-1); // Example with rational exponents in E-Coeff
1014  L3[1]; // index of variables in the center
1015  L3[2]; // exponents of ideals J_4,J_3,J_2,J_1
1016  L3[3]; // list of orders of J_4,J_3,J_2,J_1
1017  L3[4]; // list of critical values
1018  L3[5]; // components of the resolution function
1019}
1020////////////////////////////////////////////////////////
1021// idchart= identity number of the current chart
1022// infochart=chart[idchart] information related to the chart to blow up
1023// infochart= int parent,int Y,intvec a,list expJ,list Coef, list flag,                // NEEDED FOR THE RESOLUTION
1024//            intvec Hhist, list blwhist, module path, list hipercoef, list hiperexp   // NEEDED FOR THE OUTPUT
1025
1026// NOTE: IT IS NOT NECESSARY TAKE INTO ACCOUNT "y" VARIABLES BECAUSE THE CENTER IS ALREADY GIVEN
1027
1028proc Blowupcenter(list center,int idchart,int nchart,list infochart,number c,int n,int currentstep)
1029"USAGE: Blowupcenter(center,id,nchart,infochart,c,n,cstep);
1030        center, infochart lists, id, nchart, n, cstep integers, c number
1031COMPUTE: The blowing up at the chart IDCHART along the given center
1032RETURN:  new affine charts and related information, see example
1033EXAMPLE: example Blowupcenter; shows an example
1034"
1035{int num,i,j,k,l,parent,Y,lon,m,m2;
1036 intvec a,Hhist,auxHhist;
1037 number auxsum, auxsum2;
1038 list sons,aux,expJ,blexpJ,blD;
1039 list auxstep,Coef;
1040 list auxchart,auxchart1,info,flaglist;
1041 list auxblwhist,blwhist,hipercoef,hiperexp;
1042module auxpath,auxp2;
1043
1044parent=idchart;
1045num=size(center);
1046
1047// Transform to intvec the list of variables defining the center
1048  a=center[1];
1049  for (i=2;i<=num;i++){a=a,center[i];}
1050
1051expJ=infochart[4];
1052Coef=infochart[5];
1053flaglist=infochart[6];
1054Hhist=infochart[7];
1055blwhist=infochart[8];
1056auxpath=infochart[9];
1057hipercoef=infochart[10];
1058hiperexp=infochart[11];
1059
1060l=size(expJ);
1061
1062// input for the loop
1063blexpJ=expJ;
1064
1065// making the blowing up in the i-th chart
1066for (i=1;i<=num;i++)
1067{
1068// we assign the current number of charts +1 to the i-th chart
1069idchart=nchart+1;
1070nchart=nchart+1;
1071aux=idchart;
1072sons=sons+aux;
1073
1074auxstep[i]=currentstep+1;
1075
1076Y=center[i];
1077
1078// The blowing up
1079
1080 for (j=1;j<=l;j++){lon=size(Coef[j]);
1081                   if (lon==1){for (m=1;m<=n;m++){for (m2=1;m2<=num;m2++){
1082                                                    if (m==center[m2]){auxsum=auxsum+ expJ[j][1][m];}}}
1083                               blexpJ[j][1][Y]=auxsum-c;
1084                               auxsum=0;}                   // monomial
1085                   else {for (m=1;m<=n;m++){for (m2=1;m2<=num;m2++){
1086                                              if (m==center[m2]){auxsum=auxsum+expJ[j][1][m];
1087                                                                auxsum2=auxsum2+expJ[j][2][m];}}}
1088                         blexpJ[j][1][Y]=auxsum-c;
1089                         blexpJ[j][2][Y]=auxsum2-c;
1090                         auxsum=0; auxsum2=0;}               // binomial
1091                  }
1092
1093
1094auxHhist=Hhist,Y;                        // history of the exceptional divisors in this chart
1095auxblwhist=tradblwup(blwhist,n,Y,a,num); // history of the blow ups in this chart
1096
1097auxp2=auxpath,[parent,i];
1098
1099auxchart1=parent,Y,a,blexpJ,Coef,flaglist,auxHhist,auxblwhist,auxp2,hipercoef,hiperexp;
1100
1101// Coef, flaglist are not modified after the blowing-up, the hyperbolic information is the same as in the parent chart
1102
1103auxchart[i]=auxchart1;
1104
1105// Inicializating the exponents of J for the next chart
1106
1107blexpJ=expJ;
1108}
1109// end of the loop
1110
1111// we add its sons to the current chart
1112infochart=infochart+sons;
1113info[1]=infochart;
1114
1115return(info,auxchart,nchart,auxstep,num);
1116}
1117example
1118{"EXAMPLE:"; echo = 2;
1119ring r = 0,(x(1),y(2),x(3),y(4),x(5..7)),dp;
1120list flag=identifyvar();
1121ideal J=x(1)^3-x(3)^2*y(4)^2,x(1)*x(7)*y(2)-x(6)^3*x(5)*y(4)^3,x(5)^3-x(5)^3*y(2)^2;
1122list Lmb=2,list(0,0,0,0,0,0,0),list(0,0,0,0,0,0,0),list(0,0,0,0,0,0,0),iniD(7),iniD(7),list(0,0,0,0,0,0,0),-1;
1123list L=data(J,3,7);
1124list L2=determinecenter(L[1],L[2],2,7,0,0,Lmb,flag,0,-1); // Computing the center
1125module auxpath=[0,-1];
1126list infochart=0,0,0,L[2],L[1],flag,0,list(0,0,0,0,0,0,0),auxpath,list(),list();
1127list L3=Blowupcenter(L2[1],1,1,infochart,2,7,0);
1128L3[1]; // current chart (parent,Y,center,expJ,Coef,flag,Hhist,blwhist,path,hipercoef,hiperexp) with sons: [12],...,[16]
1129L3[2][1]; // information of its first son, write L3[2][2],...,L3[2][5] to see the other sons
1130L3[3];    // current number of charts
1131L3[4];    // step/level associated to each son
1132L3[5];    // number of variables in the center
1133}
1134//////////////////////////////////////////////////////////////
1135
1136proc tradblwup(list blwhist,int n,int Y,intvec a,int num)
1137"Internal procedure - no help and no example available
1138"
1139{
1140int i,j,blwnew;
1141intvec aux,aux2;
1142
1143for (j=1;j<=n;j++){
1144                   for (i=1;i<=num;i++){
1145                                       if (j==a[i] and a[i]!=Y){blwnew=Y; break;}
1146                                       else {blwnew=0;}
1147                                       }
1148                   aux=blwhist[j];
1149                   aux2=aux,blwnew;
1150                   blwhist[j]=aux2;
1151                  }
1152return(blwhist);
1153}
1154//////////////////////////////////////////////////////////////
1155// It is called only when Eord(J)=0, and J!=1 it is checked inside
1156// SO IT IS CALLED AFTER: maxEord(Coef,expJ,sJ,n,flaglist); --> gives (max E-order,sums)
1157
1158proc Nonhyp(list Coef,list expJ,int sJ,int n,list flaglist,list sums)
1159"USAGE: Nonhyp(Coef,expJ,sJ,n,flaglist,sums);
1160        Coef, expJ, flaglist, sums lists, sJ, n integers
1161COMPUTE: The "ideal" generated by the non hyperbolic generators of J
1162RETURN: lists with the following information
1163        newcoef,newJ: coefficients and exponents of the non hyperbolic generators
1164        totalhyp,totalgen: coefficients and exponents of the hyperbolic generators
1165        flaglist: new list saying status of variables
1166NOTE: the basering r is supposed to be a polynomial ring K[x,y],
1167      in fact, we work in a localization of K[x,y], of type K[x,y]_y with y invertible variables.
1168EXAMPLE: example Nonhyp; shows an example
1169"
1170{
1171int i,j,k,h,lon,lon2,cont;
1172number eordcontrol;
1173list genhyp,listgen,listid,posnumJ,newJ,newcoef,hypcoef,hyp,aux1,aux2,aux3,aux,midlist;
1174list totalhyp,totalgen;
1175
1176eordcontrol=0;
1177
1178while (eordcontrol==0 and sJ!=0)
1179{
1180
1181// Give a positional number/flag to each generator of expJ
1182
1183for (i=1;i<=sJ; i++){listgen=expJ[i]; listid=i; posnumJ[i]=listgen+listid; }
1184
1185// Select the non hyperbolic and hyperbolic generators
1186
1187for (j=1;j<=sJ; j++){lon=size(Coef[j]);
1188                     if (lon==1){
1189
1190// IS NOT NECESSARY TO CHECK IF THERE EXIST A MONOMIAL WITH ONLY UNITS, ALREADY DONE!!
1191
1192                                     aux1=aux1+posnumJ[j];
1193                                     aux3=list();
1194                                     aux3[1]=expJ[j];
1195                                     newJ=newJ+aux3;
1196                                     aux3[1]=Coef[j];
1197                                     newcoef=newcoef+aux3;
1198                                }
1199
1200                     else{   // CHECKING BINOMIALS, ONE TERM WITH E-ORDER ZERO GIVES HYPERBOLIC EQ
1201
1202                          if (sums[j][1]==0 or sums[j][2]==0){aux2=aux2+posnumJ[j];
1203                                                              aux3=list();
1204                                                              aux3[1]=expJ[j];
1205                                                              genhyp=genhyp+aux3;
1206                                                              aux3[1]=Coef[j];
1207                                                              hypcoef=hypcoef+aux3;
1208                                                              if (sums[j][1]==0){aux3[1]=expJ[j][2]; hyp=hyp+aux3;}
1209                                                              if (sums[j][2]==0){aux3[1]=expJ[j][1]; hyp=hyp+aux3;}
1210                                                             }
1211                          else {aux1=aux1+posnumJ[j];
1212                                aux3=list();
1213                                aux3[1]=expJ[j];
1214                                newJ=newJ+aux3;
1215                                aux3[1]=Coef[j];
1216                                newcoef=newcoef+aux3;}
1217
1218                          }
1219                    }
1220
1221// NOTE: aux1 and aux2 are no needed right now!
1222
1223// Identify new y variables, that is, x variables in the monomials contained in hyp
1224
1225h=size(hyp);
1226
1227for (k=1;k<=h; k++){ for(i=1;i<=n; i++){ if (hyp[k][i]!=0 and flaglist[i]==0) {flaglist[i]=1;}}}
1228
1229// To replace x by y IT IS NECESSARY TO CHANGE THE BASERING!!! We change only the list flaglist
1230
1231// CHECK IF THE IDEAL IS ALREADY GENERATED BY MONOMIALS, in this case
1232// WE HAVE FINISHED THE E-RESOLUTION PART, J GENERATED BY MONOMIALS AND HYPERBOLIC EQS
1233
1234cont=0;
1235lon2=size(newJ);
1236for (j=1;j<=lon2; j++){if (size(newJ[j])==1){cont=cont+1;}}
1237
1238if (cont==lon2){newcoef=list();
1239                newJ=list();
1240                totalgen=totalgen+genhyp;
1241                totalhyp=totalhyp+hypcoef;
1242                break;}
1243
1244// CHECK IF THERE ARE MORE HYPERBOLIC EQUATIONS AFTER UPDATE THE FLAG LIST
1245// CHECK THE MAXIMAL E-ORDER AGAIN
1246
1247if (lon2==0){   // we are in the previous case, newJ=empty list, save values and exit
1248
1249             totalgen=totalgen+genhyp;
1250             totalhyp=totalhyp+hypcoef;
1251             break;
1252             }
1253
1254midlist=maxEord(newcoef,newJ,lon2,n,flaglist);
1255
1256eordcontrol=midlist[1];
1257
1258  if (eordcontrol==0){                  // new input for the loop
1259                      Coef=newcoef;
1260                      expJ=newJ;
1261                      sJ=lon2;
1262                      sums=midlist[2]; // flaglist is already updated
1263
1264                      totalgen=totalgen+genhyp;
1265                      totalhyp=totalhyp+hypcoef;
1266
1267                      hypcoef=list();
1268                      genhyp=list();
1269
1270                      newJ=list();
1271                      newcoef=list();
1272                    }
1273else{  // If the process is already finished we save the values and exit
1274
1275     totalgen=totalgen+genhyp;
1276     totalhyp=totalhyp+hypcoef;
1277    }
1278
1279} // closing while
1280
1281return(newcoef,newJ,totalhyp,totalgen,flaglist);
1282}
1283example
1284{"EXAMPLE:"; echo = 2;
1285ring r = 0,(x(1),y(2),x(3),y(4),x(5..7)),dp;
1286list flag=identifyvar();  // List giving flag=1 to invertible variables: y(2),y(4)
1287ideal J=x(1)^3-x(3)^2*y(4)^2,x(1)*x(7)*y(2)-x(6)^3*x(5)*y(4)^3,1-x(5)^2*y(2)^2;
1288list L=data(J,3,7);
1289list L2=maxEord(L[1],L[2],3,7,flag);
1290L2[1];     // Maximum E-order
1291list New=Nonhyp(L[1],L[2],3,7,flag,L2[2]);
1292New[1];    // Coefficients of the non hyperbolic part
1293New[2];    // Exponents of the non hyperbolic part
1294New[3];    // Coefficients of the hyperbolic part
1295New[4];    // New hyperbolic equations
1296New[5];    // New list giving flag=1 to invertible variables: y(2),y(4),y(5)
1297
1298ring r = 0,(x(1..4)),dp;
1299list flag=identifyvar();
1300ideal J=1-x(1)^5*x(2)^2*x(3)^5, x(1)^2*x(3)^3+x(1)^4*x(4)^6;
1301list L=data(J,2,4);
1302list L2=maxEord(L[1],L[2],2,4,flag);
1303L2[1];     // Maximum E-order
1304list New=Nonhyp(L[1],L[2],2,4,flag,L2[2]);
1305New;
1306
1307}
1308//////////////////////////////////////////////////////////////
1309
1310proc calculateI(list Coef,list expJ,number c,int n,int Y,intvec a,number oldordI,list oldD)
1311"USAGE: calculateI(Coef,expJ,c,n,Y,a,b,D);
1312        Coef, expJ, D lists, c, b numbers, n,Y integers, a intvec
1313RETURN: ideal I, non monomial part of J
1314EXAMPLE: example calculateI; shows an example
1315"
1316{
1317 int i,cont1,b,j;
1318 number EordI,aux;
1319 list D,L,expI;
1320 list auxdiv,Dstar,aux1,rs;
1321
1322// WE NEED THE MONOMIAL PART, BUT ONLY IN DIMENSION n
1323
1324     auxdiv=list0(n);
1325     auxdiv[Y]=oldordI-c;
1326     Dstar[1]=oldD[1];
1327
1328     b=size(a);
1329     for (i=1;i<=n;i++) {for (j=1;j<=b;j++) {if (a[j]==i) {aux=aux+oldD[1][i];}}}
1330     Dstar[1][Y]=aux;
1331     aux=0;
1332
1333     D[1]=sumlist(Dstar[1],auxdiv);
1334
1335   cont1=0;
1336   for (i=1;i<=n;i++) {if (D[1][i]==0) {cont1=cont1+1;}}   // if it fails write listO(n)[i]
1337
1338   if (cont1==n) {expI=expJ;}
1339   else {
1340         for (i=1;i<=size(expJ);i++)
1341         {rs[i]=size(Coef[i]);
1342          if (rs[i]==2){ aux1=list();
1343                         aux1[1]=reslist(expJ[i][1],D[1]);
1344                         aux1[2]=reslist(expJ[i][2],D[1]);
1345                         expI[i]=aux1;}                            // binomial
1346          else {aux1=list();
1347                aux1[1]=reslist(expJ[i][1],D[1]);
1348                expI[i]=aux1;}}                                    // monomial
1349        }
1350
1351return(expI);
1352}
1353example
1354{"EXAMPLE:"; echo = 2;
1355  ring r = 0,(x(1..3)),dp;
1356  list flag=identifyvar();
1357  ideal J=x(1)^4*x(2)^2, x(3)^3;
1358  list Lmb=1,list(0,0,0),list(0,0,0),list(3),iniD(3),iniD(3),list(0,0,0),-1;
1359  list L=data(J,2,3);
1360  list LL=determinecenter(L[1],L[2],3,3,0,0,Lmb,flag,0,-1); // Calculate the center
1361  module auxpath=[0,-1];
1362  list infochart=0,0,0,L[2],L[1],flag,0,list(0,0,0),auxpath,list(),list();
1363  list L3=Blowupcenter(LL[1],1,1,infochart,3,3,0); // blowing-up and looking to the x(3) chart
1364  calculateI(L3[2][1][5],L3[2][1][4],3,3,3,L3[2][1][3],3,iniD(3)); //  (I_3)
1365  // looking to the x(1) chart
1366  calculateI(L3[2][2][5],L3[2][2][4],3,3,1,L3[2][2][3],3,iniD(3)); //  (I_3)
1367}
1368//////////////////////////////////////////////////////////////////////////////////////
1369//                                                                                  //
1370//  E-RESOLUTION: Eresol(J) subroutine computing the E-resolution of J, char 0      //
1371//                                                                                  //
1372//////////////////////////////////////////////////////////////////////////////////////
1373
1374proc Eresol(ideal J)
1375"USAGE: Eresol(J); J ideal
1376RETURN: The E-resolution of singularities of J in terms of the affine charts, see example
1377EXAMPLE: example Eresol; shows an example
1378"
1379{int i,n,k,idchart,nchart,parent,Y,oldid,tnum,s,cont,control,control2,control3,cont2,val,rs2,l,cont3,tip;
1380 intvec a,Hhist;
1381 number c,EordJ,EordI,oldordI;
1382 list L,LL,oldD,t,auxL,finalchart,chart,auxchart,newL,auxp,auxfchart,L2;
1383 list Coef,expJ,expI,sons,oldOlist,oldC,oldt,oldH,allH,auxordJ,auxordI,auxmb,mobile,invariant;
1384 list step,nsons,auxinv,extraL,totalinv,auxsum;
1385 string empstring;
1386 module auxpath;
1387
1388// ADDED LATER
1389
1390 list flag,newflag,blwhist,hipercoef,hiperexp,hipercoefson,hiperexpson;
1391 intvec infobo7;
1392
1393export finalchart;
1394// export nsons;
1395// export tnum;
1396// export nchart;
1397// export step;
1398export invariant;
1399 export auxinv;
1400export mobile;
1401
1402 n=nvars(basering);
1403 flag=identifyvar();
1404
1405 k=size(J);
1406// Checking input data
1407 if (inidata(J,k)==0){return("This library only works for binomial ideals.");}
1408
1409idchart=1;
1410nchart=1;
1411parent=0;
1412step=0;
1413control=0;
1414control2=0;
1415control3=0;
1416
1417// Translate the input ideal to a list
1418 auxL=data(J,k,n);                       // data gives (Coef,Exp)
1419
1420// THEREAFTER WE WORK ALL THE TIME WITH LISTS
1421
1422L=maxEord(auxL[1],auxL[2],k,n,flag);   // gives (max E-ord, sums)
1423EordJ=L[1];
1424
1425// before the first blow up I=J
1426EordI=EordJ;
1427
1428//  main loop AT EACH CHART WE MUST INICIALIZATE ALL THE VALUES AND
1429// CONSTRUCT THE FIRST CHART chart[1] BEFORE THE LOOP
1430
1431// at the first step, before the blow up, there are no exceptional divisors, Y=0
1432Y=0;
1433expJ=auxL[2];
1434Coef=auxL[1];
1435Hhist=0;
1436blwhist=list0(n);
1437auxpath=[0,-1];
1438hipercoef=list();   // this is for the first chart
1439hiperexp=list();
1440auxp=parent,Y,a,expJ,Coef,flag,Hhist,blwhist,auxpath,hipercoef,hiperexp;
1441chart[1]=auxp;      // information of the first chart
1442
1443tip=1;
1444oldOlist=list0(n);
1445oldC=list0(n);
1446oldC[1]=EordJ;    // non necessary here
1447c=EordJ;          // the value c is given by the previous step
1448oldt=list0(n);
1449oldD=iniD(n);
1450oldH=iniD(n);
1451allH=list0(n);
1452
1453for (i=1;i<=n;i++){infobo7[i]=-1;}
1454
1455auxmb=tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;
1456mobile[1]=auxmb;           // mobile corresponding to the first chart
1457auxinv[1]=list(0);
1458
1459// NOTE: oldC[1] is the value c to classify the chart in one of the next cases
1460
1461// HERE BEGIN THE LOOP
1462
1463while (idchart<=nchart)   // WE PROCEED WHILE THERE EXIST UNSOLVED CHARTS
1464{
1465if (idchart!=1)           // WE ARE NOT IN THE FIRST CHART, INICIALIZATE ALL THE VALUES
1466{
1467
1468parent=chart[idchart][1];
1469Y=chart[idchart][2];
1470a=chart[idchart][3];
1471expJ=chart[idchart][4];
1472Coef=chart[idchart][5];
1473flag=chart[idchart][6];
1474Hhist=chart[idchart][7]; // it is not necessary for the computations
1475blwhist=chart[idchart][8];
1476auxpath=chart[idchart][9];
1477hipercoef=chart[idchart][10];
1478hiperexp=chart[idchart][11];
1479
1480k=size(Coef);   // IT IS NECESSARY TO COMPUTE IT BECAUSE IT DECREASES IF THERE ARE HYPERBOLIC EQS
1481
1482auxordJ=maxEord(Coef,expJ,k,n,flag);
1483EordJ=auxordJ[1];
1484
1485if (control==0){c=mobile[parent+1][3][1];}  // we keep c from the last step
1486else {c=EordJ; control=0; }                  // we reset the value of c
1487
1488 if (control2==1){c=EordJ; control2=0; control3=1;}    // we reset the value of c
1489
1490// NOTE: oldC[1] is the value c to classify the chart in one of the next cases
1491
1492}
1493
1494// The E-order must be computed here
1495
1496oldid=idchart;
1497
1498if (EordJ<0) {print("ERROR in J in chart"); print(idchart); ~; break;}
1499
1500
1501//-------------------------------------------------------------
1502// CASE J=1, if we reset c, can happen Eord=c=0
1503
1504// or if there are hyperbolic equations at the beginning!!! A?ADIR!!!!
1505
1506// if (EordJ==0){auxfchart[1]=chart[idchart];       // WE HAVE FINISHED
1507//              finalchart=finalchart+auxfchart;
1508//              empstring="#";                   print("reset c and Eord=c=0"); print(idchart);
1509//              invariant[idchart]=empstring;
1510//              auxinv[idchart]=list(0);
1511//              nsons[idchart]=0;
1512//              idchart=idchart+1;}
1513
1514
1515//----------------------------------------------------------------------
1516if (EordJ>=c and EordJ!=0)      // subroutine: E-RESOLUTION OF PAIRS
1517{
1518  if (parent>0)
1519  { LL=determinecenter(Coef,expJ,c,n,Y,a,mobile[parent+1],flag,control3,chart[parent][7]); }
1520  else { LL=determinecenter(Coef,expJ,c,n,Y,a,mobile[parent+1],flag,control3,Hhist); }
1521
1522// determinecenter gives (center,auxJ,Olist,C,t,D,H,allH,auxinvlist,infobo7)
1523
1524// save current values, before the blow up
1525oldOlist=LL[3];
1526tip=computemcm(oldOlist);
1527oldC=LL[4];
1528oldt=LL[5];
1529oldD=LL[6];
1530oldH=LL[7];
1531allH=LL[8];
1532auxinv[idchart]=LL[9];
1533infobo7=LL[10];
1534
1535auxmb=tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;
1536mobile[idchart+1]=auxmb;
1537invariant[idchart]=oldt;
1538
1539newL=Blowupcenter(LL[1],idchart,nchart,chart[idchart],c,n,step[idchart]);
1540
1541// Blowupcenter gives (info,auxchart,nchart,auxstep,num)
1542
1543// IMPORTANT: ADD THE NEW CHARTS AFTER EACH BLOW UP, IN ORDER TO KEEP THEM CORRECTLY
1544
1545step=step+newL[4];
1546nsons[idchart]=newL[5];
1547
1548chart=chart+newL[2];
1549finalchart=finalchart+newL[1];
1550
1551// new input for the loop
1552
1553idchart=idchart+1;
1554nchart=newL[3];
1555
1556control3=0;
1557
1558} // END OF CASE EordJ>=c
1559//---------------------------------------------------------------------
1560
1561else{
1562
1563// compute EordI=max E-order(I)
1564
1565expI=calculateI(Coef,expJ,c,n,Y,a,mobile[parent+1][2][1],mobile[parent+1][5]);
1566k=size(expJ);                     // probably non necessary
1567auxordI=maxEord(Coef,expI,k,n,flag);
1568EordI=auxordI[1];
1569auxsum=auxordI[2];
1570
1571// CASE EordI>0  DROP c AND CONTINUE
1572
1573if (EordI>0){idchart=idchart;  // keep the chart and back to the main loop while, dropping the value of c
1574             control=1;}
1575else{                          // EordI=0, so check if I=1 or not
1576
1577cont2=0;                       // If cont2=val then all the entries of expI are zero!!
1578val=0;
1579
1580for (i=1;i<=k;i++) {rs2=size(Coef[i]);
1581                    if (rs2==1){if (auxsum[i][1]==0){cont2=val; break;} // THERE EXIST A MONOMIAL WITH ONLY UNITS
1582
1583                                val=val+n;                                               // monomials
1584                                for (l=1;l<=n; l++) {if (expI[i][1][l]==0) {cont2=cont2+1;}}
1585                               }
1586                    else{val=val+(2*n);                                                     // binomials
1587                         for (l=1;l<=n; l++) {if (expI[i][1][l]==0) {cont2=cont2+1;}
1588                                              if (expI[i][2][l]==0) {cont2=cont2+1;}}
1589                        }
1590                    }
1591
1592
1593// CASE EordI==0 AND I=1 THIS CHART IS DONE, FINISH
1594
1595// NOTE: THIS CASE IS NOT MONOMIAL BECAUSE E-Sing(J,c) is empty
1596
1597if (cont2==val){auxfchart[1]=chart[idchart];
1598                finalchart=finalchart+auxfchart;
1599                empstring="#";
1600                invariant[idchart]=empstring;
1601                auxinv[idchart]=list(0);
1602                nsons[idchart]=0;
1603
1604// information for the mobile
1605                tip=1;
1606                oldOlist=list(0);
1607                oldC=list(0);
1608                oldt=list(0);
1609                oldD=list(0);
1610                oldH=list(0);
1611                allH=list(0);  // the value of the parent + the new one
1612                infobo7=-1;
1613
1614                auxmb=tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;
1615                mobile[idchart+1]=auxmb;
1616
1617                idchart=idchart+1;}
1618
1619else{         // CASE EordI==0 AND I!=1 --> HYPERBOLIC EQUATIONS
1620
1621// COMPUTE THE IDEAL OF NON HYPERBOLIC ELEMENTS
1622
1623extraL=Nonhyp(Coef,expI,k,n,flag,auxordI[2]);    // gives (newcoef,newI,hypcoef,genhyp,flaglist)
1624
1625// CHECK IF ALL THE VARIABLES ARE ALREADY INVERTIBLE
1626
1627newflag=extraL[5];
1628chart[idchart][6]=extraL[5];          // update the status of variables
1629
1630cont3=0;
1631for (i=1;i<=n;i++){if (newflag[i]==1){cont3=cont3+1;}}
1632
1633if (cont3==n){    // ALL THE VARIABLES ARE INVERTIBLE
1634              auxfchart[1]=chart[idchart];
1635              finalchart=finalchart+auxfchart;
1636              empstring="@";
1637              invariant[idchart]=empstring;
1638              auxinv[idchart]=list(0);
1639              nsons[idchart]=0;
1640
1641// information for the mobile
1642                tip=1;
1643                oldOlist=list(0);
1644                oldC=list(0);
1645                oldt=list(0);
1646                oldD=list(0);
1647                oldH=list(0);
1648                allH=list(0);
1649                infobo7=-1;
1650
1651                auxmb=tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;
1652                mobile[idchart+1]=auxmb;
1653
1654              idchart=idchart+1;}
1655else{     // OTHERWISE, CONTINUE CHEKING IF newI=0 or not
1656
1657Coef=extraL[1];
1658expI=extraL[2];
1659
1660hipercoefson=extraL[3];  // Information about hyperbolic generators
1661hiperexpson=extraL[4];
1662
1663k=size(expI);
1664
1665if (k==0){auxfchart[1]=chart[idchart];       // WE HAVE FINISHED
1666          finalchart=finalchart+auxfchart;
1667          empstring="#";                  //  no more non-hyperbolic generators in this chart
1668          invariant[idchart]=empstring;
1669          auxinv[idchart]=list(0);
1670          nsons[idchart]=0;
1671
1672// information for the mobile
1673                tip=1;
1674                oldOlist=list(0);
1675                oldC=list(0);
1676                oldt=list(0);
1677                oldD=list(0);
1678                oldH=list(0);
1679                allH=list(0);
1680                infobo7=-1;
1681
1682                auxmb=tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;
1683                mobile[idchart+1]=auxmb;
1684
1685          idchart=idchart+1;}
1686
1687else{           // CONTINUE WITH THE IDEAL OF NON HYPERBOLIC EQS
1688
1689     chart[idchart][4]=expI;   // new input ideal and coefficients
1690     chart[idchart][5]=Coef;
1691     chart[idchart][10]=hipercoef+hipercoefson;
1692     chart[idchart][11]=hiperexp+hiperexpson;
1693
1694     idchart=idchart;
1695     control2=1;   // it is necessary to reset the value of c
1696     control3=1;   // and the previous exceptional divisors
1697    }
1698
1699// PROBABLY IT IS NEC MORE INFORMATION !!!
1700
1701} // closing else otherwise
1702
1703    } // closing else case I!=1
1704
1705} // closing else for EordI=0
1706
1707if (EordI<0) {print("ERROR in chart"); print(idchart); ~; break;}
1708
1709//----------------------- guardar de momento--------
1710// if (EordI==0) {auxfchart[1]=chart[idchart];
1711//         finalchart=finalchart+auxfchart;
1712//         L2=Gamma(expJ,c,n); // HAY QUE APLICARLO AL M NO AL J
1713//         invariant[idchart]=L2[2];
1714//         auxinv[idchart]=list(0);
1715//         nsons[idchart]=0;
1716//         idchart=idchart+1;}
1717//------------------------------------------------
1718
1719
1720} // END ELSE
1721//---------------------------------------------------
1722
1723} // END LOOP WHILE
1724
1725tnum=step[nchart];
1726
1727totalinv=resfunction(invariant,auxinv,nchart,n);
1728
1729return(chart,finalchart,invariant,nchart,step,nsons,auxinv,mobile,totalinv);
1730}
1731example
1732{"EXAMPLE:"; echo = 2;
1733  ring r = 0,(x(1..2)),dp;
1734  ideal J=x(1)^2-x(2)^3;
1735  list L=Eresol(J);
1736"Please press return after each break point to see the next element of the output list";
1737  L[1][1]; // information of the first chart, L[1] list of charts
1738~;
1739  L[2]; // list of charts with information about sons
1740~;
1741  L[3]; // invariant, "#" means solved chart
1742~;
1743  L[4]; // number of charts, 7 in this example
1744~;
1745  L[5]; // height corresponding to each chart
1746~;
1747  L[6]; // number of sons
1748~;
1749  L[7]; // auxiliary invariant
1750~;
1751  L[8]; // H exceptional divisors and more information
1752~;
1753  L[9]; // complete resolution function
1754
1755"Second example, write L[i] to see the i-th component of the list";
1756  ring r = 0,(x(1..3)),dp;
1757  ideal J=x(1)^2*x(2),x(3)^3; // SOLVED!
1758  list L=Eresol(J);
1759  L[4];  // 16 charts
1760  L[9]; // complete resolution function
1761 ~;
1762
1763"Third example, write L[i] to see the i-th component of the list";
1764  ring r = 0,(x(1..2)),dp;
1765  ideal J=x(1)^3-x(1)*x(2)^3;
1766  list L=Eresol(J);
1767  L[4];  // 8 charts, rational exponents
1768  L[9]; // complete resolution function
1769~;
1770}
1771
1772//////////////////////////////////////////////////////////////////////////////////////
1773
1774proc resfunction(list invariant, list auxinv, int nchart,int n)
1775"USAGE: resfunction(invariant,auxinv,nchart,n);
1776        invariant, auxinv lists, nchart, n integers
1777COMPUTE: Patch the resolution function
1778RETURN: The complete resolution function
1779EXAMPLE: example resfunction; shows an example
1780"
1781{
1782int i,j,l,k;
1783list patchfun,aux;
1784
1785for (i=1;i<=nchart;i++){patchfun[i]=invariant[i];}
1786
1787for (i=1;i<=nchart;i++){if (auxinv[i][1]!=0 and size(auxinv[i])==3){l=size(invariant[i]);
1788                                                                    for (j=1;j<=l;j++){
1789                                                                         if (invariant[i][j]==0){aux=auxinv[i];
1790                                                                                                 patchfun[i][j]=aux;
1791                                                                    if (l<n){for (k=j+1;k<=n;k++){patchfun[i][k]="*";}}}}
1792
1793                                                                    }
1794                        else{
1795                        if (auxinv[i][1]==1 and size(auxinv[i])==1){l=size(invariant[i]);
1796                                                                    if (l<n){for (k=l+1;k<=n;k++){patchfun[i][k]="*";}}
1797                                                                    }
1798                            }
1799                        }
1800
1801return(patchfun);
1802}
1803example
1804{"EXAMPLE:"; echo = 2;
1805 ring r = 0,(x(1..2)),dp;
1806 ideal J=x(1)^2-x(2)^3;
1807 list L=Eresol(J);
1808 L[3]; // incomplete resolution function
1809 resfunction(L[3],L[7],7,2); // complete resolution function
1810}
1811//////////////////////////////////////////////////////////////////////////////////////
1812//                                                                                  //
1813//                              MAIN PROCEDURE                                      //
1814//                                                                                  //
1815//////////////////////////////////////////////////////////////////////////////////////
1816
1817proc BINresol(ideal J)
1818"USAGE: BINresol(J); J ideal
1819RETURN: E-resolution of singularities of a binomial ideal J in terms of the affine charts, see example
1820EXAMPLE: example BINresol; shows an example
1821"
1822{
1823
1824int p,n;
1825
1826p=char(basering);
1827n=nvars(basering);  // already computed in Eresol, it can be improved
1828
1829 def rr=basering;
1830
1831// INTERNAL CHANGE: changing the name of the variables, only if it is necessary
1832
1833list Mout=changeoriginalvar();
1834
1835if (Mout[2]==1){
1836                def r=Mout[1];
1837                setring r;
1838                ideal chy=maxideal(1);
1839                map frr=rr,chy;
1840                ideal J=frr(J);
1841               }
1842// else{def r=basering;}   // CHECK THAT IS NECESSARY !!!
1843
1844// IF WE ARE IN POSTIVE CHAR
1845
1846if (p>0){list Lring=ringlist(basering);
1847         Lring[1]=0;
1848//         def r=basering;
1849         def Rnew=ring(Lring);
1850         setring Rnew;
1851         ideal chy=maxideal(1);
1852         map fRnew=r,chy;
1853         ideal J=fRnew(J);
1854
1855// E-RESOLUTION, Computations in char 0
1856
1857         list L=Eresol(J);
1858
1859// STEP 2: WRITE THE LOCALLY MONOMIAL IDEAL AS A MONOMIAL IDEAL
1860
1861// not implemented yet, CHAR p !!!!
1862
1863// STEP 3: DO THE E-RESOLUTION AGAIN (char 0 again)
1864
1865
1866// generating output in char p
1867
1868         int q=lcmofall(L[4],L[8]);    // lcm of the denominators
1869
1870         list B=genoutput(L[1],L[8],L[4],L[6],n,q,p); // generate output needed for visualization
1871
1872
1873//         setring r;                   // Back to the basering
1874//         ideal chy=maxideal(1);
1875//         map fr=Rnew,chy;
1876//         list L=fr(L);
1877//         list B=fr(B);
1878
1879         }
1880
1881else{
1882
1883// E-RESOLUTION
1884
1885 list L=Eresol(J);
1886
1887// STEP 2: WRITE THE LOCALLY MONOMIAL IDEAL AS A MONOMIAL IDEAL
1888
1889// not implemented yet
1890
1891// STEP 3: DO THE E-RESOLUTION AGAIN
1892
1893
1894// generating output
1895
1896      int q=lcmofall(L[4],L[8]);
1897
1898      list B=genoutput(L[1],L[8],L[4],L[6],n,q,p);
1899
1900     }
1901
1902return(B);
1903}
1904example
1905{"EXAMPLE:"; echo = 2;
1906  ring r = 0,(x(1..2)),dp;
1907  ideal J=x(1)^2-x(2)^3;
1908  list B=BINresol(J);
1909  B[1]; // list of final charts
1910  B[2]; // list of all charts
1911
1912  ring r = 2,(x(1..3)),dp;
1913  ideal J=x(1)^2-x(2)^2*x(3)^2;
1914  list B=BINresol(J);
1915  B[2]; // list of all charts
1916}
1917///////////////////////////////////////////////////////
1918
1919proc Maxord(list L,int n)
1920"USAGE: Maxord(L,n); L list, n integer
1921COMPUTE: Find the maximal entry of a list, input is a list defining a monomial
1922RETURN: maximum entry of a list and its position
1923EXAMPLE: example Maxord; shows an example
1924"
1925{int i,can;
1926 number canmax;
1927 list aux;
1928
1929canmax=1;
1930can=1;
1931for (i=1;i<=n;i++)
1932{ if (L[i]>=canmax and i>=can)
1933 {canmax=L[i]; can=i;}}
1934
1935return(canmax,can);
1936}
1937example
1938{"EXAMPLE:"; echo = 2;
1939  ring r = 0,(x(1..3)),dp;
1940  ideal J=x(1)^2*x(2)*x(3)^5;
1941  list L=data(J,1,3);
1942  L[2]; // list of exponents
1943  Maxord(L[2][1][1],3);
1944}
1945///////////////////////////////////////////////////////
1946
1947proc Gamma(list expM,number c,int n)
1948"USAGE: Gamma(L,c,n); L list, c number, n integer
1949COMPUTE: The Gamma function, resolution function corresponding to the monomial case
1950RETURN: lists of maximum exponents in L, value of Gamma function, center of blow up
1951EXAMPLE: example Gamma; shows an example
1952"
1953{int i,j,k,l,cont,can;
1954 intvec upla;
1955 number canmax;
1956 list expM2,gamma,L,aux,maxlist,center,aux2;
1957
1958 i=1;
1959 cont=0;
1960 expM2=expM;
1961
1962 while (cont==0 and i<=n)
1963{
1964
1965  L=Maxord(expM2,n);
1966  aux=L[1];
1967  maxlist=maxlist + aux;
1968  can=L[2];
1969
1970if (i==1) {upla=can; center=can;}
1971else {upla=upla,can; aux2=can; center=center+aux2;}
1972
1973  canmax=sum(maxlist);
1974  if (canmax>=c)
1975  {gamma[1]=-i; gamma[2]=canmax/c; gamma[3]=upla; cont=1;}
1976  else {expM2[can]=0;}
1977  i=i+1;
1978}
1979 return(maxlist,gamma,center);
1980}
1981example
1982{"EXAMPLE:"; echo = 2;
1983  ring r = 0,(x(1..5)),dp;
1984  ideal J=x(1)^2*x(2)*x(3)^5*x(4)^2*x(5)^3;
1985  list L=data(J,1,5);
1986  list G=Gamma(L[2][1][1],9,5);   // critical value c=9
1987  G[1]; // maximum exponents in the ideal
1988  G[2]; // maximal value of Gamma function
1989  G[3]; // center given by Gamma
1990}
1991///////////////////////////////////////////////////////
1992
1993proc convertdata(list C,list L, int n, list flaglist)
1994"USAGE: convertdata(C,L,n,flaglist);
1995        C, L, flaglist lists, n integer
1996COMPUTE: Compute the ideal corresponding to the given lists C,L
1997RETURN: an ideal whose coefficients are given by C, exponents given by L
1998EXAMPLE: example convertdata; shows an example
1999"
2000{int i,j,k,a,b,lon;
2001 poly aux,aux1,aux2,aux3,f;
2002 ideal J;
2003
2004aux=poly(0);
2005aux1=poly(1);
2006aux2=poly(0);
2007aux3=poly(1);
2008
2009
2010k=size(L);
2011for (i=1;i<=k;i++){lon=size(C[i]);
2012if (lon==1){                                                // variables in the monomial
2013            for (j=1;j<=n;j++){a=int(poly(L[i][1][j]));
2014                               if (a!=0){
2015                                         if (flaglist[j]==0){aux=poly(x(j)^a);
2016                                                             aux1=aux1*aux;}
2017                                         else {aux=poly(y(j)^a);
2018                                               aux1=aux1*aux;}
2019                                        }
2020                              }
2021            if (C[i][1]!=0){aux1=C[i][1]*aux1;}            // we add the coefficient
2022            else {aux1=0;}
2023
2024            J[i]=aux1;
2025            aux1=poly(1);
2026           }
2027
2028else{                                                    // variables in the binomial
2029
2030     for (j=1;j<=n;j++){a=int(poly(L[i][1][j])); b=int(poly(L[i][2][j]));
2031
2032                        if (a!=0){
2033                                  if (flaglist[j]==0){aux=poly(x(j)^a);
2034                                                      aux1=aux1*aux;}
2035                                  else {aux=poly(y(j)^a);
2036                                        aux1=aux1*aux;}
2037                                 }
2038
2039                        if (b!=0){
2040                                  if (flaglist[j]==0){aux2=poly(x(j)^b);
2041                                                      aux3=aux3*aux2;}
2042                                  else {aux2=poly(y(j)^b);
2043                                        aux3=aux3*aux2;}
2044                                 }
2045                          }
2046                                                       // we add the coefficients
2047   if (C[i][1]!=0){aux1=C[i][1]*aux1;}
2048    else {aux1=0;}
2049   if (C[i][2]!=0){aux3=C[i][2]*aux3;}
2050    else {aux3=0;}
2051
2052   f=aux1+aux3;
2053   J[i]=f;
2054   aux1=poly(1);
2055   aux3=poly(1);
2056
2057     }
2058}
2059return(J);
2060}
2061example
2062{"EXAMPLE:"; echo = 2;
2063  ring r = 0,(x(1..4),y(5)),dp;
2064  list M=identifyvar();
2065  ideal J=x(1)^2*y(5)^2-x(2)^2*x(3)^2,6*x(4)^2;
2066  list L=data(J,2,5);
2067  L[1]; // Coefficients
2068  L[2]; // Exponents
2069  ideal J2=convertdata(L[1],L[2],5,M);
2070  J2;
2071}
2072
2073/////////////////////////////////////////////////////////////////////////////
2074
2075proc lcmofall(int nchart,list mobile)
2076"USAGE: lcmofall(nchart,mobile);
2077        nchart integer, mobile list of lists
2078COMPUTE: Compute the lcm of the denominators of the E-orders of all the charts
2079RETURN: an integer given the lcm
2080NOTE: CALL BEFORE salida
2081EXAMPLE: example lcmofall; shows an example
2082"
2083
2084{
2085int i,m,tip,mcmall;
2086intvec numall;
2087
2088for (i=2;i<=nchart+1;i++){
2089                          tip=mobile[i][1];
2090                          if (tip!=1){numall=numall,tip;}
2091                         }
2092m=size(numall);
2093
2094if (m==1){mcmall=1;}
2095else{
2096     if (numall[1]==0){numall=numall[2..m];}
2097     mcmall=lcm(numall);}
2098
2099return(mcmall);
2100}
2101example
2102{"EXAMPLE:"; echo = 2;
2103  ring r = 0,(x(1..2)),dp;
2104  ideal J=x(1)^3-x(1)*x(2)^3;
2105  list L=Eresol(J);
2106  L[4];  // 8 charts, rational exponents
2107  L[8][2][2]; // E-orders at the first chart
2108  lcmofall(8,L[8]);
2109}
2110/////////////////////////////////////////////////////////////////////////////
2111
2112proc salida(int idchart,list chart,list mobile,int numson,intvec previousa,int n,int q,int p)
2113"USAGE: salida(idchart,chart,mobile,numson,previousa,n,q,p);
2114        idchart, numson, n, q, p integers, chart, mobile, lists, previousa intvec
2115COMPUTE: CONVERT THE OUTPUT OF A CHART IN A RING, WHERE DEFINE A BASIC OBJECT (BO)
2116RETURN: the ring corresponding to the chart
2117EXAMPLE: example salida; shows an example
2118"
2119{
2120int l,i,m,aux,parent,m4,j;
2121intvec Hhist,EOhist,aux7,aux9;
2122list expJ,Coef,BO,blwhist,Eolist,hipercoef,hiperexp;
2123list flag;
2124
2125// chart gives: parent,Y,a,expJ,Coef,flag,Hhist,blwhist,path,hipercoef,hiperexp
2126// mobile gives: tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;  NOTE: Eolist=mobile[2];
2127
2128// we need to define the suitable ring at this chart
2129
2130list Lring=ringlist(basering);
2131def RR2=basering;
2132
2133flag=chart[6];
2134string newl;
2135
2136for (l=1;l<=n; l++){if (flag[l]==1){newl=string(l);
2137                                    Lring[2][l]="y("+newl+")";} }
2138
2139
2140         def RRnew=ring(Lring);
2141         setring RRnew;
2142         ideal chy=maxideal(1);
2143         map fRnew=RR2,chy;
2144
2145         list chart=fRnew(chart);
2146
2147         list mobile2=fRnew(mobile);
2148
2149
2150flag=chart[6];
2151
2152// we need to convert expJ and Coef to an ideal
2153
2154expJ=chart[4];
2155Coef=chart[5];
2156Hhist=chart[7];
2157blwhist=chart[8];
2158
2159// now the ideal will be correctly defined in the ring Rnew
2160
2161ideal J2=convertdata(Coef,expJ,n,flag);        // Computations in RRnew
2162
2163//------------------------------------------------------------------------------
2164// START TO CREATE THE BO corresponding to this chart
2165
2166BO=createBO(J2);
2167
2168// MODIFY BO WITH THE INFORMATION OF THE CHART
2169
2170// BO[1] an ideal, say W_i, defining the ambient space of the i-th chart of the blowing up
2171// If there are hyperbolic equations, we put them here
2172
2173hipercoef=chart[10];
2174hiperexp=chart[11];
2175
2176if (size(hipercoef)!=0){
2177                        ideal ambJ=convertdata(hipercoef,hiperexp,n,flag);
2178                        BO[1]=ambJ;
2179                       }
2180
2181// BO[2] an ideal defining the controlled transform
2182
2183BO[2]=J2;
2184
2185// BO[3] intvec, tupla containing the maximal E-order of BO[2]
2186
2187if (numson==0){BO[3]=1;}    // we write 1 if the chart is a final chart
2188else{
2189     Eolist=mobile2[2];     // otherwise, convert the list of E-orders in an intvec
2190     m=size(Eolist);
2191     aux=int(Eolist[1]*q);
2192     EOhist=aux;
2193
2194     if (m>1){for (i=2;i<=m;i++){aux=int(Eolist[i]*q); EOhist=EOhist,aux;}}
2195
2196     BO[3]=EOhist;
2197     }
2198
2199// BO[4] the list of exceptional divisors given by Hhist
2200
2201 BO[4]=constructH(Hhist,n,flag);
2202
2203// BO[5] an ideal defining the map K[W] ----> K[Wi] given by blwhist
2204
2205BO[5]=constructblwup(blwhist,n,chy,flag);
2206
2207// BO[6] an intvec, BO[6][j]=1 indicates that <BO[4][j],BO[2]>=1, i.e. the
2208//                  strict transform does not meet the j-th exceptional divisor
2209
2210m4=size(BO[4]);
2211ideal auxydeal;
2212ideal Jint;
2213
2214for (j=1;j<=m4;j++){
2215
2216                    auxydeal=BO[4][j]+J2;
2217                    Jint=std(auxydeal);
2218
2219                    if (size(Jint)==1 and Jint[1]==1){BO[6][j]=1;}
2220                    else{BO[6][j]=0;}
2221                   }
2222
2223// BO[7] intvec, the index of the first blown-up object in the resolution process
2224//                leading to this object for which the value of b was BO[3]
2225//                the subsequent ones are the indices for the Coeff-Objects
2226//                of BO[2] used when determining the center
2227//   index of last element of H^- in H
2228
2229
2230if (numson!=0){BO[7]=mobile2[8];}  // it is always -1 at the final charts
2231
2232// BO[8] a matrix indicating that BO[4][i] meets BO[4][j] by BO[8][i,j]=1 for i < j
2233
2234if (m4>0){
2235matrix aux8[m4][m4];
2236
2237BO[8]=aux8;
2238
2239ideal auxydeal2;
2240ideal Jint2;
2241
2242for (i=1;i<=m4;i++){
2243                    for (j=i+1;j<=m4;j++){
2244                                        auxydeal2=BO[4][i]+BO[4][j];
2245                                        Jint2=std(auxydeal2);
2246
2247                                        if (size(Jint2)==1 and Jint2[1]==1){BO[8][i,j]=0;}
2248                                        else{ for (l=1;l<j;l++){BO[8][l,j]=1;} }
2249                                        }
2250
2251                    }
2252}
2253else{ matrix aux8[1][1];
2254      BO[8]=aux8;}
2255
2256
2257// BO[9] INTERNAL DATA, second component of Villamayor resolution function,
2258// only needed to use the visualization procedures
2259
2260 int m3=size(BO[3]);
2261
2262if (m3==1){aux9=intvec(0);}
2263else{ aux9[1]=0;
2264      for (i=2;i<=m3;i++){aux9=aux9,0;}
2265    }
2266
2267BO[9]=aux9;
2268
2269//------------------------------------------------------------------------------
2270
2271// START TO CREATE THE extra information corresponding to this chart
2272
2273/////////////// Short description of data in a chart ///////////////////
2274// All chart data is stored in an object of type ring, the following
2275// variables are always present in such a ring:
2276
2277// BO:      already created
2278
2279// cent:  ideal, describing the upcoming center determined by the algorithm
2280
2281   ideal cent=tradtoideal(previousa,J2,flag);
2282
2283
2284// path= module (autoconverted to matrix)
2285// path[1][idchart]=parent[idchart] index of the parent-chart in resolution history of this chart
2286// path[2][idchart]=index of this chart in relation with its brother-charts
2287
2288   module path=chart[9];
2289
2290
2291// lastMap: ideal, describing the preceding blow up leading to this chart
2292
2293   ideal lastMap=constructlastblwup(blwhist,n,chy,flag);
2294
2295
2296//------------------------------------------------------------------------------
2297
2298// EXTRA INFORMATION NEEDED
2299
2300  list invSat=ideal(0),aux9;
2301
2302
2303// BACK TO THE CHAR OF THE ORIGINAL RING, IF IT HAD p>0
2304
2305if (p>0){
2306
2307         list Lring;
2308         Lring=ringlist(RRnew);
2309         Lring[1]=p;
2310         def auxRnew=ring(Lring);
2311
2312         kill Lring;
2313         setring auxRnew;
2314 ideal chy=maxideal(1);
2315 map frnew=RRnew,chy;
2316 def BO=frnew(BO);
2317
2318// def chart=frr(chart);
2319 def invSat=frnew(invSat);
2320 def lastMap=frnew(lastMap);
2321 def cent=frnew(cent);
2322 def path=frnew(path);
2323
2324        }
2325
2326// export everything needed
2327
2328export BO;
2329export(invSat);
2330export lastMap;
2331export path;
2332export cent;
2333
2334if (p==0){return(RRnew);}
2335else{
2336     return(auxRnew);}
2337}
2338example
2339{"EXAMPLE:"; echo = 2;
2340  ring r = 0,(x(1..2)),dp;
2341  ideal J=x(1)^2-x(2)^3;
2342  list L=Eresol(J);
2343  list B=salida(5,L[1][5],L[8][6],2,L[1][3][3],2,1,0); // chart 5
2344  def RR=B[1];
2345  setring RR;
2346  BO;
2347"press return to see next example"; ~;
2348
2349  ring r = 0,(x(1..2)),dp;
2350  ideal J=x(1)^2-x(2)^3;
2351  list L=Eresol(J);
2352  list B=salida(7,L[1][7],L[8][8],0,L[1][5][3],2,1,0); // chart 7
2353  def RR=B[1];
2354  setring RR;
2355  BO;
2356  showBO(BO);
2357"press return to see next example"; ~;
2358
2359  ring r = 0,(x(1..2)),dp;
2360  ideal J=x(1)^3-x(1)*x(2)^3;
2361  list L=Eresol(J); // 8 charts, rational exponents
2362  list B=salida(1,L[1][1],L[8][2],2,0,2,2,0); // CHART 1
2363  def RR=B[1];
2364  setring RR;
2365  BO;
2366
2367}
2368
2369/////////////////////////////////////////////////////////////////////////////
2370// CONVERT THE OUTPUT OF Eresol IN A LIST OF RINGS, WHERE A BASIC OBJECT (BO) IS DEFINED
2371// IN ORDER TO INTEGRATE THIS LIBRARY INSIDE THE LIBRARY resolve.lib
2372
2373proc genoutput(list chart,list mobile,int nchart,list nsons,int n,int q, int p)
2374"USAGE: genoutput(chart,mobile,nchart,nsons,n,q,p);
2375        chart, mobile, nsons lists, nchart, n,q, p integers
2376RETURN: two lists, the first one gives the rings corresponding to the final charts,
2377        the second one is the list of all rings corresponding to the affine charts of the resolution process
2378EXAMPLE: example genoutput; shows an example
2379"
2380{
2381  int idchart,parent;
2382  list auxlist,solvedrings,totalringlist,previousa;
2383  list auxlistenp,solvedringsenp,totalringenp;
2384
2385// chart gives: parent,Y,a,expJ,Coef,flag,Hhist,blwhist,path,hipercoef,hiperexp
2386// mobile gives: tip,oldOlist,oldC,oldt,oldD,oldH,allH,infobo7;  NOTE: Eolist=mobile[2];
2387
2388  idchart=1;
2389
2390// first loop, construct list previousa
2391
2392  while (idchart<=nchart)
2393  {
2394    if (idchart==1){previousa[1]=chart[2][3];}
2395    else
2396    {
2397// if there are no sons, the next center is nothing
2398      if (nsons[idchart]==0){previousa[idchart]=0;}
2399// always fill the parent
2400      parent=chart[idchart][1];
2401      previousa[parent]=chart[idchart][3];
2402    }
2403    idchart=idchart+1;
2404  }
2405// HERE BEGIN THE LOOP
2406  idchart=1;
2407  while (idchart<=nchart)
2408  {
2409    def auxexit=salida(idchart,chart[idchart],mobile[idchart+1],nsons[idchart],previousa[idchart],n,q,p);
2410    if (p>0)
2411    { // we need the computations in char 0 too
2412      def auxexitenp=salida(idchart,chart[idchart],mobile[idchart+1],nsons[idchart],previousa[idchart],n,q,0);
2413    }
2414    else{def auxexitenp=auxexit;}
2415// we add the ring to the list of all rings
2416    auxlist[1]=auxexit;
2417    totalringlist=totalringlist+auxlist;
2418    auxlistenp[1]=auxexitenp;
2419    totalringenp=totalringenp+auxlistenp;
2420// if the chart has no sons, add it to the list of final charts
2421    if (nsons[idchart]==0)
2422    {
2423      solvedrings=solvedrings+auxlist;
2424      solvedringsenp=solvedringsenp+auxlistenp;
2425    }
2426    auxlist=list();
2427    auxlistenp=list();
2428    kill auxexit;
2429    kill auxexitenp;
2430    idchart=idchart+1;
2431  } // EXIT WHILE
2432  return(solvedrings,totalringlist,solvedringsenp,totalringenp);
2433}
2434example
2435{"EXAMPLE:"; echo = 2;
2436  ring r = 0,(x(1..2)),dp;
2437  ideal J=x(1)^3-x(1)*x(2)^3;
2438  list L=Eresol(J);         // 8 charts, rational exponents
2439  list B=genoutput(L[1],L[8],L[4],L[6],2,2,0); // generates the output
2440  presentTree(B);
2441  list iden0=collectDiv(B);
2442  ResTree(B,iden0[1]);        // generates the resolution tree
2443
2444// Use presentTree(B); to see the final charts
2445// To see the tree type in another shell
2446//    dot -Tjpg ResTree.dot -o ResTree.jpg
2447//   /usr/bin/X11/xv ResTree.jpg
2448
2449}
2450/////////////////////////////////////////////////////////////////////
2451
2452proc computemcm(list Eolist)
2453"USAGE: computemcm(Eolist); Eolist list
2454RETURN: an integer, the least common multiple of the denominators of the E-orders
2455NOTE: Make the same as lcmofall but for one chart. NECESSARY BECAUSE THE E-ORDERS ARE OF TYPE NUMBER!!
2456EXAMPLE: example computemcm; shows an example
2457"
2458{
2459  int m,i,aux,mcmchart;
2460  intvec num;
2461  m=size(Eolist);
2462  if (m==1){mcmchart=int(denominator(Eolist[1])); return(mcmchart);}
2463  if (m>1)
2464  {
2465    num=int(denominator(Eolist[1]));
2466    for (i=2;i<=m;i++)
2467    {aux=int(denominator(Eolist[i])); num=num,aux; }
2468  }
2469  mcmchart=lcm(num);
2470  return(mcmchart);
2471}
2472example
2473{"EXAMPLE:"; echo = 2;
2474  ring r = 0,(x(1..2)),dp;
2475  ideal J=x(1)^3-x(1)*x(2)^3;
2476  list L=Eresol(J);   // 8 charts, rational exponents
2477  L[8][2][2];         // maximal E-order at the first chart
2478  computemcm(L[8][2][2]);
2479
2480}
2481/////////////////////////////////////////////////////////////////////
2482
2483proc constructH(intvec Hhist,int n,list flag)
2484"USAGE: constructH(Hhist,n,flag);
2485        Hhist intvec, n integer, flag list
2486RETURN: the list of exceptional divisors accumulated at this chart
2487EXAMPLE: example constructH; shows an example
2488"
2489{
2490  int i,j,m,l;
2491  list exceplist;
2492  ideal aux;
2493  m=size(Hhist);
2494  if (Hhist[1]==0 and m>1)
2495  {
2496    Hhist=Hhist[2..m]; m=m-1;
2497    for (i=1;i<=m;i++)
2498    {
2499      l=Hhist[i];
2500      if (flag[l]==0){aux=ideal(poly(x(l))); }
2501      else {aux=ideal(poly(y(l))); }
2502      exceplist[i]=aux;
2503    }
2504// eliminate repeated variables
2505    for (i=1;i<=m;i++)
2506    {
2507      for (j=1;j<=m;j++)
2508      {
2509        if (Hhist[i]==Hhist[j] and i!=j)
2510        {
2511          if (i<j){exceplist[i]=ideal(1);}
2512          if (i>j){exceplist[j]=ideal(1);}
2513        }
2514      }
2515    }
2516  }
2517  else  {exceplist=list();}
2518// else  {exceplist=list(ideal(0));} // IF IT FAILS USE THIS
2519  return(exceplist);
2520}
2521example
2522{"EXAMPLE:"; echo = 2;
2523  ring r = 0,(x(1..3)),dp;
2524  list flag=identifyvar();
2525  ideal J=x(1)^4*x(2)^2, x(1)^2+x(3)^3;
2526  list L=Eresol(J);   // 7 charts
2527  // history of the exceptional divisors at the 7-th chart
2528  L[1][7][7]; // blow ups at x(3)-th, x(1)-th and x(1)-th charts
2529  constructH(L[1][7][7],3,flag);
2530}
2531/////////////////////////////////////////////////////////////////////
2532
2533proc constructblwup(list blwhist,int n,ideal chy,list flag)
2534"USAGE: constructblwup(blwhist,n,chy,flag);
2535        blwhist, flag lists, n integer, chy ideal
2536RETURN: the ideal defining the map K[W] --> K[Wi],
2537        which gives the composition map of all the blowing up leading to this chart
2538NOTE: NECESSARY START WITH COLUMNS
2539EXAMPLE: example constructblwup; shows an example
2540"
2541{
2542  int i,j,m,m2;
2543  poly aux2;
2544
2545  m=size(blwhist[1]);
2546
2547  for (j=1;j<=m;j++)
2548  {
2549    for (i=1;i<=n;i++)
2550    {
2551      m2=blwhist[i][j];
2552// If m2!=0 this variable changes. First decide if the variable to multiply is invertible or not
2553      if  (m2!=0)
2554      {
2555        if (flag[m2]==0){aux2=poly(x(m2));}
2556        else {aux2=poly(y(m2));}
2557// And then substitute this variable for the corresponding product in the whole ideal
2558        if (flag[i]==0){chy=subst(chy,x(i),x(i)*aux2);}
2559        else {chy=subst(chy,y(i),y(i)*aux2);}
2560      }
2561    }
2562  }
2563  return(chy);
2564}
2565example
2566{"EXAMPLE:"; echo = 2;
2567  ring r = 0,(x(1..3)),dp;
2568  list flag=identifyvar();
2569  ideal chy=maxideal(1);
2570  ideal J=x(1)^4*x(2)^2, x(1)^2+x(3)^3;
2571  list L=Eresol(J);   // 7 charts
2572  // history of the blow ups at the 7-th chart, center {x(1)=x(3)=0} every time
2573  L[1][7][8]; // blow ups at x(3)-th, x(1)-th and x(1)-th charts
2574  constructblwup(L[1][7][8],3,chy,flag);
2575}
2576/////////////////////////////////////////////////////////////////////
2577
2578proc constructlastblwup(list blwhist,int n,ideal chy,list flag)
2579"USAGE: constructlastblwup(blwhist,n,chy,flag);
2580        blwhist, flag lists, n integer, chy ideal
2581RETURN: the ideal defining the last blow up
2582NOTE: NECESSARY START WITH COLUMNS
2583EXAMPLE: example constructlastblwup; shows an example
2584"
2585{
2586  int i,j,m,m2;
2587  poly aux2;
2588  m=size(blwhist[1]);
2589
2590  if (m>0)
2591  {
2592    for (i=1;i<=n;i++){ m2=blwhist[i][m];
2593
2594    // If m2!=0 this variable changes. First decide if the variable to multiply is invertible or not
2595
2596    if  (m2!=0)
2597    {
2598      if (flag[m2]==0){aux2=poly(x(m2));}
2599      else {aux2=poly(y(m2));}
2600
2601// And then substitute this variable for the corresponding product in the whole ideal
2602
2603      if (flag[i]==0){chy=subst(chy,x(i),x(i)*aux2);}
2604      else {chy=subst(chy,y(i),y(i)*aux2);}
2605    }
2606  }
2607}
2608
2609return(chy);
2610}
2611example
2612{"EXAMPLE:"; echo = 2;
2613  ring r = 0,(x(1..3)),dp;
2614  list flag=identifyvar();
2615  ideal chy=maxideal(1);
2616  ideal J=x(1)^4*x(2)^2, x(1)^2+x(3)^3;
2617  list L=Eresol(J);   // 7 charts
2618  // history of the blow ups at the 7-th chart, center {x(1)=x(3)=0} every time
2619  L[1][7][8]; // blow ups at x(3)-th, x(1)-th and x(1)-th charts
2620  constructlastblwup(L[1][7][8],3,chy,flag);
2621}
2622/////////////////////////////////////////////////////////////////////
2623
2624proc tradtoideal(intvec a,ideal J2,list flag)
2625"USAGE: tradtoideal(a,J2,flag);
2626        a intvec, J2 ideal, flag list
2627COMPUTE: traslate to an ideal the intvec defining the center
2628RETURN: the ideal of the center, given by the intvec a, or J2 if a=0
2629EXAMPLE: example tradtoideal; shows an example
2630"
2631{
2632  int i,m;
2633  ideal acenter,aux2;
2634
2635  if (a==0)
2636  {acenter=J2;}
2637  else
2638  {
2639    m=size(a);
2640    for (i=1;i<=m;i++)
2641    {
2642      if (flag[a[i]]==0){aux2=poly(x(a[i]));}
2643      else {aux2=poly(y(a[i]));}
2644
2645      acenter=acenter+aux2;
2646    }
2647  }
2648return(acenter);
2649}
2650example
2651{"EXAMPLE:"; echo = 2;
2652  ring r = 0,(x(1..3)),dp;
2653  list flag=identifyvar();
2654  ideal J=x(1)^4*x(2)^2, x(1)^2+x(3)^3;
2655  intvec a=1,3; // first center of blowing up
2656  tradtoideal(a,J,flag);
2657}
2658//////////////////////////////////////////////////////////////////////////////////////
2659//              OPERATIONS WITH LISTS
2660//////////////////////////////////////////////////////////////////////////////////////
2661
2662proc iniD(int n)
2663"USAGE: iniD(n);   n integer
2664RETURN: list of lists of zeros of size n
2665EXAMPLE: example iniD; shows an example
2666"
2667 {int i,j;
2668  list D,auxD;
2669 for (j=1;j<=n; j++) {auxD[j]=0;}
2670 for (i=1;i<=n; i++) {D[i]=auxD;}
2671 return(D);
2672 }
2673example
2674{"EXAMPLE:"; echo = 2;
2675  iniD(3);
2676}
2677/////////////////////////////////////////////////////////
2678
2679proc sumlist(list L1,list L2)
2680"USAGE: sumlist(L1,L2);   L1,L2 lists, (size(L1)==size(L2))
2681RETURN: a list, sum of L1 and L2
2682EXAMPLE: example sumlist; shows an example
2683"
2684{
2685 int i,k;
2686 list sumL;
2687k=size(L1);
2688if (size(L2)!=k) {return("ERROR en sumlist, lists must have the same size");}
2689for (i=1;i<=k;i++) {sumL[i]=L1[i]+L2[i];}
2690return(sumL);
2691}
2692example
2693{"EXAMPLE:"; echo = 2;
2694  list L1=1,2,3;
2695  list L2=5,9,7;
2696  sumlist(L1,L2);
2697}
2698///////////////////////////////////////////////////////
2699
2700proc reslist(list L1,list L2)
2701"USAGE: reslist(L1,L2);  L1,L2 lists, (size(L1)==size(L2))
2702RETURN: a list, subtraction of L1 and L2
2703EXAMPLE: example reslist; shows an example
2704"
2705{
2706 int i,k;
2707 list resL;
2708k=size(L1);
2709if (size(L2)!=k) {return("ERROR en reslist, lists must have the same size");}
2710for (i=1;i<=k;i++) {resL[i]=L1[i]-L2[i];}
2711return(resL);
2712}
2713example
2714{"EXAMPLE:"; echo = 2;
2715  list L1=1,2,3;
2716  list L2=5,9,7;
2717  reslist(L1,L2);
2718}
2719//////////////////////////////////////////////////////
2720
2721proc multiplylist(list L,number a)
2722"USAGE: multiplylist(L,a); L list, a number
2723RETURN: list of elements of type number, multiplication of L times a
2724EXAMPLE: example multiplylist; shows an example
2725"
2726{int i,k;
2727 list newL,bb;
2728 number b;
2729 k=size(L);
2730 for (i=1;i<=k;i++) {b=L[i]*a; bb=b; newL=newL+bb;}
2731return(newL);
2732}
2733example
2734{"EXAMPLE:"; echo = 2;
2735  ring r = 0,(x(1..3)),dp;
2736  list L=1,2,3;
2737  multiplylist(L,1/5);
2738}
2739///////////////////////////////////////////////////////
2740
2741proc dividelist(list L1,list L2)
2742"USAGE: dividelist(L1,L2);  L1,L2 lists
2743RETURN: list of elements of type number, division of L1 by L2
2744EXAMPLE: example dividelist; shows an example
2745"
2746{int i,k,k1,k2;
2747list LL,bb;
2748number a1,a2,b;
2749k1=size(L1);
2750k2=size(L2);
2751if (k2!=k1) {print("ERROR en dividelist, lists must have the same size");}
2752if (k1<=k2) {k=k1;}
2753else {k=k2;}
2754 for (i=1;i<=k;i++)
2755  {a1=L1[i]; a2=L2[i]; b=a1/a2; bb=b; LL=LL+bb;}
2756return(LL);
2757}
2758example
2759{"EXAMPLE:"; echo = 2;
2760  ring r = 0,(x(1..3)),dp;
2761  list L1=1,2,3;
2762  list L2=5,9,7;
2763  dividelist(L1,L2);
2764}
2765///////////////////////////////////////////////////////
2766
2767proc createlist(list L1,list L2)
2768"USAGE: createlist(L1,L2);  L1,L2 lists, (size(L1)==size(L2))
2769RETURN: list of lists of two elements, the first one of L1 and the second of L2
2770EXAMPLE: example createlist; shows an example
2771"
2772{int i,k;
2773list L,aux;
2774k=size(L1);
2775if (size(L2)!=k) {return("ERROR en createlist, lists must have the same size");}
2776L=list0(k);
2777for (i=1;i<=k;i++) {if (L1[i]!=0) {aux=L1[i],L2[i]; L[i]=aux;}
2778                    else {L=delete(L,i);}}
2779return(L);
2780}
2781example
2782{"EXAMPLE:"; echo = 2;
2783  list L1=1,2,3;
2784  list L2=5,9,7;
2785  createlist(L1,L2);
2786}
2787///////////////////////////////////////////////////////
2788static proc list0(int n)
2789"USAGE: list0(n); n integer
2790RETURN: list of n zeros
2791EXAMPLE: example list0; shows an example
2792"
2793{int i;
2794list L0;
2795for (i=1;i<=n;i++) {L0[i]=0;}
2796return(L0);
2797}
2798example
2799{"EXAMPLE:"; echo = 2;
2800  list0(4);
2801}
2802////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.