Changeset e1f372 in git


Ignore:
Timestamp:
Sep 7, 2010, 7:37:52 PM (14 years ago)
Author:
Thomas Markwig <keilen@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '0bc2210f8055033868008a3836878db65ec6f89e')
Children:
3b614ecf39de68c3a807a600dd27a5329966b5cd
Parents:
e128fda56ac773be45f4a851d82371ff728c25a9
Message:
Procedures puiseuxExpansion and displayPuiseuxExpansion added.
For this tropicalLifting and tropicalparametrise had to be adjusted.
hnoether.lib is now needed to compute the Newton polygon of a plane curve.


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/tropical.lib

    re128fd re1f372  
    88@*               Thomas Markwig,  email: keilen@mathematik.uni-kl.de
    99
    10 WARNING:
     10WARNING: 
    1111- tropicalLifting will only work with LINUX and if in addition gfan is installed.
    12 @*- drawTropicalCurve and drawTropicalNewtonSubdivision will only display the
    13 @*  tropical curve with LINUX and if in addition latex and kghostview
     12@*- drawTropicalCurve and drawTropicalNewtonSubdivision will only display the 
     13@*  tropical curve with LINUX and if in addition latex and kghostview 
    1414@*  are installed.
    15 @*- For tropicalLifting in the definition of the basering the parameter t
     15@*- For tropicalLifting in the definition of the basering the parameter t 
    1616@*  from the Puiseux series field C{{t}} must be defined as a variable,
    1717@*  while for all other procedures it must be defined as a parameter.
    1818
    1919THEORY:
    20   Fix some base field K and a bunch of lattice points v0,...,vm in the integer
    21   lattice Z^n, then this defines a toric variety as the closure of (K*)^n in
    22   the projective space P^m, where the torus is embedded via the map sending a
     20  Fix some base field K and a bunch of lattice points v0,...,vm in the integer 
     21  lattice Z^n, then this defines a toric variety as the closure of (K*)^n in 
     22  the projective space P^m, where the torus is embedded via the map sending a 
    2323  point x in (K*)^n to the point (x^v0,...,x^vm).
    24   The generic hyperplane sections are just the images of the hypersurfaces
     24  The generic hyperplane sections are just the images of the hypersurfaces 
    2525  in (K*)^n defined by the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties
    26   of these hypersurfaces can be studied via tropicalisation.
    27 
    28   For this we suppose that K=C{{t}} is the field of Puiseux series over the
     26  of these hypersurfaces can be studied via tropicalisation. 
     27
     28  For this we suppose that K=C{{t}} is the field of Puiseux series over the 
    2929  field of complex numbers (or any other field with a valuation into the real
    30   numbers). One associates to the hypersurface given by f=a0*x^v0+...+am*x^vm
     30  numbers). One associates to the hypersurface given by f=a0*x^v0+...+am*x^vm 
    3131  the tropical hypersurface defined by the tropicalisation
    32   trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}.
     32  trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}. 
    3333  Here, <v,x> denotes the standard scalar product of the integer vector v in Z^n
    3434  with the vector x=(x1,...,xn) of variables, so that trop(f) is a piecewise
    35   linear function on R^n. The corner locus of this function (i.e. the points
    36   at which the minimum is attained a least twice) is the tropical hypersurface
    37   defined by trop(f).
    38   The theorem of Newton-Kapranov states that this tropical hypersurface is
    39   the same as if one computes pointwise the valuation of the hypersurface
    40   given by f. The analogue holds true if one replaces one equation f by an
    41   ideal I. A constructive proof of the theorem is given by an adapted
    42   version of the Newton-Puiseux algorithm. The hard part is to find a point
    43   in the variety over C{{t}} which corresponds to a given point in the
     35  linear function on R^n. The corner locus of this function (i.e. the points 
     36  at which the minimum is attained a least twice) is the tropical hypersurface 
     37  defined by trop(f). 
     38  The theorem of Newton-Kapranov states that this tropical hypersurface is 
     39  the same as if one computes pointwise the valuation of the hypersurface 
     40  given by f. The analogue holds true if one replaces one equation f by an 
     41  ideal I. A constructive proof of the theorem is given by an adapted 
     42  version of the Newton-Puiseux algorithm. The hard part is to find a point 
     43  in the variety over C{{t}} which corresponds to a given point in the 
    4444  tropical variety.
    4545
    46   It is the purpose of this library to provide basic means to deal with
    47   tropical varieties. Of course we cannot represent the field of Puiseux
    48   series over C in its full strength, however, in order to compute interesting
    49   examples it will be sufficient to replace the complex numbers C by the
    50   rational numbers Q and to replace Puiseux series in t by rational functions
    51   in t, i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t].
     46  It is the purpose of this library to provide basic means to deal with 
     47  tropical varieties. Of course we cannot represent the field of Puiseux 
     48  series over C in its full strength, however, in order to compute interesting 
     49  examples it will be sufficient to replace the complex numbers C by the 
     50  rational numbers Q and to replace Puiseux series in t by rational functions 
     51  in t, i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. 
    5252  Note, that this in particular forbids rational exponents for the t's.
    5353
    5454  Moreover, in @sc{Singular} no negative exponents of monomials are allowed, so
    55   that the integer vectors vi will have to have non-negative entries.
    56   Shifting all exponents by a fixed integer vector does not change the
    57   tropicalisation nor does it change the toric variety. Thus this does not
     55  that the integer vectors vi will have to have non-negative entries. 
     56  Shifting all exponents by a fixed integer vector does not change the 
     57  tropicalisation nor does it change the toric variety. Thus this does not 
    5858  cause any restriction.
    59   If, however, for some reason you prefer to work with general vi, then you
    60   have to pass right away to the tropicalisation of the equations, whereever
     59  If, however, for some reason you prefer to work with general vi, then you 
     60  have to pass right away to the tropicalisation of the equations, whereever 
    6161  this is allowed -- these are linear polynomials where the constant coefficient
    62   corresponds to the valuation of the original coefficient and where
    63   the non-constant coefficient correspond to the exponents of the monomials,
    64   thus they may be rational numbers respectively negative numbers:
     62  corresponds to the valuation of the original coefficient and where 
     63  the non-constant coefficient correspond to the exponents of the monomials, 
     64  thus they may be rational numbers respectively negative numbers: 
    6565  e.g. if f=t^{1/2}*x^{-2}*y^3+2t*x*y+4  then  trop(f)=min{1/2-2x+3y,1+x+y,0}.
    6666
    6767  The main tools provided in this library are as follows:
    68 @*  - tropicalLifting    implements the constructive proof of the Theorem of
    69                          Newton-Kapranov and constructs a point in the variety
    70                          over C{{t}} corresponding to a given point in the
    71                          corresponding tropical variety associated to an
    72                          ideal I; the generators of I have to be in the
    73                          polynomial ring Q[t,x1,...,xn] considered as a
    74                          subring of C{{t}}[x1,...,xn]; a solution will be
    75                          constructed up to given order; note that several
     68@*  - tropicalLifting    implements the constructive proof of the Theorem of 
     69                         Newton-Kapranov and constructs a point in the variety 
     70                         over C{{t}} corresponding to a given point in the 
     71                         corresponding tropical variety associated to an 
     72                         ideal I; the generators of I have to be in the 
     73                         polynomial ring Q[t,x1,...,xn] considered as a 
     74                         subring of C{{t}}[x1,...,xn]; a solution will be 
     75                         constructed up to given order; note that several 
    7676                         field extensions of Q might be necessary throughout
    7777                         the intermediate computations; the procedures use
    7878                         the external program gfan
    79 @*  - drawTropicalCurve  visualises a tropical plane curve either given by a
    80                          polynomial in Q(t)[x,y] or by a list of linear
    81                          polynomials of the form ax+by+c with a,b in Z and c
     79@*  - puiseuxExpansion   computes a Newton-Puiseux expansion of a plane curve
     80                         singularity
     81@*  - drawTropicalCurve  visualises a tropical plane curve either given by a
     82                         polynomial in Q(t)[x,y] or by a list of linear
     83                         polynomials of the form ax+by+c with a,b in Z and c
    8284                         in Q; latex must be installed on your computer
    83 @*  - tropicalJInvariant computes the tropical j-invaiant of a tropical
     85@*  - tropicalJInvariant computes the tropical j-invaiant of a tropical 
    8486                         elliptic curve
    8587@*  - jInvariant         computes the j-invariant of an elliptic curve
    86 @*  - weierstrassForm     computes the Weierstrass form of an elliptic curve
     88@*  - weierstrassForm     computes the Weierstrass form of an elliptic curve 
    8789
    8890PROCEDURES FOR TROPICAL LIFTING:
    89   tropicalLifting()          computes a point in the tropical variety
     91  tropicalLifting()          computes a point in the tropical variety 
    9092  displayTropicalLifting()   displays the output of tropicalLifting
     93  puiseuxExpansion()         computes a Newton-Puiseux expansion in the plane
     94  displayPuiseuxExpansion()  displays the output of puiseuxExpansion
    9195
    9296PROCEDURES FOR DRAWING TROPICAL CURVES:
     
    107111  tInitialIdeal()      computes the tInitial ideal of an ideal in Q[t,x_1,...,x_n]
    108112  initialForm()        computes the initial form of poly in Q[x_1,...,x_n]
    109   initialIdeal()       computes the initial ideal of an ideal in Q[x_1,...,x_n]
     113  initialIdeal()       computes the initial ideal of an ideal in Q[x_1,...,x_n] 
    110114
    111115PROCEDURES FOR LATEX CONVERSION:
     
    115119  texDrawBasic()       embeds output of texDrawTropical in a texdraw environment
    116120  texDrawTropical()    computes the texdraw commands for a tropical curve
    117   texDrawNewtonSubdivision()   computes texdraw commands for a Newton subdivision
     121  texDrawNewtonSubdivision()   computes texdraw commands for a Newton subdivision 
    118122  texDrawTriangulation()       computes texdraw commands for a triangulation
    119123
     
    121125  radicalMemberShip()     checks radical membership
    122126  tInitialFormPar()       computes the t-initial form of poly in Q(t)[x_1,...,x_n]
    123   tInitialFormParMax()    same as tInitialFormPar, but uses maximum
     127  tInitialFormParMax()    same as tInitialFormPar, but uses maximum 
    124128  solveTInitialFormPar()  displays approximated solution of a 0-dim ideal
    125129  detropicalise()         computes the detropicalisation of a linear form
    126130  tDetropicalise()        computes the detropicalisation of a linear form
    127   dualConic()             computes the dual of an affine plane conic
     131  dualConic()             computes the dual of an affine plane conic 
    128132  parameterSubstitute()   substitutes in the polynomial the parameter t by t^N
    129133  tropicalSubst()         makes certain substitutions in a tropical polynomial
     
    156160/// - eliminatecomponents
    157161/// - findzerosAndBasictransform
    158 /// - ordermaximalideals
     162/// - ordermaximalideals 
    159163/// - verticesTropicalCurve
    160164/// - bunchOfLines
     
    202206LIB "primdec.lib";
    203207LIB "absfact.lib";
     208LIB "hnoether.lib";
    204209//////////////////////////////////////////////////////////////////////////////
    205210
    206211///////////////////////////////////////////////////////////////////////////////
    207 /// Procedures concerned with tropical parametrisation
     212/// Procedures concerned with tropical parametrisation 
    208213///////////////////////////////////////////////////////////////////////////////
    209214
    210215proc tropicalLifting (ideal i,intvec w,int ordnung,list #)
    211216"USAGE:  tropicalLifting(i,w,ord[,opt]); i ideal, w intvec, ord int, opt string
    212 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n)
    213            and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i,
    214            and ord is the order up to which a point in V(i) over Q{{t}}
    215            lying over (w_1/w_0,...,w_n/w_0) shall be computed;
     217ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n) 
     218           and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i, 
     219           and ord is the order up to which a point in V(i) over Q{{t}} 
     220           lying over (w_1/w_0,...,w_n/w_0) shall be computed; 
    216221           w_0 may NOT be ZERO
    217 @*       - the basering should not have any parameters on its own
    218            and it should have a global monomial ordering,
     222@*       - the basering should not have any parameters on its own 
     223           and it should have a global monomial ordering, 
    219224           e.g. ring r=0,(t,x(1..n)),dp;
    220 @*       - the first variable of the basering will be treated as the
     225@*       - the first variable of the basering will be treated as the 
    221226           parameter t in the Puiseux series field
    222 @*       - the optional parameter opt should be one or more strings among
     227@*       - the optional parameter opt should be one or more strings among 
    223228           the following:
    224229@*         'isZeroDimensional'  : the dimension i is zero (not to be checked);
    225 @*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n]
     230@*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n] 
    226231                                  (not to be checked);
    227 @*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical
     232@*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical 
    228233                                  variety (not to be checked);
    229 @*         'oldGfan'            : uses gfan version 0.2.1 or less
    230 @*         'findAll'            : find all solutions of a zero-dimensional
     234@*         'oldGfan'            : uses gfan version 0.2.1 or less 
     235@*         'findAll'            : find all solutions of a zero-dimensional 
    231236                                  ideal over (w_1/w_0,...,w_n/w_0)
    232237@*         'noAbs'              : do NOT use absolute primary decomposition
    233 @*         'noResubst'         : avoids the computation of the resubstitution
     238@*         'puiseux'            : n=1 and i is generated by one equation
     239@*         'noResubst'          : avoids the computation of the resubstitution
    234240RETURN:  IF THE OPTION 'findAll' WAS NOT SET THEN:
    235241@*       list, containing one lifting of the given point (w_1/w_0,...,w_n/w_0)
    236                in the tropical variety of i to a point in V(i) over Puiseux
     242               in the tropical variety of i to a point in V(i) over Puiseux 
    237243               series field up to the first ord terms; more precisely:
    238244@*             IF THE OPTION 'noAbs' WAS NOT SET, THEN:
     
    249255@*       IF THE OPITON 'findAll' WAS SET, THEN:
    250256@*       list, containing ALL liftings of the given point ((w_1/w_0,...,w_n/w_0)
    251                in the tropical variety of i to a point in V(i) over Puiseux
    252                series field up to the first ord terms, if the ideal is
     257               in the tropical variety of i to a point in V(i) over Puiseux 
     258               series field up to the first ord terms, if the ideal is 
    253259               zero-dimensional over Q{{t}};
    254                more precisely, each entry of the list is a list l as computed
     260               more precisely, each entry of the list is a list l as computed 
    255261               if  'findAll' was NOT set
    256262@*       WE NOW DESCRIBE THE LIST ENTRIES IF 'findAll' WAS NOT SET:
    257 @*       - the ring l[1] contains an ideal LIFT, which contains
     263@*       - the ring l[1] contains an ideal LIFT, which contains 
    258264           a point in V(i) lying over w up to the first ord terms;
    259 @*       - and if the integer l[2] is N then t has to be replaced by t^1/N
     265@*       - and if the integer l[2] is N then t has to be replaced by t^1/N 
    260266           in the lift, or alternatively replace t by t^N in the defining ideal
    261 @*       - if the k+1st entry of l[3] is  non-zero, then the kth component of
    262            LIFT has to be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t
     267@*       - if the k+1st entry of l[3] is  non-zero, then the kth component of 
     268           LIFT has to be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t 
    263269           by t^1/N
    264 @*       - unless the option 'noResubst' was set, the kth entry of list l[4]
     270@*       - unless the option 'noResubst' was set, the kth entry of list l[4] 
    265271           is a string which represents the kth generator of
    266            the ideal i where the coordinates have been replaced by the result
     272           the ideal i where the coordinates have been replaced by the result 
    267273           of the lift;
    268            the t-order of the kth entry should in principle be larger than the
     274           the t-order of the kth entry should in principle be larger than the 
    269275           t-degree of LIFT
    270 @*       - if the option 'noAbs' was set, then the string in l[5] defines
    271            a maximal ideal in the field Q[X(1),...,X(k)], where X(1),...,X(k)
     276@*       - if the option 'noAbs' was set, then the string in l[5] defines 
     277           a maximal ideal in the field Q[X(1),...,X(k)], where X(1),...,X(k) 
    272278           are the parameters of the ring in l[1];
    273            the basefield of the ring in l[1] should be considered modulo this
     279           the basefield of the ring in l[1] should be considered modulo this 
    274280           ideal
    275 REMARK:  - it is best to use the procedure displayTropicalLifting to
     281REMARK:  - it is best to use the procedure displayTropicalLifting to 
    276282           display the result
    277283@*       - the option 'findAll' cannot be used if 'noAbs' is set
    278284@*       - if the parameter 'findAll' is set AND the ideal i is zero-dimensional
    279            in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are
     285           in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are 
    280286           computed up to order ord; if the ideal is not-zero dimenisonal, then
    281287           only the points in the ideal after cutting down to dimension zero
    282288           will be computed
    283289@*       - the procedure requires that the program GFAN is installed on your
    284            computer; if you have GFAN version less than 0.3.0 then you must
     290           computer; if you have GFAN version less than 0.3.0 then you must 
    285291           use the optional parameter 'oldGfan'
    286292@*       - the procedure requires the @sc{Singular} procedure absPrimdecGTZ to be
    287293           present in the package primdec.lib, unless the option 'noAbs' is set;
    288            but even if absPrimdecGTZ is present it might be necessary to set
    289            the option 'noAbs' in order to avoid the costly absolute primary
    290            decomposition; the side effect is that the field extension which is
     294           but even if absPrimdecGTZ is present it might be necessary to set 
     295           the option 'noAbs' in order to avoid the costly absolute primary 
     296           decomposition; the side effect is that the field extension which is 
    291297           computed throughout the recursion might need more than one
    292298           parameter to be described
    293299@*       - since Q is infinite, the procedure finishes with probability one
    294 @*       - you can call the procedure with Z/pZ as base field instead of Q,
     300@*       - you can call the procedure with Z/pZ as base field instead of Q, 
    295301           but there are some problems you should be aware of:
    296 @*         + the Puiseux series field over the algebraic closure of Z/pZ is
    297              NOT algebraicall closed, and thus there may not exist a point in
    298              V(i) over the Puiseux series field with the desired valuation;
     302@*         + the Puiseux series field over the algebraic closure of Z/pZ is 
     303             NOT algebraicall closed, and thus there may not exist a point in 
     304             V(i) over the Puiseux series field with the desired valuation; 
    299305             so there is no chance that the procedure produced a sensible output
    300              - e.g. if i=tx^p-tx-1
    301 @*         + if the dimension of i over Z/pZ(t) is not zero the process of
    302              reduction to zero might not work if the characteristic is small
     306             - e.g. if i=tx^p-tx-1 
     307@*         + if the dimension of i over Z/pZ(t) is not zero the process of 
     308             reduction to zero might not work if the characteristic is small 
    303309             and you are unlucky
    304 @*         + the option 'noAbs' has to be used since absolute primary
     310@*         + the option 'noAbs' has to be used since absolute primary 
    305311             decomposition in @sc{Singular} only works in characteristic zero
    306 @*       - the basefield should either be Q or Z/pZ for some prime p;
    307            field extensions will be computed if necessary; if you need
    308            parameters or field extensions from the beginning they should
    309            rather be simulated as variables possibly adding their relations to
     312@*       - the basefield should either be Q or Z/pZ for some prime p; 
     313           field extensions will be computed if necessary; if you need 
     314           parameters or field extensions from the beginning they should 
     315           rather be simulated as variables possibly adding their relations to 
    310316           the ideal; the weights for the additional variables should be zero
    311317EXAMPLE: example tropicalLifting;   shows an example"
     
    331337  int j,k,l,jj,kk;  // index variables
    332338  // work through the optionional parameters
    333   int isprime,iszerodim,isintrop,gfanold,findall,noabs,nogfan,noresubst;
     339  int isprime,iszerodim,isintrop,gfanold,findall,noabs,nogfan,noresubst,puiseux;
    334340  for (j=1;j<=size(#);j++)
    335341  {
     
    358364      noabs=1;
    359365    }
    360     // this option is not documented -- it prevents the execution of gfan and
    361     // just asks for wneu to be inserted -- it can be used to check problems
    362     // with the precedure without calling gfan, if wneu is know from previous
     366    if (#[j]=="puiseux")
     367    {
     368      int puiseuxgood=0;
     369      // test, if the option puiseux makes sense, i.e. we are considering a plane curve
     370      if ((size(i)==1) and (nvars(basering)==2))
     371      {
     372        puiseuxgood=1;
     373      }
     374      // the case, where the base field has a parameter and a minimal polynomial is
     375      // treated by an additional variable (which should be the last variable)
     376      // and an ideal containing the minimal polynomial as first entry
     377      if ((size(i)==2) and (nvars(basering)==3))
     378      {
     379        // check if the first entry is the minimal polynomial
     380        poly mpcheck=i[1];
     381        if (substitute(mpcheck,var(1),0,var(2),0)==mpcheck)
     382        {
     383          puiseuxgood=1;
     384        }
     385        kill mpcheck;
     386      }
     387      if (puiseuxgood==0)
     388      {
     389        ERROR("The option puiseux is not allowed for this ring. See: help tropicalLifting; for more information");
     390      }
     391      puiseux=1;
     392      nogfan=1;  // if puiseux is set, then gfan should not be used
     393    }
     394    // this option is not documented -- it prevents the execution of gfan and
     395    // just asks for wneu to be inserted -- it can be used to check problems
     396    // with the precedure without calling gfan, if wneu is know from previous
    363397    // computations
    364398    if (#[j]=="noGfan")
     
    371405    }
    372406  }
    373   // if the basering has characteristic not equal to zero,
     407  // if the basering has characteristic not equal to zero, 
    374408  // then absolute factorisation
    375409  // is not available, and thus we need the option noAbs
     
    385419  {
    386420    Error("The first coordinate of your input w must be NON-ZERO, since it is a DENOMINATOR!");
    387   }
     421  } 
    388422  // if w_0<0, then replace w by -w, so that the "denominator" w_0 is positive
    389423  if (w[1]<0)
     
    392426  }
    393427  intvec prew=w; // stores w for later reference
    394   // for our computations, w[1] represents the weight of t and this
     428  // for our computations, w[1] represents the weight of t and this 
    395429  // should be -w_0 !!!
    396430  w[1]=-w[1];
     
    402436    w[1]=-1;
    403437  }
    404   // if some entry of w is positive, we have to make a transformation,
     438  // if some entry of w is positive, we have to make a transformation, 
    405439  // which moves it to something non-positive
    406440  for (j=2;j<=nvars(basering);j++)
     
    428462  {
    429463    variablen=variablen+var(j);
    430   }
     464  }   
    431465  map GRUNDPHI=BASERING,t,variablen;
    432466  ideal i=GRUNDPHI(i);
    433   // compute the initial ideal of i and test if w is in the tropical
    434   // variety of i
     467  // compute the initial ideal of i and test if w is in the tropical 
     468  // variety of i 
    435469  // - the last entry 1 only means that t is the last variable in the ring
    436470  ideal ini=tInitialIdeal(i,w,1);
    437471  if (isintrop==0) // test if w is in trop(i) only if isInTrop has not been set
    438   {
     472  {   
    439473    poly product=1;
    440474    for (j=1;j<=nvars(basering)-1;j++)
     
    454488    int dd=dim(i);
    455489    setring GRUNDRING;
    456     // if the dimension is not zero, we cut the ideal down to dimension zero
     490    // if the dimension is not zero, we cut the ideal down to dimension zero 
    457491    // and compute the
    458492    // t-initial ideal of the new ideal at the same time
    459493    if(dd!=0)
    460494    {
    461       // the procedurce cutdown computes a new ring, in which there lives a
     495      // the procedurce cutdown computes a new ring, in which there lives a 
    462496      // zero-dimensional
    463       // ideal which has been computed by cutting down the input with
     497      // ideal which has been computed by cutting down the input with 
    464498      // generic linear forms
    465       // of the type x_i1-p_1,...,x_id-p_d for some polynomials
    466       // p_1,...,p_d not depending
    467       // on the variables x_i1,...,x_id; that way we have reduced
     499      // of the type x_i1-p_1,...,x_id-p_d for some polynomials 
     500      // p_1,...,p_d not depending 
     501      // on the variables x_i1,...,x_id; that way we have reduced 
    468502      // the number of variables by dd !!!
    469       // the new zero-dimensional ideal is called i, its t-initial
     503      // the new zero-dimensional ideal is called i, its t-initial 
    470504      // ideal (with respect to
    471       // the new w=CUTDOWN[2]) is ini, and finally there is a list
    472       // repl in the ring
     505      // the new w=CUTDOWN[2]) is ini, and finally there is a list 
     506      // repl in the ring 
    473507      // which contains at the polynomial p_j at position i_j and
    474508      //a zero otherwise;
     
    493527  list liftrings; // will contain the final result
    494528  // if the procedure is called without 'findAll' then it may happen, that no
    495   // proper solution is found when dd>0; in that case we have
     529  // proper solution is found when dd>0; in that case we have 
    496530  // to start all over again;
    497531  // this is controlled by the while-loop
     
    501535    if (noabs==1) // do not use absolute primary decomposition
    502536    {
    503       list TP=list(tropicalparametriseNoabs(i,w,ordnung,gfanold,nogfan,ini));
     537      list TP=list(tropicalparametriseNoabs(i,w,ordnung,gfanold,nogfan,puiseux,ini));
    504538    }
    505539    else // use absolute primary decomposition
    506540    {
    507       list TP=tropicalparametrise(i,w,ordnung,gfanold,findall,nogfan,ini);
     541      list TP=tropicalparametrise(i,w,ordnung,gfanold,findall,nogfan,puiseux,ini);
    508542    }
    509543    // compute the liftrings by resubstitution
    510544    kk=1;  // counts the liftrings
    511     int isgood;  // test in the non-zerodimensional case
     545    int isgood;  // test in the non-zerodimensional case 
    512546                 // if the result has the correct valuation
    513547    for (jj=1;jj<=size(TP);jj++)
    514548    {
    515       // the list TP contains as a first entry the ring over which the
    516       // tropical parametrisation
     549      // the list TP contains as a first entry the ring over which the 
     550      // tropical parametrisation 
    517551      // of the (possibly cutdown ideal) i lives
    518552      def LIFTRING=TP[jj][1];
    519       // if the dimension of i originally was not zero,
     553      // if the dimension of i originally was not zero, 
    520554      // then we have to fill in the missing
    521555      // parts of the parametrisation
    522556      if (dd!=0)
    523557      {
    524         // we need a ring where the parameters X_1,...,X_k
     558        // we need a ring where the parameters X_1,...,X_k 
    525559        // from LIFTRING are present,
    526560        // and where also the variables of CUTDOWNRING live
    527561        execute("ring REPLACEMENTRING=("+charstr(LIFTRING)+"),("+varstr(CUTDOWNRING)+"),dp;");
    528         list repl=imap(CUTDOWNRING,repl); // get the replacement rules
     562        list repl=imap(CUTDOWNRING,repl); // get the replacement rules 
    529563                                          // from CUTDOWNRING
    530         ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio
     564        ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio 
    531565                                          // from LIFTRING
    532566        // compute the lift of the solution of the original ideal i
     
    534568        k=1;
    535569        // the lift has as many components as GRUNDRING has variables!=t
    536         for (j=1;j<=nvars(GRUNDRING)-1;j++)
     570        for (j=1;j<=nvars(GRUNDRING)-1;j++) 
    537571        {
    538572          // if repl[j]=0, then the corresponding variable was not eliminated
    539           if (repl[j]==0)
     573          if (repl[j]==0) 
    540574          {
    541             LIFT[j]=PARA[k]; // thus the lift has been
     575            LIFT[j]=PARA[k]; // thus the lift has been 
    542576                             // computed by tropicalparametrise
    543577            k++; // k checks how many entries of PARA have already been used
     
    545579          else  // if repl[j]!=0, repl[j] contains replacement rule for the lift
    546580          {
    547             LIFT[j]=repl[j]; // we still have to replace the vars
     581            LIFT[j]=repl[j]; // we still have to replace the vars 
    548582                             // in repl[j] by the corresp. entries of PARA
    549583            // replace all variables!=t (from CUTDOWNRING)
    550             for (l=1;l<=nvars(CUTDOWNRING)-1;l++)
     584            for (l=1;l<=nvars(CUTDOWNRING)-1;l++) 
    551585            {
    552586              // substitute the kth variable by PARA[k]
    553               LIFT[j]=subst(LIFT[j],var(l),PARA[l]);
     587              LIFT[j]=subst(LIFT[j],var(l),PARA[l]); 
    554588            }
    555589          }
    556590        }
    557591        setring LIFTRING;
    558         ideal LIFT=imap(REPLACEMENTRING,LIFT);
    559         // test now if the LIFT has the correct valuation !!!
    560         // note: it may happen, that when resubstituting PARA into
     592        ideal LIFT=imap(REPLACEMENTRING,LIFT);   
     593        // test now if the LIFT has the correct valuation !!!     
     594        // note: it may happen, that when resubstituting PARA into 
    561595        //       the replacement rules
    562         //       there occured some unexpected cancellation;
     596        //       there occured some unexpected cancellation; 
    563597        //       we only know that for SOME
    564         //       solution of the zero-dimensional reduction NO
    565         //       canellation will occur,
    566         //       but for others this may very well happen;
     598        //       solution of the zero-dimensional reduction NO 
     599        //       canellation will occur, 
     600        //       but for others this may very well happen; 
    567601        //       this in particular means that
    568         //       we possibly MUST compute all zero-dimensional
     602        //       we possibly MUST compute all zero-dimensional 
    569603        //       solutions when cutting down!
    570604        intvec testw=precutdownw[1];
     
    590624      kill PARA;
    591625      // only if LIFT has the right valuation we have to do something
    592       if (isgood==1)
    593       {
    594         // it remains to reverse the original substitutions,
     626      if (isgood==1) 
     627      {
     628        // it remains to reverse the original substitutions, 
    595629        // where appropriate !!!
    596         // if some entry of the original w was positive,
     630        // if some entry of the original w was positive, 
    597631        // we replace the corresponding
    598632        // variable x_i by t^-w[i]*x_i, so we must now replace
     
    611645        */
    612646        // if LIFTRING contains a parameter @a, change it to a
    613         if ((noabs==0) and (defined(@a)==-1))
     647        if ((noabs==0) and (defined(@a)==-1)) 
    614648        {
    615           // pass first to a ring where a and @a
     649          // pass first to a ring where a and @a 
    616650          // are variables in order to use maps
    617651          poly mp=minpoly;
     
    622656          // replace @a by a in minpoly and in LIFT
    623657          map phi=INTERRING,t,a,a;
    624           mp=phi(mp);
     658          mp=phi(mp);     
    625659          LIFT=phi(LIFT);
    626660          // pass now to a ring whithout @a and with a as parameter
     
    629663          ideal LIFT=imap(INTERRING,LIFT);
    630664          kill INTERRING;
    631         }
     665        }   
    632666        // then export LIFT
    633         export(LIFT);
     667        export(LIFT); 
    634668        // test the  result by resubstitution
    635         setring GRUNDRING;
     669        setring GRUNDRING; 
    636670        list resubst;
    637671        if (noresubst==0)
     
    642676          }
    643677          else
    644           {
     678          {     
    645679            resubst=tropicalliftingresubstitute(substitute(i,t,t^(TP[jj][2])),list(LIFTRING),N*TP[jj][2]);
    646680          }
    647681        }
    648682        setring BASERING;
    649         // Finally, if t has been replaced by t^N, then we have to change the
     683        // Finally, if t has been replaced by t^N, then we have to change the 
    650684        // third entry of TP by multiplying by N.
    651685        if (noabs==1)
     
    663697      kill LIFTRING;
    664698    }
    665     // if dd!=0 and the procedure was called without the
     699    // if dd!=0 and the procedure was called without the 
    666700    // option findAll, then it might very well
    667     // be the case that no solution is found, since
     701    // be the case that no solution is found, since 
    668702    // only one solution for the zero-dimensional
    669     // reduction was computed and this one might have
     703    // reduction was computed and this one might have 
    670704    // had cancellations when resubstituting;
    671705    // if so we have to restart the process with the option findAll
     
    675709      "The procedure will be restarted with the option 'findAll'.";
    676710      "Go on by hitting RETURN!";
    677       findall=1;
     711      findall=1;   
    678712      noabs=0;
    679713      setring CUTDOWNRING;
     
    681715      "i";i;
    682716      "ini";tInitialIdeal(i,w,1);
    683 
     717     
    684718/*
    685719      setring GRUNDRING;
     
    699733    }
    700734  }
    701   // if internally the option findall was set, then return
     735  // if internally the option findall was set, then return 
    702736  // only the first solution
    703737  if (defined(hadproblems)!=0)
     
    708742  if (voice+printlevel>=2)
    709743  {
    710 
     744     
    711745      "The procedure has created a list of lists. The jth entry of this list
    712746contains a ring, an integer and an intvec.
    713747In this ring lives an ideal representing the wanted lifting,
    714748if the integer is N then in the parametrisation t has to be replaced by t^1/N,
    715 and if the ith component of the intvec is w[i] then the ith component in LIFT
     749and if the ith component of the intvec is w[i] then the ith component in LIFT 
    716750should be multiplied by t^-w[i]/N in order to get the parametrisation.
    717 
     751   
    718752Suppose your list has the name L, then you can access the 1st ring via:
    719753";
    720754    if (findall==1)
    721755    {
    722       "def LIFTRing=L[1][1]; setring LIFTRing; LIFT;
     756      "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 
    723757";
    724758    }
    725759    else
    726760    {
    727       "def LIFTRing=L[1]; setring LIFTRing; LIFT;
     761      "def LIFTRing=L[1]; setring LIFTRing; LIFT; 
    728762";
    729     }
     763    } 
    730764  }
    731765  if (findall==1) // if all solutions have been computed, return a list of lists
     
    752786   def LIFTRing=LIST[1];
    753787   setring LIFTRing;
    754    // LIFT contains the first 4 terms of a point in the variety of i
     788   // LIFT contains the first 4 terms of a point in the variety of i 
    755789   // over the Puiseux series field C{{t}} whose order is -w[1]/w[0]=1
    756790   LIFT;
     
    780814   // NOTE: since the last component of v is positive, the lifting
    781815   //       must start with a negative power of t, which in Singular
    782    //       is not allowed for a variable.
     816   //       is not allowed for a variable. 
    783817   def LIFTRing3=LIST[1];
    784818   setring LIFTRing3;
     
    835869      string Kstring="Z/"+string(char(LIFTRing))+"Z";
    836870    }
    837     // this means that tropicalLifting was called with
     871    // this means that tropicalLifting was called with 
    838872    // absolute primary decomposition
    839     if (size(troplift)==4)
    840     {
     873    if (size(troplift)==4) 
     874    {     
    841875      setring LIFTRing;
    842876      "The lifting of the point in the tropical variety lives in the ring";
    843877      if ((size(LIFTpar)==0) and (N==1))
    844878      {
    845         Kstring+"[[t]]";
     879        Kstring+"[[t]]"; 
    846880      }
    847881      if ((size(LIFTpar)==0) and (N!=1))
    848882      {
    849         Kstring+"[[t^(1/"+string(N)+")]]";
     883        Kstring+"[[t^(1/"+string(N)+")]]"; 
    850884      }
    851885      if ((size(LIFTpar)!=0) and (N!=1))
    852       {
    853         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]";
     886      {   
     887        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 
    854888      }
    855889      if ((size(LIFTpar)!=0) and (N==1))
    856       {
    857         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]";
     890      {   
     891        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 
    858892      }
    859893    }
     
    872906      }
    873907      if ((size(LIFTpar)!=0) and (N!=1))
    874       {
    875         Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]";
     908      {   
     909        Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 
    876910        "where M is the maximal ideal";
    877911        "M=<"+m+">";
    878912      }
    879913      if ((size(LIFTpar)!=0) and (N==1))
    880       {
    881         Kstring+"["+LIFTpar+"]/M[[t]]";
     914      {   
     915        Kstring+"["+LIFTpar+"]/M[[t]]"; 
    882916        "where M is the maximal ideal";
    883917        "M=<"+m+">";
    884       }
     918      }     
    885919    }
    886920    "";
     
    909943      }
    910944    }
    911   }
     945  }     
    912946}
    913947example
     
    921955}
    922956
     957proc puiseuxExpansion (poly f,int n,list #)
     958"USAGE:  puiseuxExpansion(f,n,#); f poly, n int, # list
     959ASSUME:  f is a polynomial in two variables and the base field is either
     960         the field of rational numbers or a finite extension thereof;
     961         monomial ordering is assumed to be local;
     962         the optional parameter # can be the string 'subst'
     963RETURN:  list, where each entry of the list l describes the Newton-Puiseux
     964@*             parametrisations of one branch of the plane curve singularity
     965@*             at the origin defined by f; only the first n terms of each
     966@*             parametetrisation are computed
     967@*             l[i][1] = is a ring
     968@*             l[i][2] = int
     969@*             l[i][3] = list
     970@*
     971@*       WE NOW DESCRIBE THE LIST ENTRIES l[i] IN MORE DETAIL:
     972@*       - the ring l[i][1] contains an ideal LIFT and the Newton-Puiseux
     973           parametrisation of the branch is given by x=t^N and y=LIFT[1],
     974           where N=l[i][2]
     975@*       - if the base field had a parameter and a minimal polynomial, then
     976           the new base field will have a parameter and a new minimal polynomial,
     977           and LIFT[2] describes how the old parameter can be computed from the new one
     978@*       - if the option subst was set l[i][3] contains the polynomial where
     979           y has been substituted by y(t^{1/N})
     980REMARK:  - it is best to use the procedure displayPuiseuxExpansion to
     981           display the result
     982@*       - the procedure requires the @sc{Singular} procedure absPrimdecGTZ to be
     983           present in the package primdec.lib
     984EXAMPLE:   example puiseuxExpansion;   shows an example"
     985{
     986  if (char(basering)!=0)
     987  {
     988    ERROR("In positive characteristic a Puiseux expansion will not in general exist!");
     989  }
     990  if ((npars(basering)>1) or ((npars(basering)==1) and (minpoly==0)))
     991  {
     992    ERROR("The procedure is not implemented for this base field!");
     993  }
     994  if (nvars(basering)!=2)
     995  {
     996    ERROR("The base ring should depend on exactly two variables.");
     997  }
     998  // if the ordering is not local, change to a local ordering
     999  if ((1<var(1)) or (1<var(2)))
     1000  {
     1001    def GLOBALRING=basering;
     1002    execute("ring LOCALRING=("+charstr(basering)+"),("+varstr(basering)+"),ds;");
     1003    poly f=imap(GLOBALRING,f);
     1004  }
     1005  // check if a substitution is necessary
     1006  int noResubst;
     1007  if (size(#)>1)
     1008  {
     1009    if (#[1]=="subst")
     1010    {
     1011      noResubst=0;
     1012    }
     1013  }
     1014  // compute the Newton polygon
     1015  int jj,zw;
     1016  intvec w;
     1017  int ggteiler;
     1018  list NewtP=newtonpoly(f);
     1019  list tls;
     1020  list pexp;
     1021  // if the base field has a minimal polynomial change the base ring and the ideal
     1022  if (minpoly!=0)
     1023  {
     1024    poly mp=minpoly;
     1025    def OLDRING=basering;
     1026    execute("ring NEWRING=0,("+varstr(basering)+","+parstr(basering)+"),ds;");
     1027    ideal I=imap(OLDRING,mp),imap(OLDRING,f);
     1028  }
     1029  else
     1030  {
     1031    ideal I=f;
     1032  }
     1033  // for each facet of the Newton polygon compute the corresponding parametrisations
     1034  // using tropicalLifting with the option "puiseux" which avoids gfan
     1035  for (jj=1;jj<=size(NewtP)-1;jj++)
     1036  {
     1037    w=NewtP[jj]-NewtP[jj+1];
     1038    ggteiler=gcd(w[1],w[2]);
     1039    zw=w[1]/ggteiler;
     1040    w[1]=w[2]/ggteiler;
     1041    w[2]=zw;
     1042    // if we have introduced a third variable for the parameter, then w needs a third component
     1043    if (nvars(basering)==3)
     1044    {
     1045      w[3]=0;
     1046    }
     1047    if (noResubst==0)
     1048    {
     1049      tls=tropicalLifting(I,w,n,"findAll","puiseux");
     1050    }
     1051    else
     1052    {
     1053      tls=tropicalLifting(I,w,n,"findAll","puiseux","noResubst");
     1054    }
     1055    pexp=pexp+tls;
     1056  }
     1057  // kill rings that are no longer needed
     1058  if (defined(NEWRING))
     1059  {
     1060    setring OLDRING;
     1061    kill NEWRING;
     1062  } 
     1063  if (defined(GLOBALRING))
     1064  {
     1065    setring GLOBALRING;
     1066    kill LOCALRING;
     1067  } 
     1068  // remove the third entry in the list of parametrisations since we know
     1069  // that none of the exponents in the parametrisation will be negative
     1070  for (jj=1;jj<=size(pexp);jj++)
     1071  {
     1072    pexp[jj]=delete(pexp[jj],3);
     1073  }
     1074  return(pexp);
     1075}
     1076example
     1077{
     1078   "EXAMPLE:";
     1079   echo=2;
     1080   ring r=0,(x,y),ds;
     1081   poly f=x2-y4+x5y7;
     1082   puiseuxExpansion(puiseuxExpansion(f,3));
     1083}
     1084
     1085proc displayPuiseuxExpansion (list puiseux,list #)
     1086"USAGE:    displayPuiseuxExpansion(puiseux[,#]); puiseux list, # list
     1087ASSUME:    puiseux is the output of puiseuxExpansion; the optional parameter
     1088           # can be the string 'subst'
     1089RETURN:    none
     1090NOTE:      - the procedure displays the output of the procedure puiseuxExpansion
     1091@*         - if the optional parameter 'subst' is given, then the expansion is
     1092             substituted into the polynomial and the result is displayed
     1093@*         - if the base field had a parameter and a minimal polynomial, then the
     1094             new base field will have a parameter and a minimal polynomial;
     1095             var(2) is the old parameter and it is displayed how the old parameter
     1096             can be computed from the new one
     1097EXAMPLE:   example displayPuiseuxExpansion;   shows an example"
     1098{
     1099  int j;
     1100  // if the procedure has to display more than one expansion
     1101  if (typeof(puiseux[1])=="list")
     1102  {
     1103    for (j=1;j<=size(puiseux);j++)
     1104    {
     1105      "=============================";
     1106      string(j)+". Expansion:";
     1107      "";
     1108      displayPuiseuxExpansion(puiseux[j],#);
     1109      "";
     1110    }
     1111  }
     1112  // if the procedure has to display only one expansion
     1113  else
     1114  {
     1115    list variablen;
     1116    for (j=2;j<=nvars(basering);j++)
     1117    {
     1118      variablen[j-1]=string(var(j));
     1119    }
     1120    def LIFTRing=puiseux[1];
     1121    int N=puiseux[2];
     1122    string LIFTpar=parstr(LIFTRing);
     1123    string Kstring="Q";
     1124    setring LIFTRing;
     1125    "The Puiseux expansion lives in the ring";
     1126    if ((size(LIFTpar)==0) and (N==1))
     1127    {
     1128      Kstring+"[[t]]";
     1129    }
     1130    if ((size(LIFTpar)==0) and (N!=1))
     1131    {
     1132      Kstring+"[[t^(1/"+string(N)+")]]";
     1133    }
     1134    if ((size(LIFTpar)!=0) and (N!=1))
     1135    {   
     1136      Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 
     1137    }
     1138    if ((size(LIFTpar)!=0) and (N==1))
     1139    {   
     1140      Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 
     1141    }
     1142    "";
     1143    "The expansion has the form:";
     1144    for (j=1;j<=size(LIFT);j++)
     1145    {
     1146      if (ncols(LIFT)==size(variablen))
     1147      {
     1148        variablen[j]+"="+displaypoly(LIFT[j],N,0,1);
     1149      }
     1150      else
     1151      {
     1152        "var("+string(j)+")="+displaypoly(LIFT[j],N,0,1);
     1153      }
     1154    }
     1155    if (size(#)>0)
     1156    {
     1157      if (#[1]=="subst")
     1158      {
     1159        "";
     1160        "Substituting the expansion into the polynomial gives:";
     1161        "f="+puiseux[3][size(puiseux[3])];
     1162      }
     1163    }
     1164  }     
     1165}
     1166example
     1167{
     1168   "EXAMPLE:";
     1169   echo=2;
     1170   ring r=0,(x,y),ds;
     1171   poly f=x2-y4+x5y7;
     1172   displayPuiseuxExpansion(puiseuxExpansion(f,3));
     1173}
    9231174
    9241175///////////////////////////////////////////////////////////////////////////////
    925 /// Procedures concerned with drawing a tropical curve or a Newton subdivision
     1176/// Procedures concerned with drawing a tropical curve or a Newton subdivision 
    9261177///////////////////////////////////////////////////////////////////////////////
    9271178
    9281179proc tropicalCurve (def tp,list #)
    9291180"USAGE:      tropicalCurve(tp[,#]); tp list, # optional list
    930 ASSUME:      tp is list of linear polynomials of the form ax+by+c
    931              with integers a, b and a rational number c representing
     1181ASSUME:      tp is list of linear polynomials of the form ax+by+c 
     1182             with integers a, b and a rational number c representing 
    9321183             a tropical Laurent polynomial defining a tropical plane curve;
    933              alternatively tp can be a polynomial in Q(t)[x,y] defining a
    934              tropical plane curve via the valuation map;
    935              the basering must have a global monomial ordering,
     1184             alternatively tp can be a polynomial in Q(t)[x,y] defining a 
     1185             tropical plane curve via the valuation map; 
     1186             the basering must have a global monomial ordering, 
    9361187             two variables and up to one parameter!
    937 RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex
     1188RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex 
    9381189                   in the tropical plane curve defined by tp
    9391190                   l[i][1] = x-coordinate of the ith vertex
    9401191                   l[i][2] = y-coordinate of the ith vertex
    941                    l[i][3] = intmat, if j is an entry in the first row
     1192                   l[i][3] = intmat, if j is an entry in the first row 
    9421193                             of intmat then the ith vertex of
    943                              the tropical curve is connected to the
     1194                             the tropical curve is connected to the 
    9441195                             jth vertex with multiplicity given
    9451196                             by the corresponding entry in the second row
    946                    l[i][4] = list of lists, the first entry of a list is
    947                              a primitive integer vector defining the direction
    948                              of an unbounded edge emerging from the ith vertex
    949                              of the graph, the corresponding second entry in
     1197                   l[i][4] = list of lists, the first entry of a list is 
     1198                             a primitive integer vector defining the direction 
     1199                             of an unbounded edge emerging from the ith vertex 
     1200                             of the graph, the corresponding second entry in 
    9501201                             the list is the multiplicity of the unbounded edge
    951                    l[i][5] = a polynomial whose monomials mark the vertices
     1202                   l[i][5] = a polynomial whose monomials mark the vertices 
    9521203                             in the Newton polygon corresponding to the entries
    953                              in tp which take the common minimum at the ith
    954                              vertex -- if some coefficient a or b of the
    955                              linear polynomials in the input was negative,
     1204                             in tp which take the common minimum at the ith 
     1205                             vertex -- if some coefficient a or b of the 
     1206                             linear polynomials in the input was negative, 
    9561207                             then each monomial has to be shifted by
    9571208                             the values in l[size(l)][3]
    958                    l[size(l)][1] = list, the entries describe the boundary
     1209                   l[size(l)][1] = list, the entries describe the boundary 
    9591210                                         points of the Newton subdivision
    960                    l[size(l)][2] = list, the entries are pairs of integer
     1211                   l[size(l)][2] = list, the entries are pairs of integer 
    9611212                                         vectors defining an interior
    9621213                                         edge of the Newton subdivision
    963                    l[size(l)][3] = intvec, the monmials occuring in l[i][5]
    964                                            have to be shifted by this vector
    965                                            in order to represent marked
     1214                   l[size(l)][3] = intvec, the monmials occuring in l[i][5] 
     1215                                           have to be shifted by this vector 
     1216                                           in order to represent marked 
    9661217                                           vertices in the Newton polygon
    967 NOTE:        here the tropical polynomial is supposed to be the MINIMUM
    968              of the linear forms in tp, unless the optional input #[1]
     1218NOTE:        here the tropical polynomial is supposed to be the MINIMUM 
     1219             of the linear forms in tp, unless the optional input #[1] 
    9691220             is the string 'max'
    9701221EXAMPLE:     example tropicalCurve;   shows an example"
     
    9791230    ERROR("The basering should have a global monomial ordering, e.g. ring r=(0,t),(x,y),dp;");
    9801231  }
    981   // if you insert a single polynomial instead of an ideal
     1232  // if you insert a single polynomial instead of an ideal 
    9821233  // representing a tropicalised polynomial,
    983   // then we compute first the tropicalisation of this polynomial
     1234  // then we compute first the tropicalisation of this polynomial 
    9841235  // -- this feature is not documented in the above help string
    9851236  if (typeof(tp)=="poly")
    9861237  {
    987     // exclude the case that the basering has not precisely
     1238    // exclude the case that the basering has not precisely 
    9881239    // one parameter and two indeterminates
    9891240    if ((npars(basering)!=1) or (nvars(basering)!=2))
    9901241    {
    991       ERROR("The basering should have precisely one parameter and two indeterminates!");
     1242      ERROR("The basering should have precisely one parameter and two indeterminates!");     
    9921243    }
    9931244    poly f=tp;
     
    9981249  if (nvars(basering) != 2)
    9991250  {
    1000     ERROR("The basering should have precisely two indeterminates!");
    1001   }
    1002   // -1) Exclude the pathological case that the defining
     1251    ERROR("The basering should have precisely two indeterminates!");     
     1252  }
     1253  // -1) Exclude the pathological case that the defining 
    10031254  //     tropical polynomial has only one term,
    10041255  //     so that the tropical variety is not defined.
     
    10081259    intmat M[2][1]=0,0;
    10091260    return(list(list(0,0,M,list(),detropicalise(tp[1])),list(list(leadexp(detropicalise(tp[1]))),list())));
    1010   }
    1011   // 0) If the input was a list of linear polynomials,
     1261  }   
     1262  // 0) If the input was a list of linear polynomials, 
    10121263  //    then some coefficient of x or y can be negative,
    1013   //    i.e. the input corresponds to the tropical curve
     1264  //    i.e. the input corresponds to the tropical curve 
    10141265  //    of a Laurent polynomial. In that case we should
    1015   //    add some ax+by, so that all coefficients are positive.
     1266  //    add some ax+by, so that all coefficients are positive. 
    10161267  //    This does not change the tropical curve.
    1017   //    however, we have to save (a,b), since the Newton
     1268  //    however, we have to save (a,b), since the Newton 
    10181269  //    polygone has to be shifted by (-a,-b).
    10191270  poly aa,bb; // koeffizienten
     
    10271278    {
    10281279      bb=koeffizienten(tp[i],2);
    1029     }
     1280    }   
    10301281  }
    10311282  if ((aa!=0) or (bb!=0))
     
    10361287    }
    10371288  }
    1038   // 1) compute the vertices of the tropical curve
     1289  // 1) compute the vertices of the tropical curve 
    10391290  //    defined by tp and the Newton subdivision
    10401291  list vtp=verticesTropicalCurve(tp,#);
    1041   //    if vtp is empty, then the Newton polygone is just
     1292  //    if vtp is empty, then the Newton polygone is just 
    10421293  //    a line segment and constitutes a bunch of lines
    10431294  //    which can be computed by bunchOfLines
     
    10461297    return(bunchOfLines(tp));
    10471298  }
    1048   // 2) store all vertices belonging to the ith part of the
     1299  // 2) store all vertices belonging to the ith part of the 
    10491300  //    Newton subdivision in the list vtp[i] as 4th entry,
    10501301  //    and store those, which are not corners of the ith subdivision polygon
    10511302  //    in vtp[i][6]
    1052   poly nwt;
     1303  poly nwt; 
    10531304  list boundaryNSD;  // stores the boundary of a Newton subdivision
    1054   intmat zwsp[2][1]; // used for intermediate storage
     1305  intmat zwsp[2][1]; // used for intermediate storage   
    10551306  for (i=1;i<=size(vtp);i++)
    10561307  {
    10571308    k=1;
    1058     nwt=vtp[i][3]; // the polynomial representing the
     1309    nwt=vtp[i][3]; // the polynomial representing the 
    10591310    // ith part of the Newton subdivision
    1060     // store the vertices of the ith part of the
     1311    // store the vertices of the ith part of the 
    10611312    // Newton subdivision in the list newton
    1062     list newton;
     1313    list newton; 
    10631314    while (nwt!=0)
    10641315    {
     
    10671318      k++;
    10681319    }
    1069     boundaryNSD=findOrientedBoundary(newton);// a list of the vertices
    1070                                              // of the Newton subdivision
    1071                                              // as integer vectors (only those
    1072                                              // on the boundary, and oriented
     1320    boundaryNSD=findOrientedBoundary(newton);// a list of the vertices 
     1321                                             // of the Newton subdivision 
     1322                                             // as integer vectors (only those 
     1323                                             // on the boundary, and oriented 
    10731324                                             // clockwise)
    10741325    vtp[i][4]=boundaryNSD[1];
    10751326    vtp[i][5]=boundaryNSD[2];
    1076     vtp[i][6]=zwsp; // the entries of the first row will denote to which
    1077                     // vertex the ith one is connected
    1078                     // and the entries of the second row will denote
     1327    vtp[i][6]=zwsp; // the entries of the first row will denote to which 
     1328                    // vertex the ith one is connected 
     1329                    // and the entries of the second row will denote 
    10791330                    //with which multiplicity
    10801331    kill newton; // we kill the superflous list
    10811332  }
    1082   // 3) Next we build for each part of the Newton
     1333  // 3) Next we build for each part of the Newton 
    10831334  //    subdivision the list of all pairs of vertices on the
    10841335  //    boundary, which are involved, including those which are not corners
     
    10971348    kill ipairs;
    10981349  }
    1099   // 4) Check for all pairs of verticies in the Newton diagram if they
     1350  // 4) Check for all pairs of verticies in the Newton diagram if they 
    11001351  //    occur in two different parts of the Newton subdivision
    1101   int deleted; // if a pair occurs in two NSD, it can be removed
     1352  int deleted; // if a pair occurs in two NSD, it can be removed 
    11021353               // from both - deleted is then set to 1
    1103   list inneredges; // contains the list of all pairs contained in two NSD
     1354  list inneredges; // contains the list of all pairs contained in two NSD 
    11041355                   // - these are inner the edges of NSD
    11051356  int ggt;
    11061357  d=1;  // counts the inner edges
    11071358  for (i=1;i<=size(pairs)-1;i++)
    1108   {
     1359  { 
    11091360    for (j=i+1;j<=size(pairs);j++)
    11101361    {
     
    11131364        deleted=0;
    11141365        for (l=size(pairs[j]);l>=1 and deleted==0;l--)
    1115         {
     1366        { 
    11161367          if (((pairs[i][k][1]==pairs[j][l][1]) and (pairs[i][k][2]==pairs[j][l][2])) or ((pairs[i][k][1]==pairs[j][l][2]) and (pairs[i][k][2]==pairs[j][l][1])))
    11171368          {
     
    11191370            d++;
    11201371            ggt=abs(gcd(pairs[i][k][1][1]-pairs[i][k][2][1],pairs[i][k][1][2]-pairs[i][k][2][2]));
    1121             zwsp=j,ggt;   // and it is recorded that the ith and jth
     1372            zwsp=j,ggt;   // and it is recorded that the ith and jth 
    11221373                          // vertex should be connected with mult ggt
    11231374            vtp[i][6]=intmatconcat(vtp[i][6],zwsp);
    11241375            zwsp=i,ggt;
    11251376            vtp[j][6]=intmatconcat(vtp[j][6],zwsp);
    1126             pairs[i]=delete(pairs[i],k);  // finally the pair is deleted
     1377            pairs[i]=delete(pairs[i],k);  // finally the pair is deleted 
    11271378                                          // from both sets of pairs
    11281379            pairs[j]=delete(pairs[j],l);
     
    11641415    }
    11651416  }
    1166   // 6.3) Order the vertices such that passing from one to the next we
     1417  // 6.3) Order the vertices such that passing from one to the next we 
    11671418  //      travel along the boundary of the Newton polytope clock wise.
    11681419  boundaryNSD=findOrientedBoundary(vertices);
    11691420  list orderedvertices=boundaryNSD[1];
    11701421  // 7) Find the unbounded edges emerging from a vertex in the tropical curve.
    1171   //    For this we check the remaining pairs for the ith NSD.
     1422  //    For this we check the remaining pairs for the ith NSD. 
    11721423  //    Each pair is ordered according
    1173   //    to the order in which the vertices occur in orderedvertices.
     1424  //    to the order in which the vertices occur in orderedvertices. 
    11741425  //    The direction of the
    1175   //    unbounded edge is then the outward pointing primitive normal
     1426  //    unbounded edge is then the outward pointing primitive normal 
    11761427  //    vector to the vector
    11771428  //    pointing from the first vertex in a pair to the second one.
     
    11831434  for (i=1;i<=size(pairs);i++)
    11841435  {
    1185     list ubedges; // stores the unbounded edges
     1436    list ubedges; // stores the unbounded edges 
    11861437    k=1; // counts the unbounded edges
    11871438    for (j=1;j<=size(pairs[i]);j++)
    11881439    {
    11891440      // computes the position of the vertices in the
    1190       pos1=positionInList(orderedvertices,pairs[i][j][1]);
     1441      pos1=positionInList(orderedvertices,pairs[i][j][1]); 
    11911442      // pair in the list orderedvertices
    1192       pos2=positionInList(orderedvertices,pairs[i][j][2]);
     1443      pos2=positionInList(orderedvertices,pairs[i][j][2]); 
    11931444      if (((pos1>pos2) and !((pos1==size(orderedvertices)) and (pos2==1))) or ((pos2==size(orderedvertices)) and (pos1==1)))  // reorders them if necessary
    11941445      {
     
    11981449      }
    11991450      // the vector pointing from vertex 1 in the pair to vertex2
    1200       normalvector=pairs[i][j][2]-pairs[i][j][1];
     1451      normalvector=pairs[i][j][2]-pairs[i][j][1]; 
    12011452      ggt=gcd(normalvector[1],normalvector[2]);   // the gcd of the entries
    12021453      zw=normalvector[2];    // create the outward pointing normal vector
     
    12301481    kill ubedges;
    12311482  }
    1232   // 8) Store the computed information for the ith part
     1483  // 8) Store the computed information for the ith part 
    12331484  //    of the NSD in the list graph[i].
    12341485  list graph,gr;
     
    12361487  {
    12371488    // the first coordinate of the ith vertex of the tropical curve
    1238     gr[1]=vtp[i][1];
     1489    gr[1]=vtp[i][1]; 
    12391490    // the second coordinate of the ith vertex of the tropical curve
    1240     gr[2]=vtp[i][2];
     1491    gr[2]=vtp[i][2]; 
    12411492    // to which vertices is the ith vertex of the tropical curve connected
    1242     gr[3]=vtp[i][6];
    1243     // the directions unbounded edges emerging from the ith
     1493    gr[3]=vtp[i][6]; 
     1494    // the directions unbounded edges emerging from the ith 
    12441495    // vertex of the trop. curve
    1245     gr[4]=vtp[i][7];
    1246     // the vertices of the boundary of the ith part of the NSD
    1247     gr[5]=vtp[i][3];
     1496    gr[4]=vtp[i][7]; 
     1497    // the vertices of the boundary of the ith part of the NSD 
     1498    gr[5]=vtp[i][3]; 
    12481499    graph[i]=gr;
    12491500  }
     
    12641515    }
    12651516  }
    1266   // 10) Finally store the boundary vertices and
     1517  // 10) Finally store the boundary vertices and 
    12671518  //     the inner edges as last entry in the list graph.
    12681519  //     This represents the NSD.
     
    12811532// the coordinates of the first vertex are graph[1][1],graph[1][2];
    12821533   graph[1][1],graph[1][2];
    1283 // the first vertex is connected to the vertices
     1534// the first vertex is connected to the vertices 
    12841535//     graph[1][3][1,1..ncols(graph[1][3])]
    12851536   intmat M=graph[1][3];
    12861537   M[1,1..ncols(graph[1][3])];
    1287 // the weights of the edges to these vertices are
     1538// the weights of the edges to these vertices are 
    12881539//     graph[1][3][2,1..ncols(graph[1][3])]
    12891540   M[2,1..ncols(graph[1][3])];
    12901541// from the first vertex emerge size(graph[1][4]) unbounded edges
    12911542   size(graph[1][4]);
    1292 // the primitive integral direction vector of the first unbounded edge
     1543// the primitive integral direction vector of the first unbounded edge 
    12931544//     of the first vertex
    12941545   graph[1][4][1][1];
    12951546// the weight of the first unbounded edge of the first vertex
    12961547   graph[1][4][1][2];
    1297 // the monomials which are part of the Newton subdivision of the first vertex
     1548// the monomials which are part of the Newton subdivision of the first vertex 
    12981549   graph[1][5];
    1299 // connecting the points in graph[size(graph)][1] we get
     1550// connecting the points in graph[size(graph)][1] we get 
    13001551//     the boundary of the Newton polytope
    13011552   graph[size(graph)][1];
    1302 // an entry in graph[size(graph)][2] is a pair of points
     1553// an entry in graph[size(graph)][2] is a pair of points 
    13031554//     in the Newton polytope bounding an inner edge
    13041555   graph[size(graph)][2][1];
     
    13091560proc drawTropicalCurve (def f,list #)
    13101561"USAGE:      drawTropicalCurve(f[,#]); f poly or list, # optional list
    1311 ASSUME:      f is list of linear polynomials of the form ax+by+c with
    1312              integers a, b and a rational number c representing a tropical
     1562ASSUME:      f is list of linear polynomials of the form ax+by+c with 
     1563             integers a, b and a rational number c representing a tropical 
    13131564             Laurent polynomial defining a tropical plane curve;
    1314              alternatively f can be a polynomial in Q(t)[x,y] defining
    1315              a tropical plane curve via the valuation map;
    1316              the basering must have a global monomial ordering, two
     1565             alternatively f can be a polynomial in Q(t)[x,y] defining 
     1566             a tropical plane curve via the valuation map; 
     1567             the basering must have a global monomial ordering, two 
    13171568             variables and up to one parameter!
    13181569RETURN:      NONE
    1319 NOTE:        - the procedure creates the files /tmp/tropicalcurveNUMBER.tex and
    1320                /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four
    1321                digit integer;
     1570NOTE:        - the procedure creates the files /tmp/tropicalcurveNUMBER.tex and 
     1571               /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four 
     1572               digit integer; 
    13221573               moreover it displays the tropical curve via kghostview;
    1323                if you wish to remove all these files from /tmp,
     1574               if you wish to remove all these files from /tmp, 
    13241575               call the procedure cleanTmp
    13251576@*           - edges with multiplicity greater than one carry this multiplicity
    13261577@*           - if # is empty, then the tropical curve is computed w.r.t. minimum,
    1327                if #[1] is the string 'max', then it is computed w.r.t. maximum
    1328 @*           - if the last optional argument is 'onlytexfile' then only the
    1329                latex file is produced; this option should be used if kghostview
     1578               if #[1] is the string 'max', then it is computed w.r.t. maximum 
     1579@*           - if the last optional argument is 'onlytexfile' then only the 
     1580               latex file is produced; this option should be used if kghostview 
    13301581               is not installed on your system
    1331 @*           - note that lattice points in the Newton subdivision which are
    1332                black correspond to markings of the marked subdivision,
     1582@*           - note that lattice points in the Newton subdivision which are 
     1583               black correspond to markings of the marked subdivision, 
    13331584               while lattice points in grey are not marked
    13341585EXAMPLE:     example drawTropicalCurve  shows an example"
     
    13481599  if (typeof(f)=="poly")
    13491600  {
    1350     // exclude the case that the basering has not precisely
     1601    // exclude the case that the basering has not precisely 
    13511602    // one parameter and two indeterminates
    13521603    if ((npars(basering)!=1) or (nvars(basering)!=2))
    13531604    {
    1354       ERROR("The basering should have precisely one parameter and two indeterminates!");
     1605      ERROR("The basering should have precisely one parameter and two indeterminates!");     
    13551606    }
    13561607    // if the characteristic of the base field is not 0 then replace the base field
     
    13711622      texf="\\mbox{\\tt The defining equation was not handed over!}";
    13721623      list graph=f;
    1373     }
     1624    }   
    13741625    else
    13751626    { // write the tropical polynomial defined by f
    13761627      if (size(#)==0)
    1377       {
     1628      {     
    13781629        texf="\\min\\{";
    13791630      }
     
    13841635      for (j=1;j<=size(f);j++)
    13851636      {
    1386         texf=texf+texPolynomial(f[j]);
     1637        texf=texf+texPolynomial(f[j]);   
    13871638        if (j<size(f))
    13881639        {
     
    13931644          texf=texf+"\\}";
    13941645        }
    1395       }
     1646      }   
    13961647      list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    13971648    }
     
    14111662\\addtolength{\\topmargin}{-\\headheight}
    14121663\\addtolength{\\topmargin}{-\\topskip}
    1413 \\setlength{\\textheight}{267mm}
     1664\\setlength{\\textheight}{267mm} 
    14141665\\addtolength{\\textheight}{\\topskip}
    14151666\\addtolength{\\textheight}{-\\footskip}
    14161667\\addtolength{\\textheight}{-30pt}
    1417 \\setlength{\\oddsidemargin}{-1in}
     1668\\setlength{\\oddsidemargin}{-1in} 
    14181669\\addtolength{\\oddsidemargin}{20mm}
    14191670\\setlength{\\evensidemargin}{\\oddsidemargin}
    1420 \\setlength{\\textwidth}{170mm}
     1671\\setlength{\\textwidth}{170mm} 
    14211672
    14221673\\begin{document}
    14231674   \\parindent0cm
    14241675   \\begin{center}
    1425       \\large\\bf The Tropicalisation of
     1676      \\large\\bf The Tropicalisation of 
    14261677
    14271678      \\bigskip
     
    14491700
    14501701   \\begin{center}
    1451        "+texDrawNewtonSubdivision(graph,#)+"
     1702       "+texDrawNewtonSubdivision(graph,#)+" 
    14521703   \\end{center}
    14531704\\end{document}";
     
    14561707    int rdnum=random(1000,9999);
    14571708    write(":w /tmp/tropicalcurve"+string(rdnum)+".tex",TEXBILD);
    1458     system("sh","cd /tmp; latex /tmp/tropicalcurve"+string(rdnum)+".tex; dvips /tmp/tropicalcurve"+string(rdnum)+".dvi -o; /bin/rm tropicalcurve"+string(rdnum)+".log;  /bin/rm tropicalcurve"+string(rdnum)+".aux;  /bin/rm tropicalcurve"+string(rdnum)+".ps?;  /bin/rm tropicalcurve"+string(rdnum)+".dvi; kghostview tropicalcurve"+string(rdnum)+".ps &");
     1709    system("sh","cd /tmp; latex /tmp/tropicalcurve"+string(rdnum)+".tex; dvips /tmp/tropicalcurve"+string(rdnum)+".dvi -o; /bin/rm tropicalcurve"+string(rdnum)+".log;  /bin/rm tropicalcurve"+string(rdnum)+".aux;  /bin/rm tropicalcurve"+string(rdnum)+".ps?;  /bin/rm tropicalcurve"+string(rdnum)+".dvi; kghostview tropicalcurve"+string(rdnum)+".ps &"); 
    14591710  }
    14601711  else
     
    14831734proc drawNewtonSubdivision (def f,list #)
    14841735"USAGE:   drawTropicalCurve(f[,#]); f poly, # optional list
    1485 ASSUME:   f is list of linear polynomials of the form ax+by+c with integers
    1486           a, b and a rational number c representing a tropical Laurent
     1736ASSUME:   f is list of linear polynomials of the form ax+by+c with integers 
     1737          a, b and a rational number c representing a tropical Laurent 
    14871738          polynomial defining a tropical plane curve;
    1488           alternatively f can be a polynomial in Q(t)[x,y] defining a tropical
    1489           plane curve via the valuation map;
    1490           the basering must have a global monomial ordering, two variables
     1739          alternatively f can be a polynomial in Q(t)[x,y] defining a tropical 
     1740          plane curve via the valuation map; 
     1741          the basering must have a global monomial ordering, two variables 
    14911742          and up to one parameter!
    14921743RETURN:   NONE
    1493 NOTE:     - the procedure creates the files /tmp/newtonsubdivisionNUMBER.tex,
    1494             and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random
    1495             four digit integer;
     1744NOTE:     - the procedure creates the files /tmp/newtonsubdivisionNUMBER.tex, 
     1745            and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random 
     1746            four digit integer; 
    14961747            moreover it desplays the tropical curve defined by f via kghostview;
    1497             if you wish to remove all these files from /tmp, call the procedure
     1748            if you wish to remove all these files from /tmp, call the procedure 
    14981749            cleanTmp;
    1499 @*          if # is empty, then the tropical curve is computed w.r.t. minimum,
    1500             if #[1] is the string 'max', then it is computed w.r.t. maximum
    1501 @*        - note that lattice points in the Newton subdivision which are black
    1502             correspond to markings of the marked subdivision, while lattice
     1750@*          if # is empty, then the tropical curve is computed w.r.t. minimum, 
     1751            if #[1] is the string 'max', then it is computed w.r.t. maximum 
     1752@*        - note that lattice points in the Newton subdivision which are black 
     1753            correspond to markings of the marked subdivision, while lattice 
    15031754            points in grey are not marked
    15041755EXAMPLE:     example drawNewtonSubdivision;   shows an example"
     
    15141765  { // write the tropical polynomial defined by f
    15151766    if (size(#)==0)
    1516     {
     1767    {     
    15171768      texf="\\min\\{";
    15181769    }
     
    15231774    for (j=1;j<=size(f);j++)
    15241775    {
    1525       texf=texf+texPolynomial(f[j]);
     1776      texf=texf+texPolynomial(f[j]);   
    15261777      if (j<size(f))
    15271778      {
     
    15321783        texf=texf+"\\}";
    15331784      }
    1534     }
     1785    }   
    15351786    list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    15361787  }
     
    15401791   \\parindent0cm
    15411792   \\begin{center}
    1542       \\large\\bf The Newtonsubdivison of
     1793      \\large\\bf The Newtonsubdivison of 
    15431794      \\begin{displaymath}
    15441795          f="+texf+"
     
    15481799
    15491800   \\begin{center}
    1550 "+texDrawNewtonSubdivision(graph)+
     1801"+texDrawNewtonSubdivision(graph)+ 
    15511802"   \\end{center}
    15521803
     
    15541805  int rdnum=random(1000,9999);
    15551806  write(":w /tmp/newtonsubdivision"+string(rdnum)+".tex",TEXBILD);
    1556   system("sh","cd /tmp; latex /tmp/newtonsubdivision"+string(rdnum)+".tex; dvips /tmp/newtonsubdivision"+string(rdnum)+".dvi -o; /bin/rm newtonsubdivision"+string(rdnum)+".log;  /bin/rm newtonsubdivision"+string(rdnum)+".aux;  /bin/rm newtonsubdivision"+string(rdnum)+".ps?;  /bin/rm newtonsubdivision"+string(rdnum)+".dvi; kghostview newtonsubdivision"+string(rdnum)+".ps &");
     1807  system("sh","cd /tmp; latex /tmp/newtonsubdivision"+string(rdnum)+".tex; dvips /tmp/newtonsubdivision"+string(rdnum)+".dvi -o; /bin/rm newtonsubdivision"+string(rdnum)+".log;  /bin/rm newtonsubdivision"+string(rdnum)+".aux;  /bin/rm newtonsubdivision"+string(rdnum)+".ps?;  /bin/rm newtonsubdivision"+string(rdnum)+".dvi; kghostview newtonsubdivision"+string(rdnum)+".ps &"); 
    15571808//  return(TEXBILD);
    15581809}
     
    15791830proc tropicalJInvariant (def f,list #)
    15801831"USAGE:      tropicalJInvariant(f[,#]); f poly or list, # optional list
    1581 ASSUME:      f is list of linear polynomials of the form ax+by+c with integers
    1582              a, b and a rational number c representing a tropical Laurent
     1832ASSUME:      f is list of linear polynomials of the form ax+by+c with integers 
     1833             a, b and a rational number c representing a tropical Laurent 
    15831834             polynomial defining a tropical plane curve;
    1584              alternatively f can be a polynomial in Q(t)[x,y] defining a
    1585              tropical plane curve via the valuation map;
    1586 @*           the basering must have a global monomial ordering, two variables
     1835             alternatively f can be a polynomial in Q(t)[x,y] defining a 
     1836             tropical plane curve via the valuation map; 
     1837@*           the basering must have a global monomial ordering, two variables 
    15871838             and up to one parameter!
    1588 RETURN:      number, if the graph underlying the tropical curve has precisely
    1589                      one loop then its weighted lattice length is returned,
     1839RETURN:      number, if the graph underlying the tropical curve has precisely 
     1840                     one loop then its weighted lattice length is returned, 
    15901841                     otherwise the result will be -1
    1591 NOTE:        - if the tropical curve is elliptic and its embedded graph has
    1592                precisely one loop, then the weigthed lattice length of
     1842NOTE:        - if the tropical curve is elliptic and its embedded graph has 
     1843               precisely one loop, then the weigthed lattice length of 
    15931844               the loop is its tropical j-invariant
    1594 @*           - the procedure checks if the embedded graph of the tropical
    1595                curve has genus one, but it does NOT check if the loop can
    1596                be resolved, so that the curve is not a proper tropical
    1597                elliptic curve
    1598 @*           - if the embedded graph of a tropical elliptic curve has more
    1599                than one loop, then all but one can be resolved, but this is
    1600                not observed by this procedure, so it will not compute
     1845@*           - the procedure checks if the embedded graph of the tropical 
     1846               curve has genus one, but it does NOT check if the loop can 
     1847               be resolved, so that the curve is not a proper tropical 
     1848               elliptic curve 
     1849@*           - if the embedded graph of a tropical elliptic curve has more 
     1850               than one loop, then all but one can be resolved, but this is 
     1851               not observed by this procedure, so it will not compute 
    16011852               the j-invariant
    16021853@*           - if # is empty, then the tropical curve is computed w.r.t. minimum,
    1603                if #[1] is the string 'max', then it is computed w.r.t. maximum
    1604 @*           - the tropicalJInvariant of a plane tropical cubic is the
    1605                'cycle length' of the cubic as introduced in the paper:
    1606                Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant
     1854               if #[1] is the string 'max', then it is computed w.r.t. maximum 
     1855@*           - the tropicalJInvariant of a plane tropical cubic is the 
     1856               'cycle length' of the cubic as introduced in the paper: 
     1857               Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant 
    16071858               of a cubic tropical plane curve.
    16081859EXAMPLE:     example tropicalJInvariant;   shows an example"
     
    16181869    {
    16191870      if (typeof(f[1])=="list")
    1620       {
     1871      {       
    16211872        list graph=f;
    16221873      }
     
    16301881        {
    16311882          ERROR("This is no valid input.");
    1632         }
     1883        }       
    16331884      }
    16341885    }
     
    16471898  genus=-genus/2; // we have counted each bounded edge twice
    16481899  genus=genus+size(graph); // the genus is 1-#bounded_edges+#vertices
    1649   // 3) if the embedded graph has not genus one,
     1900  // 3) if the embedded graph has not genus one, 
    16501901  //    we cannot compute the j-invariant
    16511902  if(genus!=1)
     
    16591910  else
    16601911  {
    1661     intmat nullmat[2][1];  // used to set
    1662     // 4) find a vertex which has only one bounded edge,
    1663     //    if none exists zero is returned,
     1912    intmat nullmat[2][1];  // used to set 
     1913    // 4) find a vertex which has only one bounded edge, 
     1914    //    if none exists zero is returned, 
    16641915    //    otherwise the number of the vertex in the list graph
    1665     int nonloopvertex=findNonLoopVertex(graph);
     1916    int nonloopvertex=findNonLoopVertex(graph);   
    16661917    int dv; //checks if vert. has been found to which nonloopvertex is connected
    1667     intmat delvert; // takes for a moment graph[i][3] of the vertex
     1918    intmat delvert; // takes for a moment graph[i][3] of the vertex 
    16681919                    // to which nonloopvertex is connected
    1669     // 5) delete successively vertices in the graph which
     1920    // 5) delete successively vertices in the graph which 
    16701921    //    have only one bounded edge
    16711922    while (nonloopvertex>0)
    16721923    {
    1673       // find the only vertex to which the nonloopvertex
     1924      // find the only vertex to which the nonloopvertex 
    16741925      // is connected, when it is found
    16751926      // delete the connection in graph[i][3] and set dv=1
     
    16841935            {
    16851936              delvert=graph[i][3];
    1686               delvert=intmatcoldelete(delvert,j); // delete the connection (note
     1937              delvert=intmatcoldelete(delvert,j); // delete the connection (note 
    16871938                                                  // there must have been two!)
    16881939              dv=1;
     
    16921943        }
    16931944      }
    1694       graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex
     1945      graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex 
    16951946                                       // is killed
    1696       nonloopvertex=findNonLoopVertex(graph); // find the next vertex
     1947      nonloopvertex=findNonLoopVertex(graph); // find the next vertex 
    16971948                                              // which has only one edge
    16981949    }
     
    17001951    intvec loop,weights; // encodes the loop and the edges
    17011952    i=1;
    1702     //    start by finding some vertex which belongs to the loop
    1703     while (loop==0)
     1953    //    start by finding some vertex which belongs to the loop 
     1954    while (loop==0) 
    17041955    {
    17051956      // if graph[i][3] of a vertex in the loop has 2 columns, all others have 1
    1706       if (ncols(graph[i][3])==1)
     1957      if (ncols(graph[i][3])==1) 
    17071958      {
    17081959        i++;
     
    17101961      else
    17111962      {
    1712         loop[1]=i; // a starting vertex is found
    1713         loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number
     1963        loop[1]=i; // a starting vertex is found 
     1964        loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number 
    17141965        weights[2]=graph[i][3][2,1]; // and the edge has this weight
    17151966      }
     
    17191970    while (j!=i)  // the loop ends with the same vertex with which it starts
    17201971    {
    1721       // the first row of graph[j][3] has two entries
     1972      // the first row of graph[j][3] has two entries 
    17221973      // corresponding to the two vertices
    1723       // to which the active vertex j is connected;
     1974      // to which the active vertex j is connected; 
    17241975      // one is loop[k-1], i.e. the one which
    17251976      // precedes j in the loop; we have to choose the other one
    1726       if (graph[j][3][1,1]==loop[k-1])
     1977      if (graph[j][3][1,1]==loop[k-1]) 
    17271978      {
    17281979        loop[k+1]=graph[j][3][1,2];
     
    17351986      }
    17361987      j=loop[k+1]; // set loop[k+1] the new active vertex
    1737       k++;
    1738     }
     1988      k++; 
     1989    }   
    17391990    // 7) compute for each edge in the loop the lattice length
    1740     poly xcomp,ycomp; // the x- and y-components of the vectors
     1991    poly xcomp,ycomp; // the x- and y-components of the vectors 
    17411992                      // connecting two vertices of the loop
    1742     number nenner;    // the product of the denominators of
     1993    number nenner;    // the product of the denominators of 
    17431994                      // the x- and y-components
    17441995    number jinvariant;  // the j-invariant
    1745     int eins,zwei,ggt;
     1996    int eins,zwei,ggt; 
    17461997    for (i=1;i<=size(loop)-1;i++) // compute the lattice length for each edge
    17471998    {
    1748       xcomp=graph[loop[i]][1]-graph[loop[i+1]][1];
    1749       ycomp=graph[loop[i]][2]-graph[loop[i+1]][2];
     1999      xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 
     2000      ycomp=graph[loop[i]][2]-graph[loop[i+1]][2]; 
    17502001      nenner=denominator(leadcoef(xcomp))*denominator(leadcoef(ycomp));
    1751       execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";");
    1752       execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";");
     2002      execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";"); 
     2003      execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";"); 
    17532004      ggt=gcd(eins,zwei); // the lattice length is the "gcd"
    17542005                          // of the x-component and the y-component
    1755       jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the
     2006      jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the 
    17562007                                                       // weight of the edge
    17572008    }
    1758     return(jinvariant);
     2009    return(jinvariant);   
    17592010  }
    17602011}
     
    17702021// the curve can have arbitrary degree
    17712022   tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2);
    1772 // the procedure does not realise, if the embedded graph of the tropical
     2023// the procedure does not realise, if the embedded graph of the tropical 
    17732024//     curve has a loop that can be resolved
    17742025   tropicalJInvariant(1+x+y+xy+tx2y+txy2);
    17752026// but it does realise, if the curve has no loop at all ...
    17762027   tropicalJInvariant(x+y+1);
    1777 // or if the embedded graph has more than one loop - even if only one
     2028// or if the embedded graph has more than one loop - even if only one 
    17782029//     cannot be resolved
    17792030   tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4);
     
    17842035proc weierstrassForm (poly f,list #)
    17852036"USAGE:      weierstrassForm(wf[,#]); wf poly, # list
    1786 ASSUME:      wf is a a polynomial whose Newton polygon has precisely one
    1787              interior lattice point, so that it defines an elliptic curve
     2037ASSUME:      wf is a a polynomial whose Newton polygon has precisely one 
     2038             interior lattice point, so that it defines an elliptic curve 
    17882039             on the toric surface corresponding to the Newton polygon
    17892040RETURN:      poly, the Weierstrass normal form of the polynomial
     
    17912042               to Fernando Rodriguez Villegas, villegas@math.utexas.edu
    17922043@*           - the characteristic of the base field should not be 2 or 3
    1793 @*           - if an additional argument # is given, a simplified Weierstrass
     2044@*           - if an additional argument # is given, a simplified Weierstrass 
    17942045               form is computed
    17952046EXAMPLE:     example weierstrassForm;   shows an example"
     
    18522103
    18532104proc jInvariant (poly f,list #)
    1854 "USAGE:      jInvariant(f[,#]); f poly, # list
    1855 ASSUME:      - f is a a polynomial whose Newton polygon has precisely one
    1856                interior lattice point, so that it defines an elliptic curve
     2105"USAGE:      jInvariant(f[,#]); f poly, # list 
     2106ASSUME:      - f is a a polynomial whose Newton polygon has precisely one 
     2107               interior lattice point, so that it defines an elliptic curve 
    18572108               on the toric surface corresponding to the Newton polygon
    1858 @*           - it the optional argument # is present the base field should be
    1859                Q(t) and the optional argument should be one of the following
     2109@*           - it the optional argument # is present the base field should be 
     2110               Q(t) and the optional argument should be one of the following 
    18602111               strings:
    1861 @*             'ord'   : then the return value is of type integer,
     2112@*             'ord'   : then the return value is of type integer, 
    18622113                         namely the order of the j-invariant
    1863 @*             'split' : then the return value is a list of two polynomials,
     2114@*             'split' : then the return value is a list of two polynomials, 
    18642115                         such that the quotient of these two is the j-invariant
    18652116RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    1866 NOTE:        the characteristic of the base field should not be 2 or 3,
     2117NOTE:        the characteristic of the base field should not be 2 or 3, 
    18672118             unless the input is a plane cubic
    18682119EXAMPLE:     example jInvariant;   shows an example"
     
    18902141   echo=2;
    18912142   ring r=(0,t),(x,y),dp;
    1892 // jInvariant computes the j-invariant of a cubic
     2143// jInvariant computes the j-invariant of a cubic 
    18932144   jInvariant(x+y+x2y+y3+1/t*xy);
    1894 // if the ground field has one parameter t, then we can instead
     2145// if the ground field has one parameter t, then we can instead 
    18952146//    compute the order of the j-invariant
    18962147   jInvariant(x+y+x2y+y3+1/t*xy,"ord");
     
    19002151   poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3+x14y8;
    19012152// its j-invariant is
    1902    jInvariant(h);
     2153   jInvariant(h); 
    19032154}
    19042155
     
    19192170@*                 l[6] = a list containing the vertices of the tropical conic f
    19202171@*                 l[7] = a list containing lists with vertices of the tangents
    1921 @*                 l[8] = a string which contains the latex-code to draw the
     2172@*                 l[8] = a string which contains the latex-code to draw the 
    19222173                          tropical conic and its tropicalised tangents
    19232174@*                 l[9] = if # is non-empty, this is the same data for the dual
     
    19432194  ring LINRING=(0,t),(x,y,a(1..6)),lp;
    19442195  list points=imap(BASERING,points);
    1945   ideal I; // the ideal will contain the linear equations given by the conic
     2196  ideal I; // the ideal will contain the linear equations given by the conic 
    19462197           // and the points
    19472198  for (i=1;i<=5;i++)
     
    19642215  ring tRING=0,t,ls;
    19652216  list pointdenom=imap(BASERING,pointdenom);
    1966   list pointnum=imap(BASERING,pointnum);
     2217  list pointnum=imap(BASERING,pointnum); 
    19672218  intvec pointcoordinates;
    19682219  for (i=1;i<=size(pointdenom);i++)
     
    20402291   We consider the concic through the following five points:
    20412292   \\begin{displaymath}
    2042 ";
     2293"; 
    20432294  string texf=texDrawTropical(graphf,list("",scalefactor));
    20442295  for (i=1;i<=size(points);i++)
     
    20772328\\end{document}";
    20782329  setring BASERING;
    2079   // If # non-empty, compute the dual conic and the tangents
    2080   // through the dual points
     2330  // If # non-empty, compute the dual conic and the tangents 
     2331  // through the dual points 
    20812332  // corresponding to the tangents of the given conic.
    20822333  if (size(#)>0)
    20832334  {
    20842335    list dualpoints;
    2085     for (i=1;i<=size(points);i++)
     2336    for (i=1;i<=size(points);i++) 
    20862337    {
    20872338      dualpoints[i]=list(leadcoef(tangents[i])/substitute(tangents[i],x,0,y,0),leadcoef(tangents[i]-lead(tangents[i]))/substitute(tangents[i],x,0,y,0));
     
    21072358// conic[2] is the equation of the conic f passing through the five points
    21082359   conic[2];
    2109 // conic[3] is a list containing the equations of the tangents
     2360// conic[3] is a list containing the equations of the tangents 
    21102361//          through the five points
    21112362   conic[3];
    21122363// conic[4] is an ideal representing the tropicalisation of the conic f
    21132364   conic[4];
    2114 // conic[5] is a list containing the tropicalisation
     2365// conic[5] is a list containing the tropicalisation 
    21152366//          of the five tangents in conic[3]
    21162367   conic[5];
    2117 // conic[6] is a list containing the vertices of the tropical conic
     2368// conic[6] is a list containing the vertices of the tropical conic 
    21182369   conic[6];
    21192370// conic[7] is a list containing the vertices of the five tangents
    21202371   conic[7];
    2121 // conic[8] contains the latex code to draw the tropical conic and
    2122 //          its tropicalised tangents; it can written in a file, processed and
    2123 //          displayed via kghostview
    2124    write(":w /tmp/conic.tex",conic[8]);
    2125    system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o;
     2372// conic[8] contains the latex code to draw the tropical conic and 
     2373//          its tropicalised tangents; it can written in a file, processed and 
     2374//          displayed via kghostview 
     2375   write(":w /tmp/conic.tex",conic[8]);   
     2376   system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o; 
    21262377            kghostview conic.ps &");
    2127 // with an optional argument the same information for the dual conic is computed
     2378// with an optional argument the same information for the dual conic is computed 
    21282379//         and saved in conic[9]
    21292380   conic=conicWithTangents(points,1);
    21302381   conic[9][2]; // the equation of the dual conic
    21312382}
    2132 
     2383 
    21332384///////////////////////////////////////////////////////////////////////////////
    21342385/// Procedures concerned with tropicalisation
     
    21392390ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    21402391RETURN:      list, the linear forms of the tropicalisation of f
    2141 NOTE:        if # is empty, then the valuation of t will be 1,
    2142 @*           if # is the string 'max' it will be -1;
    2143 @*           the latter supposes that we consider the maximum of the
     2392NOTE:        if # is empty, then the valuation of t will be 1, 
     2393@*           if # is the string 'max' it will be -1; 
     2394@*           the latter supposes that we consider the maximum of the 
    21442395             computed linear forms, the former that we consider their minimum
    21452396EXAMPLE:     example tropicalise;   shows an example"
     
    21642415    {
    21652416      tropicalf[i]=tropicalf[i]+exp[j]*var(j);
    2166     }
     2417    }   
    21672418    f=f-lead(f);
    21682419  }
     
    22042455/////////////////////////////////////////////////////////////////////////
    22052456
    2206 proc tInitialForm (poly f, intvec w)
     2457proc tInitialForm (poly f, intvec w) 
    22072458"USAGE:      tInitialForm(f,w); f a polynomial, w an integer vector
    22082459ASSUME:      f is a polynomial in Q[t,x_1,...,x_n] and w=(w_0,w_1,...,w_n)
    22092460RETURN:      poly, the t-initialform of f(t,x) w.r.t. w evaluated at t=1
    2210 NOTE:        the t-initialform is the sum of the terms with MAXIMAL
     2461NOTE:        the t-initialform is the sum of the terms with MAXIMAL 
    22112462             weighted order w.r.t. w
    22122463EXAMPLE:     example tInitialForm;   shows an example"
     
    22182469  // do the same for the remaining part of f and compare the results
    22192470  // keep only the smallest ones
    2220   int vglgewicht;
    2221   f=f-lead(f);
     2471  int vglgewicht; 
     2472  f=f-lead(f); 
    22222473  while (f!=0)
    22232474  {
     
    22342485        initialf=initialf+lead(f);
    22352486      }
    2236     }
     2487    }   
    22372488    f=f-lead(f);
    22382489  }
     
    22542505proc tInitialIdeal (ideal i,intvec w,list #)
    22552506"USAGE:      tInitialIdeal(i,w); i ideal, w intvec
    2256 ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n)
     2507ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 
    22572508RETURN:      ideal ini, the t-initial ideal of i with respect to w"
    22582509{
    22592510  // THE PROCEDURE WILL BE CALLED FROM OTHER PROCEDURES INSIDE THIS LIBRARY;
    2260   // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF
     2511  // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF 
    22612512  // THE FIRST,
    22622513  // AND WE THEREFORE HAVE TO MOVE IT BACK TO THE FRONT!
     
    22822533  // ... and compute a standard basis with
    22832534  // respect to the homogenised ordering defined by w. Since the generators
    2284   // of i will be homogeneous it we can instead take the ordering wp
    2285   // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some
    2286   // large M, so that all entries are positive
    2287   int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is
     2535  // of i will be homogeneous it we can instead take the ordering wp 
     2536  // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some 
     2537  // large M, so that all entries are positive 
     2538  int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is 
    22882539                              // strictly positive for all j
    22892540  intvec whomog=M;
     
    22932544  }
    22942545  execute("ring WEIGHTRING=("+charstr(basering)+"),("+varstr(basering)+"),(wp("+string(whomog)+"));");
    2295   // map i to the new ring and compute a GB of i, then dehomogenise i,
    2296   // so that we can be sure, that the
     2546  // map i to the new ring and compute a GB of i, then dehomogenise i, 
     2547  // so that we can be sure, that the 
    22972548  // initial forms of the generators generate the initial ideal
    22982549  ideal i=subst(groebner(imap(HOMOGRING,i)),@s,1);
     
    25482799proc texDrawBasic (list texdraw)
    25492800"USAGE:      texDrawBasic(texdraw); list texdraw
    2550 ASSUME:      texdraw is a list of strings representing texdraw commands
    2551              (as produced by texDrawTropical) which should be embedded into
     2801ASSUME:      texdraw is a list of strings representing texdraw commands 
     2802             (as produced by texDrawTropical) which should be embedded into 
    25522803             a texdraw environment
    25532804RETURN:      string, a texdraw environment enclosing the input
     
    25692820    \\end{texdraw}";
    25702821  return(texdrawtp);
    2571 }
     2822} 
    25722823example
    25732824{
     
    25862837ASSUME:  graph is the output of tropicalCurve
    25872838RETURN:  string, the texdraw code of the tropical plane curve encoded by graph
    2588 NOTE:    - if the list # is non-empty, the first entry should be a string;
    2589            if this string is 'max', then the tropical curve is considered
     2839NOTE:    - if the list # is non-empty, the first entry should be a string; 
     2840           if this string is 'max', then the tropical curve is considered 
    25902841           with respect to the maximum
    2591 @*       - the procedure computes a scalefactor for the texdraw command which
    2592            should help to display the curve in the right way; this may,
    2593            however, be a bad idea if several texDrawTropical outputs are
    2594            put together to form one image; the scalefactor can be prescribed
     2842@*       - the procedure computes a scalefactor for the texdraw command which 
     2843           should help to display the curve in the right way; this may, 
     2844           however, be a bad idea if several texDrawTropical outputs are 
     2845           put together to form one image; the scalefactor can be prescribed 
    25952846           by the further optional entry of type poly
    2596 @*       - one can add a string as last opional argument to the list #;
    2597            it can be used to insert further texdraw commands (e.g. to have
    2598            a lighter image as when called from inside conicWithTangents);
     2847@*       - one can add a string as last opional argument to the list #; 
     2848           it can be used to insert further texdraw commands (e.g. to have 
     2849           a lighter image as when called from inside conicWithTangents); 
    25992850@*       - the list # is optional and may as well be empty
    26002851EXAMPLE:     example texDrawTropical;   shows an example"
    26012852{
    2602   // there is one possible argument, which is not explained to the user;
     2853  // there is one possible argument, which is not explained to the user; 
    26032854  // it is used to draw several tropical curves; there we want to suppress
    2604   // the weights sometimes; this is done by handing over the string "noweights"
    2605   int i,j;
     2855  // the weights sometimes; this is done by handing over the string "noweights" 
     2856  int i,j; 
    26062857  int noweights; // controls if weights should be drawn or not
    26072858  for (i=1;i<=size(#);i++)
     
    26162867    }
    26172868  }
    2618   // deal first with the pathological case that
     2869  // deal first with the pathological case that 
    26192870  // the input polynomial was a monomial
    2620   // and does therefore not define a tropical curve,
    2621   // and check if the Newton polytope is
     2871  // and does therefore not define a tropical curve, 
     2872  // and check if the Newton polytope is 
    26222873  // a line segment so that the curve defines a bunch of lines
    26232874  int bunchoflines;
    26242875  // if the boundary of the Newton polytope consists of a single point
    2625   if (size(graph[size(graph)][1])==1)
     2876  if (size(graph[size(graph)][1])==1) 
    26262877  {
    26272878    return(string());
     
    26362887    }
    26372888    // then the Newton polytope is a line segment
    2638     if ((size(graph[size(graph)][1])-size(syz(M)))==1)
     2889    if ((size(graph[size(graph)][1])-size(syz(M)))==1) 
    26392890    {
    26402891      bunchoflines=1;
     
    26672918  int nachkomma=2; // number of decimals for the scalefactor
    26682919  number sf=1; // correction factor for scalefactor
    2669   // if no scale factor was handed over to the procedure, use the
     2920  // if no scale factor was handed over to the procedure, use the 
    26702921  // one computed by minScaleFactor;
    26712922  // check first if a scale factor has been handed over
     
    26752926  {
    26762927    // if the scalefactor as polynomial was handed over, get it
    2677     if (typeof(#[i])=="poly")
     2928    if (typeof(#[i])=="poly") 
    26782929    {
    26792930      poly scalefactor=#[2];
    26802931      scfpresent=1;
    26812932    }
    2682     // if the procedure is called for drawing more than one tropical curve
     2933    // if the procedure is called for drawing more than one tropical curve 
    26832934    // then scalefactor,sf,nachkomma,minx,miny,maxx,maxy,centerx,centery
    26842935    // has been handed over to the procedure
     
    26972948    }
    26982949    i++;
    2699   }
     2950  }   
    27002951  // if no scalefactor was handed over we take the one computed in SCF
    27012952  if (scfpresent==0)
     
    27122963  {
    27132964    // if the curve is a bunch of lines no vertex has to be drawn
    2714     if (bunchoflines==0)
     2965    if (bunchoflines==0) 
    27152966    {
    27162967      texdrawtp=texdrawtp+"
     
    27182969    }
    27192970    // draw the bounded edges emerging from the ith vertex
    2720     for (j=1;j<=ncols(graph[i][3]);j++)
    2721     {
    2722       // don't draw it twice - and if there is only one vertex
     2971    for (j=1;j<=ncols(graph[i][3]);j++) 
     2972    {
     2973      // don't draw it twice - and if there is only one vertex 
    27232974      //                       and graph[i][3][1,1] is thus 0, nothing is done
    2724       if (i<graph[i][3][1,j])
    2725       {
     2975      if (i<graph[i][3][1,j]) 
     2976      {                       
    27262977        texdrawtp=texdrawtp+"
    27272978       \\move ("+decimal((graph[i][1]-centerx)/sf)+" "+decimal((graph[i][2]-centery)/sf)+") \\lvec ("+decimal((graph[graph[i][3][1,j]][1]-centerx)/sf)+" "+decimal((graph[graph[i][3][1,j]][2]-centery)/sf)+")";
     
    27362987    // draw the unbounded edges emerging from the ith vertex
    27372988    // they should not be too long
    2738     for (j=1;j<=size(graph[i][4]);j++)
    2739     {
     2989    for (j=1;j<=size(graph[i][4]);j++) 
     2990    {     
    27402991      relxy=shorten(list(decimal((3*graph[i][4][j][1][1]/scalefactor)*sf),decimal((3*graph[i][4][j][1][2]/scalefactor)*sf),string(5*sf/2)));
    27412992      texdrawtp=texdrawtp+"
     
    28363087  // check if scaling is necessary
    28373088  if (scalefactor<1)
    2838   {
     3089  {   
    28393090    subdivision=subdivision+"
    28403091       \\relunitscale"+ decimal(scalefactor);
     
    28443095  {
    28453096    subdivision=subdivision+"
    2846         \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")
     3097        \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")       
    28473098        \\lvec ("+string(boundary[i+1][1])+" "+string(boundary[i+1][2])+")";
    2848   }
     3099  } 
    28493100  subdivision=subdivision+"
    2850         \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")
     3101        \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")       
    28513102        \\lvec ("+string(boundary[1][1])+" "+string(boundary[1][2])+")
    28523103
     
    28553106  {
    28563107    subdivision=subdivision+"
    2857         \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")
     3108        \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")       
    28583109        \\lvec ("+string(inneredges[i][2][1])+" "+string(inneredges[i][2][2])+")";
    28593110  }
     
    28663117      {
    28673118        if (scalefactor > 2)
    2868         {
     3119        {     
    28693120          subdivision=subdivision+"
    28703121        \\move ("+string(i)+" "+string(j)+") \\fcir f:0.6 r:"+decimal(2/(10*scalefactor),size(string(int(scalefactor)))+1);
     
    28763127        }
    28773128      }
    2878     }
     3129    } 
    28793130    if ((shiftvector[1]!=0) or (shiftvector[2]!=0))
    28803131    {
     
    28833134    }
    28843135  }
    2885   // deal with the pathological cases
     3136  // deal with the pathological cases 
    28863137  if (size(boundary)==1) // then the Newton polytope is a point
    28873138  {
     
    29383189  {
    29393190    if (scalefactor > 2)
    2940     {
     3191    {     
    29413192      subdivision=subdivision+"
    2942        \\move ("+string(markings[i][1])+" "+string(markings[i][2])+")
     3193       \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 
    29433194       \\fcir f:0 r:"+decimal(2/(8*scalefactor),size(string(int(scalefactor)))+1);
    29443195    }
     
    29463197    {
    29473198      subdivision=subdivision+"
    2948        \\move ("+string(markings[i][1])+" "+string(markings[i][2])+")
     3199       \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 
    29493200       \\fcir f:0 r:"+decimal(2/(16*scalefactor),size(string(int(scalefactor)))+1);
    29503201    }
    29513202  }
    29523203  // enclose subdivision in the texdraw environment
    2953   string texsubdivision="
     3204  string texsubdivision="     
    29543205    \\begin{texdraw}
    2955        \\drawdim cm  \\relunitscale 1
     3206       \\drawdim cm  \\relunitscale 1 
    29563207       \\linewd 0.05"
    29573208    +subdivision+"
     
    29673218   poly f=x+y+x2y+xy2+1/t*xy;
    29683219   list graph=tropicalCurve(f);
    2969 // compute the texdraw code of the Newton subdivision of the tropical curve
     3220// compute the texdraw code of the Newton subdivision of the tropical curve 
    29703221   texDrawNewtonSubdivision(graph);
    29713222}
     
    29753226proc texDrawTriangulation (list triang,list polygon)
    29763227"USAGE:      texDrawTriangulation(triang,polygon);  triang,polygon list
    2977 ASSUME:      polygon is a list of integer vectors describing the
     3228ASSUME:      polygon is a list of integer vectors describing the 
    29783229             lattice points of a marked polygon;
    2979              triang is a list of integer vectors describing a
     3230             triang is a list of integer vectors describing a 
    29803231             triangulation of the marked polygon
    2981              in the sense that an integer vector of the form (i,j,k) describes
     3232             in the sense that an integer vector of the form (i,j,k) describes 
    29823233             the triangle formed by polygon[i], polygon[j] and polygon[k]
    2983 RETURN:      string, a texdraw code for the triangulation described
     3234RETURN:      string, a texdraw code for the triangulation described 
    29843235                     by triang without the texdraw environment
    29853236EXAMPLE:     example texDrawTriangulation;   shows an example"
     
    29903241   ";
    29913242  int i,j; // indices
    2992   list pairs,markings; // stores edges of the triangulation, respecively
    2993   // the marked points for each triangle store the edges and marked
     3243  list pairs,markings; // stores edges of the triangulation, respecively 
     3244  // the marked points for each triangle store the edges and marked 
    29943245  // points of the triangle
    29953246  for (i=1;i<=size(triang);i++)
     
    30003251    markings[3*i-2]=triang[i][1];
    30013252    markings[3*i-1]=triang[i][2];
    3002     markings[3*i]=triang[i][3];
     3253    markings[3*i]=triang[i][3];   
    30033254  }
    30043255  // delete redundant pairs which occur more than once
     
    30333284  {
    30343285    latex=latex+"
    3035         \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")
     3286        \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")       
    30363287        \\fcir f:0 r:0.08";
    30373288  }
     
    30403291  {
    30413292    latex=latex+"
    3042         \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")
     3293        \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")       
    30433294        \\lvec ("+string(polygon[pairs[i][2]][1])+" "+string(polygon[pairs[i][2]][2])+")";
    30443295  }
     
    30473298  {
    30483299    latex=latex+"
    3049         \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")
     3300        \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")       
    30503301        \\fcir f:0.7 r:0.04";
    30513302  }
     
    30563307   "EXAMPLE:";
    30573308   echo=2;
    3058    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
     3309   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
    30593310   // with all integer points as markings
    30603311   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0),
    30613312                intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3);
    3062    // define a triangulation by connecting the only interior point
     3313   // define a triangulation by connecting the only interior point 
    30633314   //        with the vertices
    30643315   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10);
     
    30683319
    30693320///////////////////////////////////////////////////////////////////////////////
    3070 /// Auxilary Procedures
     3321/// Auxilary Procedures 
    30713322///////////////////////////////////////////////////////////////////////////////
    30723323
     
    30743325"USAGE:  radicalMemberShip (f,i); f poly, i ideal
    30753326RETURN:  int, 1 if f is in the radical of i, 0 else
    3076 EXAMPLE:     example radicalMemberShip;   shows an example"
     3327EXAMPLE:     example radicalMemberShip;   shows an example" 
    30773328{
    30783329  def BASERING=basering;
     
    31143365{
    31153366  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    3116   // the rational constant corresponding to this order in leadkoef(f)
     3367  // the rational constant corresponding to this order in leadkoef(f) 
    31173368  // (leitkoef[2])
    31183369  list leitkoef=simplifyToOrder(f);
     
    31243375  // do the same for the remaining part of f and compare the results
    31253376  // keep only the smallest ones
    3126   int vglgewicht;
    3127   f=f-lead(f);
     3377  int vglgewicht; 
     3378  f=f-lead(f); 
    31283379  while (f!=0)
    31293380  {
    3130     leitkoef=simplifyToOrder(f);
     3381    leitkoef=simplifyToOrder(f);   
    31313382    vglgewicht=leitkoef[1]+scalarproduct(w,leadexp(f));
    31323383    if (vglgewicht<gewicht)
     
    31433394        initialf=initialf+koef*leadmonom(f);
    31443395      }
    3145     }
     3396    }   
    31463397    f=f-lead(f);
    31473398  }
     
    31683419{
    31693420  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    3170   // the rational constant corresponding to this order in leadkoef(f)
     3421  // the rational constant corresponding to this order in leadkoef(f) 
    31713422  // (leitkoef[2])
    3172   list leitkoef=simplifyToOrder(f);
     3423  list leitkoef=simplifyToOrder(f); 
    31733424  execute("poly koef="+leitkoef[2]+";");
    31743425  // take in lead(f) only the term of lowest t-order and set t=1
     
    31793430  // keep only the largest ones
    31803431  int vglgewicht;
    3181   f=f-lead(f);
     3432  f=f-lead(f); 
    31823433  while (f!=0)
    31833434  {
     
    31973448        initialf=initialf+koef*leadmonom(f);
    31983449      }
    3199     }
     3450    }   
    32003451    f=f-lead(f);
    32013452  }
     
    32163467proc solveTInitialFormPar (ideal i)
    32173468"USAGE:      solveTInitialFormPar(i); i ideal
    3218 ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated
    3219              by the (1,w)-homogeneous elements for some integer vector w
     3469ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated 
     3470             by the (1,w)-homogeneous elements for some integer vector w 
    32203471             - i.e. by the (1,w)-initialforms of polynomials
    32213472RETURN:      none
    3222 NOTE:        the procedure just displays complex approximations
     3473NOTE:        the procedure just displays complex approximations 
    32233474             of the solution set of i
    32243475EXAMPLE:     example solveTInitialFormPar;   shows an example"
     
    32453496/////////////////////////////////////////////////////////////////////////
    32463497
    3247 proc detropicalise (def p)
     3498proc detropicalise (def p) 
    32483499"USAGE:   detropicalise(f); f poly or f list
    3249 ASSUME:   if f is of type poly then t is a linear polynomial with
    3250           an arbitrary constant term and positive integer coefficients
     3500ASSUME:   if f is of type poly then t is a linear polynomial with 
     3501          an arbitrary constant term and positive integer coefficients 
    32513502          as further coefficients;
    32523503@*        if f is of type list then f is a list of polynomials of
    32533504          the type just described in before
    32543505RETURN:   poly, the detropicalisation of f ignoring the constant parts
    3255 NOTE:     the output will be a monomial and the constant coefficient
     3506NOTE:     the output will be a monomial and the constant coefficient 
    32563507          has been ignored
    32573508EXAMPLE:  example detropicalise;   shows an example"
     
    32613512  {
    32623513    if (leadmonom(p)!=1)
    3263     {
     3514    { 
    32643515      dtp=dtp*leadmonom(p)^int(leadcoef(p));
    32653516    }
     
    32783529/////////////////////////////////////////////////////////////////////////
    32793530
    3280 proc tDetropicalise (def p)
     3531proc tDetropicalise (def p) 
    32813532"USAGE:   tDetropicalise(f); f poly or f list
    3282 ASSUME:   if f is of type poly then f is a linear polynomial with an
    3283           integer constant term and positive integer coefficients
     3533ASSUME:   if f is of type poly then f is a linear polynomial with an 
     3534          integer constant term and positive integer coefficients 
    32843535          as further coefficients;
    32853536@*        if f is of type list then it is a list of polynomials of
    3286           the type just described in before
     3537          the type just described in before 
    32873538RETURN:   poly, the detropicalisation of f over the field Q(t)
    32883539NOTE:     the output will be a term where the coeffiecient is a Laurent
     
    32933544  if (typeof(p)=="list")
    32943545  {
    3295     int i;
     3546    int i;   
    32963547    for (i=1;i<=size(p);i++)
    32973548    {
     
    33053556    {
    33063557      if (leadmonom(p)!=1)
    3307       {
     3558      { 
    33083559        dtp=dtp*leadmonom(p)^int(leadcoef(p));
    33093560      }
     
    33633614proc parameterSubstitute (poly f,int N)
    33643615"USAGE:   parameterSubstitute(f,N); f poly, N int
    3365 ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing
     3616ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing 
    33663617          a plane curve over Q(t)
    33673618RETURN:   poly f with t replaced by t^N
     
    34173668   poly f=t2x+1/t*y-1;
    34183669   tropicalSubst(f,2,x,x+t,y,tx+y+t2);
    3419    // The procedure can be used to study the effect of a transformation of
     3670   // The procedure can be used to study the effect of a transformation of 
    34203671   // the form x -> x+t^b, with b a rational number, on the tropicalisation and
    34213672   // the j-invariant of a cubic over the Puiseux series.
    34223673   f=t7*y3+t3*y2+t*(x3+xy2+y+1)+xy;
    3423    // - the j-invariant, and hence its valuation,
     3674   // - the j-invariant, and hence its valuation, 
    34243675   //   does not change under the transformation
    34253676   jInvariant(f,"ord");
    3426    // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)
    3427    list g32=tropicalSubst(f,2,x,x+t3,y,y);
     3677   // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)   
     3678   list g32=tropicalSubst(f,2,x,x+t3,y,y); 
    34283679   tropicalJInvariant(g32);
    34293680   // - b=1, then it is still true, but only just ...
     
    34383689
    34393690proc randomPoly (int d,int ug, int og, list #)
    3440 "USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list
     3691"USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list 
    34413692ASSUME:      the basering has a parameter t
    3442 RETURN:      poly, a polynomial of degree d where the coefficients are
     3693RETURN:      poly, a polynomial of degree d where the coefficients are 
    34433694                   of the form t^j with j a random integer between ug and og
    3444 NOTE:        if an optional argument # is given, then the coefficients are
    3445              instead either of the form t^j as above or they are zero,
     3695NOTE:        if an optional argument # is given, then the coefficients are 
     3696             instead either of the form t^j as above or they are zero, 
    34463697             and this is chosen randomly
    34473698EXAMPLE:     example randomPoly;   shows an example"
     
    34603711  {
    34613712    if (size(#)!=0)
    3462     {
     3713    {     
    34633714      k=random(0,1);
    34643715    }
    34653716    if (k==0)
    3466     {
     3717    {     
    34673718      j=random(ug,og);
    34683719      randomPolynomial=randomPolynomial+t^j*m[i];
     
    34943745RETURN:  none"
    34953746{
    3496   system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*");
     3747  system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 
    34973748}
    34983749
     
    35513802static proc cutdown (ideal jideal,intvec wvec,int dimension,list #)
    35523803"USAGE:      cutdown(i,w,d); i ideal, w intvec, d int, # list
    3553 ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical
    3554              variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional
    3555              parameter # can contain the string 'isPrime' to indicate that
    3556              the input ideal is prime and no minimal associated primes have
     3804ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical 
     3805             variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional 
     3806             parameter # can contain the string 'isPrime' to indicate that 
     3807             the input ideal is prime and no minimal associated primes have 
    35573808             to be computed
    3558 RETURN:      list, the first entry is a ring, namely the basering where some
    3559                    variables have been eliminated, and the ring contains
     3809RETURN:      list, the first entry is a ring, namely the basering where some 
     3810                   variables have been eliminated, and the ring contains 
    35603811                   the ideal i (with the same variables eliminated),
    3561                    the t-initial ideal ini of i (w.r.t. the weight vector
    3562                    where the entries corresponding to the deleted variables
    3563                    have been eliminated) and a list repl where for each
     3812                   the t-initial ideal ini of i (w.r.t. the weight vector 
     3813                   where the entries corresponding to the deleted variables 
     3814                   have been eliminated) and a list repl where for each 
    35643815                   eliminated variable there is one entry, namely a polynomial
    3565                    in the remaining variables and t that explains how
    3566                    resubstitution of a solution for the new i gives a solution
     3816                   in the remaining variables and t that explains how 
     3817                   resubstitution of a solution for the new i gives a solution 
    35673818                   for the old i; the second entry is the weight vector
    3568                    wvec with the components corresponding to the eliminated
     3819                   wvec with the components corresponding to the eliminated 
    35693820                   variables removed
    3570 NOTE:        needs the libraries random.lib and primdec.lib;
     3821NOTE:        needs the libraries random.lib and primdec.lib; 
    35713822             is called from tropicalLifting"
    3572 {
    3573   // IDEA: i is an ideal of dimension d; we want to cut it with d random linear
     3823{ 
     3824  // IDEA: i is an ideal of dimension d; we want to cut it with d random linear 
    35743825  //       forms in such a way that the resulting
    35753826  //       ideal is 0-dim and still contains w in the tropical variety
    3576   // NOTE: t is the last variable in the basering
     3827  // NOTE: t is the last variable in the basering 
    35773828  ideal pideal;  //this is the ideal we want to return
    35783829  ideal cutideal;
     
    35923843  for (j1=1;j1<=nvars(basering)-1;j1++)
    35933844  {
    3594     variablen=variablen+var(j1); // read the set of variables
     3845    variablen=variablen+var(j1); // read the set of variables 
    35953846                                 // (needed to make the quotring later)
    3596     product=product*var(j1); // make product of all variables
     3847    product=product*var(j1); // make product of all variables 
    35973848                             // (needed for the initial-monomial-check later
    3598   }
     3849  }   
    35993850  execute("ring QUOTRING=("+charstr(basering)+",t),("+string(variablen)+"),dp;");
    36003851  setring BASERING;
     
    36033854  {
    36043855    setring QUOTRING;
    3605     ideal jideal=imap(BASERING,jideal);
    3606     list primp=minAssGTZ(jideal); //compute the primary decomposition
     3856    ideal jideal=imap(BASERING,jideal); 
     3857    list primp=minAssGTZ(jideal); //compute the primary decomposition 
    36073858    for (j1=1;j1<=size(primp);j1++)
    3608     {
     3859    {     
    36093860      for(j2=1;j2<=size(primp[j1]);j2++)
    36103861      {
    36113862        // clear all denominators
    36123863        primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);
    3613       }
     3864      }       
    36143865    }
    36153866    setring BASERING;
    36163867    list primp=imap(QUOTRING,primp);
    36173868    // if i is not primary itself
    3618     // go through the list of min. ass. primes and find the first
     3869    // go through the list of min. ass. primes and find the first 
    36193870    // one which has w in its tropical variety
    3620     if (size(primp)>1)
     3871    if (size(primp)>1) 
    36213872    {
    36223873      j1=1;
     
    36253876        //compute the t-initial of the associated prime
    36263877        // - the last entry 1 only means that t is the last variable in the ring
    3627         primini=tInitialIdeal(primp[j1],wvec,1);
    3628         // check if it contains a monomial (resp if the product of var
     3878        primini=tInitialIdeal(primp[j1],wvec,1); 
     3879        // check if it contains a monomial (resp if the product of var 
    36293880        // is in the radical)
    3630         if (radicalMemberShip(product,primini)==0)
    3631         {
     3881        if (radicalMemberShip(product,primini)==0) 
     3882        { 
    36323883          // if w is in the tropical variety of the prime, we take that
    36333884          jideal=primp[j1];
     
    36363887          setring BASERING;
    36373888          winprim=1; // and stop the checking
    3638         }
     3889        } 
    36393890        j1=j1+1;  //else we look at the next associated prime
    36403891      }
     
    36433894    {
    36443895      jideal=primp[1]; //if i is primary itself we take its prime instead
    3645     }
     3896    } 
    36463897  }
    36473898  // now we start as a first try to intersect with a hyperplane parallel to
    36483899  // coordinate axes, because this would make our further computations
    3649   // a lot easier.
    3650   // We choose a subset of our n variables of size d=dim(ideal).
     3900  // a lot easier. 
     3901  // We choose a subset of our n variables of size d=dim(ideal). 
    36513902  // For each of these
    3652   // variables, we want to fix a value: x_i= a_i*t^-w_i.
     3903  // variables, we want to fix a value: x_i= a_i*t^-w_i. 
    36533904  // This will only work if the
    3654   // projection of the d-dim variety to the other n-d variables
     3905  // projection of the d-dim variety to the other n-d variables 
    36553906  // is the whole n-d plane.
    3656   // Then a general choice for a_i will intersect the variety
     3907  // Then a general choice for a_i will intersect the variety 
    36573908  // in finitely many points.
    3658   // If the projection is not the whole n-d plane,
     3909  // If the projection is not the whole n-d plane, 
    36593910  // then a general choice will not work.
    3660   // We could determine if we picked a good
     3911  // We could determine if we picked a good 
    36613912  // d-subset of variables using elimination
    3662   // (NOTE, there EXIST d variables such that
     3913  // (NOTE, there EXIST d variables such that 
    36633914  // a random choice of a_i's would work!).
    3664   // But since this involves many computations,
     3915  // But since this involves many computations, 
    36653916  // we prefer to choose randomly and just
    3666   // try in the end if our intersected ideal
    3667   // satisfies our requirements. If this does not
     3917  // try in the end if our intersected ideal 
     3918  // satisfies our requirements. If this does not 
    36683919  // work, we give up this try and use our second intersection idea, which
    36693920  // will work for a Zariksi-open subset (i.e. almost always).
    36703921  //
    3671   // As random subset of d variables we choose
     3922  // As random subset of d variables we choose 
    36723923  // those for which the absolute value of the
    3673   // wvec-coordinate is smallest, because this will
     3924  // wvec-coordinate is smallest, because this will 
    36743925  // give us the smallest powers of t and hence
    3675   // less effort in following computations.
     3926  // less effort in following computations. 
    36763927  // Note that the smallest absolute value have those
    3677   // which are biggest, because wvec is negative.
     3928  // which are biggest, because wvec is negative. 
    36783929  //print("first try");
    36793930  intvec wminust=intvecdelete(wvec,1);
     
    36823933  A[1,1..size(wminust)]=-wminust;
    36833934  A[2,1..size(wminust)]=1..size(wminust);
    3684   // sort this matrix in order to get
     3935  // sort this matrix in order to get 
    36853936  // the d biggest entries and their position in wvec
    3686   A=sortintmat(A);
    3687   // we construct a vector which has 1 at entry j if j belongs to the list
     3937  A=sortintmat(A); 
     3938  // we construct a vector which has 1 at entry j if j belongs to the list 
    36883939  // of the d biggest entries of wvec and a 0 else
    36893940  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    36943945      {
    36953946        setvec[j1]=1;//put a 1
    3696       }
    3697     }
    3698   }
    3699   // using this 0/1-vector we produce
    3700   // a random constant (i.e. coeff in Q times something in t)
    3701   // for each of the biggest variables,
     3947      }       
     3948    } 
     3949  }
     3950  // using this 0/1-vector we produce 
     3951  // a random constant (i.e. coeff in Q times something in t) 
     3952  // for each of the biggest variables, 
    37023953  // we add the forms x_i-random constant to the ideal
    3703   // and we save the constant at the i-th place of
     3954  // and we save the constant at the i-th place of 
    37043955  // a list we want to return for later computations
    37053956  j3=0;
     
    37123963    {
    37133964      if(setvec[j1]==1)//if x_i belongs to the biggest variables
    3714       {
     3965      {     
    37153966        if ((j3==1) and ((char(basering)==0) or (char(basering)>3)))
    3716         {
     3967        {       
    37173968          randomp1=random(1,3);
    3718           randomp=t^(A[1,j2])*randomp1;// make a random constant
     3969          randomp=t^(A[1,j2])*randomp1;// make a random constant 
    37193970                                       // --- first we try small numbers
    3720         }
     3971        }   
    37213972        if ((j3==2) and ((char(basering)==0) or (char(basering)>100)))
    37223973        {
    37233974          randomp1=random(1,100);
    3724           randomp=t^(A[1,j2])*randomp1;// make a random constant
     3975          randomp=t^(A[1,j2])*randomp1;// make a random constant 
    37253976                                       // --- next we try bigger numbers
    3726         }
     3977        }   
    37273978        else
    37283979        {
     
    37363987      else
    37373988      {
    3738         ergl[j1]=0; //if the variable is not among the d biggest ones,
     3989        ergl[j1]=0; //if the variable is not among the d biggest ones, 
    37393990                    //save 0 in the list
    37403991        erglini[j1]=0;
    3741       }
     3992      }       
    37423993    }
    37433994      // print(ergl);print(pideal);
    3744       // now we check if we made a good choice of pideal, i.e. if dim=0 and
     3995      // now we check if we made a good choice of pideal, i.e. if dim=0 and 
    37453996      // wvec is still in the tropical variety
    37463997      // change to quotring where we compute dimension
     
    37494000    {
    37504001      if(setvec[j1]==1)
    3751       {
    3752         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3753       }
     4002      {     
     4003        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     4004      }     
    37544005    }
    37554006    setring QUOTRING;
     
    37634014    {
    37644015      // compute the t-initial of the associated prime
    3765       // - the last 1 just means that the variable t is
     4016      // - the last 1 just means that the variable t is 
    37664017      //   the last variable in the ring
    37674018      pini=tInitialIdeal(cutideal,wvec ,1);
    37684019      //print("initial");
    37694020      //print(pini);
    3770       // and if the initial w.r.t. t contains no monomial
     4021      // and if the initial w.r.t. t contains no monomial 
    37714022      // as we want (checked with
    37724023      // radical-membership of the product of all variables)
    3773       if (radicalMemberShip(product,pini)==0)
    3774       {
    3775         // we made the right choice and now
    3776         // we substitute the variables in the ideal
     4024      if (radicalMemberShip(product,pini)==0) 
     4025      {
     4026        // we made the right choice and now 
     4027        // we substitute the variables in the ideal   
    37774028        // to get an ideal in less variables
    3778         // also we make a projected vector
     4029        // also we make a projected vector 
    37794030        // from wvec only the components of the remaining variables
    37804031        wvecp=wvec;
    3781         variablen=0;
     4032        variablen=0;   
    37824033        j2=0;
    37834034        for(j1=1;j1<=nvars(basering)-1;j1++)
     
    37924043          else
    37934044          {
    3794             variablen=variablen+var(j1); // read the set of remaining variables
     4045            variablen=variablen+var(j1); // read the set of remaining variables 
    37954046                                         // (needed to make quotring later)
    3796           }
    3797         }
     4047          }   
     4048        }     
    37984049        // return pideal, the initial and the list ergl which tells us
    37994050        // which variables we replaced by which form
     
    38054056        export(ini);
    38064057        export(repl);
    3807         return(list(BASERINGLESS1,wvecp));
     4058        return(list(BASERINGLESS1,wvecp)); 
    38084059      }
    38094060    }
    38104061  }
    38114062  // this is our second try to cut down, which we only use if the first try
    3812   // didn't work out. We intersect with d general hyperplanes
     4063  // didn't work out. We intersect with d general hyperplanes 
    38134064  // (i.e. we don't choose
    38144065  // them to be parallel to coordinate hyperplanes anymore. This works out with
    38154066  // probability 1.
    38164067  //
    3817   // We choose general hyperplanes, i.e. linear forms which involve all x_i.
    3818   // Each x_i has to be multiplied bz t^(w_i) in order
    3819   // to get the same weight (namely 0)
     4068  // We choose general hyperplanes, i.e. linear forms which involve all x_i. 
     4069  // Each x_i has to be multiplied bz t^(w_i) in order 
     4070  // to get the same weight (namely 0) 
    38204071  // for each term. As we cannot have negative exponents, we multiply
    3821   // the whole form by t^minimumw. Notice that then in the first form,
     4072  // the whole form by t^minimumw. Notice that then in the first form, 
    38224073  // there is one term without t- the term of the variable
    38234074  // x_i such that w_i is minimal. That is, we can solve for this variable.
    3824   // In the second form, we can replace that variable,
    3825   // and divide by t as much as possible.
    3826   // Then there is again one term wihtout t -
    3827   // the term of the variable with second least w.
     4075  // In the second form, we can replace that variable, 
     4076  // and divide by t as much as possible. 
     4077  // Then there is again one term wihtout t - 
     4078  // the term of the variable with second least w. 
    38284079  // So we can solve for this one again and also replace it in the first form.
    3829   // Since all our coefficients are chosen randomly,
    3830   // we can also from the beginning on
    3831   // choose the set of variables which belong to the d smallest entries of wvec
    3832   // (t not counting) and pick random forms g_i(t,x')
    3833   // (where x' is the set of remaining variables)
    3834   // and set x_i=g_i(t,x').
     4080  // Since all our coefficients are chosen randomly, 
     4081  // we can also from the beginning on 
     4082  // choose the set of variables which belong to the d smallest entries of wvec 
     4083  // (t not counting) and pick random forms g_i(t,x') 
     4084  // (where x' is the set of remaining variables) 
     4085  // and set x_i=g_i(t,x'). 
    38354086  //
    38364087  // make a matrix with first row wvec (without t) and second row 1..n
    38374088  //print("second try");
    38384089  setring BASERING;
    3839   A[1,1..size(wminust)]=wminust;
     4090  A[1,1..size(wminust)]=wminust; 
    38404091  A[2,1..size(wminust)]=1..size(wminust);
    3841   // sort this matrix in otder to get the d smallest entries
     4092  // sort this matrix in otder to get the d smallest entries 
    38424093  // (without counting the t-entry)
    38434094  A=sortintmat(A);
     
    38454096  setvec=0;
    38464097  setvec[nvars(basering)-1]=0;
    3847   // we construct a vector which has 1 at entry j if j belongs to the list of
     4098  // we construct a vector which has 1 at entry j if j belongs to the list of 
    38484099  // the d smallest entries of wvec and a 0 else
    38494100  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    38654116    {
    38664117      j2=j2+1;
    3867       wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components
     4118      wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components 
    38684119                                        // we substitute from wvec
    38694120    }
    38704121    else
    38714122    {
    3872       variablen=variablen+var(j1); // read the set of remaining variables
     4123      variablen=variablen+var(j1); // read the set of remaining variables 
    38734124                                   // (needed to make the quotring later)
    38744125    }
    3875   }
     4126  } 
    38764127  setring BASERING;
    38774128  execute("ring BASERINGLESS2=("+charstr(BASERING)+"),("+string(variablen)+",t),(dp("+string(ncols(variablen))+"),lp(1));");
    3878   // using the 0/1-vector which tells us which variables belong
     4129  // using the 0/1-vector which tells us which variables belong 
    38794130  // to the set of smallest entries of wvec
    3880   // we construct a set of d random linear
    3881   // polynomials of the form x_i=g_i(t,x'),
     4131  // we construct a set of d random linear 
     4132  // polynomials of the form x_i=g_i(t,x'), 
    38824133  // where the set of all x_i is the set of
    3883   // all variables which are in the list of smallest
     4134  // all variables which are in the list of smallest 
    38844135  // entries in wvec, and x' are the other variables.
    3885   // We add these d random linear polynomials to
    3886   // the ideal pideal, i.e. we intersect
     4136  // We add these d random linear polynomials to 
     4137  // the ideal pideal, i.e. we intersect 
    38874138  // with these and hope to get something
    3888   // 0-dim which still contains wvec in its
    3889   // tropical variety. Also, we produce a list ergl
     4139  // 0-dim which still contains wvec in its 
     4140  // tropical variety. Also, we produce a list ergl 
    38904141  // with g_i at the i-th position.
    38914142  // This is a list we want to return.
     
    38934144  setring BASERING;
    38944145  pideal=jideal;
    3895   for(j1=1;j1<=dimension;j1++)//go through the list of variables
     4146  for(j1=1;j1<=dimension;j1++)//go through the list of variables 
    38964147  { // corres to the d smallest in wvec
    38974148    if ((char(basering)==0) or (char(basering)>3))
    3898     {
     4149    { 
    38994150      randomp1=random(1,3);
    39004151      randomp=randomp1*t^(-A[1,j1]);
     
    39094160      if(setvec[j2]==0)//if x_j belongs to the set x'
    39104161      {
    3911         // add a random term with the suitable power
     4162        // add a random term with the suitable power 
    39124163        // of t to the random linear form
    39134164        if ((char(basering)==0) or (char(basering)>3))
     
    39344185    }
    39354186  //print(ergl);
    3936   // Again, we have to test if we made a good choice
    3937   // to intersect,i.e. we have to check whether
     4187  // Again, we have to test if we made a good choice 
     4188  // to intersect,i.e. we have to check whether 
    39384189  // pideal is 0-dim and contains wvec in the tropical variety.
    39394190  cutideal=pideal;
     
    39424193    if(setvec[j1]==1)
    39434194    {
    3944       cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3945     }
     4195      cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     4196    }   
    39464197  }
    39474198  setring QUOTRING;
     
    39554206  {
    39564207    // compute the t-initial of the associated prime
    3957     // - the last 1 just means that the variable t
     4208    // - the last 1 just means that the variable t 
    39584209    // is the last variable in the ring
    39594210    pini=tInitialIdeal(cutideal,wvec ,1);
     
    39624213    // and if the initial w.r.t. t contains no monomial as we want (checked with
    39634214    // radical-membership of the product of all variables)
    3964     if (radicalMemberShip(product,pini)==0)
     4215    if (radicalMemberShip(product,pini)==0) 
    39654216    {
    39664217      // we want to replace the variables x_i by the forms -g_i in
    3967       // our ideal in order to return an ideal with less variables
     4218      // our ideal in order to return an ideal with less variables 
    39684219      // first we substitute the chosen variables
    39694220      for(j1=1;j1<=nvars(basering)-1;j1++)
     
    39824233      export(ini);
    39834234      export(repl);
    3984       return(list(BASERINGLESS2,wvecp));
     4235      return(list(BASERINGLESS2,wvecp)); 
    39854236    }
    39864237  }
    39874238  // now we try bigger numbers
    3988   while (1) //a never-ending loop which will stop with prob. 1
     4239  while (1) //a never-ending loop which will stop with prob. 1 
    39894240  { // as we find a suitable ideal with that prob
    39904241    setring BASERING;
    39914242    pideal=jideal;
    3992     for(j1=1;j1<=dimension;j1++)//go through the list of variables
     4243    for(j1=1;j1<=dimension;j1++)//go through the list of variables 
    39934244    { // corres to the d smallest in wvec
    39944245      randomp1=random(1,100);
    39954246      randomp=randomp1*t^(-A[1,j1]);
    39964247      for(j2=1;j2<=nvars(basering)-1;j2++)//go through all variables
    3997       {
     4248      { 
    39984249        if(setvec[j2]==0)//if x_j belongs to the set x'
    39994250        {
    4000           // add a random term with the suitable power
     4251          // add a random term with the suitable power 
    40014252          // of t to the random linear form
    40024253          if ((char(basering)==0) or (char(basering)>100))
    4003           {
     4254          { 
    40044255            randomp2=random(1,100);
    40054256            randomp1=randomp1+randomp2*var(j2);
     
    40224273      }
    40234274    //print(ergl);
    4024     // Again, we have to test if we made a good choice to
    4025     // intersect,i.e. we have to check whether
     4275    // Again, we have to test if we made a good choice to 
     4276    // intersect,i.e. we have to check whether 
    40264277    // pideal is 0-dim and contains wvec in the tropical variety.
    40274278    cutideal=pideal;
     
    40304281      if(setvec[j1]==1)
    40314282      {
    4032         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    4033       }
     4283        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     4284      }     
    40344285    }
    40354286    setring QUOTRING;
     
    40394290    //print(dimp);
    40404291    kill cutideal;
    4041     setring BASERING;
     4292    setring BASERING; 
    40424293    if (dimp==0) // if it is 0 as we want
    40434294    {
    40444295      // compute the t-initial of the associated prime
    4045       // - the last 1 just means that the variable t
     4296      // - the last 1 just means that the variable t 
    40464297      // is the last variable in the ring
    40474298      pini=tInitialIdeal(cutideal,wvec ,1);
    40484299      //print("initial");
    40494300      //print(pini);
    4050       // and if the initial w.r.t. t contains no monomial
     4301      // and if the initial w.r.t. t contains no monomial 
    40514302      // as we want (checked with
    40524303      // radical-membership of the product of all variables)
    4053       if (radicalMemberShip(product,pini)==0)
     4304      if (radicalMemberShip(product,pini)==0) 
    40544305      {
    40554306        // we want to replace the variables x_i by the forms -g_i in
     
    40624313            pideal=subst(pideal,var(j1),ergl[j1]);//substitute it
    40634314            pini=subst(pini,var(j1),erglini[j1]);
    4064           }
    4065         }
     4315          }   
     4316        }   
    40664317        // return pideal and the list ergl which tells us
    40674318        // which variables we replaced by which form
     
    40734324        export(ini);
    40744325        export(repl);
    4075         return(list(BASERINGLESS2,wvecp));
     4326        return(list(BASERINGLESS2,wvecp)); 
    40764327      }
    40774328    }
     
    40824333/////////////////////////////////////////////////////////////////////////
    40834334
    4084 static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,list #)
    4085 "USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list
    4086 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
    4087            tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in
    4088            the tropical variety of i, and ord is the order up to which a point
    4089            in V(i) over C((t)) lying over w shall be computed;
     4335static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,int puiseux,list #)
     4336"USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng,pu[,#]); i ideal, tw intvec, ord int, gf,ng,pu int, # opt. list
     4337ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 
     4338           tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in 
     4339           the tropical variety of i, and ord is the order up to which a point 
     4340           in V(i) over C((t)) lying over w shall be computed; 
    40904341         - moreover, k should be zero if the procedure is not called recursively;
    4091          - the point in the tropical variety is supposed to lie in the NEGATIVE
     4342         - the point in the tropical variety is supposed to lie in the NEGATIVE 
    40924343           orthant;
    4093          - the ideal is zero-dimensional when considered
     4344         - the ideal is zero-dimensional when considered 
    40944345           in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n],
    4095            where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k];
     4346           where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k]; 
    40964347         - gf is 0 if version 2.2 or larger is used and it is 1 else
    4097          - ng is 1 if gfan should not be executed
     4348         - ng is 1 if gfan should not be executed
     4349         - pu is 1 if n=1 and i is generated by one polynomial and newtonpoly is used to find a
     4350           point in the tropical variety instead of gfan
    40984351RETURN:  list, l[1] = ring Q(0,X_1,...,X_r)[[t]]
    40994352               l[2] = int
    41004353               l[3] = string
    41014354NOTE:    - the procedure is also called recursively by itself, and
    4102            if it is called in the first recursion, the list # is empty,
    4103            otherwise #[1] is an integer, one more than the number
     4355           if it is called in the first recursion, the list # is empty, 
     4356           otherwise #[1] is an integer, one more than the number 
    41044357           of true variables x_1,...,x_n,
    41054358           and #[2] will contain the maximal ideal m in the variables X_1,...X_k
     
    41074360           work correctly in K[t,x_1,...,x_n] where K=Q[X_1,...,X_k]/m is a field
    41084361           extension of Q;
    4109          - the ring l[1] contains an ideal PARA, which contains the
    4110            parametrisation of a point in V(i) lying over w up to the
     4362         - the ring l[1] contains an ideal PARA, which contains the 
     4363           parametrisation of a point in V(i) lying over w up to the 
    41114364           first ord terms;
    4112          - the string m=l[3] contains the code of the maximal ideal m,
    4113            by which we have to divide Q[X_1,...,X_r] in order to have
     4365         - the string m=l[3] contains the code of the maximal ideal m, 
     4366           by which we have to divide Q[X_1,...,X_r] in order to have 
    41144367           the appropriate field extension over which the parametrisation lives;
    4115          - and if the integer l[2] is N then t has to be replaced by t^1/N in
    4116            the parametrisation, or alternatively replace t by t^N in the
     4368         - and if the integer l[2] is N then t has to be replaced by t^1/N in 
     4369           the parametrisation, or alternatively replace t by t^N in the 
    41174370           defining ideal
    4118          - the procedure REQUIRES that the program GFAN is installed on
     4371         - the procedure REQUIRES that the program GFAN is installed on 
    41194372           your computer"
    41204373{
     
    41244377  if (size(#)==2) // this means the precedure has been called recursively
    41254378  {
    4126     // how many variables are true variables, and how many come
     4379    // how many variables are true variables, and how many come 
    41274380    // from the field extension
    41284381    // only true variables have to be transformed
     
    41304383    ideal gesamt_m=std(#[2]); // stores all maxideals used for field extensions
    41314384    // find the zeros of the w-initial ideal and transform the ideal i;
    4132     // findzeros and basictransformideal need to know how
     4385    // findzeros and basictransformideal need to know how 
    41334386    // many of the variables are true variables
    41344387    list m_ring=findzeros(i,ww,anzahlvariablen);
     
    41374390  else // the procedure has been called by tropicalLifting
    41384391  {
    4139     // how many variables are true variables, and how many come from
     4392    // how many variables are true variables, and how many come from 
    41404393    // the field extension only true variables have to be transformed
    41414394    int anzahlvariablen=nvars(basering);
     
    41444397    ideal ini=#[1];
    41454398    // find the zeros of the w-initial ideal and transform the ideal i;
    4146     // we should hand the t-initial ideal ine to findzeros,
     4399    // we should hand the t-initial ideal ine to findzeros, 
    41474400    // since we know it already
    41484401    list m_ring=findzeros(i,ww,ini);
     
    41664419    list a=btr[2];
    41674420    ideal m=btr[3];
    4168     gesamt_m=gesamt_m+m; // add the newly found maximal
     4421    gesamt_m=gesamt_m+m; // add the newly found maximal 
    41694422                         // ideal to the previous ones
    41704423  }
    41714424  // check if there is a solution which has the n-th component zero,
    4172   // if so, then eliminate the n-th variable from sat(i+x_n,t),
     4425  // if so, then eliminate the n-th variable from sat(i+x_n,t), 
    41734426  // otherwise leave i as it is;
    4174   // then check if the (remaining) ideal has as solution
     4427  // then check if the (remaining) ideal has as solution 
    41754428  // where the n-1st component is zero,
    41764429  // and procede as before; do the same for the remaining variables;
    4177   // this way we make sure that the remaining ideal has
     4430  // this way we make sure that the remaining ideal has 
    41784431  // a solution which has no component zero;
    41794432  intvec deletedvariables;    // the jth entry is set 1, if we eliminate x_j
    41804433  int numberdeletedvariables; // the number of eliminated variables
    41814434  ideal variablen;  // will contain the variables which are not eliminated
    4182   intvec tw=ww;     // in case some variables are deleted,
     4435  intvec tw=ww;     // in case some variables are deleted, 
    41834436                    // we have to store the old weight vector
    41844437  deletedvariables[anzahlvariablen]=0;
    4185   ideal I,LI;
     4438  ideal I,LI; 
    41864439  i=i+m; // if a field extension was necessary, then i has to be extended by m
    41874440  for (jj=anzahlvariablen-1;jj>=1;jj--)  // the variable t is the last one !!!
     
    41904443    LI=subst(I,var(nvars(basering)),0);
    41914444    //size(deletedvariables)=anzahlvariablen(before elim.)
    4192     for (kk=1;kk<=size(deletedvariables)-1;kk++)
     4445    for (kk=1;kk<=size(deletedvariables)-1;kk++) 
    41934446    {
    41944447      LI=subst(LI,var(kk),0);
    41954448    }
    4196     if (size(LI)==0) // if no power of t is in lead(I)
     4449    if (size(LI)==0) // if no power of t is in lead(I) 
    41974450    { // (where the X(i) are considered as field elements)
    4198       // get rid of var(jj)
     4451      // get rid of var(jj)   
    41994452      i=eliminate(I,var(jj));
    42004453      deletedvariables[jj]=1;
    4201       anzahlvariablen--; // if a variable is eliminated,
     4454      anzahlvariablen--; // if a variable is eliminated, 
    42024455                         // then the number of true variables drops
    42034456      numberdeletedvariables++;
     
    42094462  }
    42104463  variablen=invertorder(variablen);
    4211   // store also the additional variables and t,
     4464  // store also the additional variables and t, 
    42124465  // since they for sure have not been eliminated
    42134466  for (jj=anzahlvariablen+numberdeletedvariables-1;jj<=nvars(basering);jj++)
     
    42154468    variablen=variablen+var(jj);
    42164469  }
    4217   // if some variables have been eliminated,
     4470  // if some variables have been eliminated, 
    42184471  // then pass to a new ring which has less variables,
    42194472  // but if no variables are left, then we are done
    42204473  def BASERING=basering;
    4221   if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains,
     4474  if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains, 
    42224475  { // all true variables are gone
    42234476    execute("ring NEURING=("+charstr(basering)+"),("+string(variablen)+"),(dp("+string(size(variablen)-1)+"),lp(1));");
    42244477    ideal i=imap(BASERING,i);
    4225     ideal gesamt_m=imap(BASERING,gesamt_m);
    4226   }
    4227   // now we have to compute a point ww on the tropical variety
     4478    ideal gesamt_m=imap(BASERING,gesamt_m);   
     4479  }
     4480  // now we have to compute a point ww on the tropical variety 
    42284481  // of the transformed ideal i;
    4229   // of course, we only have to do so, if we have not yet
     4482  // of course, we only have to do so, if we have not yet 
    42304483  // reached the order up to which we
    42314484  // were supposed to do our computations
    4232   if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
     4485  if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 
    42334486  { // all true variables are gone
     4487    // else we have to use gfan
    42344488    def PREGFANRING=basering;
    42354489    if (nogfan!=1)
    4236     {
     4490    {     
    42374491      // pass to a ring which has variables which are suitable for gfan
    42384492      execute("ring GFANRING=("+charstr(basering)+"),(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),dp;");
    4239       ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
     4493      ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 
    42404494      phiideal[nvars(PREGFANRING)]=a; // map t to a
    4241       map phi=PREGFANRING,phiideal;
     4495      map phi=PREGFANRING,phiideal; 
    42424496      ideal i=phi(i);
    4243       // homogenise the ideal i with the first not yet
    4244       // used variable in our ring, since gfan
    4245       // only handles homogenous ideals; in principle
     4497      // homogenise the ideal i with the first not yet 
     4498      // used variable in our ring, since gfan 
     4499      // only handles homogenous ideals; in principle 
    42464500      // for this one has first to compute a
    4247       // standard basis of i and homogenise that,
    4248       // but for the tropical variety (says Anders)
     4501      // standard basis of i and homogenise that, 
     4502      // but for the tropical variety (says Anders) 
    42494503      // it suffices to homogenise an arbitrary system of generators
    4250       // i=groebner(i);
     4504      // i=groebner(i); 
    42514505      i=homog(i,maxideal(1)[nvars(PREGFANRING)+1]);
    42524506      // if gfan version >= 0.3.0 is used and the characteristic
     
    42604514        write(":a /tmp/gfaninput","{"+string(i)+"}");
    42614515      }
    4262       else
     4516      else 
    42634517      {
    42644518        // write the ideal to a file which gfan takes as input and call gfan
     
    42744528        else
    42754529        {
    4276 //      system("sh","gfan_tropicalstartingcone < /tmp/gfaninput > /tmp/gfantropstcone");
    4277 //      system("sh","gfan_tropicaltraverse < /tmp/gfantropstcone > /tmp/gfanoutput");
     4530//          system("sh","gfan_tropicalstartingcone < /tmp/gfaninput > /tmp/gfantropstcone");
     4531//          system("sh","gfan_tropicaltraverse < /tmp/gfantropstcone > /tmp/gfanoutput");
    42784532          system("sh","gfan_tropicalbasis < /tmp/gfaninput > /tmp/gfanbasis");
    42794533          system("sh","gfan_tropicalintersection < /tmp/gfanbasis > /tmp/gfanoutput");
     
    42814535        string trop=read("/tmp/gfanoutput");
    42824536        setring PREGFANRING;
    4283         intvec wneu=-1;    // this integer vector will store
     4537        intvec wneu=-1;    // this integer vector will store 
    42844538                           // the point on the tropical variety
    42854539        wneu[nvars(basering)]=0;
     
    42944548        "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    42954549        ~
    4296           // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE
    4297           // TROPICAL PREVARIETY
    4298           // test, if wneu really is in the tropical variety
     4550        // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE
     4551        // TROPICAL PREVARIETY
     4552        // test, if wneu really is in the tropical variety   
    42994553        while (goon==0)
    43004554        {
     
    43034557            "CHOOSE A DIFFERENT RAY";
    43044558            ~
    4305               }
     4559          }
    43064560          else
    43074561          {
     
    43134567      {
    43144568        system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    4315         // read the result from gfan and store it to a string,
     4569        // read the result from gfan and store it to a string, 
    43164570        // which in a later version
    43174571        // should be interpreded by Singular
     
    43224576    else // if gfan is NOT executed
    43234577    {
    4324       "Set intvec wneu!";
    4325       ~
    4326     }
    4327   }
    4328   // if we have not yet computed our parametrisation
     4578      // if puiseux is set, then we are in the case of a plane curve and can use the command newtonpoly
     4579      if (puiseux==1)
     4580      {
     4581        list NewtP=newtonpoly(i[1]);
     4582        wneu=NewtP[1]-NewtP[2];
     4583        int ggteiler=gcd(wneu[1],wneu[2]);
     4584        wneu[1]=-wneu[1]/ggteiler;
     4585        wneu[2]=wneu[2]/ggteiler;
     4586        if (wneu[1]>0)
     4587        {
     4588          wneu=-wneu;
     4589        }
     4590        kill NewtP,ggteiler;
     4591      }
     4592      else // set wneu by hand
     4593      {
     4594        "Set intvec wneu!";
     4595        ~
     4596      }
     4597    }   
     4598  }
     4599  // if we have not yet computed our parametrisation
    43294600  // up to the required order and
    4330   // zero is not yet a solution, then we have
     4601  // zero is not yet a solution, then we have 
    43314602  // to go on by calling the procedure recursively;
    43324603  // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    43334604  if ((ordnung>1) and (anzahlvariablen>1))
    4334   {
    4335     // we call the procedure with the transformed ideal i,
     4605  {   
     4606    // we call the procedure with the transformed ideal i, 
    43364607    // the new weight vector, with the
    4337     // required order lowered by one, and with
     4608    // required order lowered by one, and with 
    43384609    // additional parameters, namely the number of
    4339     // true variables and the maximal ideal that
     4610    // true variables and the maximal ideal that 
    43404611    // was computed so far to describe the field extension
    4341     list PARALIST=tropicalparametriseNoabs(i,wneu,ordnung-1,gfanold,nogfan,anzahlvariablen,gesamt_m);
    4342     // the output will be a ring, in which the
     4612    list PARALIST=tropicalparametriseNoabs(i,wneu,ordnung-1,gfanold,nogfan,puiseux,anzahlvariablen,gesamt_m);
     4613    // the output will be a ring, in which the 
    43434614    // parametrisation lives, and a string, which contains
    43444615    // the maximal ideal that describes the necessary field extension
     
    43474618    string PARAm=PARALIST[3];
    43484619    setring PARARing;
    4349     // if some variables have been eliminated in before,
    4350     // then we have to insert zeros
     4620    // if some variables have been eliminated in before, 
     4621    // then we have to insert zeros 
    43514622    // into the parametrisation for those variables
    43524623    if (numberdeletedvariables>0)
     
    43544625      ideal PARAneu=PARA;
    43554626      int k;
    4356       for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits
     4627      for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits 
    43574628      { // no parametrisation
    43584629        if (deletedvariables[jj]!=1)
     
    43684639    }
    43694640  }
    4370   // otherwise we are done and we can start to compute
     4641  // otherwise we are done and we can start to compute 
    43714642  // the last step of the parametrisation
    43724643  else
     
    43744645    // we store the information on m in a string
    43754646    string PARAm=string(gesamt_m);
    4376     // we define the weight of t, i.e. in the parametrisation t
     4647    // we define the weight of t, i.e. in the parametrisation t 
    43774648    // has to be replaced by t^1/tweight
    43784649    int tweight=-tw[1];
    4379     // if additional variables were necessary,
     4650    // if additional variables were necessary, 
    43804651    // we introduce them now as parameters;
    4381     // in any case the parametrisation ring will
    4382     // have only one variable, namely t,
    4383     // and its order will be local, so that it
     4652    // in any case the parametrisation ring will 
     4653    // have only one variable, namely t, 
     4654    // and its order will be local, so that it 
    43844655    // displays the lowest term in t first
    43854656    if (anzahlvariablen+numberdeletedvariables<nvars(basering))
     
    43924663    }
    43934664    ideal PARA; // will contain the parametrisation
    4394     // we start by initialising the entries to be zero;
     4665    // we start by initialising the entries to be zero; 
    43954666    // one entry for each true variable
    4396     // here we also have to consider the variables
     4667    // here we also have to consider the variables 
    43974668    // that we have eliminated in before
    43984669    for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++)
     
    44014672    }
    44024673  }
    4403   // we now have to change the parametrisation by
     4674  // we now have to change the parametrisation by 
    44044675  // reverting the transformations that we have done
    44054676  list a=imap(BASERING,a);
    4406   if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the
    4407   { // last time, it does not enter the part, where wneu is defined and the
     4677  if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the 
     4678  { // last time, it does not enter the part, where wneu is defined and the 
    44084679    intvec wneu=-1;     // variable t should have weight -1
    44094680  }
     
    44124683    PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight/ww[1]);
    44134684  }
    4414   // if we have reached the stop-level, i.e. either
     4685  // if we have reached the stop-level, i.e. either 
    44154686  // we had only to compute up to order 1
    4416   // or zero was a solution of the ideal, then we have
     4687  // or zero was a solution of the ideal, then we have 
    44174688  // to export the computed parametrisation
    44184689  // otherwise it has already been exported before
    44194690  // note, if all variables were deleted, then i==0 and thus testaufnull==0
    44204691  if ((ordnung==1) or (anzahlvariablen==1))
    4421   {
     4692  {   
    44224693    export(PARA);
    44234694  }
    44244695  // kill the gfan files in /tmp
    4425   system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput");
    4426   // we return a list which contains the
     4696  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
     4697  // we return a list which contains the 
    44274698  // parametrisation ring (with the parametrisation ideal)
    4428   // and the string representing the maximal ideal
     4699  // and the string representing the maximal ideal 
    44294700  // describing the necessary field extension
    44304701  return(list(PARARing,tweight,PARAm));
     
    44354706static proc findzeros (ideal i,intvec w,list #)
    44364707"USAGE:      findzeros(i,w[,#]); i ideal, w intvec, # an optional list
    4437 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and
     4708ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and 
    44384709             w=(w_0,...,w_n,0,...,0) is in the tropical variety of i
    4439 RETURN:      list, l[1] = is polynomial ring containing an associated maximal
    4440                           ideal m of the w-initial ideal of i which does not
     4710RETURN:      list, l[1] = is polynomial ring containing an associated maximal 
     4711                          ideal m of the w-initial ideal of i which does not 
    44414712                          contain any monomial and where the variables
    4442                           which do not lead to a field extension have already
    4443                           been eliminated, and containing a list a such that
    4444                           the non-zero entries of a correspond to the values
     4713                          which do not lead to a field extension have already 
     4714                          been eliminated, and containing a list a such that 
     4715                          the non-zero entries of a correspond to the values 
    44454716                          of the zero of the associated maximal ideal for the
    44464717                          eliminated variables
    44474718                   l[2] = number of variables which have not been eliminated
    4448                    l[3] = intvec, if the entry is one then the corresponding
     4719                   l[3] = intvec, if the entry is one then the corresponding 
    44494720                                  variable has not been eliminated
    4450 NOTE:        the procedure is called from inside the recursive procedure
     4721NOTE:        the procedure is called from inside the recursive procedure 
    44514722             tropicalparametriseNoabs;
    4452              if it is called in the first recursion, the list #[1] contains
    4453              the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
     4723             if it is called in the first recursion, the list #[1] contains 
     4724             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 
    44544725             one more than the number of true variables x_1,...,x_n"
    44554726{
    4456   def BASERING=basering;
     4727  def BASERING=basering; 
    44574728  // set anzahlvariablen to the number of true variables
    44584729  if (typeof(#[1])=="int")
     
    44604731    int anzahlvariablen=#[1];
    44614732    // compute the initial ideal of i
    4462     // - the last 1 just means that the variable t is the last
     4733    // - the last 1 just means that the variable t is the last 
    44634734    //   variable in the ring
    44644735    ideal ini=tInitialIdeal(i,w,1);
     
    44674738  {
    44684739    int anzahlvariablen=nvars(basering);
    4469     ideal ini=#[1]; // the t-initial ideal has been computed
     4740    ideal ini=#[1]; // the t-initial ideal has been computed 
    44704741                    // in before and was handed over
    44714742  }
    4472   // move to a polynomial ring with global monomial ordering
     4743  // move to a polynomial ring with global monomial ordering 
    44734744  // - the variable t is superflous
    44744745  ideal variablen;
    44754746  for (int j=1;j<=nvars(basering)-1;j++)
    4476   {
     4747  {   
    44774748    variablen=variablen+var(j);
    44784749  }
     
    44804751  ideal ini=imap(BASERING,ini);
    44814752  // compute the associated primes of the initialideal
    4482   // ordering the maximal ideals shall help to avoid
     4753  // ordering the maximal ideals shall help to avoid 
    44834754  // unneccessary field extensions
    44844755  list maximalideals=ordermaximalidealsNoabs(minAssGTZ(std(ini)),anzahlvariablen);
    44854756  ideal m=maximalideals[1][1];              // the first associated maximal ideal
    44864757  int neuvar=maximalideals[1][2];           // the number of new variables needed
    4487   intvec neuevariablen=maximalideals[1][3]; // the information which variable
     4758  intvec neuevariablen=maximalideals[1][3]; // the information which variable 
    44884759                                            // leads to a new one
    4489   list a=maximalideals[1][4];               // a_k is the kth component of a
     4760  list a=maximalideals[1][4];               // a_k is the kth component of a 
    44904761                                            // zero of m, if it is not zero
    4491   // eliminate from m the superflous variables, that is those ones,
     4762  // eliminate from m the superflous variables, that is those ones, 
    44924763  // which do not lead to a new variable
    44934764  poly elimvars=1;
     
    44994770    }
    45004771  }
    4501   m=eliminate(m,elimvars);
    4502   export(a);
     4772  m=eliminate(m,elimvars); 
     4773  export(a); 
    45034774  export(m);
    45044775  list m_ring=INITIALRING,neuvar,neuevariablen;
     
    45124783static proc basictransformideal (ideal i,intvec w,list m_ring,list #)
    45134784"USAGE:  basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list
    4514 ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
    4515          w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and
     4785ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], 
     4786         w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and 
    45164787         m_ring contains a ring containing a maximal ideal m needed
    4517          to describe the field extension over which a corresponding
    4518          associated maximal ideal of the initialideal of i, considered
    4519          in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and
     4788         to describe the field extension over which a corresponding 
     4789         associated maximal ideal of the initialideal of i, considered 
     4790         in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and 
    45204791         containing a list a describing the zero of m, and m_ring contains
    45214792         the information how many new variables are needed for m
     
    45244795                      l[3] = ideal, the maximal ideal m
    45254796               or l[1] = ring which contains the ideals i and m, and the list a
    4526 NOTE:    the procedure is called from inside the recursive procedure
     4797NOTE:    the procedure is called from inside the recursive procedure 
    45274798         tropicalparametriseNoabs;
    4528          if it is called in the first recursion, the list # is empty,
     4799         if it is called in the first recursion, the list # is empty, 
    45294800         otherwise #[1] is an integer, the number of true variables x_1,...,x_n;
    4530          during the procedure we check if a field extension is necessary
    4531          to express a zero (a_1,...,a_n) of m; if so, we have to introduce
    4532          new variables and a list containing a ring is returned, otherwise
    4533          the list containing i, a and m is returned;
    4534          the ideal m will be changed during the procedure since all variables
     4801         during the procedure we check if a field extension is necessary 
     4802         to express a zero (a_1,...,a_n) of m; if so, we have to introduce 
     4803         new variables and a list containing a ring is returned, otherwise 
     4804         the list containing i, a and m is returned; 
     4805         the ideal m will be changed during the procedure since all variables 
    45354806         which reduce to a polynomial in X_1,...,X_k modulo m will be eliminated,
    45364807         while the others are replaced by new variables X_k+1,...,X_k'"
     
    45444815    wdegs[j]=deg(i[j],intvec(w[2..size(w)],w[1]));
    45454816  }
    4546   // how many variables are true variables,
     4817  // how many variables are true variables, 
    45474818  // and how many come from the field extension
    45484819  // only real variables have to be transformed
     
    45594830  // get the information if any new variables are needed from m_ring
    45604831  int neuvar=m_ring[2];  // number of variables which have to be added
    4561   intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp.
     4832  intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp. 
    45624833                                   // of a zero of m a new variable is needed
    45634834  def MRING=m_ring[1];   // MRING contains a and m
    4564   list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be
     4835  list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be 
    45654836                         // a common zero of the ideal m
    4566   ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0,
     4837  ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0, 
    45674838                              // otherwise we change the ring anyway
    4568   // if a field extension is needed, then extend the polynomial
     4839  // if a field extension is needed, then extend the polynomial 
    45694840  // ring by new variables X_k+1,...,X_k';
    45704841  if (neuvar>0)
    45714842  {
    4572     // change to a ring where for each variable needed
     4843    // change to a ring where for each variable needed 
    45734844    // in m a new variable has been introduced
    45744845    ideal variablen;
     
    45814852    // map i into the new ring
    45824853    ideal i=imap(BASERING,i);
    4583     // define a map phi which maps the true variables, which are not
     4854    // define a map phi which maps the true variables, which are not 
    45844855    // reduced to polynomials in the additional variables modulo m, to
    4585     // the corresponding newly introduced variables, and which maps
     4856    // the corresponding newly introduced variables, and which maps 
    45864857    // the old additional variables to themselves
    45874858    ideal phiideal;
    45884859    k=1;
    4589     for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the
     4860    for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the 
    45904861    { // first entry corresponds to t
    45914862      if(neuevariablen[j]==1)
     
    45964867      else
    45974868      {
    4598         phiideal[j-1]=0;
     4869        phiideal[j-1]=0; 
    45994870      }
    46004871    }
     
    46034874      phiideal=phiideal,X(1..nvars(BASERING)-anzahlvariablen);
    46044875    }
    4605     map phi=MRING,phiideal;
    4606     // map m and a to the new ring via phi, so that the true variables
     4876    map phi=MRING,phiideal; 
     4877    // map m and a to the new ring via phi, so that the true variables 
    46074878    // in m and a are replaced by
    46084879    // the corresponding newly introduced variables
     
    46104881    list a=phi(a);
    46114882  }
    4612   // replace now the zeros among the a_j by the corresponding
     4883  // replace now the zeros among the a_j by the corresponding 
    46134884  // newly introduced variables;
    4614   // note that no component of a can be zero
     4885  // note that no component of a can be zero 
    46154886  // since the maximal ideal m contains no variable!
    4616   // moreover, substitute right away in the ideal i
     4887  // moreover, substitute right away in the ideal i 
    46174888  // the true variable x_j by (a_j+x_j)*t^w_j
    46184889  zaehler=nvars(BASERING)-anzahlvariablen+1;
    4619   for (j=1;j<=anzahlvariablen;j++)
     4890  for (j=1;j<=anzahlvariablen;j++) 
    46204891  {
    46214892    if ((a[j]==0) and (j!=1))  // a[1]=0, since t->t^w_0
    4622     {
     4893    {       
    46234894      a[j]=X(zaehler);
    46244895      zaehler++;
     
    46274898    {
    46284899      if (j!=1) // corresponds to  x_(j-1) --  note t is the last variable
    4629       {
     4900      {       
    46304901        i[k]=substitute(i[k],var(j-1),(a[j]+var(j-1))*t^(-w[j]));
    46314902      }
     
    46394910  for (j=1;j<=ncols(i);j++)
    46404911  {
    4641     if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and
     4912    if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and 
    46424913    { // we made sure that it is no positive
    46434914      i[j]=i[j]/t^(-wdegs[j]);
    46444915    }
    46454916  }
    4646   // since we want to consider i now in the ring
     4917  // since we want to consider i now in the ring 
    46474918  // (Q[X_1,...,X_k']/m)[t,x_1,...,x_n]
    4648   // we can  reduce i modulo m, so that "constant terms"
     4919  // we can  reduce i modulo m, so that "constant terms" 
    46494920  // which are "zero" since they
    46504921  // are in m will disappear; simplify(...,2) then really removes them
    46514922  i=simplify(reduce(i,m),2);
    4652   // if new variables have been introduced, we have
     4923  // if new variables have been introduced, we have 
    46534924  // to return the ring containing i, a and m
    46544925  // otherwise we can simply return a list containing i, a and m
     
    46714942static proc testw (ideal i,intvec w,int anzahlvariablen,list #)
    46724943"USAGE:      testw(i,w,n); i ideal, w intvec, n number
    4673 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and
    4674              w=(w_0,...,w_n,0,...,0)
    4675 RETURN:      int b, 0 if the t-initial ideal of i considered in
     4944ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and 
     4945             w=(w_0,...,w_n,0,...,0)           
     4946RETURN:      int b, 0 if the t-initial ideal of i considered in 
    46764947                    Q(X_1,...,X_k)[t,x_1,...,x_n] is monomial free, 1 else
    46774948NOTE:        the procedure is called by tinitialform"
     
    46874958    ideal tin=tInitialIdeal(i,w,1);
    46884959  }
    4689 
     4960 
    46904961  int j;
    46914962  ideal variablen;
     
    47194990  def BASERING=basering;
    47204991  if (anzahlvariablen<nvars(basering))
    4721   {
     4992  {   
    47224993    execute("ring TINRING=("+charstr(basering)+","+string(Parameter)+"),("+string(variablen)+"),dp;");
    47234994  }
     
    47295000  poly monom=imap(BASERING,monom);
    47305001  return(radicalMemberShip(monom,tin));
    4731 }
     5002} 
    47325003
    47335004/////////////////////////////////////////////////////////////////////////
     
    47355006static proc simplifyToOrder (poly f)
    47365007"USAGE:      simplifyToOrder(f); f a polynomial
    4737 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
     5008ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] 
    47385009RETURN:      list, l[1] = t-order of leading term of f
    47395010                   l[2] = the rational coefficient of the term of lowest t-order
     
    47585029static proc scalarproduct (intvec w,intvec v)
    47595030"USAGE:      scalarproduct(w,v); w,v intvec
    4760 ASSUME:      w and v are integer vectors of the same length
     5031ASSUME:      w and v are integer vectors of the same length 
    47615032RETURN:      int, the scalarproduct of v and w
    47625033NOTE:        the procedure is called by tropicalparametriseNoabs"
     
    48165087"USAGE:      ordermaximalidealsNoabs(minassi); minassi list
    48175088ASSUME:      minassi is a list of maximal ideals
    4818 RETURN:      list, the procedure orders the maximal ideals in minassi according
    4819                    to how many new variables are needed to describe the zeros
     5089RETURN:      list, the procedure orders the maximal ideals in minassi according 
     5090                   to how many new variables are needed to describe the zeros 
    48205091                   of the ideal
    48215092                   l[j][1] = jth maximal ideal
    48225093                   l[j][2] = the number of variables needed
    4823                    l[j][3] = intvec, if for the kth variable a new variable is
    4824                                      needed to define the corresponding zero of
     5094                   l[j][3] = intvec, if for the kth variable a new variable is 
     5095                                     needed to define the corresponding zero of 
    48255096                                     l[j][1], then the k+1st entry is one
    4826                    l[j][4] = list, if for the kth variable no new variable is
    4827                                    needed to define the corresponding zero of
     5097                   l[j][4] = list, if for the kth variable no new variable is 
     5098                                   needed to define the corresponding zero of 
    48285099                                   l[j][1], then its value is the k+1st entry
    48295100NOTE:        if a maximal ideal contains a variable, it is removed from the list;
     
    48345105  int pruefer;       // is set one if a maximal ideal contains a variable
    48355106  list minassisort;  // will contain the output
    4836   for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort
     5107  for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort 
    48375108                                                    // to fix its initial length
    48385109  list zwischen;     // needed for reordering
    48395110  list a;// (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m
    48405111  poly nf;           // normalform of a variable w.r.t. m
    4841   intvec neuevariablen; // ith entry is 1, if for the ith component of a zero
     5112  intvec neuevariablen; // ith entry is 1, if for the ith component of a zero 
    48425113                        // of m a new variable is needed
    48435114  intvec testvariablen; // integer vector of length n=number of variables
    4844   // compute for each maximal ideal the number of new variables,
     5115  // compute for each maximal ideal the number of new variables, 
    48455116  // which are needed to describe
    4846   // its zeros -- note, a new variable is needed if modulo
    4847   // the maximal ideal it does not reduce
     5117  // its zeros -- note, a new variable is needed if modulo 
     5118  // the maximal ideal it does not reduce 
    48485119  // to something which only depends on the following variables;
    4849   // if no new variable is needed, then store the value
    4850   // a variable reduces to in the list a;
     5120  // if no new variable is needed, then store the value 
     5121  // a variable reduces to in the list a; 
    48515122  for (j=size(minassi);j>=1;j--)
    48525123  {
    4853     a[1]=poly(0);         // the first entry in a and in neuevariablen
     5124    a[1]=poly(0);         // the first entry in a and in neuevariablen 
    48545125                          // corresponds to the variable t,
    48555126    neuevariablen[1]=0;   // which is not present in the INITIALRING
     
    48595130    {
    48605131      nf=reduce(var(k),minassi[j]);
    4861       // if a variable reduces to zero, then the maximal ideal
     5132      // if a variable reduces to zero, then the maximal ideal 
    48625133      // contains a variable and we can delete it
    48635134      if (nf==0)
     
    48655136        pruefer=1;
    48665137      }
    4867       // set the entries of testvariablen corresponding to the first
     5138      // set the entries of testvariablen corresponding to the first 
    48685139      // k variables to 1, and the others to 0
    48695140      for (l=1;l<=nvars(basering);l++)
    48705141      {
    48715142        if (l<=k)
    4872         {
     5143        {         
    48735144          testvariablen[l]=1;
    48745145        }
     
    48785149        }
    48795150      }
    4880       // if the variable x_j reduces to a polynomial
     5151      // if the variable x_j reduces to a polynomial 
    48815152      // in x_j+1,...,x_n,X_1,...,X_k modulo m
    4882       // then we can eliminate x_j from the maximal ideal
     5153      // then we can eliminate x_j from the maximal ideal 
    48835154      // (since we do not need any
    4884       // further field extension to express a_j) and a_j
     5155      // further field extension to express a_j) and a_j 
    48855156      // will just be this normalform,
    48865157      // otherwise we have to introduce a new variable in order to express a_j;
     
    48895160        a[k+1]=nf; // a_k is the normal form of the kth variable modulo m
    48905161        neuevariablen[k+1]=0;  // no new variable is needed
    4891       }
     5162      }   
    48925163      else
    48935164      {
    4894         a[k+1]=poly(0); // a_k is set to zero until we have
     5165        a[k+1]=poly(0); // a_k is set to zero until we have 
    48955166                        // introduced the new variable
    48965167        neuevariablen[k+1]=1;
     
    49005171    // if the maximal ideal contains a variable, we simply delete it
    49015172    if (pruefer==0)
    4902     {
     5173    {     
    49035174      minassisort[j]=list(minassi[j],neuvar,neuevariablen,a);
    49045175    }
    4905     // otherwise we store the information on a,
     5176    // otherwise we store the information on a, 
    49065177    // neuevariablen and neuvar together with the ideal
    49075178    else
     
    49125183    }
    49135184  }
    4914   // sort the maximal ideals ascendingly according to
     5185  // sort the maximal ideals ascendingly according to 
    49155186  // the number of new variables needed to
    49165187  // express the zero of the maximal ideal
     
    49195190    l=j;
    49205191    for (k=j-1;k>=1;k--)
    4921     {
     5192    {     
    49225193      if (minassisort[l][2]<minassisort[k][2])
    49235194      {
     
    49375208"USAGE:  displaypoly(p,N,wj,w1); p poly, N, wj, w1 int
    49385209ASSUME:  p is a polynomial in r=(0,X(1..k)),t,ls
    4939 RETURN:  string, the string of t^-wj/w1*p(t^1/N)
     5210RETURN:  string, the string of t^-wj/w1*p(t^1/N) 
    49405211NOTE:    the procedure is called from displayTropicalLifting"
    49415212{
     
    49555226  {
    49565227    if (koeffizienten[j-ord(p)+1]!=0)
    4957     {
     5228    {     
    49585229      if ((j-(N*wj)/w1)==0)
    49595230      {
     
    50055276static proc displaycoef (poly p)
    50065277"USAGE:      displaycoef(p); p poly
    5007 RETURN:      string, the string of p where brackets around
     5278RETURN:      string, the string of p where brackets around 
    50085279                     have been added if they were missing
    50095280NOTE:        the procedure is called from displaypoly"
     
    50775348static proc tropicalliftingresubstitute (ideal i,list liftring,int N,list #)
    50785349"USAGE:   tropicalliftingresubstitute(i,L,N[,#]); i ideal, L list, N int, # string
    5079 ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a
    5080           point in the tropical variety of i computed with tropicalLifting;
    5081           t has to be replaced by t^1/N in the lifting; #[1]=m is the string
    5082           of the maximal ideal defining the necessary field extension as
     5350ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a 
     5351          point in the tropical variety of i computed with tropicalLifting; 
     5352          t has to be replaced by t^1/N in the lifting; #[1]=m is the string 
     5353          of the maximal ideal defining the necessary field extension as 
    50835354          computed by tropicalLifting, if #[1] is present
    50845355RETURN:   string, the lifting has been substituted into i
     
    51035374      ideal i=imap(BASERING,i);
    51045375    }
    5105   }
     5376  } 
    51065377  else
    51075378  {
     
    51165387  }
    51175388  // map the resulting i back to LIFTRing;
    5118   // if noAbs, then reduce i modulo the maximal ideal
     5389  // if noAbs, then reduce i modulo the maximal ideal 
    51195390  // before going back to LIFTRing
    51205391  if ((size(parstr(LIFTRing))!=0) and size(#)>0)
     
    51335404  for (j=1;j<=ncols(i);j++)
    51345405  {
    5135     SUBSTTEST[j]=displaypoly(i[j],N,0,1);
     5406    SUBSTTEST[j]=displaypoly(i[j],N,0,1); 
    51365407  }
    51375408  return(SUBSTTEST);
     
    51435414/// - eliminatecomponents
    51445415/// - findzerosAndBasictransform
    5145 /// - ordermaximalideals
     5416/// - ordermaximalideals 
    51465417///////////////////////////////////////////////////////////////////////////////
    51475418
    5148 static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,list #)
    5149 "USAGE:  tropicalparametrise(i,tw,ord,gf,fa,ng[,#]); i ideal, tw intvec, ord int, gf,fa,ng int, # opt. list
    5150 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0)
    5151            and (w_0,...,w_n,0) is in the tropical variety of i,
    5152            and ord is the order up to which a point in V(i)
    5153            over K{{t}} lying over w shall be computed;
    5154          - moreover, @a should be not be there if the procedure is not
     5419static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,int puiseux,list #)
     5420"USAGE:  tropicalparametrise(i,tw,ord,gf,fa,ng,pu[,#]); i ideal, tw intvec, ord int, gf,fa,ng,pu int, # opt. list
     5421ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0) 
     5422           and (w_0,...,w_n,0) is in the tropical variety of i, 
     5423           and ord is the order up to which a point in V(i) 
     5424           over K{{t}} lying over w shall be computed; 
     5425         - moreover, @a should be not be there if the procedure is not 
    51555426           called recursively;
    51565427         - the point in the tropical variety is supposed to lie in the
    51575428           NEGATIVE orthant;
    5158          - the ideal is zero-dimensional when considered in
    5159            (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a];
     5429         - the ideal is zero-dimensional when considered in 
     5430           (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a]; 
    51605431         - gf is 0 if version 2.2 or larger is used and it is 1 else
    51615432         - fa is 1 if all solutions should be found
    51625433         - ng is 1 if gfan should not be executed
     5434         - pu is 1 if n=1 and i is generated by one polynomial and newtonpoly is used to find a
     5435           point in the tropical variety instead of gfan
    51635436RETURN:  list, l[1] = ring K[@a]/m[[t]]
    51645437               l[2] = int
    51655438NOTE:    - the procedure is also called recursively by itself, and
    5166            if it is called in the first recursion, the list # is empty,
    5167            otherwise #[1] is an integer, one more than the number of
    5168            true variables x_1,...,x_n, and #[2] will contain the maximal
    5169            ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a]
    5170            should be divided to work correctly in L[t,x_1,...,x_n] where
     5439           if it is called in the first recursion, the list # is empty, 
     5440           otherwise #[1] is an integer, one more than the number of 
     5441           true variables x_1,...,x_n, and #[2] will contain the maximal 
     5442           ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a] 
     5443           should be divided to work correctly in L[t,x_1,...,x_n] where 
    51715444           L=Q[@a]/m is a field extension of K
    5172          - the ring l[1] contains an ideal PARA, which contains the
    5173            parametrisation of a point in V(i) lying over w up to the first
     5445         - the ring l[1] contains an ideal PARA, which contains the 
     5446           parametrisation of a point in V(i) lying over w up to the first 
    51745447           ord terms;
    5175          - the string m contains the code of the maximal ideal m, by which we
     5448         - the string m contains the code of the maximal ideal m, by which we 
    51765449           have to divide K[@a] in order to have the appropriate field extension
    51775450           over which the parametrisation lives;
    51785451         - and if the integer l[3] is N then t has to be replaced by t^1/N in the
    5179            parametrisation, or alternatively replace t by t^N in the defining
     5452           parametrisation, or alternatively replace t by t^N in the defining 
    51805453           ideal
    5181          - the procedure REQUIRES that the program GFAN is installed
     5454         - the procedure REQUIRES that the program GFAN is installed 
    51825455           on your computer"
    51835456{
     
    51855458  int recursively; // is set 1 if the procedure is called recursively by itself
    51865459  int ii,jj,kk,ll,jjj,kkk,lll;
    5187   if (typeof(#[1])=="int") // this means the precedure has been
     5460  if (typeof(#[1])=="int") // this means the precedure has been 
    51885461  { // called recursively
    5189     // how many variables are true variables, and how many come
     5462    // how many variables are true variables, and how many come 
    51905463    // from the field extension
    51915464    // only true variables have to be transformed
    51925465    int anzahlvariablen=#[1];
    51935466    // find the zeros of the w-initial ideal and transform the ideal i;
    5194     // findzeros and basictransformideal need to know
     5467    // findzeros and basictransformideal need to know 
    51955468    // how many of the variables are true variables
    51965469    // and do the basic transformation as well
     
    52005473  else // the procedure has been called by tropicalLifting
    52015474  {
    5202     // how many variables are true variables, and
     5475    // how many variables are true variables, and 
    52035476    // how many come from the field extension
    52045477    // only true variables have to be transformed
    52055478    int anzahlvariablen=nvars(basering);
    5206     list zerolist; // will carry the zeros which are
    5207     //computed in the recursion steps
     5479    list zerolist; // will carry the zeros which are 
     5480    //computed in the recursion steps   
    52085481    // the initial ideal of i has been handed over as #[1]
    52095482    ideal ini=#[1];
    52105483    // find the zeros of the w-initial ideal and transform the ideal i;
    5211     // we should hand the t-initial ideal ine to findzeros,
     5484    // we should hand the t-initial ideal ine to findzeros, 
    52125485    // since we know it already;
    52135486    // and do the basic transformation as well
     
    52155488  }
    52165489  list wneulist; // carries all newly computed weight vector
    5217   intvec wneu;   // carries the newly computed weight vector
     5490  intvec wneu;   // carries the newly computed weight vector 
    52185491  int tweight;   // carries the weight of t
    5219   list PARALIST; // carries the result when tropicalparametrise
     5492  list PARALIST; // carries the result when tropicalparametrise 
    52205493                 // is recursively called
    52215494  list eliminaterings;     // carries the result of eliminatecomponents
     
    52265499  list liftings,partliftings;  // the computed liftings (all resp. partly)
    52275500  // consider each ring which has been returned when computing the zeros of the
    5228   // the t-initial ideal, equivalently, consider
     5501  // the t-initial ideal, equivalently, consider 
    52295502  // each zero which has been returned
    52305503  for (jj=1;jj<=size(trring);jj++)
     
    52325505    def TRRING=trring[jj];
    52335506    setring TRRING;
    5234     // check if a certain number of components lead to suitable
     5507    // check if a certain number of components lead to suitable 
    52355508    // solutions with zero components;
    52365509    // compute them all if findall==1
    52375510    eliminaterings=eliminatecomponents(i,m,oldanzahlvariablen,findall,oldanzahlvariablen-1,deletedvariables);
    5238     // consider each of the rings returned by eliminaterings ...
     5511    // consider each of the rings returned by eliminaterings ... 
    52395512    // there is at least one !!!
    52405513    for (ii=1;ii<=size(eliminaterings);ii++)
    52415514    {
    52425515      // #variables which have been eliminated
    5243       numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2];
     5516      numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2]; 
    52445517      // #true variables which remain (including t)
    5245       anzahlvariablen=eliminaterings[ii][2];
     5518      anzahlvariablen=eliminaterings[ii][2]; 
    52465519      // a 1 in this vector says that variable was eliminated
    5247       deletedvariables=eliminaterings[ii][3];
     5520      deletedvariables=eliminaterings[ii][3]; 
    52485521      setring TRRING; // set TRRING - this is important for the loop
    52495522      // pass the ring computed by eliminatecomponents
    5250       def PREGFANRING=eliminaterings[ii][1];
     5523      def PREGFANRING=eliminaterings[ii][1]; 
    52515524      setring PREGFANRING;
    52525525      poly m=imap(TRRING,m);        // map the maximal ideal to this ring
    52535526      list zero=imap(TRRING,zero);  // map the vector of zeros to this ring
    5254       // now we have to compute a point ww on the tropical
     5527      // now we have to compute a point ww on the tropical 
    52555528      // variety of the transformed ideal i;
    5256       // of course, we only have to do so, if we have
     5529      // of course, we only have to do so, if we have 
    52575530      // not yet reached the order up to which we
    52585531      // were supposed to do our computations
    5259       if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
     5532      if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, 
    52605533      { // all true variables are gone
    52615534        if (nogfan!=1)
    5262         {
     5535        {         
    52635536          // pass to a ring which has variables which are suitable for gfan
    52645537          execute("ring GFANRING=("+string(char(basering))+"),(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),dp;");
    5265           ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
     5538          ideal phiideal=b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; 
    52665539          phiideal[nvars(PREGFANRING)]=a; // map t to a
    5267           map phi=PREGFANRING,phiideal;
     5540          map phi=PREGFANRING,phiideal; 
    52685541          ideal II=phi(i);
    5269           // homogenise the ideal II with the first not yet
    5270           // used variable in our ring, since gfan
    5271           // only handles homogenous ideals; in principle for this
     5542          // homogenise the ideal II with the first not yet 
     5543          // used variable in our ring, since gfan 
     5544          // only handles homogenous ideals; in principle for this 
    52725545          // one has first to compute a
    5273           // standard basis of II and homogenise that,
    5274           // but for the tropical variety (says Anders)
     5546          // standard basis of II and homogenise that, 
     5547          // but for the tropical variety (says Anders) 
    52755548          // it suffices to homogenise an arbitrary system of generators
    5276           // II=groebner(II);
     5549          // II=groebner(II); 
    52775550          II=homog(II,maxideal(1)[nvars(PREGFANRING)+1]);
    52785551          // if gfan version >= 0.3.0 is used and the characteristic
     
    53125585            int goon=1;
    53135586            trop;
    5314             "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY";
     5587            "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY"; 
    53155588            "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
    53165589            "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -";
     
    53195592            "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    53205593            ~
    5321             // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY
     5594            // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY 
    53225595            // THE TROPICAL PREVARIETY
    5323             // test, if wneu really is in the tropical variety
     5596            // test, if wneu really is in the tropical variety   
    53245597            while (goon==0)
    53255598            {
     
    53395612          {
    53405613            system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    5341             // read the result from gfan and store it to a string,
     5614            // read the result from gfan and store it to a string, 
    53425615            // which in a later version
    53435616            // should be interpreded by Singular
     
    53495622        else // if gfan is NOT executed
    53505623        {
    5351           if (findall==1)
     5624          // if puiseux is set, then we are in the case of a plane curve and can use the command newtonpoly
     5625          if (puiseux==1)
    53525626          {
    5353             "Set wneulist!";
    5354             ~
     5627            if (nvars(basering)>2) // if the basering has a parameter
     5628            { // we have to pass to a ring with two variables to compute the newtonpoly
     5629              def PRENPRing=basering;
     5630              poly NPpoly=i[size(i)];
     5631              ring NPRING=(0,@a),(x(1),t),ds;
     5632              poly NPpoly=imap(PRENPRing,NPpoly);
     5633              list NewtP=newtonpoly(NPpoly);
     5634              setring PRENPRing;
     5635              kill NPRING;
     5636            }
     5637            else
     5638            {             
     5639              list NewtP=newtonpoly(i[1]);
     5640            }
     5641            for (jjj=1;jjj<=size(NewtP)-1;jjj++)
     5642            {
     5643              wneu=NewtP[jjj]-NewtP[jjj+1];
     5644              int ggteiler=gcd(wneu[1],wneu[2]);
     5645              wneu[1]=-wneu[1]/ggteiler;
     5646              wneu[2]=wneu[2]/ggteiler;
     5647              if (wneu[1]>0)
     5648              {
     5649                wneu=-wneu;
     5650              }
     5651              if (nvars(basering)>2)
     5652              {       
     5653                wneu[3]=0;
     5654              }
     5655              wneulist[jjj]=wneu;
     5656            } 
     5657            kill NewtP,ggteiler;
    53555658          }
    5356           else
     5659          else // we have to set the points in the tropical variety by hand
    53575660          {
    5358             "Set intvec wneu!";
    5359             ~
    5360             wneulist[1]=wneu;
    5361          }
     5661            if (findall==1)
     5662            {
     5663              "Set wneulist!";
     5664              ~
     5665            }
     5666            else
     5667            {
     5668              "Set intvec wneu!";
     5669              ~
     5670              wneulist[1]=wneu;
     5671            }
     5672          }
    53625673        }
    53635674      }
    5364       // if we have not yet computed our parametrisation up to
     5675      // if we have not yet computed our parametrisation up to 
    53655676      // the required order and
    5366       // zero is not yet a solution, then we have to go on
     5677      // zero is not yet a solution, then we have to go on 
    53675678      // by calling the procedure recursively;
    53685679      // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    53695680      lll=0;
    53705681      if ((ordnung>1) and (anzahlvariablen>1))
    5371       {
     5682      { 
    53725683        partliftings=list(); // initialise partliftings
    5373         // we call the procedure with the transformed
     5684        // we call the procedure with the transformed 
    53745685        // ideal i, the new weight vector, with the
    5375         // required order lowered by one, and with
     5686        // required order lowered by one, and with 
    53765687        // additional parameters, namely the number of
    5377         // true variables and the maximal ideal that
     5688        // true variables and the maximal ideal that 
    53785689        // was computed so far to describe the field extension
    53795690        for (kk=1;kk<=size(wneulist);kk++)
    53805691        {
    53815692          wneu=wneulist[kk];
    5382           PARALIST=tropicalparametrise(i,wneu,ordnung-1,gfanold,findall,nogfan,anzahlvariablen,zero);
    5383           // the output will be a ring, in which the
     5693          PARALIST=tropicalparametrise(i,wneu,ordnung-1,gfanold,findall,nogfan,puiseux,anzahlvariablen,zero);
     5694          // the output will be a ring, in which the 
    53845695          // parametrisation lives, and a string, which contains
    53855696          // the maximal ideal that describes the necessary field extension
    53865697          for (ll=1;ll<=size(PARALIST);ll++)
    5387           {
     5698          { 
    53885699            def PARARing=PARALIST[ll][1];
    53895700            tweight=-ww[1]*PARALIST[ll][2];
    53905701            setring PARARing;
    5391             // if some variables have been eliminated
    5392             // in before, then we have to insert zeros
     5702            // if some variables have been eliminated 
     5703            // in before, then we have to insert zeros 
    53935704            // into the parametrisation for those variables
    53945705            if (numberdeletedvariables>0)
     
    53965707              ideal PARAneu=PARA;
    53975708              kkk=0;
    5398               for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
     5709              for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) 
    53995710              { // t admits no parametrisation
    54005711                if (deletedvariables[jjj]!=1)
     
    54165727        }
    54175728      }
    5418       // otherwise we are done and we can start
     5729      // otherwise we are done and we can start 
    54195730      // to compute the last step of the parametrisation
    54205731      else
    54215732      {
    5422         // we define the weight of t, i.e. in the
     5733        // we define the weight of t, i.e. in the 
    54235734        // parametrisation t has to be replaced by t^1/tweight
    54245735        tweight=-ww[1];
    5425         // if additional variables were necessary,
     5736        // if additional variables were necessary, 
    54265737        // we introduce them now as parameters;
    5427         // in any case the parametrisation ring will
    5428         // have only one variable, namely t,
    5429         // and its order will be local, so that it
     5738        // in any case the parametrisation ring will 
     5739        // have only one variable, namely t, 
     5740        // and its order will be local, so that it 
    54305741        // displays the lowest term in t first
    54315742        if (anzahlvariablen<nvars(basering))
     
    54395750        }
    54405751        ideal PARA; // will contain the parametrisation
    5441         // we start by initialising the entries to be zero;
     5752        // we start by initialising the entries to be zero; 
    54425753        // one entry for each true variable
    5443         // here we also have to consider the variables
     5754        // here we also have to consider the variables 
    54445755        // that we have eliminated in before
    54455756        for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
     
    54535764        kill PARARing;
    54545765      }
    5455       // we now have to change the parametrisation by
     5766      // we now have to change the parametrisation by 
    54565767      // reverting the transformations that we have done
    54575768      for (lll=1;lll<=size(partliftings);lll++)
    54585769      {
    5459         if (size(partliftings[lll])==2) // when tropicalparametrise is called
    5460         { // for the last time, it does not enter the part, where wneu is
     5770        if (size(partliftings[lll])==2) // when tropicalparametrise is called 
     5771        { // for the last time, it does not enter the part, where wneu is 
    54615772          wneu=-1;     // defined and the variable t should have weight -1
    54625773        }
     
    54735784          PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight/ww[1]);
    54745785        }
    5475         // delete the last entry in zero, since that one has
     5786        // delete the last entry in zero, since that one has 
    54765787        // been used for the transformation
    54775788        zeros=delete(zeros,size(zeros));
    5478         // in order to avoid redefining commands an empty
     5789        // in order to avoid redefining commands an empty 
    54795790        // zeros list should be removed
    54805791        if (size(zeros)==0)
     
    54915802    kill TRRING;
    54925803  }
    5493   // kill the gfan files in /tmp
    5494   system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput");
    5495   // we return a list which contains lists of the parametrisation
     5804  if (nogfan!=1)
     5805  {
     5806    // kill the gfan files in /tmp
     5807    system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
     5808  }
     5809  // we return a list which contains lists of the parametrisation
    54965810  // rings (with the parametrisation ideal)
    54975811  // and an integer N such that t should be replaced by t^1/N
     
    55035817static proc eliminatecomponents (ideal i,ideal m,int anzahlvariablen,int findall,int lastvar,intvec deletedvariables)
    55045818"USAGE:  eliminatecomponents(i,m,n,a,v,d); i,m ideal, n,a,v int, d intvec
    5505 ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0)
    5506          is in the tropical variety of i considered in
    5507          Q[@a]/m{{t}}[x_1,...,x_n];
    5508          considered in this ring i is zero-dimensional; @a need not be present
     5819ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0) 
     5820         is in the tropical variety of i considered in 
     5821         Q[@a]/m{{t}}[x_1,...,x_n]; 
     5822         considered in this ring i is zero-dimensional; @a need not be present 
    55095823         in which case m is zero; 1<=v<=n
    55105824RETURN:  list, L of lists
     
    55125826               L[j][2] = an integer anzahlvariablen
    55135827               L[j][3] = an intvec deletedvariables
    5514 NOTE:    - the procedure is called from inside the recursive
     5828NOTE:    - the procedure is called from inside the recursive 
    55155829           procedure tropicalparametrise
    5516          - the procedure checks for solutions which have certain
    5517            components zero; these are separated from the rest by
    5518            elimination and saturation; the integer deletedvariables
    5519            records which variables have been eliminated;
    5520            the integer anzahlvariablen records how many true variables remain
     5830         - the procedure checks for solutions which have certain 
     5831           components zero; these are separated from the rest by 
     5832           elimination and saturation; the integer deletedvariables 
     5833           records which variables have been eliminated; 
     5834           the integer anzahlvariablen records how many true variables remain 
    55215835           after the elimination
    5522          - if the integer a is one then all zeros of the ideal i are
    5523            considered and found, otherwise only one is considered, so that L
     5836         - if the integer a is one then all zeros of the ideal i are 
     5837           considered and found, otherwise only one is considered, so that L 
    55245838           has length one"
    55255839{
     
    55295843  // if all solutions have to be found
    55305844  if (findall==1)
    5531   {
     5845  {   
    55325846    list saturatelist,eliminatelist; // carry the solution of the two tests
    5533     // we test first if there is a solution which has the component
    5534     // lastvar zero and
     5847    // we test first if there is a solution which has the component 
     5848    // lastvar zero and 
    55355849    // where the order of each component is strictly positive;
    5536     // if so, we add this variable to the ideal and
     5850    // if so, we add this variable to the ideal and 
    55375851    // eliminate it - which amounts to
    5538     // to projecting the solutions with this component
     5852    // to projecting the solutions with this component 
    55395853    // zero to the hyperplane without this component;
    5540     // for the test we compute the saturation with
     5854    // for the test we compute the saturation with 
    55415855    // respect to t and replace each variable
    5542     // x_i and also t by zero -- if the result is zero,
    5543     // then 1 is not in I:t^infty
     5856    // x_i and also t by zero -- if the result is zero, 
     5857    // then 1 is not in I:t^infty 
    55445858    // (i.e. there is a solution which has the component lastvar zero) and
    5545     // the result lives in the maximal
    5546     // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that
     5859    // the result lives in the maximal 
     5860    // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that 
    55475861    // there is a solution which has strictly positive valuation
    55485862/*
    55495863    // DER NACHFOLGENDE TEIL IST MUELL UND WIRD NICHT MEHR GAMACHT
    5550     // for the test we simply compute the leading ideal
     5864    // for the test we simply compute the leading ideal 
    55515865    // and set all true variables zero;
    5552     // since the ordering was an elimination ordering
     5866    // since the ordering was an elimination ordering 
    55535867    // with respect to (@a if present and) t
    5554     // there remains something not equal to zero
     5868    // there remains something not equal to zero 
    55555869    // if and only if there is polynomial which only
    5556     // depends on t (and @a if present), but that is
     5870    // depends on t (and @a if present), but that is 
    55575871    // a unit in K{{t}}, which would show that there
    55585872    // is no solution with the component lastvar zero;
    5559     // however, we also have to ensure that if there
     5873    // however, we also have to ensure that if there 
    55605874    // exists a solution with the component lastvar
    5561     // equal to zero then this component has a
     5875    // equal to zero then this component has a 
    55625876    // valuation with all strictly positive values!!!!;
    5563     // for this we can either saturate the ideal
     5877    // for this we can either saturate the ideal 
    55645878    // after elimination with respect to <t,x_1,...,x_n>
    5565     // and see if the saturated ideal is contained in <t,x_1,...x_n>+m,
    5566     // or ALTERNATIVELY we can pass to the
     5879    // and see if the saturated ideal is contained in <t,x_1,...x_n>+m, 
     5880    // or ALTERNATIVELY we can pass to the 
    55675881    // ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)),
    5568     // compute a standard basis of the elimination
     5882    // compute a standard basis of the elimination 
    55695883    // ideal (plus m) there and check if the dimension 1
    5570     // (since we have not omitted the variable lastvar,
     5884    // (since we have not omitted the variable lastvar, 
    55715885    // this means that we have the ideal
    5572     // generated by t,x_1,...,[no x_lastvar],...,x_n
     5886    // generated by t,x_1,...,[no x_lastvar],...,x_n 
    55735887    // and this defines NO curve after omitting x_lastvar)
    55745888    I=std(ideal(var(lastvar)+i));
     
    55765890    LI=lead(reduce(I,std(m)));
    55775891    //size(deletedvariables)=anzahlvariablen(before elimination)
    5578     for (j=1;j<=anzahlvariablen-1;j++)
     5892    for (j=1;j<=anzahlvariablen-1;j++) 
    55795893    {
    55805894      LI=subst(LI,var(j),0);
     
    55825896    if (size(LI)==0) // if no power of t is in lead(I) (where @a is considered as a field element)
    55835897*/
    5584     I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal
     5898    I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal 
    55855899                                                      // polynomial for the test
    55865900    LI=subst(I,var(nvars(basering)),0);
    55875901    //size(deletedvariables)=anzahlvariablen(before elimination)
    5588     for (j=1;j<=anzahlvariablen-1;j++)
     5902    for (j=1;j<=anzahlvariablen-1;j++) 
    55895903    {
    55905904      LI=subst(LI,var(j),0);
    55915905    }
    5592     if (size(LI)==0) // the saturation lives in the maximal
     5906    if (size(LI)==0) // the saturation lives in the maximal 
    55935907    { // ideal generated by t and the x_i
    55945908      // get rid of var(lastvar)
     
    56055919      {
    56065920        string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(simplify(reduce(maxideal(1),std(var(lastvar))),2))+"),(";
    5607       }
    5608       if (anzahlvariablen<nvars(basering)) // if @a was present, the
     5921      }   
     5922      if (anzahlvariablen<nvars(basering)) // if @a was present, the 
    56095923      { // ordersting needs an additional entry
    56105924        elring=elring+"dp(1),";
    56115925      }
    56125926      elring=elring+"lp(1));";
    5613       execute(elring);
     5927      execute(elring);     
    56145928      ideal i=imap(BASERING,I); // move the ideal I to the new ring
    5615       // if not yet all variables have been checked,
     5929      // if not yet all variables have been checked, 
    56165930      // then go on with the next smaller variable,
    5617       // else prepare the elimination ring and the neccessary
     5931      // else prepare the elimination ring and the neccessary 
    56185932      // information for return
    56195933      if (lastvar>1)
     
    56285942      setring BASERING;
    56295943    }
    5630     // next we have to test if there is also a solution
     5944    // next we have to test if there is also a solution 
    56315945    // which has the variable lastvar non-zero;
    5632     // to do so, we saturate with respect to this variable;
    5633     // since when considered over K{{t}}
    5634     // the ideal is zero dimensional, this really removes
     5946    // to do so, we saturate with respect to this variable; 
     5947    // since when considered over K{{t}} 
     5948    // the ideal is zero dimensional, this really removes 
    56355949    // all solutions with that component zero;
    56365950    // the checking is then done as above
    56375951    i=std(sat(i,var(lastvar))[1]);
    56385952    I=reduce(i,std(m)); // "remove" m from i
    5639     // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then
    5640     // we know that i has no longer a point in the tropical
     5953    // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then 
     5954    // we know that i has no longer a point in the tropical 
    56415955    // variety with all components negative
    56425956    LI=subst(I,var(nvars(basering)),0);
    5643     for (j=1;j<=anzahlvariablen-1;j++) // set all variables
     5957    for (j=1;j<=anzahlvariablen-1;j++) // set all variables 
    56445958    { // t,x_1,...,x_n equal to zero
    56455959      LI=subst(LI,var(j),0);
    56465960    }
    56475961    if (size(LI)==0) // the entries of i have not constant part
    5648     {
    5649       // check now, if the leading ideal of i contains an element
     5962    {     
     5963      // check now, if the leading ideal of i contains an element 
    56505964      // which only depends on t
    56515965      LI=lead(I);
    56525966      //size(deletedvariables)=anzahlvariablen(before elimination)
    5653       for (j=1;j<=anzahlvariablen-1;j++)
     5967      for (j=1;j<=anzahlvariablen-1;j++) 
    56545968      {
    56555969        LI=subst(LI,var(j),0);
    56565970      }
    5657       if (size(LI)==0) // if no power of t is in lead(i)
     5971      if (size(LI)==0) // if no power of t is in lead(i) 
    56585972      { // (where @a is considered as a field element)
    5659         // if not yet all variables have been tested, go on with the
     5973        // if not yet all variables have been tested, go on with the 
    56605974        // next smaller variable
    56615975        // else prepare the neccessary information for return
     
    56655979        }
    56665980        else
    5667         {
     5981        {   
    56685982          execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");");
    56695983          ideal i=imap(BASERING,i);
     
    56765990    return(eliminatelist+saturatelist);
    56775991  }
    5678   else // only one solution is searched for, we can do a simplified
     5992  else // only one solution is searched for, we can do a simplified 
    56795993  { // version of the above
    5680     // check if there is a solution which has the n-th component
     5994    // check if there is a solution which has the n-th component 
    56815995    // zero and with positive valuation,
    5682     // if so, then eliminate the n-th variable from
     5996    // if so, then eliminate the n-th variable from 
    56835997    // sat(i+x_n,t), otherwise leave i as it is;
    5684     // then check if the (remaining) ideal has as
     5998    // then check if the (remaining) ideal has as 
    56855999    // solution where the n-1st component is zero ...,
    56866000    // and procede as before; do the same for the remaining variables;
    5687     // this way we make sure that the remaining ideal has
     6001    // this way we make sure that the remaining ideal has 
    56886002    // a solution which has no component zero;
    56896003    ideal variablen; // will contain the variables which are not eliminated
     
    56936007      LI=subst(I,var(nvars(basering)),0);
    56946008      //size(deletedvariables)=anzahlvariablen-1(before elimination)
    5695       for (k=1;k<=size(deletedvariables);k++)
     6009      for (k=1;k<=size(deletedvariables);k++) 
    56966010      {
    56976011        LI=subst(LI,var(k),0);
    56986012      }
    5699       if (size(LI)==0) // if no power of t is in lead(I)
     6013      if (size(LI)==0) // if no power of t is in lead(I) 
    57006014      { // (where the X(i) are considered as field elements)
    5701         // get rid of var(j)
     6015        // get rid of var(j)   
    57026016        i=eliminate(I,var(j));
    57036017        deletedvariables[j]=1;
    5704         anzahlvariablen--; // if a variable is eliminated,
     6018        anzahlvariablen--; // if a variable is eliminated, 
    57056019                           // then the number of true variables drops
    57066020      }
     
    57116025    }
    57126026    variablen=invertorder(variablen);
    5713     // store also the additional variable and t,
     6027    // store also the additional variable and t, 
    57146028    // since they for sure have not been eliminated
    57156029    for (j=size(deletedvariables)+1;j<=nvars(basering);j++)
     
    57176031      variablen=variablen+var(j);
    57186032    }
    5719     // if there are variables left, then pass to a ring which
    5720     // only realises these variables else we are done
     6033    // if there are variables left, then pass to a ring which 
     6034    // only realises these variables else we are done 
    57216035    if (anzahlvariablen>1)
    57226036    {
     
    57266040    {
    57276041      string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(variablen)+"),(";
    5728     }
    5729     if (size(deletedvariables)+1<nvars(basering)) // if @a was present,
     6042    }   
     6043    if (size(deletedvariables)+1<nvars(basering)) // if @a was present, 
    57306044    { // the ordersting needs an additional entry
    57316045      elring=elring+"dp(1),";
    57326046    }
    57336047    elring=elring+"lp(1));";
    5734     execute(elring);
     6048    execute(elring);     
    57356049    ideal i=imap(BASERING,i);
    57366050    ideal m=imap(BASERING,m);
     
    57456059static proc findzerosAndBasictransform (ideal i,intvec w,list zerolist,int findall,list #)
    57466060"USAGE:  findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list
    5747 ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0)
     6061ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0) 
    57486062         is in the tropical variety of i; @a need not be present;
    57496063         the list 'zero' contains the zeros computed in previous recursion steps;
    5750          if 'f' is one then all zeros should be found and returned,
     6064         if 'f' is one then all zeros should be found and returned, 
    57516065         otherwise only one
    5752 RETURN:  list, each entry is a ring corresponding to one conjugacy class of
    5753                zeros of the t-initial ideal inside the torus; each of the rings
     6066RETURN:  list, each entry is a ring corresponding to one conjugacy class of 
     6067               zeros of the t-initial ideal inside the torus; each of the rings 
    57546068               contains the following objects
    57556069               ideal i    = the ideal i, where the variable @a (if present) has
    5756                             possibly been transformed according to the new
    5757                             minimal polynomial, and where itself has been
    5758                             submitted to the basic transform of the algorithm
     6070                            possibly been transformed according to the new 
     6071                            minimal polynomial, and where itself has been 
     6072                            submitted to the basic transform of the algorithm 
    57596073                            given by the jth zero found for the t-initial ideal;
    5760                             note that the new minimal polynomial has already
     6074                            note that the new minimal polynomial has already 
    57616075                            been added
    5762                poly m     = the new minimal polynomial for @a
     6076               poly m     = the new minimal polynomial for @a 
    57636077                            (it is zero if no @a is present)
    5764                list zero  = zero[k+1] is the kth component of a zero
     6078               list zero  = zero[k+1] is the kth component of a zero 
    57656079                            the t-initial ideal of i
    5766 NOTE:     -  the procedure is called from inside the recursive procedure
     6080NOTE:     -  the procedure is called from inside the recursive procedure 
    57676081             tropicalparametrise;
    5768              if it is called in the first recursion, the list #[1] contains
    5769              the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
     6082             if it is called in the first recursion, the list #[1] contains 
     6083             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer, 
    57706084             one more than the number of true variables x_1,...,x_n
    5771           -  if #[2] is present, then it is an integer which tells whether
     6085          -  if #[2] is present, then it is an integer which tells whether 
    57726086             ALL zeros should be found or not"
    57736087{
     
    57876101    int anzahlvariablen=#[1];
    57886102    // compute the initial ideal of i
    5789     // - the last 1 just means that the variable t is the last
     6103    // - the last 1 just means that the variable t is the last 
    57906104    //   variable in the ring
    57916105    ideal ini=tInitialIdeal(i,w,1);
     
    57956109    int recursive=0;
    57966110    int anzahlvariablen=nvars(basering);
    5797     ideal ini=#[1]; // the t-initial ideal has been computed
     6111    ideal ini=#[1]; // the t-initial ideal has been computed 
    57986112                    // in before and was handed over
    5799   }
     6113  } 
    58006114  // collect the true variables x_1,...,x_n plus @a, if it is defined in BASERING
    58016115  ideal variablen;
    58026116  for (j=1;j<=nvars(basering)-1;j++)
    5803   {
     6117  {   
    58046118    variablen=variablen+var(j);
    58056119  }
    5806   // move to a polynomial ring with global monomial ordering
     6120  // move to a polynomial ring with global monomial ordering 
    58076121  // - the variable t is superflous,
    58086122  // the variable @a is not if it was already present
    58096123  execute("ring INITIALRING=("+charstr(basering)+"),("+string(variablen)+"),dp;");
    58106124  ideal ini=imap(BASERING,ini);
    5811   // compute the minimal associated primes of the
     6125  // compute the minimal associated primes of the 
    58126126  // initialideal over the algebraic closure;
    5813   // ordering the maximal ideals shall help to
     6127  // ordering the maximal ideals shall help to 
    58146128  // avoid unneccessary field extensions
    58156129  list absminass=absPrimdecGTZ(ini);
    5816   def ABSRING=absminass[1]; // the ring in which the minimal
     6130  def ABSRING=absminass[1]; // the ring in which the minimal 
    58176131                            // associated primes live
    58186132  setring ABSRING;
     
    58256139  for (j=1;j<=size(maximalideals);j++)
    58266140  {
    5827     // check fort the jth maximal ideal a field extension is necessary;
     6141    // check if for the jth maximal ideal a field extension is necessary;
    58286142    // the latter condition says that @a is not in BASERING;
    5829     // if some of the maximal ideals needs a field extension,
     6143    // if some of the maximal ideals needs a field extension, 
    58306144    // then everything will live in this ring
    58316145    if ((maximalideals[j][1]!=0) and (nvars(BASERING)==anzahlvariablen))
    58326146    {
    5833       // define the extension ring which contains
     6147      // define the extension ring which contains 
    58346148      // the new variable @a, if it is not yet present
    58356149      execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+string(imap(BASERING,variablen))+",@a,"+tvar+"),(dp("+string(anzahlvariablen-1)+"),dp(1),lp(1));");
    5836       // phi maps x_i to x_i, @a to @a (if present in the ring),
     6150      // phi maps x_i to x_i, @a to @a (if present in the ring), 
    58376151      // and the additional variable
    5838       // for the field extension is mapped to @a as well
     6152      // for the field extension is mapped to @a as well 
    58396153      // -- note that we only apply phi
    5840       // to the list a, and in this list no @a is present;
     6154      // to the list a, and in this list no @a is present; 
    58416155      // therefore, it does not matter where this is mapped to
    58426156      map phi=ABSRING,imap(BASERING,variablen),@a;
    58436157    }
    5844     else // @a was already present in the BASERING or no
     6158    else // @a was already present in the BASERING or no 
    58456159    { // field extension is necessary
    58466160      execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+varstr(BASERING)+"),("+ordstr(BASERING)+");");
    5847       // phi maps x_i to x_i, @a to @a (if present in the ring),
     6161      // phi maps x_i to x_i, @a to @a (if present in the ring), 
    58486162      // and the additional variable
    5849       // for the field extension is mapped to @a as well respectively to 0,
     6163      // for the field extension is mapped to @a as well respectively to 0, 
    58506164      // if no @a is present;
    5851       // note that we only apply phi to the list a and to
     6165      // note that we only apply phi to the list a and to 
    58526166      // the replacement rule for
    5853       // the old variable @a, and in this list resp.
    5854       // replacement rule no @a is present;
     6167      // the old variable @a, and in this list resp. 
     6168      // replacement rule no @a is present; 
    58556169      // therefore, it does not matter where this is mapped to;
    58566170      if (anzahlvariablen<nvars(EXTENSIONRING)) // @a is in EXTENSIONRING
    5857     &