Changeset 087a94 in git


Ignore:
Timestamp:
Mar 25, 2009, 12:27:13 PM (14 years ago)
Author:
Thomas Markwig <keilen@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
16ed2f5aab6d00da628b5f73458c7045c9adaaf6
Parents:
76afcdc23066a190fc8c0d2d82b16b5fd08c0215
Message:
Alle Zeilen auf Laenge 80 beschraenkt.


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/tropical.lib

    r76afcd r087a94  
    1 version="$Id: tropical.lib,v 1.11 2009-03-16 11:32:31 keilen Exp $";
     1version="$Id: tropical.lib,v 1.12 2009-03-25 11:27:13 keilen Exp $";
    22category="Tropical Geometry";
    33info="
     
    88@*               Thomas Markwig,  email: keilen@mathematik.uni-kl.de
    99
    10 WARNING:
    11      - tropicalLifting will only work under LINUX and if in addition gfan is installed.
    12 @*   - drawTropicalCurve and drawTropicalNewtonSubdivision will only display the tropical
    13        curve under LINUX and if in addition latex and kghostview are installed.
    14 @*   - In tropicalLifting the basering needs the parameter t as a variable, while otherwise
    15        it needs it as a parameter.
     10WARNING:
     11- 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
     14@*  are installed.
     15@*- For tropicalLifting in the definition of the basering the parameter t
     16@*  from the Puiseux series field C{{t}} must be defined as a variable,
     17@*  while for all other procedures it must be defined as a parameter.
    1618
    1719THEORY:
    18      Fix some base field K and a bunch of lattice points v0,...,vm in the integer lattice Z^n,
    19      then this defines a toric variety as the closure of (K*)^n in the projective space P^m, where
    20      the torus is embedded via the map sending a point x in (K*)^n to the point (x^v0,...,x^vm).
    21      The generic hyperplane sections are just the images of the hypersurfaces in (K*)^n defined by
    22      the polynomials f=a0*x^v0+...+am*x^vm=0. Some properties of these hypersurfaces can be studied
    23      via tropicalisation.
    24 
    25      For this we suppose that K=C{{t}} is the field of Puiseux series over the field of complex
    26      numbers (or any other field with a valuation into the real numbers). One associates to the
    27      hypersurface given by f=a0*x^v0+...+am*x^vm the tropical hypersurface defined by the tropicalisation
    28      trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}. Here, <v,x> denotes the standard scalar product
    29      of the integer vector v in Z^n with the vector x=(x1,...,xn) of variables, so that trop(f) is
    30      a piecewise linear function on R^n. The corner locus of this function (i.e. the points at which
    31      the minimum is attained a least twice) is the tropical hypersurface defined by trop(f).
    32      The theorem of Newton-Kapranov states that this tropical hypersurface is the same as if one
    33      computes pointwise the valuation of the hypersurface given by f. The analogue holds true if one
    34      replaces one equation f by an ideal I. A constructive proof of the theorem is given by an adapted
    35      version of the Newton-Puiseux algorithm. The hard part is to find a point in the variety over
    36      C{{t}} which corresponds to a given point in the tropical variety.
    37 
    38      It is the purpose of this library to provide basic means to deal with tropical varieties.
    39      Of course we cannot represent the field of Puiseux series over C in its full strength, however,
    40      in order to compute interesting examples it will be sufficient to replace the complex numbers C
    41      by the rational numbers Q and to replace Puiseux series in t by rational functions in t,
    42      i.e. we replace C{{t}} by Q(t), or sometimes even by Q[t]. Note, that this in particular
    43      forbits rational exponents for the t's.
    44 
    45      Moreover, in Singular no negative exponents of monomials are allowed, so that the integer vectors
    46      vi will have to have non-negative entries. Shifting all exponents by a fixed integer vector does not
    47      change the tropicalisation nor does it change the toric variety.
    48      Thus this does not cause any restriction.
    49      If, however, for some reason you prefer to work with general vi, then you have to pass right away to
    50      the tropicalisation of the equations, whereever this is allowed -- these are linear polynomials
    51      where the constant coefficient correspond to the valuation of the original coefficient and where
    52      the non-constant coefficient correspond to the exponents of the monomials, thus they may be rational
    53      numbers respectively negative numbers:
    54      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}.
    55 
    56      The main tools provided in this library are as follows:
    57 @*   - tropicalLifting    implements the constructive proof of the Theorem of Newton-Kapranov and constructs
    58                           a point in the variety over C{{t}} corresponding to a given point in the
    59                           corresponding tropical variety associated to an ideal I; the generators of
    60                           I have to be in the polynomial ring Q[t,x1,...,xn] considered as a subring of
    61                           C{{t}}[x1,...,xn]; a solution will be constructed up to given order; note that
    62                           several field extensions of Q might be necessary thoughout the intermediate
    63                           computations; the procedures uses the external program gfan
    64 @*   - drawTropicalCurve  visualises a tropical plane curve either given by a polynomial in Q(t)[x,y]
    65                           or by a list of linear polynomials of the form ax+by+c with a,b in Z and c in Q;
    66                           latex must be installed on your computer
    67 @*   - tropicalJInvariant computes the tropical j-invaiant of a tropical elliptic curve
    68 @*   - jInvariant         computes the j-invariant of an elliptic curve
    69 @*   - weierstrassFom     computes the Weierstrass form of an elliptic curve
    70 
    71 PROCEDURES CONCERNED WITH TROPICAL LIFTING:
    72      tropicalLifting(ideal,intvec,int) computes a point in the tropical variety of ideal over intvec
    73      displayTropicalLifting(list)      displays the output of tropicalLifting
    74 
    75 PROCEDURES CONCERNED WITH DRAWING TROPICAL CURVES:
    76      tropicalCurve(list)            computes a tropical curve and its Newton subdivision
    77      drawTropicalCurve(poly)        produces a post script image of the tropical curve defined by poly
    78      drawNewtonSubdivision(poly)    produces a post script image of the Newton subdivision a tropical curve
    79 
    80 PROCEDURES CONCERNED WITH J-INVARIANTS:
    81      tropicalJInvariant(poly)       computes the tropical j-invariant of the tropical curve poly
    82      weierstrassForm(poly)          computes the Weierstrass form of a cubic polynomial
    83      jInvariant(poly)               computes the j-invariant of a cubic polynomial
     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
     23  point x in (K*)^n to the point (x^v0,...,x^vm).
     24  The generic hyperplane sections are just the images of the hypersurfaces
     25  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
     29  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
     31  the tropical hypersurface defined by the tropicalisation
     32  trop(f)=min{val(a0)+<v0,x>,...,val(am)+<vm,x>}.
     33  Here, <v,x> denotes the standard scalar product of the integer vector v in Z^n
     34  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
     44  tropical variety.
     45
     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].
     52  Note, that this in particular forbits rational exponents for the t's.
     53
     54  Moreover, in 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
     58  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
     61  this is allowed -- these are linear polynomials where the constant coefficient
     62  correspond 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:
     65  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}.
     66
     67  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
     76                         field extensions of Q might be necessary thoughout
     77                         the intermediate computations; the procedures uses
     78                         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
     82                         in Q; latex must be installed on your computer
     83@*  - tropicalJInvariant computes the tropical j-invaiant of a tropical
     84                         elliptic curve
     85@*  - jInvariant         computes the j-invariant of an elliptic curve
     86@*  - weierstrassForm     computes the Weierstrass form of an elliptic curve
     87
     88PROCEDURES FOR TROPICAL LIFTING:
     89  tropicalLifting          computes a point in the tropical variety
     90  displayTropicalLifting   displays the output of tropicalLifting
     91
     92PROCEDURES FOR DRAWING TROPICAL CURVES:
     93  tropicalCurve            computes a tropical curve and its Newton subdivision
     94  drawTropicalCurve        produces a post script image of a tropical curve
     95  drawNewtonSubdivision    produces a post script image of a Newton subdivision
     96
     97PROCEDURES FOR J-INVARIANTS:
     98  tropicalJInvariant       computes the tropical j-invariant of a tropical curve
     99  weierstrassForm          computes the Weierstrass form of a cubic polynomial
     100  jInvariant               computes the j-invariant of a cubic polynomial
    84101
    85102GENERAL PROCEDURES:
    86      conicWithTangents(list)        computes a conic through five points and the tangents in these points
    87      tropicalise(poly)              computes the tropicalisation of the polynomial
    88      tropicaliseSet(ideal)          computes the tropicalisation of all polynomials in the ideal
    89      tInitialForm(poly,intvec)      computes the tInitial form of poly in Q[t,x_1,...,x_n] w.r.t. intvec
    90      tInitialIdeal(ideal,intvec)    computes the tInitial form of ideal in Q[t,x_1,...,x_n] w.r.t. intvec
    91      initialForm(poly,intvec)       computes the initial form of poly in Q[x_1,...,x_n] w.r.t. intvec
    92      initialIdeal(ideal,intvec)     computes the initial ideal of an ideal in Q[x_1,...,x_n] w.r.t. intvec
    93 
    94 PROCEDURES CONCERNED WITH THE LATEX CONVERSION:
    95      texNumber(poly)                  outputs the texcommand for the leading coefficient of poly
    96      texPolynomial(poly)              outputs the texcommand for the polynomial poly
    97      texMatrix(matrix)                outputs the texcommand for the matrix
    98      texDrawBasic(list)               embeds the output of texDrawTropical in a texdraw environment
    99      texDrawTropical(list)            computes the texdraw commands for a tropical curve
    100      texDrawNewtonSubdivision(list)   computes the texdraw commands for a Newton subdivision
    101      texDrawTriangulation(list,list)  computes the texdraw commands for a triangulation
     103  conicWithTangents  computes a conic through five points with tangents
     104  tropicalise        computes the tropicalisation of a polynomial
     105  tropicaliseSet     computes the tropicalisation several polynomials
     106  tInitialForm       computes the tInitial form of a poly in Q[t,x_1,...,x_n]
     107  tInitialIdeal      computes the tInitial ideal of an ideal in Q[t,x_1,...,x_n]
     108  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]
     110
     111PROCEDURES FOR LATEX CONVERSION:
     112  texNumber          outputs the texcommand for the leading coefficient of poly
     113  texPolynomial      outputs the texcommand for the polynomial poly
     114  texMatrix          outputs the texcommand for the matrix
     115  texDrawBasic       embeds output of texDrawTropical in a texdraw environment
     116  texDrawTropical    computes the texdraw commands for a tropical curve
     117  texDrawNewtonSubdivision   computes texdraw commands for a Newton subdivision
     118  texDrawTriangulation       computes texdraw commands for a triangulation
    102119
    103120AUXILARY PROCEDURES:
    104      radicalMemberShip(poly,ideal)    checks if the poly is contained in the radical of ideal
    105      tInitialFormPar(poly,intvec)     computes the t-initial form of poly in Q(t)[x_1,...,x_n] w.r.t. intvec
    106      tInitialFormParMax(poly,intvec)  same as tInitialFormPar, but uses maximum instead of minimum
    107      solveTInitialFormPar(ideal)      displays the approximated solution of a zero-dimensional ideal
    108      detropcialise(poly)              computes the detropicalisation of a linear form
    109      dualConic(poly)                  computes the dual of the affine plane conic defined by poly
    110      parameterSubstitute(poly,int)    substitutes in the poly the parameter t by t^N
    111      tropcialSubst(poly,int,list)     computes the tropical polynomial of poly with certain substitutions
    112      randomPoly(int,int,int)          computes a polynomial with random coefficients
    113      cleanTmp()                       removes the latex and ps files from /tmp created by other procedures
     121  radicalMemberShip     checks radical membership
     122  tInitialFormPar       computes the t-initial form of poly in Q(t)[x_1,...,x_n]
     123  tInitialFormParMax    same as tInitialFormPar, but uses maximum
     124  solveTInitialFormPar  displays approximated solution of a 0-dim ideal
     125  detropicalise         computes the detropicalisation of a linear form
     126  dualConic             computes the dual of an affine plane conic
     127  parameterSubstitute   substitutes in the poly the parameter t by t^N
     128  tropicalSubst         makes certain substitutions in a tropical polynomial
     129  randomPoly            computes a polynomial with random coefficients
     130  cleanTmp              clears /tmp from files created by other procedures
    114131
    115132KEYWORDS:        tropical curves; tropical polynomials
     
    117134";
    118135
    119 ////////////////////////////////////////////////////////////////////////////////////
     136///////////////////////////////////////////////////////////////////////////////
    120137/// Auxilary Static Procedures in this Library
    121 ////////////////////////////////////////////////////////////////////////////////////
     138///////////////////////////////////////////////////////////////////////////////
    122139/// - phiOmega
    123140/// - cutdown
     
    138155/// - eliminatecomponents
    139156/// - findzerosAndBasictransform
    140 /// - ordermaximalideals
     157/// - ordermaximalideals 
    141158/// - verticesTropicalCurve
    142159/// - bunchOfLines
     
    171188/// - jInvariantOfA2x2Curve
    172189/// - jInvariantOfAPuiseuxCubic
    173 /////////////////////////////////////////////////////////////////////////////////////
    174 
    175 
    176 
    177 ////////////////////////////////////////////////////////////////////////////////////
     190//////////////////////////////////////////////////////////////////////////////
     191
     192
     193
     194//////////////////////////////////////////////////////////////////////////////
    178195LIB "random.lib";
    179196LIB "solve.lib";
     
    184201LIB "primdec.lib";
    185202LIB "absfact.lib";
    186 ////////////////////////////////////////////////////////////////////////////////////
    187 
    188 ////////////////////////////////////////////////////////////////////////////////////
    189 /// Procedures concerned with tropical parametrisation
    190 ///////////////////////////////////////////////////////////////////////////////////
     203//////////////////////////////////////////////////////////////////////////////
     204
     205///////////////////////////////////////////////////////////////////////////////
     206/// Procedures concerned with tropical parametrisation 
     207///////////////////////////////////////////////////////////////////////////////
    191208
    192209proc tropicalLifting (ideal i,intvec w,int ordnung,list #)
    193210"USAGE:  tropicalLifting(i,w,ord[,opt]); i ideal, w intvec, ord int, opt string
    194 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n)
    195            and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i,
    196            and ord is the order up to which a point in V(i) over Q{{t}} lying over
    197            (w_1/w_0,...,w_n/w_0) shall be computed; w_0 may NOT be ZERO
    198 @*       - the basering should not have any parameters on its own
    199            and it should have a global monomial ordering, e.g. ring r=0,(t,x(1..n)),dp;
    200 @*       - the first variable of the basering will be treated as the parameter t
    201            in the Puiseux series field !!!!
    202 @*       - the optional parameter opt should be one or more strings among the following:
     211ASSUME:  - i is an ideal in Q[t,x_1,...,x_n], w=(w_0,w_1,...,w_n) 
     212           and (w_1/w_0,...,w_n/w_0) is in the tropical variety of i,
     213           and ord is the order up to which a point in V(i) over Q{{t}}
     214           lying over (w_1/w_0,...,w_n/w_0) shall be computed;
     215           w_0 may NOT be ZERO
     216@*       - the basering should not have any parameters on its own
     217           and it should have a global monomial ordering,
     218           e.g. ring r=0,(t,x(1..n)),dp;
     219@*       - the first variable of the basering will be treated as the
     220           parameter t in the Puiseux series field !!!!
     221@*       - the optional parameter opt should be one or more strings among
     222           the following:
    203223@*         'isZeroDimensional'  : the dimension i is zero (not to be checked);
    204 @*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n]  (not to be checked);
    205 @*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical variety (not to be checked);
    206 @*         'oldGfan'            : uses gfan version 0.2.1 or less
    207 @*         'findAll'            : find all solutions of a zero-dimensional ideal over (w_1/w_0,...,w_n/w_0)
     224@*         'isPrime'            : the ideal is prime over Q(t)[x_1,...,x_n] 
     225                                  (not to be checked);
     226@*         'isInTrop'           : (w_1/w_0,...,w_n/w_0) is in the tropical
     227                                  variety (not to be checked);
     228@*         'oldGfan'            : uses gfan version 0.2.1 or less
     229@*         'findAll'            : find all solutions of a zero-dimensional
     230                                  ideal over (w_1/w_0,...,w_n/w_0)
    208231@*         'noAbs'              : do NOT use absolute primary decomposition
    209232@*         'noResubst'         : avoids computing the resubstitution
    210233RETURN:  IF THE OPTION 'findAll' WAS NOT SET THEN:
    211234@*       list, containing one lifting of the given point (w_1/w_0,...,w_n/w_0)
    212                in the tropical variety of i to a point in V(i) over Puiseux series field up to
    213                the first ord terms; more precisely:
     235               in the tropical variety of i to a point in V(i) over Puiseux
     236               series field up to the first ord terms; more precisely:
    214237@*             IF THE OPTION 'noAbs' WAS NOT SET THEN:
    215238@*             l[1] = ring Q[a]/m[[t]]
     
    225248@*       IF THE OPITON 'findAll' WAS NOT SET THEN:
    226249@*       list, containing ALL liftings of the given point ((w_1/w_0,...,w_n/w_0)
    227                in the tropical variety of i to a point in V(i) over Puiseux series field up to
    228                the first ord terms, if the ideal is zero-dimensional over Q{{t}};
    229                more precisely, each entry of the list is a list l as computed if
    230                'find_all' was NOT set
     250               in the tropical variety of i to a point in V(i) over Puiseux
     251               series field up to the first ord terms, if the ideal is
     252               zero-dimensional over Q{{t}};
     253               more precisely, each entry of the list is a list l as computed
     254               if  'find_all' was NOT set
    231255@*       WE NOW DESCRIBE THE LIST ENTRIES IF 'findAll' WAS NOT SET:
    232 @*       - the ring l[1] contains an ideal LIFT, which contains
     256@*       - the ring l[1] contains an ideal LIFT, which contains 
    233257           a point in V(i) lying over w up to the first ord terms;
    234 @*       - and if the integer l[2] is N then t has to be replaced by t^1/N in the
    235            lift, or alternatively replace t by t^N in the defining ideal
    236 @*       - if the k+1st entry of l[3] is  non-zero, then the kth component of LIFT has to
    237            be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t by t^1/N
    238 @*       - unless the option 'noResubst' was set, the kth entry of list l[4]
     258@*       - and if the integer l[2] is N then t has to be replaced by t^1/N
     259           in the lift, or alternatively replace t by t^N in the defining ideal
     260@*       - if the k+1st entry of l[3] is  non-zero, then the kth component of
     261           LIFT has to be multiplied t^(-l[3][k]/l[3][1]) AFTER substituting t
     262           by t^1/N
     263@*       - unless the option 'noResubst' was set, the kth entry of list l[4]
    239264           is a string which represents the kth generator of
    240            the ideal i where the coordinates have been replaced by the result of the lift;
    241            the t-order of the kth entry should in principle be larger than the t-degree of LIFT
    242 @*       - if the option 'noAbs' was set, then the string in l[5] defines a maximal ideal in the
    243            field Q[X(1),...,X(k)], where X(1),...,X(k) are the parameters of the ring in l[1];
    244            the basefield of the ring in l[1] should be considered modulo this ideal
    245 REMARK:  - it is best to use the procedure displayTropicalLifting to display the result
     265           the ideal i where the coordinates have been replaced by the result
     266           of the lift;
     267           the t-order of the kth entry should in principle be larger than the
     268           t-degree of LIFT
     269@*       - if the option 'noAbs' was set, then the string in l[5] defines
     270           a maximal ideal in the field Q[X(1),...,X(k)], where X(1),...,X(k)
     271           are the parameters of the ring in l[1];
     272           the basefield of the ring in l[1] should be considered modulo this
     273           ideal
     274REMARK:  - it is best to use the procedure displayTropicalLifting to
     275           display the result
    246276@*       - the option 'findAll' cannot be used if 'noAbs' is set
    247 @*       - if the parameter 'findAll' is set AND the ideal i is zero-dimensional in Q{{t}}[x_1,...,x_n]
    248            then ALL points in V(i) lying over w are computed up to order ord; if the ideal
    249            is not-zero dimenisonal, then only all points in the ideal after cutting down
    250            to dimension zero will be computed
    251 @*       - the procedure REQUIRES that the program GFAN is installed on your computer;
    252            if you have GFAN version less than 0.3.0 then you MUST use the optional
    253            parameter 'oldGfan'
    254 @*       - the procedure requires the Singular procedure absPrimdecGTZ to be present in
    255            the package primdec.lib, unless the option 'noAbs' is set; but even if absPrimdecGTZ
    256            is present it might be necessary to set the option 'noAbs' in order to avoid
    257            the costly absolute primary decomposition; the side effect is that the field
    258            extension which is computed throughout the recursion might need more only one
     277@*       - if the parameter 'findAll' is set AND the ideal i is zero-dimensional
     278           in Q{{t}}[x_1,...,x_n] then ALL points in V(i) lying over w are
     279           computed up to order ord; if the ideal is not-zero dimenisonal, then
     280           only all points in the ideal after cutting down to dimension zero
     281           will be computed
     282@*       - the procedure REQUIRES that the program GFAN is installed on your
     283           computer; if you have GFAN version less than 0.3.0 then you MUST
     284           use the optional parameter 'oldGfan'
     285@*       - the procedure requires the Singular procedure absPrimdecGTZ to be
     286           present in the package primdec.lib, unless the option 'noAbs' is set;
     287           but even if absPrimdecGTZ is present it might be necessary to set
     288           the option 'noAbs' in order to avoid the costly absolute primary
     289           decomposition; the side effect is that the field extension which is
     290           computed throughout the recursion might need more only one
    259291           parameter to be described
    260292@*       - since Q is infinite, the procedure finishes with probability one
    261 @*       - you can call the procedure with Z/pZ as base field instead of Q, but there
    262            are some problems you should be aware of:
    263 @*         + the Puiseux series field over the algebraic closure of Z/pZ is NOT algebraicall closed,
    264              and thus there may not exist a point in V(i) over the Puiseux series field
    265              with the desired valuation; so there is no chance that the procedure produced
    266              a sensible output - e.g. if i=tx^p-tx-1
    267 @*         + if the dimension of i over Z/pZ(t) is not zero the process of reduction to
    268              zero might not work if the characteristic is small and you are unlucky
    269 @*         + the option 'noAbs' has to be used since absolute primary decomposition in
    270              Singular only works in characteristic zero
    271 @*       - the basefield should either be Q or Z/pZ for some prime p; field extensions
    272            will be computed where necessary; if you need parameters or field extensions
    273            from the beginning they should rather be simulated as variables possibly adding
    274            their relations to the ideal; the weights for the additional variables should be zero
     293@*       - you can call the procedure with Z/pZ as base field instead of Q,
     294           but there are some problems you should be aware of:
     295@*         + the Puiseux series field over the algebraic closure of Z/pZ is
     296             NOT algebraicall closed, and thus there may not exist a point in
     297             V(i) over the Puiseux series field with the desired valuation;
     298             so there is no chance that the procedure produced a sensible output
     299             - e.g. if i=tx^p-tx-1
     300@*         + if the dimension of i over Z/pZ(t) is not zero the process of
     301             reduction to zero might not work if the characteristic is small
     302             and you are unlucky
     303@*         + the option 'noAbs' has to be used since absolute primary
     304             decomposition in Singular only works in characteristic zero
     305@*       - the basefield should either be Q or Z/pZ for some prime p;
     306           field extensions will be computed where necessary; if you need
     307           parameters or field extensions from the beginning they should
     308           rather be simulated as variables possibly adding their relations to
     309           the ideal; the weights for the additional variables should be zero
    275310EXAMPLE: example tropicalLifting;   shows an example"
    276311{
     
    280315    ERROR("The procedure is not implemented for rings with parameters. See: help tropicalLifting; for more information");
    281316  }
    282   // in order to avoid unpleasent surprises with the names of the variables we change
    283   // to a ring where the variables have names t and x(1),...,x(n)
     317  // in order to avoid unpleasent surprises with the names of the variables
     318  // we change to a ring where the variables have names t and x(1),...,x(n)
    284319  def ALTERRING=basering;
    285320  if (nvars(basering)==2)
     
    322357      noabs=1;
    323358    }
    324     // this option is not documented -- it prevents the execution of gfan and just asks
    325     // for wneu to be inserted -- it can be used to check problems with the precedure
    326     // without calling gfan, if wneu is know from previous computations
     359    // this option is not documented -- it prevents the execution of gfan and
     360    // just asks for wneu to be inserted -- it can be used to check problems
     361    // with the precedure without calling gfan, if wneu is know from previous
     362    // computations
    327363    if (#[j]=="noGfan")
    328364    {
     
    334370    }
    335371  }
    336   // if the basering has characteristic not equal to zero, then absolute factorisation
     372  // if the basering has characteristic not equal to zero,
     373  // then absolute factorisation
    337374  // is not available, and thus we need the option noAbs
    338375/*
     
    347384  {
    348385    Error("The first coordinate of your input w must be NON-ZERO, since it is a DENOMINATOR!");
    349   }
     386  } 
    350387  // if w_0<0, then replace w by -w, so that the "denominator" w_0 is positive
    351388  if (w[1]<0)
     
    354391  }
    355392  intvec prew=w; // stores w for later reference
    356   // for our computations, w[1] represents the weight of t and this should be -w_0 !!!
     393  // for our computations, w[1] represents the weight of t and this
     394  // should be -w_0 !!!
    357395  w[1]=-w[1];
    358396  // if w_0!=-1 then replace t by t^-w_0 and w_0 by -1
     
    363401    w[1]=-1;
    364402  }
    365   // if some entry of w is positive, we have to make a transformation,
     403  // if some entry of w is positive, we have to make a transformation, 
    366404  // which moves it to something non-positive
    367405  for (j=2;j<=nvars(basering);j++)
     
    375413  }
    376414  prew[1]=prew[1]+w[1];
    377   prew=prew-w; // this now contains the positive part of the original w, but the original first comp. of w
     415  prew=prew-w; // this now contains the positive part of the original w,
     416  // but the original first comp. of w
    378417  // pass to a ring which represents Q[t]_<t>[x1,...,xn]
    379418  // for this, unfortunately, t has to be the last variable !!!
     
    388427  {
    389428    variablen=variablen+var(j);
    390   }
     429  }   
    391430  map GRUNDPHI=BASERING,t,variablen;
    392431  ideal i=GRUNDPHI(i);
    393   // compute the initial ideal of i and test if w is in the tropical variety of i
     432  // compute the initial ideal of i and test if w is in the tropical
     433  // variety of i
    394434  // - the last entry 1 only means that t is the last variable in the ring
    395435  ideal ini=tInitialIdeal(i,w,1);
    396436  if (isintrop==0) // test if w is in trop(i) only if isInTrop has not been set
    397   {
     437  {   
    398438    poly product=1;
    399439    for (j=1;j<=nvars(basering)-1;j++)
     
    401441      product=product*var(j);
    402442    }
    403     if (radicalMemberShip(product,ini)==1) // if w is not in Trop(i) return an error message
     443    if (radicalMemberShip(product,ini)==1) // if w is not in Trop(i) - error
    404444    {
    405445      ERROR("The integer vector is not in the tropical variety of the ideal.");
    406446    }
    407447  }
    408   // compute next the dimension of i in K(t)[x] and cut the ideal down to dimension zero
     448  // compute next the dimension of i in K(t)[x] and cut the ideal down to dim 0
    409449  if (iszerodim==0) // do so only if is_dim_zero is not set
    410450  {
     
    413453    int dd=dim(i);
    414454    setring GRUNDRING;
    415     // if the dimension is not zero, we cut the ideal down to dimension zero and compute the
     455    // if the dimension is not zero, we cut the ideal down to dimension zero
     456    // and compute the
    416457    // t-initial ideal of the new ideal at the same time
    417458    if(dd!=0)
    418459    {
    419       // the procedurce cutdown computes a new ring, in which there lives a zero-dimensional
    420       // ideal which has been computed by cutting down the input with generic linear forms
    421       // of the type x_i1-p_1,...,x_id-p_d for some polynomials p_1,...,p_d not depending
    422       // on the variables x_i1,...,x_id; that way we have reduced the number of variables by dd !!!
    423       // the new zero-dimensional ideal is called i, its t-initial ideal (with respect to
    424       // the new w=CUTDOWN[2]) is ini, and finally there is a list repl in the ring
    425       // which contains at the polynomial p_j at position i_j and a zero otherwise;
     460      // the procedurce cutdown computes a new ring, in which there lives a
     461      // zero-dimensional
     462      // ideal which has been computed by cutting down the input with
     463      // generic linear forms
     464      // of the type x_i1-p_1,...,x_id-p_d for some polynomials
     465      // p_1,...,p_d not depending
     466      // on the variables x_i1,...,x_id; that way we have reduced
     467      // the number of variables by dd !!!
     468      // the new zero-dimensional ideal is called i, its t-initial
     469      // ideal (with respect to
     470      // the new w=CUTDOWN[2]) is ini, and finally there is a list
     471      // repl in the ring
     472      // which contains at the polynomial p_j at position i_j and
     473      //a zero otherwise;
    426474      if (isprime==0) // the minimal associated primes of i are computed
    427475      {
     
    444492  list liftrings; // will contain the final result
    445493  // if the procedure is called without 'findAll' then it may happen, that no
    446   // proper solution is found when dd>0; in that case we have to start all over again;
     494  // proper solution is found when dd>0; in that case we have
     495  // to start all over again;
    447496  // this is controlled by the while-loop
    448497  while (size(liftrings)==0)
    449498  {
    450     // compute the lifting for the zero-dimensional ideal via tropicalparametrise
     499    // compute lifting for the zero-dimensional ideal via tropicalparametrise
    451500    if (noabs==1) // do not use absolute primary decomposition
    452501    {
     
    459508    // compute the liftrings by resubstitution
    460509    kk=1;  // counts the liftrings
    461     int isgood;  // test in the non-zerodimensional case if the result has the correct valuation
     510    int isgood;  // test in the non-zerodimensional case
     511                 // if the result has the correct valuation
    462512    for (jj=1;jj<=size(TP);jj++)
    463513    {
    464       // the list TP contains as a first entry the ring over which the tropical parametrisation
     514      // the list TP contains as a first entry the ring over which the
     515      // tropical parametrisation
    465516      // of the (possibly cutdown ideal) i lives
    466517      def LIFTRING=TP[jj][1];
    467       // if the dimension of i originally was not zero, then we have to fill in the missing
     518      // if the dimension of i originally was not zero,
     519      // then we have to fill in the missing
    468520      // parts of the parametrisation
    469521      if (dd!=0)
    470522      {
    471         // we need a ring where the parameters X_1,...,X_k from LIFTRING are present,
     523        // we need a ring where the parameters X_1,...,X_k
     524        // from LIFTRING are present,
    472525        // and where also the variables of CUTDOWNRING live
    473526        execute("ring REPLACEMENTRING=("+charstr(LIFTRING)+"),("+varstr(CUTDOWNRING)+"),dp;");
    474         list repl=imap(CUTDOWNRING,repl); // get the replacement rules from CUTDOWNRING
    475         ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisation from LIFTRING
     527        list repl=imap(CUTDOWNRING,repl); // get the replacement rules
     528                                          // from CUTDOWNRING
     529        ideal PARA=imap(LIFTRING,PARA);   // get the zero-dim. parametrisatio
     530                                          // from LIFTRING
    476531        // compute the lift of the solution of the original ideal i
    477532        ideal LIFT;
    478533        k=1;
    479         for (j=1;j<=nvars(GRUNDRING)-1;j++) // the lift has as many components as GRUNDRING has variables!=t
     534        // the lift has as many components as GRUNDRING has variables!=t
     535        for (j=1;j<=nvars(GRUNDRING)-1;j++)
    480536        {
    481           if (repl[j]==0) // if repl[j]=0, then the corresponding variable was not eliminated
     537          // if repl[j]=0, then the corresponding variable was not eliminated
     538          if (repl[j]==0)
    482539          {
    483             LIFT[j]=PARA[k]; // thus the lift has been computed by tropicalparametrise
     540            LIFT[j]=PARA[k]; // thus the lift has been
     541                             // computed by tropicalparametrise
    484542            k++; // k checks how many entries of PARA have already been used
    485543          }
    486           else  // if repl[j]!=0, then repl[j] contains the replacement rule for the lift
     544          else  // if repl[j]!=0, repl[j] contains replacement rule for the lift
    487545          {
    488             LIFT[j]=repl[j]; // we still have to replace the vars in repl[j] by the corresp. entries of PARA
    489             for (l=1;l<=nvars(CUTDOWNRING)-1;l++) // replace all variables!=t (from CUTDOWNRING)
     546            LIFT[j]=repl[j]; // we still have to replace the vars
     547                             // in repl[j] by the corresp. entries of PARA
     548            // replace all variables!=t (from CUTDOWNRING)
     549            for (l=1;l<=nvars(CUTDOWNRING)-1;l++)
    490550            {
    491               LIFT[j]=subst(LIFT[j],var(l),PARA[l]); // substitute the kth variable by PARA[k]
     551              // substitute the kth variable by PARA[k]
     552              LIFT[j]=subst(LIFT[j],var(l),PARA[l]);
    492553            }
    493554          }
    494555        }
    495556        setring LIFTRING;
    496         ideal LIFT=imap(REPLACEMENTRING,LIFT);
    497         // test now if the LIFT has the correct valuation !!!
    498         // note: it may happen, that when resubstituting PARA into the replacement rules
    499         //       there occured some unexpected cancellation; we only know that for SOME
    500         //       solution of the zero-dimensional reduction NO canellation will occur,
    501         //       but for others this may very well happen; this in particular means that
    502         //       we possibly MUST compute all zero-dimensional solutions when cutting down!
     557        ideal LIFT=imap(REPLACEMENTRING,LIFT);   
     558        // test now if the LIFT has the correct valuation !!!     
     559        // note: it may happen, that when resubstituting PARA into
     560        //       the replacement rules
     561        //       there occured some unexpected cancellation;
     562        //       we only know that for SOME
     563        //       solution of the zero-dimensional reduction NO
     564        //       canellation will occur,
     565        //       but for others this may very well happen;
     566        //       this in particular means that
     567        //       we possibly MUST compute all zero-dimensional
     568        //       solutions when cutting down!
    503569        intvec testw=precutdownw[1];
    504570        for (j=1;j<=size(LIFT);j++)
     
    522588      }
    523589      kill PARA;
    524       if (isgood==1) // only if LIFT has the right valuation we have to do something
    525       {
    526         // it remains to reverse the original substitutions, where appropriate !!!
    527         // if some entry of the original w was positive, we replace the corresponding
    528         // variable x_i by t^-w[i]*x_i, so we must now replace the corresponding entry
     590      // only if LIFT has the right valuation we have to do something
     591      if (isgood==1)
     592      {
     593        // it remains to reverse the original substitutions,
     594        // where appropriate !!!
     595        // if some entry of the original w was positive,
     596        // we replace the corresponding
     597        // variable x_i by t^-w[i]*x_i, so we must now replace
     598        // the corresponding entry
    529599        // LIFT[i] by t^-w[i]*LIFT[i] --- the original w is stored in prew
    530600        // PROBLEM: THIS CANNOT BE DONE SINCE -w[i] IS NEGATIVE
     
    539609          }
    540610        */
    541         if ((noabs==0) and (defined(@a)==-1)) // if LIFTRING contains a parameter @a, change it to a
     611        // if LIFTRING contains a parameter @a, change it to a
     612        if ((noabs==0) and (defined(@a)==-1))
    542613        {
    543           // pass first to a ring where a and @a are variables in order to use maps
     614          // pass first to a ring where a and @a
     615          // are variables in order to use maps
    544616          poly mp=minpoly;
    545617          ring INTERRING=char(LIFTRING),(t,@a,a),dp;
     
    549621          // replace @a by a in minpoly and in LIFT
    550622          map phi=INTERRING,t,a,a;
    551           mp=phi(mp);
     623          mp=phi(mp);     
    552624          LIFT=phi(LIFT);
    553625          // pass now to a ring whithout @a and with a as parameter
     
    556628          ideal LIFT=imap(INTERRING,LIFT);
    557629          kill INTERRING;
    558         }
     630        }   
    559631        // then export LIFT
    560         export(LIFT);
     632        export(LIFT); 
    561633        // test the  result by resubstitution
    562         setring GRUNDRING;
     634        setring GRUNDRING; 
    563635        list resubst;
    564636        if (noresubst==0)
     
    569641          }
    570642          else
    571           {
     643          {     
    572644            resubst=tropicalliftingresubstitute(substitute(i,t,t^(TP[jj][2])),list(LIFTRING),N*TP[jj][2]);
    573645          }
    574646        }
    575647        setring BASERING;
    576         // Finally, if t has been replaced by t^N, then we have to change the
     648        // Finally, if t has been replaced by t^N, then we have to change the 
    577649        // third entry of TP by multiplying by N.
    578650        if (noabs==1)
     
    590662      kill LIFTRING;
    591663    }
    592     // if dd!=0 and the procedure was called without the option findAll, then it might very well
    593     // be the case that no solution is found, since only one solution for the zero-dimensional
    594     // reduction was computed and this one might have had cancellations when resubstituting;
     664    // if dd!=0 and the procedure was called without the
     665    // option findAll, then it might very well
     666    // be the case that no solution is found, since
     667    // only one solution for the zero-dimensional
     668    // reduction was computed and this one might have
     669    // had cancellations when resubstituting;
    595670    // if so we have to restart the process with the option findAll
    596671    if (size(liftrings)==0)
     
    599674      "The procedure will be restarted with the option 'findAll'.";
    600675      "Go on by hitting RETURN!";
    601       findall=1;
     676      findall=1;   
    602677      noabs=0;
    603678      setring CUTDOWNRING;
     
    605680      "i";i;
    606681      "ini";tInitialIdeal(i,w,1);
    607 
     682     
    608683/*
    609684      setring GRUNDRING;
     
    623698    }
    624699  }
    625   // if internally the option findall was set, then return only the first solution
     700  // if internally the option findall was set, then return
     701  // only the first solution
    626702  if (defined(hadproblems)!=0)
    627703  {
     
    631707  if (voice+printlevel>=2)
    632708  {
    633 
     709     
    634710      "The procedure has created a list of lists. The jth entry of this list
    635711contains a ring, an integer and an intvec.
    636712In this ring lives an ideal representing the wanted lifting,
    637713if the integer is N then in the parametrisation t has to be replaced by t^1/N,
    638 and if the ith component of the intvec is w[i] then the ith component in LIFT
     714and if the ith component of the intvec is w[i] then the ith component in LIFT 
    639715should be multiplied by t^-w[i]/N in order to get the parametrisation.
    640 
     716   
    641717Suppose your list has the name L, then you can access the 1st ring via:
    642718";
    643719    if (findall==1)
    644720    {
    645       "def LIFTRing=L[1][1]; setring LIFTRing; LIFT;
     721      "def LIFTRing=L[1][1]; setring LIFTRing; LIFT; 
    646722";
    647723    }
    648724    else
    649725    {
    650       "def LIFTRing=L[1]; setring LIFTRing; LIFT;
     726      "def LIFTRing=L[1]; setring LIFTRing; LIFT; 
    651727";
    652     }
     728    } 
    653729  }
    654730  if (findall==1) // if all solutions have been computed, return a list of lists
     
    656732    return(liftrings);
    657733  }
    658   else // if only one solution was to be computed, then return only the first list in liftrings
     734  else //if only 1 solution was to be computed, return the 1st list in liftrings
    659735  {
    660736    liftrings=liftrings[1];
     
    675751   def LIFTRing=LIST[1];
    676752   setring LIFTRing;
    677    // LIFT contains the first 4 terms of a point in the variety of i
     753   // LIFT contains the first 4 terms of a point in the variety of i 
    678754   // over the Puiseux series field C{{t}} whose order is -w[1]/w[0]=1
    679755   LIFT;
     
    703779   // NOTE: since the last component of v is positive, the lifting
    704780   //       must start with a negative power of t, which in Singular
    705    //       is not allowed for a variable.
     781   //       is not allowed for a variable. 
    706782   def LIFTRing3=LIST[1];
    707783   setring LIFTRing3;
     
    713789}
    714790
     791///////////////////////////////////////////////////////////////////////////////
     792
    715793proc displayTropicalLifting (list troplift,list #)
    716 "USAGE:      displaytropcallifting(troplift[,#]); troplift list, # list
    717 ASSUME:      troplift is the output of tropicalLifting; the optional parameter
    718              # can be the string 'subst'
    719 RETURN:      none
    720 NOTE:        - the procedure displays the output of the procedure tropicalLifting
    721 @*           - if the optional parameter 'subst' is given, then the lifting is
    722                substituted into the ideal and the result is displayed
    723 EXAMPLE:     example displayTropicalLifting;   shows an example"
     794"USAGE:    displaytropcallifting(troplift[,#]); troplift list, # list
     795ASSUME:    troplift is the output of tropicalLifting; the optional parameter
     796           # can be the string 'subst'
     797RETURN:    none
     798NOTE:      - the procedure displays the output of the procedure tropicalLifting
     799@*         - if the optional parameter 'subst' is given, then the lifting is
     800             substituted into the ideal and the result is displayed
     801EXAMPLE:   example displayTropicalLifting;   shows an example"
    724802{
    725803  int j;
     
    756834      string Kstring="Z/"+string(char(LIFTRing))+"Z";
    757835    }
    758     if (size(troplift)==4) // this means that tropicalLifting was called with absolute primary decomposition
    759     {
     836    // this means that tropicalLifting was called with
     837    // absolute primary decomposition
     838    if (size(troplift)==4)
     839    {     
    760840      setring LIFTRing;
    761841      "The lifting of the point in the tropical variety lives in the ring";
    762842      if ((size(LIFTpar)==0) and (N==1))
    763843      {
    764         Kstring+"[[t]]";
     844        Kstring+"[[t]]"; 
    765845      }
    766846      if ((size(LIFTpar)==0) and (N!=1))
    767847      {
    768         Kstring+"[[t^(1/"+string(N)+")]]";
     848        Kstring+"[[t^(1/"+string(N)+")]]"; 
    769849      }
    770850      if ((size(LIFTpar)!=0) and (N!=1))
    771       {
    772         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]";
     851      {   
     852        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t^(1/"+string(N)+")]]"; 
    773853      }
    774854      if ((size(LIFTpar)!=0) and (N==1))
    775       {
    776         Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]";
     855      {   
     856        Kstring+"["+LIFTpar+"]/"+string(minpoly)+"[[t]]"; 
    777857      }
    778858    }
     
    791871      }
    792872      if ((size(LIFTpar)!=0) and (N!=1))
    793       {
    794         Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]";
     873      {   
     874        Kstring+"["+LIFTpar+"]/M[[t^(1/"+string(N)+")]]"; 
    795875        "where M is the maximal ideal";
    796876        "M=<"+m+">";
    797877      }
    798878      if ((size(LIFTpar)!=0) and (N==1))
    799       {
    800         Kstring+"["+LIFTpar+"]/M[[t]]";
     879      {   
     880        Kstring+"["+LIFTpar+"]/M[[t]]"; 
    801881        "where M is the maximal ideal";
    802882        "M=<"+m+">";
    803       }
     883      }     
    804884    }
    805885    "";
     
    828908      }
    829909    }
    830   }
     910  }     
    831911}
    832912example
     
    841921
    842922
    843 ////////////////////////////////////////////////////////////////////////////////////
    844 /// Procedures concerned with drawing a tropical curve or a Newton subdivision
    845 ////////////////////////////////////////////////////////////////////////////////////
     923///////////////////////////////////////////////////////////////////////////////
     924/// Procedures concerned with drawing a tropical curve or a Newton subdivision
     925///////////////////////////////////////////////////////////////////////////////
     926
    846927proc tropicalCurve (def tp,list #)
    847928"USAGE:      tropicalCurve(tp[,#]); tp list, # optional list
    848 ASSUME:      tp is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
    849              representing a tropical Laurent polynomial defining a tropical plane curve;
    850              alternatively tp can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    851              via the valuation map;
    852              the basering must have a global monomial ordering, two variables and up to one parameter!
    853 RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex in the tropical plane
    854                    curve defined by tp
     929ASSUME:      tp is list of linear polynomials of the form ax+by+c
     930             with integers a, b and a rational number c representing
     931             a tropical Laurent polynomial defining a tropical plane curve;
     932             alternatively tp can be a polynomial in Q(t)[x,y] defining a
     933             tropical plane curve via the valuation map;
     934             the basering must have a global monomial ordering,
     935             two variables and up to one parameter!
     936RETURN:      list, each entry i=1,...,size(l)-1 corresponds to a vertex
     937                   in the tropical plane curve defined by tp
    855938                   l[i][1] = x-coordinate of the ith vertex
    856939                   l[i][2] = y-coordinate of the ith vertex
    857                    l[i][3] = intmat, if j is an entry in the first row of intmat then the ith vertex of
    858                              the tropical curve is connected to the jth vertex with multiplicity given
     940                   l[i][3] = intmat, if j is an entry in the first row
     941                             of intmat then the ith vertex of
     942                             the tropical curve is connected to the
     943                             jth vertex with multiplicity given
    859944                             by the corresponding entry in the second row
    860                    l[i][4] = list of lists, the first entry of a list is a primitive integer vector
    861                              defining the direction of an unbounded edge emerging from the ith vertex
    862                              of the graph, the corresponding second entry in the list is the multiplicity
    863                              of the unbounded edge
    864                    l[i][5] = a polynomial whose monomials mark the vertices in the Newton polygon
    865                              corresponding to the entries in tp which take the common minimum
    866                              at the ith vertex -- if some coefficient a or b of the linear polynomials
    867                              in the input was negative, then each monomial has to be shifted by
     945                   l[i][4] = list of lists, the first entry of a list is
     946                             a primitive integer vector defining the direction
     947                             of an unbounded edge emerging from the ith vertex
     948                             of the graph, the corresponding second entry in
     949                             the list is the multiplicity of the unbounded edge
     950                   l[i][5] = a polynomial whose monomials mark the vertices
     951                             in the Newton polygon corresponding to the entries
     952                             in tp which take the common minimum at the ith
     953                             vertex -- if some coefficient a or b of the
     954                             linear polynomials in the input was negative,
     955                             then each monomial has to be shifted by
    868956                             the values in l[size(l)][3]
    869                    l[size(l)][1] = list, the entries describe the boundary points of the Newton subdivision
    870                    l[size(l)][2] = list, the entries are pairs of integer vectors defining an interior
    871                                    edge of the Newton subdivision
    872                    l[size(l)][3] = intvec, the monmials occuring in l[i][5] have to be shifted by this
    873                                    vector in order to represent marked vertices in the Newton polygon
    874 NOTE:        here the tropical polynomial is supposed to be the MINIMUM of the linear forms in tp,
    875              unless the optional input #[1] is the string 'max'
     957                   l[size(l)][1] = list, the entries describe the boundary
     958                                         points of the Newton subdivision
     959                   l[size(l)][2] = list, the entries are pairs of integer
     960                                         vectors defining an interior
     961                                         edge of the Newton subdivision
     962                   l[size(l)][3] = intvec, the monmials occuring in l[i][5]
     963                                           have to be shifted by this vector
     964                                           in order to represent marked
     965                                           vertices in the Newton polygon
     966NOTE:        here the tropical polynomial is supposed to be the MINIMUM
     967             of the linear forms in tp, unless the optional input #[1]
     968             is the string 'max'
    876969EXAMPLE:     example tropicalCurve;   shows an example"
    877970{
     
    885978    ERROR("The basering should have a global monomial ordering, e.g. ring r=(0,t),(x,y),dp;");
    886979  }
    887   // if you insert a single polynomial instead of an ideal representing a tropicalised polynomial,
    888   // then we compute first the tropicalisation of this polynomial -- this feature is not
    889   // documented in the above help string
     980  // if you insert a single polynomial instead of an ideal
     981  // representing a tropicalised polynomial,
     982  // then we compute first the tropicalisation of this polynomial
     983  // -- this feature is not documented in the above help string
    890984  if (typeof(tp)=="poly")
    891985  {
    892     // exclude the case that the basering has not precisely one parameter and two indeterminates
     986    // exclude the case that the basering has not precisely
     987    // one parameter and two indeterminates
    893988    if ((npars(basering)!=1) or (nvars(basering)!=2))
    894989    {
    895       ERROR("The basering should have precisely one parameter and two indeterminates!");
     990      ERROR("The basering should have precisely one parameter and two indeterminates!");     
    896991    }
    897992    poly f=tp;
     
    902997  if (nvars(basering) != 2)
    903998  {
    904     ERROR("The basering should have precisely two indeterminates!");
    905   }
    906   // -1) Exclude the pathological case that the defining tropical polynomial has only one term,
    907   //    so that the tropical variety is not defined.
     999    ERROR("The basering should have precisely two indeterminates!");     
     1000  }
     1001  // -1) Exclude the pathological case that the defining
     1002  //     tropical polynomial has only one term,
     1003  //     so that the tropical variety is not defined.
    9081004  if (size(tp)==1)
    9091005  {
     
    9111007    intmat M[2][1]=0,0;
    9121008    return(list(list(0,0,M,list(),detropicalise(tp[1])),list(list(leadexp(detropicalise(tp[1]))),list())));
    913   }
    914   // 0) If the input was a list of linear polynomials, then some coefficient of x or y can be negative,
    915   //    i.e. the input corresponds to the tropical curve of a Laurent polynomial. In that case we should
    916   //    add some ax+by, so that all coefficients are positive. This does not change the tropical curve.
    917   //    however, we have to save (a,b), since the Newton polygone has to be shifted by (-a,-b).
     1009  }   
     1010  // 0) If the input was a list of linear polynomials,
     1011  //    then some coefficient of x or y can be negative,
     1012  //    i.e. the input corresponds to the tropical curve
     1013  //    of a Laurent polynomial. In that case we should
     1014  //    add some ax+by, so that all coefficients are positive.
     1015  //    This does not change the tropical curve.
     1016  //    however, we have to save (a,b), since the Newton
     1017  //    polygone has to be shifted by (-a,-b).
    9181018  poly aa,bb; // koeffizienten
    9191019  for (i=1;i<=size(tp);i++)
     
    9261026    {
    9271027      bb=koeffizienten(tp[i],2);
    928     }
     1028    }   
    9291029  }
    9301030  if ((aa!=0) or (bb!=0))
     
    9351035    }
    9361036  }
    937   // 1) compute the vertices of the tropical curve defined by tp and the Newton subdivision
     1037  // 1) compute the vertices of the tropical curve
     1038  //    defined by tp and the Newton subdivision
    9381039  list vtp=verticesTropicalCurve(tp,#);
    939   //    if vtp is empty, then the Newton polygone is just a line segment and constitutes a bunch of lines
     1040  //    if vtp is empty, then the Newton polygone is just
     1041  //    a line segment and constitutes a bunch of lines
    9401042  //    which can be computed by bunchOfLines
    9411043  if (size(vtp)==0)
     
    9431045    return(bunchOfLines(tp));
    9441046  }
    945   // 2) store all vertices belonging to the ith part of the
     1047  // 2) store all vertices belonging to the ith part of the 
    9461048  //    Newton subdivision in the list vtp[i] as 4th entry,
    9471049  //    and store those, which are not corners of the ith subdivision polygon
    9481050  //    in vtp[i][6]
    949   poly nwt;
     1051  poly nwt; 
    9501052  list boundaryNSD;  // stores the boundary of a Newton subdivision
    951   intmat zwsp[2][1]; // used for intermediate storage
     1053  intmat zwsp[2][1]; // used for intermediate storage   
    9521054  for (i=1;i<=size(vtp);i++)
    9531055  {
    9541056    k=1;
    955     nwt=vtp[i][3]; // the polynomial representing the ith part of the Newton subdivision
    956     // store the vertices of the ith part of the Newton subdivision in the list newton
    957     list newton;
     1057    nwt=vtp[i][3]; // the polynomial representing the
     1058    // ith part of the Newton subdivision
     1059    // store the vertices of the ith part of the
     1060    // Newton subdivision in the list newton
     1061    list newton; 
    9581062    while (nwt!=0)
    9591063    {
     
    9621066      k++;
    9631067    }
    964     boundaryNSD=findOrientedBoundary(newton);// a list of the vertices of the Newton subdivision as integer vectors (only those on the boundary, and oriented clockwise)
     1068    boundaryNSD=findOrientedBoundary(newton);// a list of the vertices
     1069                                             // of the Newton subdivision
     1070                                             // as integer vectors (only those
     1071                                             // on the boundary, and oriented
     1072                                             // clockwise)
    9651073    vtp[i][4]=boundaryNSD[1];
    9661074    vtp[i][5]=boundaryNSD[2];
    967     vtp[i][6]=zwsp; // the entries of the first row will denote to which vertex the ith one is connected
    968                  // and the entries of the second row will denote with which multiplicity
     1075    vtp[i][6]=zwsp; // the entries of the first row will denote to which
     1076                    // vertex the ith one is connected
     1077                    // and the entries of the second row will denote
     1078                    //with which multiplicity
    9691079    kill newton; // we kill the superflous list
    9701080  }
    971   // 3) Next we build for each part of the Newton subdivision the list of all pairs of vertices on the
     1081  // 3) Next we build for each part of the Newton
     1082  //    subdivision the list of all pairs of vertices on the
    9721083  //    boundary, which are involved, including those which are not corners
    9731084  list pairs,pair;
     
    9851096    kill ipairs;
    9861097  }
    987   // 4) Check for all pairs of verticies in the Newton diagram if they
     1098  // 4) Check for all pairs of verticies in the Newton diagram if they 
    9881099  //    occur in two different parts of the Newton subdivision
    989   int deleted; // if a pair occurs in two NSD, it can be removed from both - deleted is then set to 1
    990   list inneredges; // contains the list of all pairs contained in two NSD - these are inner the edges of NSD
     1100  int deleted; // if a pair occurs in two NSD, it can be removed
     1101               // from both - deleted is then set to 1
     1102  list inneredges; // contains the list of all pairs contained in two NSD
     1103                   // - these are inner the edges of NSD
    9911104  int ggt;
    9921105  d=1;  // counts the inner edges
    9931106  for (i=1;i<=size(pairs)-1;i++)
    994   {
     1107  { 
    9951108    for (j=i+1;j<=size(pairs);j++)
    9961109    {
     
    9991112        deleted=0;
    10001113        for (l=size(pairs[j]);l>=1 and deleted==0;l--)
    1001         {
     1114        { 
    10021115          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])))
    10031116          {
    1004             inneredges[d]=pairs[i][k];  // the new inner edge is saved in inneredges,
     1117            inneredges[d]=pairs[i][k];  // new inner edge is saved in inneredges
    10051118            d++;
    10061119            ggt=abs(gcd(pairs[i][k][1][1]-pairs[i][k][2][1],pairs[i][k][1][2]-pairs[i][k][2][2]));
    1007             zwsp=j,ggt;   // and it is recorded that the ith and jth vertex should be connected with mult ggt
     1120            zwsp=j,ggt;   // and it is recorded that the ith and jth
     1121                          // vertex should be connected with mult ggt
    10081122            vtp[i][6]=intmatconcat(vtp[i][6],zwsp);
    10091123            zwsp=i,ggt;
    10101124            vtp[j][6]=intmatconcat(vtp[j][6],zwsp);
    1011             pairs[i]=delete(pairs[i],k);  // finally the pair is deleted from both sets of pairs
     1125            pairs[i]=delete(pairs[i],k);  // finally the pair is deleted
     1126                                          // from both sets of pairs
    10121127            pairs[j]=delete(pairs[j],l);
    10131128            deleted=1;
     
    10171132    }
    10181133  }
    1019   // 5) The entries in vtp[i][6] are ordered, multiple entries are removed, and the
    1020   //    redundant zero is removed as well
     1134  // 5) The entries in vtp[i][6] are ordered, multiple entries are removed,
     1135  //    and the redundant zero is removed as well
    10211136  for (i=1;i<=size(vtp);i++)
    10221137  {
     
    10481163    }
    10491164  }
    1050   // 6.3) Order the vertices such that passing from one to the next we travel along
    1051   //      the boundary of the Newton polytope clock wise.
     1165  // 6.3) Order the vertices such that passing from one to the next we
     1166  //      travel along the boundary of the Newton polytope clock wise.
    10521167  boundaryNSD=findOrientedBoundary(vertices);
    10531168  list orderedvertices=boundaryNSD[1];
    10541169  // 7) Find the unbounded edges emerging from a vertex in the tropical curve.
    1055   //    For this we check the remaining pairs for the ith NSD. Each pair is ordered according
    1056   //    to the order in which the vertices occur in orderedvertices. The direction of the
    1057   //    unbounded edge is then the outward pointing primitive normal vector to the vector
     1170  //    For this we check the remaining pairs for the ith NSD.
     1171  //    Each pair is ordered according
     1172  //    to the order in which the vertices occur in orderedvertices.
     1173  //    The direction of the
     1174  //    unbounded edge is then the outward pointing primitive normal
     1175  //    vector to the vector
    10581176  //    pointing from the first vertex in a pair to the second one.
    10591177  intvec normalvector;  // stores the outward pointing normal vector
    10601178  intvec zwspp; // used for intermediate storage
    1061   int zw,pos1,pos2; // stores the gcd of entries of the non-normalised normal vector, etc.
     1179  int zw,pos1,pos2; // stores the gcd of entries of the
     1180                    // non-normalised normal vector, etc.
    10621181  int gestorben; // tests if unbounded edges are multiple
    10631182  for (i=1;i<=size(pairs);i++)
    10641183  {
    1065     list ubedges; // stores the unbounded edges
     1184    list ubedges; // stores the unbounded edges 
    10661185    k=1; // counts the unbounded edges
    10671186    for (j=1;j<=size(pairs[i]);j++)
    10681187    {
    1069       pos1=positionInList(orderedvertices,pairs[i][j][1]); // computes the position of the vertices in the
    1070       pos2=positionInList(orderedvertices,pairs[i][j][2]); // pair in the list orderedvertices
     1188      // computes the position of the vertices in the
     1189      pos1=positionInList(orderedvertices,pairs[i][j][1]);
     1190      // pair in the list orderedvertices
     1191      pos2=positionInList(orderedvertices,pairs[i][j][2]);
    10711192      if (((pos1>pos2) and !((pos1==size(orderedvertices)) and (pos2==1))) or ((pos2==size(orderedvertices)) and (pos1==1)))  // reorders them if necessary
    10721193      {
     
    10751196        pairs[i][j][2]=zwspp;
    10761197      }
    1077       normalvector=pairs[i][j][2]-pairs[i][j][1]; // the vector pointing from vertex 1 in the pair to vertex2
     1198      // the vector pointing from vertex 1 in the pair to vertex2
     1199      normalvector=pairs[i][j][2]-pairs[i][j][1];
    10781200      ggt=gcd(normalvector[1],normalvector[2]);   // the gcd of the entries
    1079       zw=normalvector[2];                         // create the outward pointing normal vector
     1201      zw=normalvector[2];    // create the outward pointing normal vector
    10801202      normalvector[2]=-normalvector[1]/ggt;
    10811203      normalvector[1]=zw/ggt;
    10821204      if (size(#)==0) // we are computing w.r.t. minimum
    10831205      {
    1084         ubedges[k]=list(normalvector,ggt); // store the outward pointing normal vector
     1206        ubedges[k]=list(normalvector,ggt); // store outward pointing normal vec.
    10851207      }
    10861208      else // we are computing w.r.t. maximum
    10871209      {
    1088         ubedges[k]=list(-normalvector,ggt); // store the outward pointing normal vector
     1210        ubedges[k]=list(-normalvector,ggt); //store outward pointing normal vec.
    10891211      }
    10901212      k++;
     
    11071229    kill ubedges;
    11081230  }
    1109   // 8) Store the computed information for the ith part of the NSD in the list graph[i].
     1231  // 8) Store the computed information for the ith part
     1232  //    of the NSD in the list graph[i].
    11101233  list graph,gr;
    11111234  for (i=1;i<=size(vtp);i++)
    11121235  {
    1113     gr[1]=vtp[i][1];  // the first coordinate of the ith vertex of the tropical curve
    1114     gr[2]=vtp[i][2];  // the second coordinate of the ith vertex of the tropical curve
    1115     gr[3]=vtp[i][6];  // to which vertices is the ith vertex of the tropical curve connected
    1116     gr[4]=vtp[i][7];  // the directions unbounded edges emerging from the ith vertex of the trop. curve
    1117     gr[5]=vtp[i][3];  // the vertices of the boundary of the ith part of the NSD
     1236    // the first coordinate of the ith vertex of the tropical curve
     1237    gr[1]=vtp[i][1]; 
     1238    // the second coordinate of the ith vertex of the tropical curve
     1239    gr[2]=vtp[i][2]; 
     1240    // to which vertices is the ith vertex of the tropical curve connected
     1241    gr[3]=vtp[i][6]; 
     1242    // the directions unbounded edges emerging from the ith
     1243    // vertex of the trop. curve
     1244    gr[4]=vtp[i][7]; 
     1245    // the vertices of the boundary of the ith part of the NSD
     1246    gr[5]=vtp[i][3]; 
    11181247    graph[i]=gr;
    11191248  }
     
    11341263    }
    11351264  }
    1136   // 10) Finally store the boundary vertices and the inner edges as last entry in the list graph.
     1265  // 10) Finally store the boundary vertices and
     1266  //     the inner edges as last entry in the list graph.
    11371267  //     This represents the NSD.
    11381268  graph[size(vtp)+1]=list(boundaryNSD[2],inneredges,shiftvector);
     
    11501280// the coordinates of the first vertex are graph[1][1],graph[1][2];
    11511281   graph[1][1],graph[1][2];
    1152 // the first vertex is connected to the vertices
     1282// the first vertex is connected to the vertices 
    11531283//     graph[1][3][1,1..ncols(graph[1][3])]
    11541284   intmat M=graph[1][3];
    11551285   M[1,1..ncols(graph[1][3])];
    1156 // the weights of the edges to these vertices are
     1286// the weights of the edges to these vertices are 
    11571287//     graph[1][3][2,1..ncols(graph[1][3])]
    11581288   M[2,1..ncols(graph[1][3])];
    11591289// from the first vertex emerge size(graph[1][4]) unbounded edges
    11601290   size(graph[1][4]);
    1161 // the primitive integral direction vector of the first unbounded edge
     1291// the primitive integral direction vector of the first unbounded edge 
    11621292//     of the first vertex
    11631293   graph[1][4][1][1];
    11641294// the weight of the first unbounded edge of the first vertex
    11651295   graph[1][4][1][2];
    1166 // the monomials which are part of the Newton subdivision of the first vertex
     1296// the monomials which are part of the Newton subdivision of the first vertex 
    11671297   graph[1][5];
    1168 // connecting the points in graph[size(graph)][1] we get
     1298// connecting the points in graph[size(graph)][1] we get 
    11691299//     the boundary of the Newton polytope
    11701300   graph[size(graph)][1];
    1171 // an entry in graph[size(graph)][2] is a pair of points
     1301// an entry in graph[size(graph)][2] is a pair of points 
    11721302//     in the Newton polytope bounding an inner edge
    11731303   graph[size(graph)][2][1];
    11741304}
    11751305
     1306/////////////////////////////////////////////////////////////////////////
     1307
    11761308proc drawTropicalCurve (def f,list #)
    11771309"USAGE:      drawTropicalCurve(f[,#]); f poly or list, # optional list
    1178 ASSUME:      f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
    1179              representing a tropical Laurent polynomial defining a tropical plane curve;
    1180              alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    1181              via the valuation map;
    1182              the basering must have a global monomial ordering, two variables and up to one parameter!
     1310ASSUME:      f is list of linear polynomials of the form ax+by+c with
     1311             integers a, b and a rational number c representing a tropical
     1312             Laurent polynomial defining a tropical plane curve;
     1313             alternatively f can be a polynomial in Q(t)[x,y] defining
     1314             a tropical plane curve via the valuation map;
     1315             the basering must have a global monomial ordering, two
     1316             variables and up to one parameter!
    11831317RETURN:      NONE
    1184 NOTE:        - the procedure produces the files /tmp/tropicalcurveNUMBER.tex and
    1185                /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four digit integer;
    1186                moreover it displays the tropical curve defined by f via kghostview;
    1187                if you wish to remove all these files from /tmp, call the procedure cleanTmp
     1318NOTE:        - the procedure produces the files /tmp/tropicalcurveNUMBER.tex and
     1319               /tmp/tropicalcurveNUMBER.ps, where NUMBER is a random four
     1320               digit integer;
     1321               moreover it displays the tropical curve via kghostview;
     1322               if you wish to remove all these files from /tmp,
     1323               call the procedure cleanTmp
    11881324@*           - edges with multiplicity greater than one carry this multiplicity
    1189 @*           - if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the
    1190                string 'max', then it is computed w.r.t. maximum
    1191 @*           - if the last optional argument is 'onlytexfile' then only the latex file
    1192                is produced; this option should be used if kghostview is not installed on
    1193                your system
    1194 @*           - note that lattice points in the Newton subdivision which are black correspond to markings
    1195                of the marked subdivision, while lattice points in grey are not marked
     1325@*           - if # is empty, then the tropical curve is computed w.r.t. minimum,
     1326               if #[1] is the string 'max', then it is computed w.r.t. maximum
     1327@*           - if the last optional argument is 'onlytexfile' then only the
     1328               latex file is produced; this option should be used if kghostview
     1329               is not installed on your system
     1330@*           - note that lattice points in the Newton subdivision which are
     1331               black correspond to markings of the marked subdivision,
     1332               while lattice points in grey are not marked
    11961333EXAMPLE:     example drawTropicalCurve  shows an example"
    11971334{
    1198   // check if the option "onlytexfile" is set, so that only a tex file is produced
     1335  // check if the option "onlytexfile" is set, then only a tex file is produced
    11991336  if (size(#)!=0)
    12001337  {
     
    12101347  if (typeof(f)=="poly")
    12111348  {
    1212     // exclude the case that the basering has not precisely one parameter and two indeterminates
     1349    // exclude the case that the basering has not precisely
     1350    // one parameter and two indeterminates
    12131351    if ((npars(basering)!=1) or (nvars(basering)!=2))
    12141352    {
    1215       ERROR("The basering should have precisely one parameter and two indeterminates!");
     1353      ERROR("The basering should have precisely one parameter and two indeterminates!");     
    12161354    }
    12171355    texf=texPolynomial(f); // write the polynomial over Q(t)
    1218     list graph=tropicalCurve(tropicalise(f,#),#); // the graph of the tropicalisation of f
     1356    list graph=tropicalCurve(tropicalise(f,#),#); // graph of tropicalis. of f
    12191357  }
    12201358  if (typeof(f)=="list")
     
    12241362      texf="\\mbox{\\tt The defining equation was not handed over!}";
    12251363      list graph=f;
    1226     }
     1364    }   
    12271365    else
    12281366    { // write the tropical polynomial defined by f
    12291367      if (size(#)==0)
    1230       {
     1368      {     
    12311369        texf="\\min\\{";
    12321370      }
     
    12371375      for (j=1;j<=size(f);j++)
    12381376      {
    1239         texf=texf+texPolynomial(f[j]);
     1377        texf=texf+texPolynomial(f[j]);   
    12401378        if (j<size(f))
    12411379        {
     
    12461384          texf=texf+"\\}";
    12471385        }
    1248       }
     1386      }   
    12491387      list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    12501388    }
     
    12641402\\addtolength{\\topmargin}{-\\headheight}
    12651403\\addtolength{\\topmargin}{-\\topskip}
    1266 \\setlength{\\textheight}{267mm}
     1404\\setlength{\\textheight}{267mm} 
    12671405\\addtolength{\\textheight}{\\topskip}
    12681406\\addtolength{\\textheight}{-\\footskip}
    12691407\\addtolength{\\textheight}{-30pt}
    1270 \\setlength{\\oddsidemargin}{-1in}
     1408\\setlength{\\oddsidemargin}{-1in} 
    12711409\\addtolength{\\oddsidemargin}{20mm}
    12721410\\setlength{\\evensidemargin}{\\oddsidemargin}
    1273 \\setlength{\\textwidth}{170mm}
     1411\\setlength{\\textwidth}{170mm} 
    12741412
    12751413\\begin{document}
    12761414   \\parindent0cm
    12771415   \\begin{center}
    1278       \\large\\bf The Tropicalisation of
     1416      \\large\\bf The Tropicalisation of 
    12791417
    12801418      \\bigskip
     
    13001438
    13011439   \\begin{center}
    1302        "+texDrawNewtonSubdivision(graph,#)+"
     1440       "+texDrawNewtonSubdivision(graph,#)+" 
    13031441   \\end{center}
    13041442\\end{document}";
     
    13071445    int rdnum=random(1000,9999);
    13081446    write(":w /tmp/tropicalcurve"+string(rdnum)+".tex",TEXBILD);
    1309     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 &");
     1447    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 &"); 
    13101448  }
    13111449  else
     
    13241462   drawTropicalCurve(f);
    13251463// we can instead apply the procedure to a tropical polynomial and use "maximum"
    1326    poly g=t3*(x7+y7+1)+1/t3*(x4+y4+x2+y2+x3y+xy3)+1/t21*x2y2;
     1464   poly g=1/t3*(x7+y7+1)+t3*(x4+y4+x2+y2+x3y+xy3)+t21*x2y2;
    13271465   list tropical_g=tropicalise(g);
    13281466   tropical_g;
     
    13301468}
    13311469
     1470/////////////////////////////////////////////////////////////////////////
     1471
    13321472proc drawNewtonSubdivision (def f,list #)
    13331473"USAGE:   drawTropicalCurve(f[,#]); f poly, # optional list
    1334 ASSUME:   f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
    1335           representing a tropical Laurent polynomial defining a tropical plane curve;
    1336           alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    1337           via the valuation map;
    1338           the basering must have a global monomial ordering, two variables and up to one parameter!
     1474ASSUME:   f is list of linear polynomials of the form ax+by+c with integers
     1475          a, b and a rational number c representing a tropical Laurent
     1476          polynomial defining a tropical plane curve;
     1477          alternatively f can be a polynomial in Q(t)[x,y] defining a tropical
     1478          plane curve via the valuation map;
     1479          the basering must have a global monomial ordering, two variables
     1480          and up to one parameter!
    13391481RETURN:   NONE
    1340 NOTE:     - the procedure produces the files /tmp/newtonsubdivisionNUMBER.tex,
    1341             and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random four digit integer;
     1482NOTE:     - the procedure produces the files /tmp/newtonsubdivisionNUMBER.tex,
     1483            and /tmp/newtonsubdivisionNUMBER.ps, where NUMBER is a random
     1484            four digit integer;
    13421485            moreover it desplays the tropical curve defined by f via kghostview;
    1343             if you wish to remove all these files from /tmp, call the procedure cleanTmp
    1344 @*          if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the
    1345             string 'max', then it is computed w.r.t. maximum
    1346 @*        - note that lattice points in the Newton subdivision which are black correspond to markings
    1347             of the marked subdivision, while lattice points in grey are not marked
     1486            if you wish to remove all these files from /tmp, call the procedure
     1487            cleanTmp;
     1488@*          if # is empty, then the tropical curve is computed w.r.t. minimum,
     1489            if #[1] is the string 'max', then it is computed w.r.t. maximum
     1490@*        - note that lattice points in the Newton subdivision which are black
     1491            correspond to markings of the marked subdivision, while lattice
     1492            points in grey are not marked
    13481493EXAMPLE:     example drawNewtonSubdivision;   shows an example"
    13491494{
     
    13531498  {
    13541499    texf=texPolynomial(f); // write the polynomial over Q(t)
    1355     list graph=tropicalCurve(tropicalise(f,#),#); // the graph of the tropicalisation of f
     1500    list graph=tropicalCurve(tropicalise(f,#),#); // graph of tropicalis. of f
    13561501  }
    13571502  else
    13581503  { // write the tropical polynomial defined by f
    13591504    if (size(#)==0)
    1360     {
     1505    {     
    13611506      texf="\\min\\{";
    13621507    }
     
    13671512    for (j=1;j<=size(f);j++)
    13681513    {
    1369       texf=texf+texPolynomial(f[j]);
     1514      texf=texf+texPolynomial(f[j]);   
    13701515      if (j<size(f))
    13711516      {
     
    13761521        texf=texf+"\\}";
    13771522      }
    1378     }
     1523    }   
    13791524    list graph=tropicalCurve(f,#); // the graph of the tropical polynomial f
    13801525  }
     
    13841529   \\parindent0cm
    13851530   \\begin{center}
    1386       \\large\\bf The Newtonsubdivison of
     1531      \\large\\bf The Newtonsubdivison of 
    13871532      \\begin{displaymath}
    13881533          f="+texf+"
     
    13921537
    13931538   \\begin{center}
    1394 "+texDrawNewtonSubdivision(graph)+
     1539"+texDrawNewtonSubdivision(graph)+ 
    13951540"   \\end{center}
    13961541
     
    13981543  int rdnum=random(1000,9999);
    13991544  write(":w /tmp/newtonsubdivision"+string(rdnum)+".tex",TEXBILD);
    1400   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 &");
     1545  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 &"); 
    14011546//  return(TEXBILD);
    14021547}
     
    14171562}
    14181563
    1419 ////////////////////////////////////////////////////////////////////////////////////
     1564///////////////////////////////////////////////////////////////////////////////
    14201565/// Procedures concerned with cubics
    1421 ////////////////////////////////////////////////////////////////////////////////////
     1566///////////////////////////////////////////////////////////////////////////////
    14221567
    14231568proc tropicalJInvariant (def f,list #)
    14241569"USAGE:      tropicalJInvariant(f[,#]); f poly or list, # optional list
    1425 ASSUME:      f is list of linear polynomials of the form ax+by+c with integers a, b and a rational number c
    1426              representing a tropical Laurent polynomial defining a tropical plane curve;
    1427              alternatively f can be a polynomial in Q(t)[x,y] defining a tropical plane curve
    1428              via the valuation map;
    1429 @*           the basering must have a global monomial ordering, two variables and up to one parameter!
    1430 RETURN:      number, if the graph underlying the tropical curve has precisely one loop then its weighted
    1431                      lattice length is returned, otherwise the result will be -1
    1432 NOTE:        - if the tropical curve is elliptic and its embedded graph has precisely one loop,
    1433                then the weigthed lattice length of the loop is its tropical j-invariant
    1434 @*           - the procedure checks if the embedded graph of the tropical curve has genus one,
    1435                but it does NOT check if the loop can be resolved, so that the curve is not
    1436                a proper tropical elliptic curve
    1437 @*           - if the embedded graph of a tropical elliptic curve has more than one loop, then
    1438                all but one can be resolved, but this is not observed by this procedure, so it
    1439                will not compute the j-invariant
    1440 @*           - if # is empty, then the tropical curve is computed w.r.t. minimum, if #[1] is the
    1441                string 'max', then it is computed w.r.t. maximum
    1442 @*           - the tropicalJInvariant of a plane tropical cubic is the 'cycle length' of the
    1443                cubic as introduced in the paper:
    1444                Erik Katz, Hannah Markwig, Thomas Markwig: The j-invariant of a cubic tropical plane curve.
     1570ASSUME:      f is list of linear polynomials of the form ax+by+c with integers
     1571             a, b and a rational number c representing a tropical Laurent
     1572             polynomial defining a tropical plane curve;
     1573             alternatively f can be a polynomial in Q(t)[x,y] defining a
     1574             tropical plane curve via the valuation map;
     1575@*           the basering must have a global monomial ordering, two variables
     1576             and up to one parameter!
     1577RETURN:      number, if the graph underlying the tropical curve has precisely
     1578                     one loop then its weighted lattice length is returned,
     1579                     otherwise the result will be -1
     1580NOTE:        - if the tropical curve is elliptic and its embedded graph has
     1581               precisely one loop, then the weigthed lattice length of
     1582               the loop is its tropical j-invariant
     1583@*           - the procedure checks if the embedded graph of the tropical
     1584               curve has genus one, but it does NOT check if the loop can
     1585               be resolved, so that the curve is not a proper tropical
     1586               elliptic curve
     1587@*           - if the embedded graph of a tropical elliptic curve has more
     1588               than one loop, then all but one can be resolved, but this is
     1589               not observed by this procedure, so it will not compute
     1590               the j-invariant
     1591@*           - if # is empty, then the tropical curve is computed w.r.t. minimum,
     1592               if #[1] is the string 'max', then it is computed w.r.t. maximum
     1593@*           - the tropicalJInvariant of a plane tropical cubic is the
     1594               'cycle length' of the cubic as introduced in the paper:
     1595               Eric Katz, Hannah Markwig, Thomas Markwig: The j-invariant
     1596               of a cubic tropical plane curve.
    14451597EXAMPLE:     example tropicalJInvariant;   shows an example"
    14461598{
     
    14551607    {
    14561608      if (typeof(f[1])=="list")
    1457       {
     1609      {       
    14581610        list graph=f;
    14591611      }
     
    14671619        {
    14681620          ERROR("This is no valid input.");
    1469         }
     1621        }       
    14701622      }
    14711623    }
     
    14841636  genus=-genus/2; // we have counted each bounded edge twice
    14851637  genus=genus+size(graph); // the genus is 1-#bounded_edges+#vertices
    1486   // 3) if the embedded graph has not genus one, we cannot compute the j-invariant
     1638  // 3) if the embedded graph has not genus one,
     1639  //    we cannot compute the j-invariant
    14871640  if(genus!=1)
    14881641  {
     
    14951648  else
    14961649  {
    1497     intmat nullmat[2][1];  // used to set
    1498     // 4) find a vertex which has only one bounded edge, if none exists zero is returned,
     1650    intmat nullmat[2][1];  // used to set
     1651    // 4) find a vertex which has only one bounded edge,
     1652    //    if none exists zero is returned,
    14991653    //    otherwise the number of the vertex in the list graph
    1500     int nonloopvertex=findNonLoopVertex(graph);
    1501     int dv; // checks if the vertex has been found to which the nonloopvertex is connected
    1502     intmat delvert; // takes for a moment graph[i][3] of the vertex to which nonloopvertex is connected
    1503     // 5) delete successively vertices in the graph which have only one bounded edge
     1654    int nonloopvertex=findNonLoopVertex(graph);   
     1655    int dv; //checks if vert. has been found to which nonloopvertex is connected
     1656    intmat delvert; // takes for a moment graph[i][3] of the vertex
     1657                    // to which nonloopvertex is connected
     1658    // 5) delete successively vertices in the graph which
     1659    //    have only one bounded edge
    15041660    while (nonloopvertex>0)
    15051661    {
    1506       // find the only vertex to which the nonloopvertex is connected, when it is found
     1662      // find the only vertex to which the nonloopvertex
     1663      // is connected, when it is found
    15071664      // delete the connection in graph[i][3] and set dv=1
    15081665      dv=0;
     
    15161673            {
    15171674              delvert=graph[i][3];
    1518               delvert=intmatcoldelete(delvert,j); // delete the connection (note, there must have been two!)
     1675              delvert=intmatcoldelete(delvert,j); // delete the connection (note
     1676                                                  // there must have been two!)
    15191677              dv=1;
    15201678              graph[i][3]=delvert;
     
    15231681        }
    15241682      }
    1525       graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex is killed
    1526       nonloopvertex=findNonLoopVertex(graph); // find the next vertex which has only one edge
     1683      graph[nonloopvertex][3]=nullmat; // the only connection of nonloopvertex
     1684                                       // is killed
     1685      nonloopvertex=findNonLoopVertex(graph); // find the next vertex
     1686                                              // which has only one edge
    15271687    }
    15281688    // 6) find the loop and the weights of the edges
    15291689    intvec loop,weights; // encodes the loop and the edges
    15301690    i=1;
    1531     //    start by finding some vertex which belongs to the loop
    1532     while (loop==0)
    1533     {
    1534       if (ncols(graph[i][3])==1) // the graph[i][3] of a vertex in the loop has 2 columns, all others have 1
     1691    //    start by finding some vertex which belongs to the loop
     1692    while (loop==0)
     1693    {
     1694      // if graph[i][3] of a vertex in the loop has 2 columns, all others have 1
     1695      if (ncols(graph[i][3])==1)
    15351696      {
    15361697        i++;
     
    15381699      else
    15391700      {
    1540         loop[1]=i; // a starting vertex is found
    1541         loop[2]=graph[i][3][1,1]; // it is connected to the vertex with this number
     1701        loop[1]=i; // a starting vertex is found 
     1702        loop[2]=graph[i][3][1,1]; // it is connected to vertex with this number
    15421703        weights[2]=graph[i][3][2,1]; // and the edge has this weight
    15431704      }
     
    15471708    while (j!=i)  // the loop ends with the same vertex with which it starts
    15481709    {
    1549       // the first row of graph[j][3] has two entries corresponding to the two vertices
    1550       // to which the active vertex j is connected; one is loop[k-1], i.e. the one which
     1710      // the first row of graph[j][3] has two entries
     1711      // corresponding to the two vertices
     1712      // to which the active vertex j is connected;
     1713      // one is loop[k-1], i.e. the one which
    15511714      // precedes j in the loop; we have to choose the other one
    1552       if (graph[j][3][1,1]==loop[k-1])
     1715      if (graph[j][3][1,1]==loop[k-1]) 
    15531716      {
    15541717        loop[k+1]=graph[j][3][1,2];
     
    15611724      }
    15621725      j=loop[k+1]; // set loop[k+1] the new active vertex
    1563       k++;
    1564     }
     1726      k++; 
     1727    }   
    15651728    // 7) compute for each edge in the loop the lattice length
    1566     poly xcomp,ycomp; // the x- and y-components of the vectors connecting two vertices of the loop
    1567     number nenner;    // the product of the denominators of the x- and y-components
     1729    poly xcomp,ycomp; // the x- and y-components of the vectors
     1730                      // connecting two vertices of the loop
     1731    number nenner;    // the product of the denominators of
     1732                      // the x- and y-components
    15681733    number jinvariant;  // the j-invariant
    1569     int eins,zwei,ggt;
     1734    int eins,zwei,ggt; 
    15701735    for (i=1;i<=size(loop)-1;i++) // compute the lattice length for each edge
    15711736    {
    1572       xcomp=graph[loop[i]][1]-graph[loop[i+1]][1];
    1573       ycomp=graph[loop[i]][2]-graph[loop[i+1]][2];
     1737      xcomp=graph[loop[i]][1]-graph[loop[i+1]][1]; 
     1738      ycomp=graph[loop[i]][2]-graph[loop[i+1]][2]; 
    15741739      nenner=denominator(leadcoef(xcomp))*denominator(leadcoef(ycomp));
    1575       execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";");
    1576       execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";");
    1577       ggt=gcd(eins,zwei); // the lattice length is the "gcd" of the x-component and the y-component
    1578       jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the weight of the edge
    1579     }
    1580     return(jinvariant);
     1740      execute("eins="+string(numerator(leadcoef(nenner*xcomp)))+";");
     1741      execute("zwei="+string(numerator(leadcoef(nenner*ycomp)))+";");
     1742      ggt=gcd(eins,zwei); // the lattice length is the "gcd"
     1743                          // of the x-component and the y-component
     1744      jinvariant=jinvariant+ggt/(nenner*weights[i+1]); // divided by the
     1745                                                       // weight of the edge
     1746    }
     1747    return(jinvariant);   
    15811748  }
    15821749}
     
    15921759// the curve can have arbitrary degree
    15931760   tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2);
    1594 // the procedure does not realise, if the embedded graph of the tropical
     1761// the procedure does not realise, if the embedded graph of the tropical 
    15951762//     curve has a loop that can be resolved
    15961763   tropicalJInvariant(1+x+y+xy+tx2y+txy2);
    15971764// but it does realise, if the curve has no loop at all ...
    15981765   tropicalJInvariant(x+y+1);
    1599 // or if the embedded graph has more than one loop - even if only one
     1766// or if the embedded graph has more than one loop - even if only one 
    16001767//     cannot be resolved
    16011768   tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4);
    16021769}
    16031770
     1771/////////////////////////////////////////////////////////////////////////
     1772
    16041773proc weierstrassForm (poly f,list #)
    16051774"USAGE:      weierstrassForm(wf[,#]); wf poly, # list
    1606 ASSUME:      wf is a a polynomial whose Newton polygon has precisely one interior lattice
    1607              point, so that it defines an elliptic curve on the toric surface corresponding
    1608              to the Newton polygon
     1775ASSUME:      wf is a a polynomial whose Newton polygon has precisely one
     1776             interior lattice point, so that it defines an elliptic curve
     1777             on the toric surface corresponding to the Newton polygon
    16091778RETURN:      poly, the Weierstrass normal form of the polynomial
    1610 NOTE:        - the algorithm for the coefficients of the Weierstrass form is due to
    1611                Fernando Rodriguez Villegas, villegas@math.utexas.edu
     1779NOTE:        - the algorithm for the coefficients of the Weierstrass form is due
     1780               to Fernando Rodriguez Villegas, villegas@math.utexas.edu
    16121781@*           - the characteristic of the base field should not be 2 or 3
    1613 @*           - if an additional argument # is given, a simplified Weierstrass form
    1614                is computed
     1782@*           - if an additional argument # is given, a simplified Weierstrass
     1783               form is computed
    16151784EXAMPLE:     example weierstrassForm;   shows an example"
    16161785{
     
    16691838}
    16701839
     1840/////////////////////////////////////////////////////////////////////////
     1841
    16711842proc jInvariant (poly f,list #)
    1672 "USAGE:      jInvariant(f[,#]); f poly, # list
    1673 ASSUME:      - f is a a polynomial whose Newton polygon has precisely one interior lattice
    1674                point, so that it defines an elliptic curve on the toric surface corresponding
    1675                to the Newton polygon
    1676 @*           - it the optional argument # is present the base field should be Q(t) and
    1677                the optional argument should be one of the following strings:
    1678 @*             'ord'   : then the return value is of type integer, namely the order of the j-invariant
    1679 @*             'split' : then the return value is a list of two polynomials, such that the quotient
    1680                          of these two is the j-invariant
     1843"USAGE:      jInvariant(f[,#]); f poly, # list
     1844ASSUME:      - f is a a polynomial whose Newton polygon has precisely one
     1845               interior lattice point, so that it defines an elliptic curve
     1846               on the toric surface corresponding to the Newton polygon
     1847@*           - it the optional argument # is present the base field should be
     1848               Q(t) and the optional argument should be one of the following
     1849               strings:
     1850@*             'ord'   : then the return value is of type integer,
     1851                         namely the order of the j-invariant
     1852@*             'split' : then the return value is a list of two polynomials,
     1853                         such that the quotient of these two is the j-invariant
    16811854RETURN:      poly, the j-invariant of the elliptic curve defined by poly
    1682 NOTE:        the characteristic of the base field should not be 2 or 3, unless the input is a plane cubic
     1855NOTE:        the characteristic of the base field should not be 2 or 3,
     1856             unless the input is a plane cubic
    16831857EXAMPLE:     example jInvariant;   shows an example"
    16841858{
     
    17051879   echo=2;
    17061880   ring r=(0,t),(x,y),dp;
    1707 // jInvariant computes the j-invariant of a cubic
     1881// jInvariant computes the j-invariant of a cubic 
    17081882   jInvariant(x+y+x2y+y3+1/t*xy);
    1709 // if the ground field has one parameter t, then we can instead
     1883// if the ground field has one parameter t, then we can instead 
    17101884//    compute the order of the j-invariant
    17111885   jInvariant(x+y+x2y+y3+1/t*xy,"ord");
     
    17151889   poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3+x14y8;
    17161890// its j-invariant is
    1717    jInvariant(h);
    1718 }
    1719 
    1720 
    1721 
    1722 ////////////////////////////////////////////////////////////////////////////////////
     1891   jInvariant(h); 
     1892}
     1893
     1894
     1895
     1896///////////////////////////////////////////////////////////////////////////////
    17231897/// Procedures concerned with conics
    1724 ////////////////////////////////////////////////////////////////////////////////////
     1898///////////////////////////////////////////////////////////////////////////////
    17251899
    17261900proc conicWithTangents (list points,list #)
     
    17291903RETURN:      list, l[1] = the list points of the five given points
    17301904@*                 l[2] = the conic f passing through the five points
    1731 @*                 l[3] = list of equations of the tangents to f in the given points
    1732 @*                 l[4] = ideal, the tropicalisation of f (i.e. a list of linear forms)
     1905@*                 l[3] = list of equations of tangents to f in the given points
     1906@*                 l[4] = ideal, tropicalisation of f (i.e. list of linear forms)
    17331907@*                 l[5] = a list of the tropicalisation of the tangents
    17341908@*                 l[6] = a list containing the vertices of the tropical conic f
    1735 @*                 l[7] = a list containing lists with the vertices of the tangents
    1736 @*                 l[8] = a string which contains the latex-code to draw the tropical
    1737                           conic and its tropicalised tangents
    1738 @*                 l[9] = if # is non-empty, this is the same data for the dual conic
    1739                           and the points dual to the computed tangents
     1909@*                 l[7] = a list containing lists with vertices of the tangents
     1910@*                 l[8] = a string which contains the latex-code to draw the
     1911                          tropical conic and its tropicalised tangents
     1912@*                 l[9] = if # is non-empty, this is the same data for the dual
     1913                          conic and the points dual to the computed tangents
    17401914NOTE:        the points must be generic, i.e. no three on a line
    17411915EXAMPLE:     example conicWithTangents;   shows an example"
     
    17581932  ring LINRING=(0,t),(x,y,a(1..6)),lp;
    17591933  list points=imap(BASERING,points);
    1760   ideal I; // the ideal will contain the linear equations given by the conic and the points
     1934  ideal I; // the ideal will contain the linear equations given by the conic
     1935           // and the points
    17611936  for (i=1;i<=5;i++)
    17621937  {
     
    17781953  ring tRING=0,t,ls;
    17791954  list pointdenom=imap(BASERING,pointdenom);
    1780   list pointnum=imap(BASERING,pointnum);
     1955  list pointnum=imap(BASERING,pointnum); 
    17811956  intvec pointcoordinates;
    17821957  for (i=1;i<=size(pointdenom);i++)
     
    18542029   We consider the concic through the following five points:
    18552030   \\begin{displaymath}
    1856 ";
     2031"; 
    18572032  string texf=texDrawTropical(graphf,list("",scalefactor));
    18582033  for (i=1;i<=size(points);i++)
     
    18922067\\end{document}";
    18932068  setring BASERING;
    1894   // If # non-empty, compute the dual conic and the tangents through the dual points
     2069  // If # non-empty, compute the dual conic and the tangents
     2070  // through the dual points
    18952071  // corresponding to the tangents of the given conic.
    18962072  if (size(#)>0)
    18972073  {
    18982074    list dualpoints;
    1899     for (i=1;i<=size(points);i++)
     2075    for (i=1;i<=size(points);i++) 
    19002076    {
    19012077      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));
     
    19212097// conic[2] is the equation of the conic f passing through the five points
    19222098   conic[2];
    1923 // conic[3] is a list containing the equations of the tangents
     2099// conic[3] is a list containing the equations of the tangents 
    19242100//          through the five points
    19252101   conic[3];
    19262102// conic[4] is an ideal representing the tropicalisation of the conic f
    19272103   conic[4];
    1928 // conic[5] is a list containing the tropicalisation
     2104// conic[5] is a list containing the tropicalisation 
    19292105//          of the five tangents in conic[3]
    19302106   conic[5];
    1931 // conic[6] is a list containing the vertices of the tropical conic
     2107// conic[6] is a list containing the vertices of the tropical conic 
    19322108   conic[6];
    19332109// conic[7] is a list containing the vertices of the five tangents
    19342110   conic[7];
    1935 // conic[8] contains the latex code to draw the tropical conic and
    1936 //          its tropicalised tangents; it can written in a file, processed and
    1937 //          displayed via kghostview
    1938    write(":w /tmp/conic.tex",conic[8]);
    1939    system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o;
     2111// conic[8] contains the latex code to draw the tropical conic and 
     2112//          its tropicalised tangents; it can written in a file, processed and 
     2113//          displayed via kghostview 
     2114   write(":w /tmp/conic.tex",conic[8]);   
     2115   system("sh","cd /tmp; latex /tmp/conic.tex; dvips /tmp/conic.dvi -o; 
    19402116            kghostview conic.ps &");
    1941 // with an optional argument the same information for the dual conic is computed
     2117// with an optional argument the same information for the dual conic is computed 
    19422118//         and saved in conic[9]
    19432119   conic=conicWithTangents(points,1);
    19442120   conic[9][2]; // the equation of the dual conic
    19452121}
    1946 
    1947 ////////////////////////////////////////////////////////////////////////////////////
     2122 
     2123///////////////////////////////////////////////////////////////////////////////
    19482124/// Procedures concerned with tropicalisation
    1949 ////////////////////////////////////////////////////////////////////////////////////
     2125///////////////////////////////////////////////////////////////////////////////
    19502126
    19512127proc tropicalise (poly f,list #)
     
    19532129ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
    19542130RETURN:      list, the linear forms of the tropicalisation of f
    1955 NOTE:        if # is empty, then the valuation of t will be 1,
    1956 @*           if # is the string 'max' it will be -1;
    1957 @*           the latter supposes that we consider the maximum of the the computed
    1958              linear forms, the former that we consider their minimum
     2131NOTE:        if # is empty, then the valuation of t will be 1, 
     2132@*           if # is the string 'max' it will be -1; 
     2133@*           the latter supposes that we consider the maximum of the the
     2134             computed linear forms, the former that we consider their minimum
    19592135EXAMPLE:     example tropicalise;   shows an example"
    19602136{
     
    19782154    {
    19792155      tropicalf[i]=tropicalf[i]+exp[j]*var(j);
    1980     }
     2156    }   
    19812157    f=f-lead(f);
    19822158  }
     
    19922168
    19932169
     2170/////////////////////////////////////////////////////////////////////////
     2171
    19942172proc tropicaliseSet (ideal i)
    1995 "USAGE:      tropicaliseSet(i); i ideal
    1996 ASSUME:      i is an ideal in Q(t)[x_1,...,x_n]
    1997 RETURN:      list, the jth entry is the tropicalisation of the jth generator of i
    1998 EXAMPLE:     example tropicaliseSet;   shows an example"
     2173"USAGE:    tropicaliseSet(i); i ideal
     2174ASSUME:    i is an ideal in Q(t)[x_1,...,x_n]
     2175RETURN:    list, the jth entry is the tropicalisation of the jth generator of i
     2176EXAMPLE:   example tropicaliseSet;   shows an example"
    19992177{
    20002178  list tropicalid;
     
    20142192}
    20152193
    2016 proc tInitialForm (poly f, intvec w)
     2194/////////////////////////////////////////////////////////////////////////
     2195
     2196proc tInitialForm (poly f, intvec w)
    20172197"USAGE:      tInitialForm(f,w); f a polynomial, w an integer vector
    20182198ASSUME:      f is a polynomial in Q[t,x_1,...,x_n] and w=(w_0,w_1,...,w_n)
    20192199RETURN:      poly, the t-initialform of f(t,x) w.r.t. w evaluated at t=1
    2020 NOTE:        the t-initialform is the sum of the terms with MAXIMAL weighted order w.r.t. w
     2200NOTE:        the t-initialform is the sum of the terms with MAXIMAL
     2201             weighted order w.r.t. w
    20212202EXAMPLE:     example tInitialForm;   shows an example"
    20222203{
     
    20272208  // do the same for the remaining part of f and compare the results
    20282209  // keep only the smallest ones
    2029   int vglgewicht;
    2030   f=f-lead(f);
     2210  int vglgewicht; 
     2211  f=f-lead(f); 
    20312212  while (f!=0)
    20322213  {
     
    20432224        initialf=initialf+lead(f);
    20442225      }
    2045     }
     2226    }   
    20462227    f=f-lead(f);
    20472228  }
     
    20592240}
    20602241
    2061 proc tInitialIdeal (ideal i,intvec w,list #)
     2242/////////////////////////////////////////////////////////////////////////
     2243
     2244proc tInitialIdeal (ideal i,intvec w,list #)
    20622245"USAGE:      tInitialIdeal(i,w); i ideal, w intvec
    2063 ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n)
     2246ASSUME:      i is an ideal in Q[t,x_1,...,x_n] and w=(w_0,...,w_n) 
    20642247RETURN:      ideal ini, the t-initial ideal of i with respect to w"
    20652248{
    20662249  // THE PROCEDURE WILL BE CALLED FROM OTHER PROCEDURES INSIDE THIS LIBRARY;
    2067   // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF THE FIRST,
     2250  // IN THIS CASE THE VARIABLE t WILL INDEED BE THE LAST VARIABLE INSTEAD OF
     2251  // THE FIRST,
    20682252  // AND WE THEREFORE HAVE TO MOVE IT BACK TO THE FRONT!
    20692253  // THIS IS NOT DOCUMENTED FOR THE GENERAL USER!!!!
     
    20882272  // ... and compute a standard basis with
    20892273  // respect to the homogenised ordering defined by w. Since the generators
    2090   // of i will be homogeneous it we can instead take the ordering wp
    2091   // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some
    2092   // large M, so that all entries are positive
    2093   int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is strictly positive for all j
     2274  // of i will be homogeneous it we can instead take the ordering wp
     2275  // with the weightvector (0,w) replaced by (M,...,M)+(0,w) for some
     2276  // large M, so that all entries are positive
     2277  int M=-minInIntvec(w)[1]+1; // find M such that w[j]+M is
     2278                              // strictly positive for all j
    20942279  intvec whomog=M+1;
    20952280  for (j=1;j<=size(w);j++)
     
    20982283  }
    20992284  execute("ring WEIGHTRING=("+charstr(basering)+"),("+varstr(basering)+"),(wp("+string(whomog)+"));");
    2100   // map i to the new ring and compute a GB of i, then dehomogenise i,
    2101   // so that we can be sure, that the
     2285  // map i to the new ring and compute a GB of i, then dehomogenise i, 
     2286  // so that we can be sure, that the 
    21022287  // initial forms of the generators generate the initial ideal
    21032288  ideal i=subst(groebner(imap(HOMOGRING,i)),@s,1);
     
    21302315}
    21312316
     2317/////////////////////////////////////////////////////////////////////////
     2318
    21322319proc initialForm (poly f, intvec w)
    21332320"USAGE:      initialForm(f,w); f a polynomial, w an integer vector
     
    21612348}
    21622349
     2350/////////////////////////////////////////////////////////////////////////
     2351
    21632352proc initialIdeal (ideal i, intvec w)
    21642353"USAGE:      initialIdeal(i,w); i ideal, w intvec
     
    21902379}
    21912380
    2192 ////////////////////////////////////////////////////////////////////////////////////
     2381///////////////////////////////////////////////////////////////////////////////
    21932382/// PROCEDURES CONCERNED WITH THE LATEX CONVERSION
    2194 ////////////////////////////////////////////////////////////////////////////////////
    2195 
     2383///////////////////////////////////////////////////////////////////////////////
    21962384
    21972385proc texNumber (poly p)
    2198 "USAGE:      texNumber(f); f poly
    2199 RETURN:      string, the tex command representing the leading coefficient of f using \frac
    2200 EXAMPLE:     example texNumber;   shows an example"
     2386"USAGE:   texNumber(f); f poly
     2387RETURN:   string, tex command representing leading coefficient of f using \frac
     2388EXAMPLE:  example texNumber;   shows an example"
    22012389{
    22022390  number n=leadcoef(p);
     
    22392427   texNumber((3t2-1)/t3);
    22402428}
     2429
     2430/////////////////////////////////////////////////////////////////////////
    22412431
    22422432proc texPolynomial (poly f)
     
    23002490}
    23012491
     2492/////////////////////////////////////////////////////////////////////////
     2493
    23022494proc texMatrix (matrix M)
    23032495"USAGE:      texMatrix(M); M matrix
     
    23422534
    23432535
     2536/////////////////////////////////////////////////////////////////////////
     2537
    23442538proc texDrawBasic (list texdraw)
    23452539"USAGE:      texDrawBasic(texdraw); list texdraw
    2346 ASSUME:      texdraw is a list of strings representing texdraw commands (as produced by
    2347              texDrawTropical) which should be embedded into a texdraw environment
     2540ASSUME:      texdraw is a list of strings representing texdraw commands
     2541             (as produced by texDrawTropical) which should be embedded into
     2542             a texdraw environment
    23482543RETURN:      string, a texdraw environment enclosing the input
    23492544NOTE:        is called from conicWithTangents
     
    23642559    \\end{texdraw}";
    23652560  return(texdrawtp);
    2366 }
     2561} 
    23672562example
    23682563{
     
    23752570}
    23762571
     2572/////////////////////////////////////////////////////////////////////////
     2573
    23772574proc texDrawTropical (list graph,list #)
    23782575"USAGE:  texDrawTropical(graph[,#]); graph list, # optional list
    23792576ASSUME:  graph is the output of tropicalCurve
    23802577RETURN:  string, the texdraw code of the tropical plane curve encoded by graph
    2381 NOTE:    - if the list # is non-empty, the first entry should be a string; if this string is 'max',
    2382            then the tropical curve is considered with respect to the maximum; otherwise the curve
    2383            is considered with respect to the minimum and the string can be used to
    2384            insert further texdraw commands (e.g. to have a lighter image as when called
    2385            from inside conicWithTangents);
    2386 @*       - the procedure computes a scalefactor for the texdraw command which should
    2387            help to display the curve in the right way; this may, however, be a bad idea
    2388            if several texDrawTropical outputs are put together to form one image; the
    2389            scalefactor can be prescribed by a second optional entry of type poly
     2578NOTE:    - if the list # is non-empty, the first entry should be a string;
     2579           if this string is 'max', then the tropical curve is considered
     2580           with respect to the maximum; otherwise the curve is considered
     2581           with respect to the minimum and the string can be used to insert
     2582           further texdraw commands (e.g. to have a lighter image as when called
     2583           from inside conicWithTangents);
     2584@*       - the procedure computes a scalefactor for the texdraw command which
     2585           should help to display the curve in the right way; this may,
     2586           however, be a bad idea if several texDrawTropical outputs are
     2587           put together to form one image; the scalefactor can be prescribed
     2588           by a second optional entry of type poly
    23902589@*       - the list # is optional and may as well be empty
    23912590EXAMPLE:     example texDrawTropical;   shows an example"
    23922591{
    23932592  int i,j;
    2394   // deal first with the pathological case that the input polynomial was a monomial
    2395   // and does therefore not define a tropical curve, and check if the Newton polytope is
     2593  // deal first with the pathological case that
     2594  // the input polynomial was a monomial
     2595  // and does therefore not define a tropical curve,
     2596  // and check if the Newton polytope is
    23962597  // a line segment so that the curve defines a bunch of lines
    23972598  int bunchoflines;
    2398   if (size(graph[size(graph)][1])==1) // the boundary of the Newton polytope consists of a single point
     2599  // if the boundary of the Newton polytope consists of a single point
     2600  if (size(graph[size(graph)][1])==1)
    23992601  {
    24002602    return(string());
     
    24082610      M[2,i]=graph[size(graph)][1][i][2];
    24092611    }
    2410     if ((size(graph[size(graph)][1])-size(syz(M)))==1) // then the Newton polytope is a line segment
     2612    // then the Newton polytope is a line segment
     2613    if ((size(graph[size(graph)][1])-size(syz(M)))==1)
    24112614    {
    24122615      bunchoflines=1;
     
    24152618  // go on with the case that a tropical curve is defined
    24162619  if (size(#)==0)
    2417   {
     2620  {   
    24182621     string texdrawtp="
    24192622
     
    24232626  {
    24242627    if ((#[1]!="max") and (#[1]!=""))
    2425     {
     2628    {     
    24262629      string texdrawtp=#[1];
    24272630    }
     
    24712674  for (i=1;i<=size(graph)-1;i++)
    24722675  {
    2473     if (bunchoflines==0) // if the curve is a bunch of lines no vertex has to be drawn
     2676    // if the curve is a bunch of lines no vertex has to be drawn
     2677    if (bunchoflines==0)
    24742678    {
    24752679      texdrawtp=texdrawtp+"
    24762680       \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\fcir f:0 r:"+decimal(2/(leadcoef(scalefactor)*10),size(string(int(scalefactor)))+1);
    24772681    }
    2478     for (j=1;j<=ncols(graph[i][3]);j++) // draw the bounded edges emerging from the ith vertex
    2479     {
    2480       if (i<graph[i][3][1,j]) // don't draw it twice - and if there is only one vertex and graph[i][3][1,1]
    2481       {                       // is thus 0, nothing is done
     2682    // draw the bounded edges emerging from the ith vertex
     2683    for (j=1;j<=ncols(graph[i][3]);j++)
     2684    {
     2685      // don't draw it twice - and if there is only one vertex
     2686      //                       and graph[i][3][1,1] is thus 0, nothing is done
     2687      if (i<graph[i][3][1,j])
     2688      {                       
    24822689        texdrawtp=texdrawtp+"
    24832690       \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\lvec ("+decimal(graph[graph[i][3][1,j]][1]-centerx)+" "+decimal(graph[graph[i][3][1,j]][2]-centery)+")";
    2484         if (graph[i][3][2,j]>1) // if the multiplicity is more than one, denote it in the picture
     2691        // if the multiplicity is more than one, denote it in the picture
     2692        if (graph[i][3][2,j]>1)
    24852693        {
    24862694          texdrawtp=texdrawtp+"
     
    24892697      }
    24902698    }
    2491     for (j=1;j<=size(graph[i][4]);j++) // draw the unbounded edges emerging from the ith vertex
    2492     {
    2493       // they should not be too long
     2699    // draw the unbounded edges emerging from the ith vertex
     2700    // they should not be too long
     2701    for (j=1;j<=size(graph[i][4]);j++)
     2702    {     
    24942703      relxy=shorten(list(decimal(3*graph[i][4][j][1][1]/scalefactor),decimal(3*graph[i][4][j][1][2]/scalefactor),"2.5"));
    24952704      texdrawtp=texdrawtp+"
    24962705       \\move ("+decimal(graph[i][1]-centerx)+" "+decimal(graph[i][2]-centery)+") \\rlvec ("+relxy[1]+" "+relxy[2]+")";
    2497       if (graph[i][4][j][2]>1) // if the multiplicity is more than one, denote it in the picture
     2706      // if the multiplicity is more than one, denote it in the picture
     2707      if (graph[i][4][j][2]>1)
    24982708      {
    24992709        texdrawtp=texdrawtp+"
     
    25402750}
    25412751
     2752/////////////////////////////////////////////////////////////////////////
     2753
    25422754proc texDrawNewtonSubdivision (list graph,list #)
    25432755"USAGE:      texDrawNewtonSubdivision(graph[,#]); graph list, # optional list
    25442756ASSUME:      graph is the output of tropicalCurve
    2545 RETURN:      string, the texdraw code of the Newton subdivision of the tropical plane curve encoded by graph
    2546 NOTE:        - the list # should contain as only entry a string; if this string is 'max', then
    2547                the tropical curve is considered with respect to the maximum; otherwise the curve
    2548                is considered with respect to the minimum and the string can be used to
    2549                insert further texdraw commands (e.g. to have a lighter image as when called
    2550                from inside conicWithTangents); the list # is optional and may as well be empty
    2551 @*           - note that lattice points in the Newton subdivision which are black correspond to markings
    2552                of the marked subdivision, while lattice points in grey are not marked
     2757RETURN:      string, the texdraw code of the Newton subdivision of the
     2758                     tropical plane curve encoded by graph
     2759NOTE:        - the list # should contain as only entry a string; if this string
     2760               is 'max', then the tropical curve is considered with respect
     2761               to the maximum; otherwise the curve is considered with respect
     2762               to the minimum and the string can be used to insert further
     2763               texdraw commands (e.g. to have a lighter image as when called
     2764               from inside conicWithTangents); the list # is optional and may
     2765               as well be empty
     2766@*           - note that lattice points in the Newton subdivision which are
     2767               black correspond to markings of the marked subdivision,
     2768               while lattice points in grey are not marked
    25532769EXAMPLE:     example texDrawNewtonSubdivision;   shows an example"
    25542770{
    25552771  int i,j,k,l;
    25562772  list boundary=graph[size(graph)][1];
    2557   list inneredges=graph[size(graph)][2];
     2773  list inneredges=graph[size(graph)][2]; 
    25582774  intvec shiftvector=graph[size(graph)][3];
    25592775  string subdivision;
    2560   // find the maximal and minimal x- and y-coordinates and define the scalefactor
     2776  // find maximal and minimal x- and y-coordinates and define the scalefactor
    25612777  poly maxx,maxy=1,1;
    25622778  for (i=1;i<=size(boundary);i++)
     
    25672783  poly scalefactor=minOfPolys(list(12/leadcoef(maxx),12/leadcoef(maxy)));
    25682784  if (scalefactor<1)
    2569   {
     2785  {   
    25702786    subdivision=subdivision+"
    25712787       \\relunitscale"+ decimal(scalefactor);
     
    25752791  {
    25762792    subdivision=subdivision+"
    2577         \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")
     2793        \\move ("+string(boundary[i][1])+" "+string(boundary[i][2])+")       
    25782794        \\lvec ("+string(boundary[i+1][1])+" "+string(boundary[i+1][2])+")";
    2579   }
     2795  } 
    25802796  subdivision=subdivision+"
    2581         \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")
     2797        \\move ("+string(boundary[size(boundary)][1])+" "+string(boundary[size(boundary)][2])+")       
    25822798        \\lvec ("+string(boundary[1][1])+" "+string(boundary[1][2])+")
    25832799
     
    25862802  {
    25872803    subdivision=subdivision+"
    2588         \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")
     2804        \\move ("+string(inneredges[i][1][1])+" "+string(inneredges[i][1][2])+")       
    25892805        \\lvec ("+string(inneredges[i][2][1])+" "+string(inneredges[i][2][2])+")";
    25902806  }
     
    26062822    }
    26072823  }
    2608   // deal with the pathological cases
     2824  // deal with the pathological cases 
    26092825  if (size(boundary)==1) // then the Newton polytope is a point
    26102826  {
     
    26612877  {
    26622878    subdivision=subdivision+"
    2663        \\move ("+string(markings[i][1])+" "+string(markings[i][2])+")
     2879       \\move ("+string(markings[i][1])+" "+string(markings[i][2])+") 
    26642880       \\fcir f:0 r:"+decimal(2/(8*scalefactor),size(string(int(scalefactor)))+1);
    26652881  }
    26662882  // enclose subdivision in the texdraw environment
    2667   string texsubdivision="
     2883  string texsubdivision="     
    26682884    \\begin{texdraw}
    2669        \\drawdim cm  \\relunitscale 1
     2885       \\drawdim cm  \\relunitscale 1 
    26702886       \\linewd 0.05"
    26712887    +subdivision+"
     
    26812897   poly f=x+y+x2y+xy2+1/t*xy;
    26822898   list graph=tropicalCurve(f);
    2683 // compute the texdraw code of the Newton subdivision of the tropical curve
     2899// compute the texdraw code of the Newton subdivision of the tropical curve 
    26842900   texDrawNewtonSubdivision(graph);
    26852901}
     2902
     2903/////////////////////////////////////////////////////////////////////////
    26862904
    26872905proc texDrawTriangulation (list triang,list polygon)
    26882906"USAGE:      texDrawTriangulation(triang,polygon);  triang,polygon list
    2689 ASSUME:      polygon is a list of integer vectors describing the lattice points of a marked polygon;
    2690              triang is a list of integer vectors describing a triangulation of the marked polygon
    2691              in the sense that an integer vector of the form (i,j,k) describes the triangle formed
    2692              by polygon[i], polygon[j] and polygon[k]
    2693 RETURN:      string, a texdraw code for the triangulation described by triang without the texdraw environment
     2907ASSUME:      polygon is a list of integer vectors describing the
     2908             lattice points of a marked polygon;
     2909             triang is a list of integer vectors describing a
     2910             triangulation of the marked polygon
     2911             in the sense that an integer vector of the form (i,j,k) describes
     2912             the triangle formed by polygon[i], polygon[j] and polygon[k]
     2913RETURN:      string, a texdraw code for the triangulation described
     2914                     by triang without the texdraw environment
    26942915EXAMPLE:     example texDrawTriangulation;   shows an example"
    26952916{
     
    26992920   ";
    27002921  int i,j; // indices
    2701   list pairs,markings; // stores edges of the triangulation, respecively the marked points
    2702   // for each triangle store the edges and marked points of the triangle
     2922  list pairs,markings; // stores edges of the triangulation, respecively
     2923  // the marked points for each triangle store the edges and marked
     2924  // points of the triangle
    27032925  for (i=1;i<=size(triang);i++)
    27042926  {
     
    27082930    markings[3*i-2]=triang[i][1];
    27092931    markings[3*i-1]=triang[i][2];
    2710     markings[3*i]=triang[i][3];
     2932    markings[3*i]=triang[i][3];   
    27112933  }
    27122934  // delete redundant pairs which occur more than once
     
    27412963  {
    27422964    latex=latex+"
    2743         \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")
     2965        \\move ("+string(polygon[markings[i]][1])+" "+string(polygon[markings[i]][2])+")       
    27442966        \\fcir f:0 r:0.08";
    27452967  }
     
    27482970  {
    27492971    latex=latex+"
    2750         \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")
     2972        \\move ("+string(polygon[pairs[i][1]][1])+" "+string(polygon[pairs[i][1]][2])+")       
    27512973        \\lvec ("+string(polygon[pairs[i][2]][1])+" "+string(polygon[pairs[i][2]][2])+")";
    27522974  }
     
    27552977  {
    27562978    latex=latex+"
    2757         \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")
     2979        \\move ("+string(polygon[i][1])+" "+string(polygon[i][2])+")       
    27582980        \\fcir f:0.7 r:0.04";
    27592981  }
     
    27642986   "EXAMPLE:";
    27652987   echo=2;
    2766    // the lattice polygon spanned by the points (0,0), (3,0) and (0,3)
     2988   // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 
    27672989   // with all integer points as markings
    27682990   list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0),
    27692991                intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3);
    2770    // define a triangulation by connecting the only interior point
     2992   // define a triangulation by connecting the only interior point 
    27712993   //        with the vertices
    27722994   list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10);
     
    27752997}
    27762998
    2777 ////////////////////////////////////////////////////////////////////////////////////
    2778 /// Auxilary Procedures
    2779 ////////////////////////////////////////////////////////////////////////////////////
     2999///////////////////////////////////////////////////////////////////////////////
     3000/// Auxilary Procedures 
     3001///////////////////////////////////////////////////////////////////////////////
    27803002
    27813003proc radicalMemberShip (poly f,ideal i)
    27823004"USAGE:  radicalMemberShip (f,i); f poly, i ideal
    2783 RETURN:  int, 1 if f is in the radical of i, 0 else"
     3005RETURN:  int, 1 if f is in the radical of i, 0 else
     3006EXAMPLE:     example radicalMemberShip;   shows an example"
    27843007{
    27853008  def BASERING=basering;
     
    28093032}
    28103033
    2811 ////////////////////////////////////////////////////////////////////////////////////
     3034///////////////////////////////////////////////////////////////////////////////
    28123035/// Auxilary Procedures concerned with initialforms
    2813 ////////////////////////////////////////////////////////////////////////////////////
     3036///////////////////////////////////////////////////////////////////////////////
    28143037
    28153038proc tInitialFormPar (poly f, intvec w)
    2816 "USAGE:      tInitialFormPar(f,w); f a polynomial, w an integer vector
    2817 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] and w=(w_1,...,w_2)
    2818 RETURN:      poly, the t-initialform of f(t,x) w.r.t. (1,w) evaluated at t=1
    2819 NOTE:        the t-initialform are the terms with MINIMAL weighted order w.r.t. (1,w)
    2820 EXAMPLE:     example tInitialFormPar;   shows an example"
     3039"USAGE:  tInitialFormPar(f,w); f a polynomial, w an integer vector
     3040ASSUME:  f is a polynomial in Q(t)[x_1,...,x_n] and w=(w_1,...,w_2)
     3041RETURN:  poly, the t-initialform of f(t,x) w.r.t. (1,w) evaluated at t=1
     3042NOTE:    the t-initialform are the terms with MINIMAL weighted order w.r.t. (1,w)
     3043EXAMPLE: example tInitialFormPar;   shows an example"
    28213044{
    28223045  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    2823   // the rational constant corresponding to this order in leadkoef(f) (leitkoef[2])
     3046  // the rational constant corresponding to this order in leadkoef(f)
     3047  // (leitkoef[2])
    28243048  list leitkoef=simplifyToOrder(f);
    28253049  execute("poly koef="+leitkoef[2]+";");
     
    28303054  // do the same for the remaining part of f and compare the results
    28313055  // keep only the smallest ones
    2832   int vglgewicht;
    2833   f=f-lead(f);
     3056  int vglgewicht; 
     3057  f=f-lead(f); 
    28343058  while (f!=0)
    28353059  {
    2836     leitkoef=simplifyToOrder(f);
     3060    leitkoef=simplifyToOrder(f);   
    28373061    vglgewicht=leitkoef[1]+scalarproduct(w,leadexp(f));
    28383062    if (vglgewicht<gewicht)
     
    28493073        initialf=initialf+koef*leadmonom(f);
    28503074      }
    2851     }
     3075    }   
    28523076    f=f-lead(f);
    28533077  }
     
    28643088}
    28653089
     3090/////////////////////////////////////////////////////////////////////////
     3091
    28663092proc tInitialFormParMax (poly f, intvec w)
    2867 "USAGE:      tInitialFormParMax(f,w); f a polynomial, w an integer vector
    2868 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] and w=(w_1,...,w_2)
    2869 RETURN:      poly, the t-initialform of f(t,x) w.r.t. (-1,w) evaluated at t=1
    2870 NOTE:        the t-initialform are the terms with MAXIMAL weighted order w.r.t. (1,w)
    2871 EXAMPLE:     example tInitialFormParMax;   shows an example"
     3093"USAGE:  tInitialFormParMax(f,w); f a polynomial, w an integer vector
     3094ASSUME:  f is a polynomial in Q(t)[x_1,...,x_n] and w=(w_1,...,w_2)
     3095RETURN:  poly, the t-initialform of f(t,x) w.r.t. (-1,w) evaluated at t=1
     3096NOTE:    the t-initialform are the terms with MAXIMAL weighted order w.r.t. (1,w)
     3097EXAMPLE: example tInitialFormParMax;   shows an example"
    28723098{
    28733099  // compute first the t-order of the leading coefficient of f (leitkoef[1]) and
    2874   // the rational constant corresponding to this order in leadkoef(f) (leitkoef[2])
    2875   list leitkoef=simplifyToOrder(f);
     3100  // the rational constant corresponding to this order in leadkoef(f)
     3101  // (leitkoef[2])
     3102  list leitkoef=simplifyToOrder(f); 
    28763103  execute("poly koef="+leitkoef[2]+";");
    28773104  // take in lead(f) only the term of lowest t-order and set t=1
     
    28823109  // keep only the largest ones
    28833110  int vglgewicht;
    2884   f=f-lead(f);
     3111  f=f-lead(f); 
    28853112  while (f!=0)
    28863113  {
     
    29003127        initialf=initialf+koef*leadmonom(f);
    29013128      }
    2902     }
     3129    }   
    29033130    f=f-lead(f);
    29043131  }
     
    29153142}
    29163143
     3144/////////////////////////////////////////////////////////////////////////
     3145
    29173146proc solveTInitialFormPar (ideal i)
    29183147"USAGE:      solveTInitialFormPar(i); i ideal
    2919 ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated by the (1,w)-homogeneous
    2920              elements for some integer vector w - i.e. by the (1,w)-initialforms of polynomials
     3148ASSUME:      i is a zero-dimensional ideal in Q(t)[x_1,...,x_n] generated
     3149             by the (1,w)-homogeneous elements for some integer vector w
     3150             - i.e. by the (1,w)-initialforms of polynomials
    29213151RETURN:      none
    2922 NOTE:        the procedure just displays complex approximations of the solution set of i
     3152NOTE:        the procedure just displays complex approximations
     3153             of the solution set of i
    29233154EXAMPLE:     example solveTInitialFormPar;   shows an example"
    29243155{
     
    29423173}
    29433174
    2944 proc detropicalise (poly p)
    2945 "USAGE:      detropicalise(f); f poly
    2946 ASSUME:      f is a linear polynomial with an arbitrary constant term and
    2947              positive integer coefficients as further coefficients;
    2948 RETURN:      poly, the detropicalisation of (the non-constant part of) f
    2949 NOTE:        the output will be a monomial and the constant coefficient has been ignored
    2950 EXAMPLE:     example detropicalise;   shows an example"
     3175/////////////////////////////////////////////////////////////////////////
     3176
     3177proc detropicalise (poly p)
     3178"USAGE:   detropicalise(f); f poly
     3179ASSUME:   f is a linear polynomial with an arbitrary constant term and
     3180          positive integer coefficients as further coefficients;
     3181RETURN:   poly, the detropicalisation of (the non-constant part of) f
     3182NOTE:     the output will be a monomial and the constant coefficient
     3183          has been ignored
     3184EXAMPLE:  example detropicalise;   shows an example"
    29513185{
    29523186  poly dtp=1;
     
    29543188  {
    29553189    if (leadmonom(p)!=1)
    2956     {
     3190    { 
    29573191      dtp=dtp*leadmonom(p)^int(leadcoef(p));
    29583192    }
     
    29693203}
    29703204
    2971 ////////////////////////////////////////////////////////////////////////////////////
     3205///////////////////////////////////////////////////////////////////////////////
    29723206/// Auxilary Procedures concerned with conics
    2973 ////////////////////////////////////////////////////////////////////////////////////
     3207///////////////////////////////////////////////////////////////////////////////
    29743208
    29753209proc dualConic (poly f)
     
    30013235}
    30023236
    3003 ////////////////////////////////////////////////////////////////////////////////////
     3237///////////////////////////////////////////////////////////////////////////////
    30043238/// Auxilary Procedures concerned with substitution
    3005 ////////////////////////////////////////////////////////////////////////////////////
     3239///////////////////////////////////////////////////////////////////////////////
    30063240
    30073241proc parameterSubstitute (poly f,int N)
    3008 "USAGE:      parameterSubstitute(f,N); f poly, N int
    3009 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] describing a plane curve over Q(t)
    3010 RETURN:      poly, f with t replaced by t^N
    3011 EXAMPLE:     example parameterSubstitute;   shows an example"
     3242"USAGE:   parameterSubstitute(f,N); f poly, N int
     3243ASSUME:   f is a polynomial in Q(t)[x_1,...,x_n] describing
     3244          a plane curve over Q(t)
     3245RETURN:   poly, f with t replaced by t^N
     3246EXAMPLE:  example parameterSubstitute;   shows an example"
    30123247{
    30133248  def BASERING=basering;
     
    30313266}
    30323267
     3268/////////////////////////////////////////////////////////////////////////
     3269
    30333270proc tropicalSubst (poly f,int N,list #)
    3034 "USAGE:      parameterSubstitute(f,N,L); f poly, N int, L list
    3035 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_k]
    3036              and L is a list of the form var(i_1),poly_1,...,v(i_k),poly_k
    3037 RETURN:      list, the list is the tropical polynomial which we get from f
    3038                    by replacing the i-th variable be the i-th polynomial
    3039                    but in the i-th polynomial the parameter t is replaced by t^1/N
    3040 EXAMPLE:     example tropicalSubst;   shows an example"
     3271"USAGE:   parameterSubstitute(f,N,L); f poly, N int, L list
     3272ASSUME:   f is a polynomial in Q(t)[x_1,...,x_k]
     3273          and L is a list of the form var(i_1),poly_1,...,v(i_k),poly_k
     3274RETURN:   list, the list is the tropical polynomial which we get from f
     3275                by replacing the i-th variable be the i-th polynomial
     3276                but in the i-th polynomial the parameter t is replaced by t^1/N
     3277EXAMPLE:  example tropicalSubst;   shows an example"
    30413278{
    30423279  f=parameterSubstitute(f,N);
     
    30583295   poly f=t2x+1/t*y-1;
    30593296   tropicalSubst(f,2,x,x+t,y,tx+y+t2);
    3060    // The procedure can be used to study the effect of a transformation of
     3297   // The procedure can be used to study the effect of a transformation of 
    30613298   // the form x -> x+t^b, with b a rational number, on the tropicalisation and
    30623299   // the j-invariant of a cubic over the Puiseux series.
    30633300   f=t7*y3+t3*y2+t*(x3+xy2+y+1)+xy;
    3064    // - the j-invariant, and hence its valuation, does not change under the transformation
     3301   // - the j-invariant, and hence its valuation,
     3302   //   does not change under the transformation
    30653303   jInvariant(f,"ord");
    3066    // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)
    3067    list g32=tropicalSubst(f,2,x,x+t3,y,y);
     3304   // - b=3/2, then the cycle length of the tropical cubic equals -val(j-inv)   
     3305   list g32=tropicalSubst(f,2,x,x+t3,y,y); 
    30683306   tropicalJInvariant(g32);
    30693307   // - b=1, then it is still true, but only just ...
     
    30753313}
    30763314
     3315/////////////////////////////////////////////////////////////////////////
     3316
    30773317proc randomPoly (int d,int ug, int og, list #)
    3078 "USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list
     3318"USAGE:      randomPoly(d,ug,og[,#]);   d, ug, og int, # list 
    30793319ASSUME:      the basering has a parameter t
    3080 RETURN:      poly, a polynomial of degree d where the coefficients are of the form t^j with
    3081                    j a random integer between ug and og
    3082 NOTE:        if an optional argument # is given, then the coefficients are instead either of the
    3083              form t^j as above or they are zero, and this is chosen randomly
     3320RETURN:      poly, a polynomial of degree d where the coefficients are
     3321                   of the form t^j with j a random integer between ug and og
     3322NOTE:        if an optional argument # is given, then the coefficients are
     3323             instead either of the form t^j as above or they are zero,
     3324             and this is chosen randomly
    30843325EXAMPLE:     example randomPoly;   shows an example"
    30853326{
     
    30963337  {
    30973338    if (size(#)!=0)
    3098     {
     3339    {     
    30993340      k=random(0,1);
    31003341    }
    31013342    if (k==0)
    3102     {
     3343    {     
    31033344      j=random(ug,og);
    31043345      randomPolynomial=randomPolynomial+t^j*m[i];
     
    31223363}
    31233364
     3365/////////////////////////////////////////////////////////////////////////
     3366
    31243367proc cleanTmp ()
    31253368"USAGE:  cleanTmp()
     
    31283371RETURN:  none"
    31293372{
    3130   system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*");
    3131 }
    3132 
    3133 /////////////////////////////////////////////////////////////////////////////////
    3134 /////////////////////////////////////////////////////////////////////////////////
     3373  system("sh","cd /tmp; /bin/rm -f tropicalcurve*; /bin/rm -f tropicalnewtonsubdivision*"); 
     3374}
     3375
     3376//////////////////////////////////////////////////////////////////////////////
     3377//////////////////////////////////////////////////////////////////////////////
    31353378/// AUXILARY PROCEDURES, WHICH ARE DECLARED STATIC
    3136 /////////////////////////////////////////////////////////////////////////////////
    3137 /////////////////////////////////////////////////////////////////////////////////
    3138 
    3139 /////////////////////////////////////////////////////////////////////////////////
     3379//////////////////////////////////////////////////////////////////////////////
     3380//////////////////////////////////////////////////////////////////////////////
     3381
     3382//////////////////////////////////////////////////////////////////////////////
    31403383/// Procedures used in tropicalparametriseNoabs respectively in tropicalLifting:
    31413384/// - phiOmega
     
    31543397/// - choosegfanvector
    31553398/// - tropicalliftingresubstitute
    3156 /////////////////////////////////////////////////////////////////////////////////
     3399//////////////////////////////////////////////////////////////////////////////
    31573400
    31583401static proc phiOmega (ideal i,int j,int wj)
     
    31813424
    31823425
     3426/////////////////////////////////////////////////////////////////////////
     3427
    31833428static proc cutdown (ideal jideal,intvec wvec,int dimension,list #)
    31843429"USAGE:      cutdown(i,w,d); i ideal, w intvec, d int, # list
    3185 ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical variety of jideal
    3186              and d=dim(i)>0, in Q(t)[x]; the optional parameter # can contain the string 'isPrime'
    3187              to indicate that the input ideal is prime and no minimal associated primes have
     3430ASSUME:      i an ideal in Q[t,x_1,...,x_n], (w_1,...,w_n) is in the tropical
     3431             variety of jideal and d=dim(i)>0, in Q(t)[x]; the optional
     3432             parameter # can contain the string 'isPrime' to indicate that
     3433             the input ideal is prime and no minimal associated primes have
    31883434             to be computed
    3189 RETURN:      list, the first entry is a ring, namely the basering where some variables have been
    3190                    eliminated, and the ring contains the ideal i (with the same variables eliminated),
    3191                    the t-initial ideal ini of i (w.r.t. the weight vector where the entries
    3192                    corresponding to the deleted variables have been eliminated) and a list
    3193                    repl where for each eliminated variable there is one entry, namely a polynomial
    3194                    in the remaining variables and t that explains how resubstitution of a solution
    3195                    for the new i gives a solution for the old i; the second entry is the weight vector
    3196                    wvec with the components corresponding to the eliminated variables removed
    3197 NOTE:        needs the libraries random.lib and primdec.lib; is called from tropicalLifting"
    3198 {
    3199   // IDEA: i is an ideal of dimension d; we want to cut it with d random linear
     3435RETURN:      list, the first entry is a ring, namely the basering where some
     3436                   variables have been eliminated, and the ring contains
     3437                   the ideal i (with the same variables eliminated),
     3438                   the t-initial ideal ini of i (w.r.t. the weight vector
     3439                   where the entries corresponding to the deleted variables
     3440                   have been eliminated) and a list repl where for each
     3441                   eliminated variable there is one entry, namely a polynomial
     3442                   in the remaining variables and t that explains how
     3443                   resubstitution of a solution for the new i gives a solution
     3444                   for the old i; the second entry is the weight vector
     3445                   wvec with the components corresponding to the eliminated
     3446                   variables removed
     3447NOTE:        needs the libraries random.lib and primdec.lib;
     3448             is called from tropicalLifting"
     3449{
     3450  // IDEA: i is an ideal of dimension d; we want to cut it with d random linear
    32003451  //       forms in such a way that the resulting
    32013452  //       ideal is 0-dim and still contains w in the tropical variety
    3202   // NOTE: t is the last variable in the basering
     3453  // NOTE: t is the last variable in the basering 
    32033454  ideal pideal;  //this is the ideal we want to return
    32043455  ideal cutideal;
     
    32183469  for (j1=1;j1<=nvars(basering)-1;j1++)
    32193470  {
    3220     variablen=variablen+var(j1); //read the set of variables (needed to make the quotring later)
    3221     product=product*var(j1); //make product of all variables (needed for the initial-monomial-check later
    3222   }
     3471    variablen=variablen+var(j1); // read the set of variables
     3472                                 // (needed to make the quotring later)
     3473    product=product*var(j1); // make product of all variables
     3474                             // (needed for the initial-monomial-check later
     3475  }   
    32233476  execute("ring QUOTRING=("+charstr(basering)+",t),("+string(variablen)+"),dp;");
    32243477  setring BASERING;
    3225 // change to quotring where we want to compute the primary decomposition of i
     3478  // change to quotring where we want to compute the primary decomposition of i
    32263479  if (size(#)==0) // we only have to do so if isPrime is not set
    32273480  {
    32283481    setring QUOTRING;
    3229     ideal jideal=imap(BASERING,jideal);
    3230     list primp=minAssGTZ(jideal); //compute the primary decomposition
     3482    ideal jideal=imap(BASERING,jideal); 
     3483    list primp=minAssGTZ(jideal); //compute the primary decomposition 
    32313484    for (j1=1;j1<=size(primp);j1++)
    3232     {
     3485    {     
    32333486      for(j2=1;j2<=size(primp[j1]);j2++)
    32343487      {
    3235         primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);// clear all denominators
    3236       }
     3488        // clear all denominators
     3489        primp[j1][j2]=primp[j1][j2]/content(primp[j1][j2]);
     3490      }       
    32373491    }
    32383492    setring BASERING;
    32393493    list primp=imap(QUOTRING,primp);
    32403494    // if i is not primary itself
    3241     // go through the list of min. ass. primes and find the first one which has w in its tropical variety
    3242     if (size(primp)>1)
     3495    // go through the list of min. ass. primes and find the first
     3496    // one which has w in its tropical variety
     3497    if (size(primp)>1)
    32433498    {
    32443499      j1=1;
     
    32473502        //compute the t-initial of the associated prime
    32483503        // - the last entry 1 only means that t is the last variable in the ring
    3249         primini=tInitialIdeal(primp[j1],wvec,1);
    3250         // check if it contains a monomial (resp if the product of var is in the radical)
    3251         if (radicalMemberShip(product,primini)==0)
    3252         {
    3253           jideal=primp[j1];// if w is in the tropical variety of the prime, we take that
     3504        primini=tInitialIdeal(primp[j1],wvec,1);
     3505        // check if it contains a monomial (resp if the product of var
     3506        // is in the radical)
     3507        if (radicalMemberShip(product,primini)==0)
     3508        {
     3509          // if w is in the tropical variety of the prime, we take that
     3510          jideal=primp[j1];
    32543511          setring QUOTRING;
    32553512          dimension=dim(groebner(imap(BASERING,jideal)));//compute its dimension
    32563513          setring BASERING;
    32573514          winprim=1; // and stop the checking
    3258         }
     3515        } 
    32593516        j1=j1+1;  //else we look at the next associated prime
    32603517      }
     
    32633520    {
    32643521      jideal=primp[1]; //if i is primary itself we take its prime instead
    3265     }
     3522    } 
    32663523  }
    32673524  // now we start as a first try to intersect with a hyperplane parallel to
    32683525  // coordinate axes, because this would make our further computations
    3269   // a lot easier.
    3270   // We choose a subset of our n variables of size d=dim(ideal). For each of these
    3271   // variables, we want to fix a value: x_i= a_i*t^-w_i. This will only work if the
    3272   // projection of the d-dim variety to the other n-d variables is the whole n-d plane.
    3273   // Then a general choice for a_i will intersect the variety in finitely many points.
    3274   // If the projection is not the whole n-d plane, then a general choice will not work.
    3275   // We could determine if we picked a good d-subset of variables using elimination
    3276   // (NOTE, there EXIST d variables such that a random choice of a_i's would work!).
    3277   // But since this involves many computations, we prefer to choose randomly and just
    3278   // try in the end if our intersected ideal satisfies our requirements. If this does not
     3526  // a lot easier.
     3527  // We choose a subset of our n variables of size d=dim(ideal).
     3528  // For each of these
     3529  // variables, we want to fix a value: x_i= a_i*t^-w_i.
     3530  // This will only work if the
     3531  // projection of the d-dim variety to the other n-d variables
     3532  // is the whole n-d plane.
     3533  // Then a general choice for a_i will intersect the variety
     3534  // in finitely many points.
     3535  // If the projection is not the whole n-d plane,
     3536  // then a general choice will not work.
     3537  // We could determine if we picked a good
     3538  // d-subset of variables using elimination
     3539  // (NOTE, there EXIST d variables such that
     3540  // a random choice of a_i's would work!).
     3541  // But since this involves many computations,
     3542  // we prefer to choose randomly and just
     3543  // try in the end if our intersected ideal
     3544  // satisfies our requirements. If this does not
    32793545  // work, we give up this try and use our second intersection idea, which
    32803546  // will work for a Zariksi-open subset (i.e. almost always).
    32813547  //
    3282   // As random subset of d variables we choose those for which the absolute value of the
    3283   // wvec-coordinate is smallest, because this will give us the smallest powers of t and hence
    3284   // less effort in following computations. Note that the smallest absolute value have those
    3285   // which are biggest, because wvec is negative.
     3548  // As random subset of d variables we choose
     3549  // those for which the absolute value of the
     3550  // wvec-coordinate is smallest, because this will
     3551  // give us the smallest powers of t and hence
     3552  // less effort in following computations.
     3553  // Note that the smallest absolute value have those
     3554  // which are biggest, because wvec is negative.
    32863555  //print("first try");
    32873556  intvec wminust=intvecdelete(wvec,1);
     
    32903559  A[1,1..size(wminust)]=-wminust;
    32913560  A[2,1..size(wminust)]=1..size(wminust);
    3292   // sort this matrix in order to get the d biggest entries and their position in wvec
    3293   A=sortintmat(A);
    3294   // we construct a vector which has 1 at entry j if j belongs to the list
     3561  // sort this matrix in order to get
     3562  // the d biggest entries and their position in wvec
     3563  A=sortintmat(A);
     3564  // we construct a vector which has 1 at entry j if j belongs to the list
    32953565  // of the d biggest entries of wvec and a 0 else
    32963566  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    33013571      {
    33023572        setvec[j1]=1;//put a 1
    3303       }
    3304     }
    3305   }
    3306   // using this 0/1-vector we produce a random constant (i.e. coeff in Q times something in t)
    3307   // for each of the biggest variables, we add the forms x_i-random constant to the ideal
    3308   // and we save the constant at the i-th place of a list we want to return for later computations
     3573      }       
     3574    } 
     3575  }
     3576  // using this 0/1-vector we produce
     3577  // a random constant (i.e. coeff in Q times something in t)
     3578  // for each of the biggest variables,
     3579  // we add the forms x_i-random constant to the ideal
     3580  // and we save the constant at the i-th place of
     3581  // a list we want to return for later computations
    33093582  j3=0;
    33103583  while (j3<=1)
     
    33163589    {
    33173590      if(setvec[j1]==1)//if x_i belongs to the biggest variables
    3318       {
     3591      {     
    33193592        if ((j3==1) and ((char(basering)==0) or (char(basering)>3)))
    3320         {
     3593        {       
    33213594          randomp1=random(1,3);
    3322           randomp=t^(A[1,j2])*randomp1;//make a random constant --- first we try small numbers
    3323         }
     3595          randomp=t^(A[1,j2])*randomp1;// make a random constant
     3596                                       // --- first we try small numbers
     3597        }   
    33243598        if ((j3==2) and ((char(basering)==0) or (char(basering)>100)))
    33253599        {
    33263600          randomp1=random(1,100);
    3327           randomp=t^(A[1,j2])*randomp1;//make a random constant --- next we try bigger numbers
    3328         }
     3601          randomp=t^(A[1,j2])*randomp1;// make a random constant
     3602                                       // --- next we try bigger numbers
     3603        }   
    33293604        else
    33303605        {
     
    33383613      else
    33393614      {
    3340         ergl[j1]=0; //if the variable belongs not the the d biggest ones, save 0 in the list
     3615        ergl[j1]=0; //if the variable belongs not the the d biggest ones,
     3616                    //save 0 in the list
    33413617        erglini[j1]=0;
    3342       }
     3618      }       
    33433619    }
    33443620      // print(ergl);print(pideal);
    3345       // now we check if we made a good choice of pideal, i.e. if dim=0 and
     3621      // now we check if we made a good choice of pideal, i.e. if dim=0 and 
    33463622      // wvec is still in the tropical variety
    3347       //change to quotring where we compute dimension
     3623      // change to quotring where we compute dimension
    33483624      cutideal=pideal;
    33493625    for(j1=1;j1<=nvars(basering)-1;j1++)
    33503626    {
    33513627      if(setvec[j1]==1)
    3352       {
    3353         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3354       }
     3628      {     
     3629        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     3630      }     
    33553631    }
    33563632    setring QUOTRING;
     
    33643640    {
    33653641      // compute the t-initial of the associated prime
    3366       // - the last 1 just means that the variable t is the last variable in the ring
     3642      // - the last 1 just means that the variable t is
     3643      //   the last variable in the ring
    33673644      pini=tInitialIdeal(cutideal,wvec ,1);
    33683645      //print("initial");
    33693646      //print(pini);
    3370       // and if the initial w.r.t. t contains no monomial as we want (checked with
     3647      // and if the initial w.r.t. t contains no monomial
     3648      // as we want (checked with
    33713649      // radical-membership of the product of all variables)
    3372       if (radicalMemberShip(product,pini)==0)
    3373       {
    3374         // we made the right choice and now we substitute the variables in the ideal
    3375         //to get an ideal in less variables
    3376         // also we make a projected vector from wvec only the components of the remaining variables
     3650      if (radicalMemberShip(product,pini)==0)
     3651      {
     3652        // we made the right choice and now
     3653        // we substitute the variables in the ideal   
     3654        // to get an ideal in less variables
     3655        // also we make a projected vector
     3656        // from wvec only the components of the remaining variables
    33773657        wvecp=wvec;
    3378         variablen=0;
     3658        variablen=0;   
    33793659        j2=0;
    33803660        for(j1=1;j1<=nvars(basering)-1;j1++)
     
    33893669          else
    33903670          {
    3391             variablen=variablen+var(j1); //read the set of remaining variables (needed to make quotring later)
    3392           }
    3393         }
     3671            variablen=variablen+var(j1); // read the set of remaining variables
     3672                                         // (needed to make quotring later)
     3673          }   
     3674        }     
    33943675        // return pideal, the initial and the list ergl which tells us
    33953676        // which variables we replaced by which form
     
    34013682        export(ini);
    34023683        export(repl);
    3403         return(list(BASERINGLESS1,wvecp));
     3684        return(list(BASERINGLESS1,wvecp)); 
    34043685      }
    34053686    }
    34063687  }
    34073688  // this is our second try to cut down, which we only use if the first try
    3408   // didn't work out. We intersect with d general hyperplanes (i.e. we don't choose
     3689  // didn't work out. We intersect with d general hyperplanes
     3690  // (i.e. we don't choose
    34093691  // them to be parallel to coordinate hyperplanes anymore. This works out with
    34103692  // probability 1.
    34113693  //
    3412   // We choose general hyperplanes, i.e. linear forms which involve all x_i.
    3413   // Each x_i has to be multiplied bz t^(w_i) in order to get the same weight (namely 0)
     3694  // We choose general hyperplanes, i.e. linear forms which involve all x_i.
     3695  // Each x_i has to be multiplied bz t^(w_i) in order
     3696  // to get the same weight (namely 0)
    34143697  // for each term. As we cannot have negative exponents, we multiply
    3415   // the whole form by t^minimumw. Notice that then in the first form,
     3698  // the whole form by t^minimumw. Notice that then in the first form, 
    34163699  // there is one term without t- the term of the variable
    34173700  // x_i such that w_i is minimal. That is, we can solve for this variable.
    3418   // In the second form, we can replace that variable, and divide by t as much as possible.
    3419   // Then there is again one term wihtout t - the term of the variable with second least w.
     3701  // In the second form, we can replace that variable,
     3702  // and divide by t as much as possible.
     3703  // Then there is again one term wihtout t -
     3704  // the term of the variable with second least w.
    34203705  // So we can solve for this one again and also replace it in the first form.
    3421   // Since all our coefficients are chosen randomly, we can also from the beginning on
    3422   // choose the set of variables which belong to the d smallest entries of wvec
    3423   // (t not counting) and pick random forms g_i(t,x') (where x' is the set of remaining variables)
    3424   // and set x_i=g_i(t,x').
     3706  // Since all our coefficients are chosen randomly,
     3707  // we can also from the beginning on
     3708  // choose the set of variables which belong to the d smallest entries of wvec
     3709  // (t not counting) and pick random forms g_i(t,x')
     3710  // (where x' is the set of remaining variables)
     3711  // and set x_i=g_i(t,x').
    34253712  //
    34263713  // make a matrix with first row wvec (without t) and second row 1..n
    34273714  //print("second try");
    34283715  setring BASERING;
    3429   A[1,1..size(wminust)]=wminust;
     3716  A[1,1..size(wminust)]=wminust; 
    34303717  A[2,1..size(wminust)]=1..size(wminust);
    3431   // sort this matrix in otder to get the d smallest entries (without counting the t-entry)
     3718  // sort this matrix in otder to get the d smallest entries
     3719  // (without counting the t-entry)
    34323720  A=sortintmat(A);
    34333721  randomp=0;
    34343722  setvec=0;
    34353723  setvec[nvars(basering)-1]=0;
    3436   // we construct a vector which has 1 at entry j if j belongs to the list of
     3724  // we construct a vector which has 1 at entry j if j belongs to the list of 
    34373725  // the d smallest entries of wvec and a 0 else
    34383726  for (j1=1;j1<=nvars(basering)-1;j1++) //go through the variables
     
    34543742    {
    34553743      j2=j2+1;
    3456       wvecp=intvecdelete(wvecp,j1+2-j2);//delete the components we substitute from wvec
     3744      wvecp=intvecdelete(wvecp,j1+2-j2);// delete the components
     3745                                        // we substitute from wvec
    34573746    }
    34583747    else
    34593748    {
    3460       variablen=variablen+var(j1); //read the set of remaining variables (needed to make the quotring later)
    3461     }
    3462   }
     3749      variablen=variablen+var(j1); // read the set of remaining variables
     3750                                   // (needed to make the quotring later)
     3751    }
     3752  }
    34633753  setring BASERING;
    34643754  execute("ring BASERINGLESS2=("+charstr(BASERING)+"),("+string(variablen)+",t),(dp("+string(ncols(variablen))+"),lp(1));");
    3465   // using the 0/1-vector which tells us which variables belong to the set of smallest entries of wvec
    3466   // we construct a set of d random linear polynomials of the form x_i=g_i(t,x'),
     3755  // using the 0/1-vector which tells us which variables belong
     3756  // to the set of smallest entries of wvec
     3757  // we construct a set of d random linear
     3758  // polynomials of the form x_i=g_i(t,x'),
    34673759  // where the set of all x_i is the set of
    3468   // all variables which are in the list of smallest entries in wvec, and x' are the other variables.
    3469   // We add these d random linear polynomials to the indeal pideal, i.e. we intersect
     3760  // all variables which are in the list of smallest
     3761  // entries in wvec, and x' are the other variables.
     3762  // We add these d random linear polynomials to
     3763  // the ideal pideal, i.e. we intersect
    34703764  // with these and hope to get something
    3471   // 0-dim which still contains wvec in its tropical variety. Also, we produce a list ergl
     3765  // 0-dim which still contains wvec in its
     3766  // tropical variety. Also, we produce a list ergl 
    34723767  // with g_i at the i-th position.
    34733768  // This is a list we want to return.
     
    34753770  setring BASERING;
    34763771  pideal=jideal;
    3477   for(j1=1;j1<=dimension;j1++)//go through the list of variables corres to the d smallest in wvec
    3478   {
     3772  for(j1=1;j1<=dimension;j1++)//go through the list of variables
     3773  { // corres to the d smallest in wvec
    34793774    if ((char(basering)==0) or (char(basering)>3))
    3480     {
     3775    { 
    34813776      randomp1=random(1,3);
    34823777      randomp=randomp1*t^(-A[1,j1]);
     
    34913786      if(setvec[j2]==0)//if x_j belongs to the set x'
    34923787      {
    3493         // add a random term with the suitable power of t to the random linear form
     3788        // add a random term with the suitable power
     3789        // of t to the random linear form
    34943790        if ((char(basering)==0) or (char(basering)>3))
    34953791        {
     
    35153811    }
    35163812  //print(ergl);
    3517   // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether
     3813  // Again, we have to test if we made a good choice
     3814  // to intersect,i.e. we have to check whether
    35183815  // pideal is 0-dim and contains wvec in the tropical variety.
    35193816  cutideal=pideal;
     
    35223819    if(setvec[j1]==1)
    35233820    {
    3524       cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3525     }
     3821      cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     3822    }   
    35263823  }
    35273824  setring QUOTRING;
     
    35353832  {
    35363833    // compute the t-initial of the associated prime
    3537     // - the last 1 just means that the variable t is the last variable in the ring
     3834    // - the last 1 just means that the variable t
     3835    // is the last variable in the ring
    35383836    pini=tInitialIdeal(cutideal,wvec ,1);
    35393837    //print("initial");
     
    35413839    // and if the initial w.r.t. t contains no monomial as we want (checked with
    35423840    // radical-membership of the product of all variables)
    3543     if (radicalMemberShip(product,pini)==0)
     3841    if (radicalMemberShip(product,pini)==0) 
    35443842    {
    35453843      // we want to replace the variables x_i by the forms -g_i in
    3546       // our ideal in order to return an ideal with less variables
     3844      // our ideal in order to return an ideal with less variables 
    35473845      // first we substitute the chosen variables
    35483846      for(j1=1;j1<=nvars(basering)-1;j1++)
     
    35613859      export(ini);
    35623860      export(repl);
    3563       return(list(BASERINGLESS2,wvecp));
     3861      return(list(BASERINGLESS2,wvecp)); 
    35643862    }
    35653863  }
    35663864  // now we try bigger numbers
    3567   while (1) //a never-ending loop which will stop with prob. 1 as we find a suitable ideal with that prob
    3568   {
     3865  while (1) //a never-ending loop which will stop with prob. 1
     3866  { // as we find a suitable ideal with that prob
    35693867    setring BASERING;
    35703868    pideal=jideal;
    3571     for(j1=1;j1<=dimension;j1++)//go through the list of variables corres to the d smallest in wvec
    3572     {
     3869    for(j1=1;j1<=dimension;j1++)//go through the list of variables
     3870    { // corres to the d smallest in wvec
    35733871      randomp1=random(1,100);
    35743872      randomp=randomp1*t^(-A[1,j1]);
    35753873      for(j2=1;j2<=nvars(basering)-1;j2++)//go through all variables
    3576       {
     3874      { 
    35773875        if(setvec[j2]==0)//if x_j belongs to the set x'
    35783876        {
    3579           // add a random term with the suitable power of t to the random linear form
     3877          // add a random term with the suitable power
     3878          // of t to the random linear form
    35803879          if ((char(basering)==0) or (char(basering)>100))
    3581           {
     3880          { 
    35823881            randomp2=random(1,100);
    35833882            randomp1=randomp1+randomp2*var(j2);
     
    36003899      }
    36013900    //print(ergl);
    3602     // Again, we have to test if we made a good choice to intersect,i.e. we have to check whether
     3901    // Again, we have to test if we made a good choice to
     3902    // intersect,i.e. we have to check whether
    36033903    // pideal is 0-dim and contains wvec in the tropical variety.
    36043904    cutideal=pideal;
     
    36073907      if(setvec[j1]==1)
    36083908      {
    3609         cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal
    3610       }
     3909        cutideal=cutideal,var(j1)-ergl[j1];//add all forms to the ideal 
     3910      }     
    36113911    }
    36123912    setring QUOTRING;
     
    36163916    //print(dimp);
    36173917    kill cutideal;
    3618     setring BASERING;
     3918    setring BASERING; 
    36193919    if (dimp==0) // if it is 0 as we want
    36203920    {
    36213921      // compute the t-initial of the associated prime
    3622       // - the last 1 just means that the variable t is the last variable in the ring
     3922      // - the last 1 just means that the variable t
     3923      // is the last variable in the ring
    36233924      pini=tInitialIdeal(cutideal,wvec ,1);
    36243925      //print("initial");
    36253926      //print(pini);
    3626       // and if the initial w.r.t. t contains no monomial as we want (checked with
     3927      // and if the initial w.r.t. t contains no monomial
     3928      // as we want (checked with
    36273929      // radical-membership of the product of all variables)
    3628       if (radicalMemberShip(product,pini)==0)
     3930      if (radicalMemberShip(product,pini)==0) 
    36293931      {
    36303932        // we want to replace the variables x_i by the forms -g_i in
     
    36373939            pideal=subst(pideal,var(j1),ergl[j1]);//substitute it
    36383940            pini=subst(pini,var(j1),erglini[j1]);
    3639           }
    3640         }
     3941          }   
     3942        }   
    36413943        // return pideal and the list ergl which tells us
    36423944        // which variables we replaced by which form
     
    36483950        export(ini);
    36493951        export(repl);
    3650         return(list(BASERINGLESS2,wvecp));
    3651       }
    3652     }
    3653   }
    3654 }
    3655 
     3952        return(list(BASERINGLESS2,wvecp));
     3953      }
     3954    }
     3955  }
     3956}
     3957
     3958
     3959/////////////////////////////////////////////////////////////////////////
    36563960
    36573961static proc tropicalparametriseNoabs (ideal i,intvec ww,int ordnung,int gfanold,int nogfan,list #)
    3658   "USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list
    3659 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], tw=(w_0,w_1,...,w_n,0,...,0)
    3660            and (w_0,...,w_n,0,...,0) is in the tropical variety of i,
    3661            and ord is the order up to which a point in V(i) over C((t)) lying over w shall be computed;
     3962"USAGE:  tropicalparametriseNoabs(i,tw,ord,gf,ng[,#]); i ideal, tw intvec, ord int, gf,ng int, # opt. list
     3963ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
     3964           tw=(w_0,w_1,...,w_n,0,...,0) and (w_0,...,w_n,0,...,0) is in
     3965           the tropical variety of i, and ord is the order up to which a point
     3966           in V(i) over C((t)) lying over w shall be computed;
    36623967         - moreover, k should be zero if the procedure is not called recursively;
    3663          - the point in the tropical variety is supposed to lie in the NEGATIVE orthant;
    3664          - the ideal is zero-dimensional when considered in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n],
    3665            where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k];
     3968         - the point in the tropical variety is supposed to lie in the NEGATIVE
     3969           orthant;
     3970         - the ideal is zero-dimensional when considered
     3971           in (Q(t)[X_1,...,X_k]/m)[x_1,...,x_n],
     3972           where m=#[2] is a maximal ideal in Q(t)[X_1,...,X_k];
    36663973         - gf is 0 if version 2.2 or larger is used and it is 1 else
    3667          - ng is 1 if gfan should not be executed
     3974         - ng is 1 if gfan should not be executed 
    36683975RETURN:  list, l[1] = ring Q(0,X_1,...,X_r)[[t]]
    36693976               l[2] = int
    36703977               l[3] = string
    36713978NOTE:    - the procedure is also called recursively by itself, and
    3672            if it is called in the first recursion, the list # is empty,
    3673            otherwise #[1] is an integer, one more than the number of true variables x_1,...,x_n,
     3979           if it is called in the first recursion, the list # is empty,
     3980           otherwise #[1] is an integer, one more than the number
     3981           of true variables x_1,...,x_n,
    36743982           and #[2] will contain the maximal ideal m in the variables X_1,...X_k
    36753983           by which the ring Q[t,x_1,...,x_n,X_1,...,X_k] should be divided to
    36763984           work correctly in K[t,x_1,...,x_n] where K=Q[X_1,...,X_k]/m is a field
    36773985           extension of Q;
    3678          - the ring l[1] contains an ideal PARA, which contains the parametrisation
    3679            of a point in V(i) lying over w up to the first ord terms;
    3680          - the string m=l[3] contains the code of the maximal ideal m, by which we have
    3681            to divide Q[X_1,...,X_r] in order to have the appropriate field extension
    3682            over which the parametrisation lives;
    3683          - and if the integer l[2] is N then t has to be replaced by t^1/N in the
    3684            parametrisation, or alternatively replace t by t^N in the defining ideal
    3685          - the procedure REQUIRES that the program GFAN is installed on your computer"
     3986         - the ring l[1] contains an ideal PARA, which contains the
     3987           parametrisation of a point in V(i) lying over w up to the
     3988           first ord terms;
     3989         - the string m=l[3] contains the code of the maximal ideal m,
     3990           by which we have to divide Q[X_1,...,X_r] in order to have
     3991           the appropriate field extension over which the parametrisation lives;
     3992         - and if the integer l[2] is N then t has to be replaced by t^1/N in
     3993           the parametrisation, or alternatively replace t by t^N in the
     3994           defining ideal
     3995         - the procedure REQUIRES that the program GFAN is installed on
     3996           your computer"
    36863997{
    36873998  def ALTRING=basering;
     
    36904001  if (size(#)==2) // this means the precedure has been called recursively
    36914002  {
    3692     // how many variables are true variables, and how many come from the field extension
     4003    // how many variables are true variables, and how many come
     4004    // from the field extension
    36934005    // only true variables have to be transformed
    36944006    int anzahlvariablen=#[1];
    36954007    ideal gesamt_m=std(#[2]); // stores all maxideals used for field extensions
    36964008    // find the zeros of the w-initial ideal and transform the ideal i;
    3697     // findzeros and basictransformideal need to know how many of the variables are true variables
     4009    // findzeros and basictransformideal need to know how
     4010    // many of the variables are true variables
    36984011    list m_ring=findzeros(i,ww,anzahlvariablen);
    36994012    list btr=basictransformideal(i,ww,m_ring,anzahlvariablen);
     
    37014014  else // the procedure has been called by tropicalLifting
    37024015  {
    3703     // how many variables are true variables, and how many come from the field extension
    3704     // only true variables have to be transformed
     4016    // how many variables are true variables, and how many come from
     4017    // the field extension only true variables have to be transformed
    37054018    int anzahlvariablen=nvars(basering);
    37064019    ideal gesamt_m; // stores all maxideals used for field extensions
     
    37084021    ideal ini=#[1];
    37094022    // find the zeros of the w-initial ideal and transform the ideal i;
    3710     // we should hand the t-initial ideal ine to findzeros, since we know it already
     4023    // we should hand the t-initial ideal ine to findzeros,
     4024    // since we know it already
    37114025    list m_ring=findzeros(i,ww,ini);
    37124026    list btr=basictransformideal(i,ww,m_ring);
     
    37214035    def TRRING=btr[1];
    37224036    setring TRRING;
    3723     ideal gesamt_m=imap(PREVIOUSRING,gesamt_m)+m; // add the newly found maximal ideal to the previous ones
     4037    ideal gesamt_m=imap(PREVIOUSRING,gesamt_m)+m; // add the newly found maximal
     4038                                                  // ideal to the previous ones
    37244039  }
    37254040  else
     
    37284043    list a=btr[2];
    37294044    ideal m=btr[3];
    3730     gesamt_m=gesamt_m+m; // add the newly found maximal ideal to the previous ones
     4045    gesamt_m=gesamt_m+m; // add the newly found maximal
     4046                         // ideal to the previous ones
    37314047  }
    37324048  // check if there is a solution which has the n-th component zero,
    3733   // if so, then eliminate the n-th variable from sat(i+x_n,t), otherwise leave i as it is;
    3734   // then check if the (remaining) ideal has as solution where the n-1st component is zero,
     4049  // if so, then eliminate the n-th variable from sat(i+x_n,t),
     4050  // otherwise leave i as it is;
     4051  // then check if the (remaining) ideal has as solution
     4052  // where the n-1st component is zero,
    37354053  // and procede as before; do the same for the remaining variables;
    3736   // this way we make sure that the remaining ideal has a solution which has no component zero;
     4054  // this way we make sure that the remaining ideal has
     4055  // a solution which has no component zero;
    37374056  intvec deletedvariables;    // the jth entry is set 1, if we eliminate x_j
    37384057  int numberdeletedvariables; // the number of eliminated variables
    3739   ideal variablen;            // will contain the variables which are not eliminated
    3740   intvec tw=ww; // in case some variables are deleted, we have to store the old weight vector
     4058  ideal variablen;  // will contain the variables which are not eliminated
     4059  intvec tw=ww;     // in case some variables are deleted,
     4060                    // we have to store the old weight vector
    37414061  deletedvariables[anzahlvariablen]=0;
    3742   ideal I,LI;
     4062  ideal I,LI; 
    37434063  i=i+m; // if a field extension was necessary, then i has to be extended by m
    37444064  for (jj=anzahlvariablen-1;jj>=1;jj--)  // the variable t is the last one !!!
     
    37464066    I=sat(ideal(var(jj)+i),t)[1];
    37474067    LI=subst(I,var(nvars(basering)),0);
    3748     for (kk=1;kk<=size(deletedvariables)-1;kk++) //size(deletedvariables)=anzahlvariablen(before elim.)
     4068    //size(deletedvariables)=anzahlvariablen(before elim.)
     4069    for (kk=1;kk<=size(deletedvariables)-1;kk++)
    37494070    {
    37504071      LI=subst(LI,var(kk),0);
    37514072    }
    3752     if (size(LI)==0) // if no power of t is in lead(I) (where the X(i) are considered as field elements)
    3753     {
    3754       // get rid of var(jj)
     4073    if (size(LI)==0) // if no power of t is in lead(I)
     4074    { // (where the X(i) are considered as field elements)
     4075      // get rid of var(jj)   
    37554076      i=eliminate(I,var(jj));
    37564077      deletedvariables[jj]=1;
    3757       anzahlvariablen--;         // if a variable is eliminated, then the number of true variables drops
     4078      anzahlvariablen--; // if a variable is eliminated,
     4079                         // then the number of true variables drops
    37584080      numberdeletedvariables++;
    37594081    }
     
    37644086  }
    37654087  variablen=invertorder(variablen);
    3766   // store also the additional variables and t, since they for sure have not been eliminated
     4088  // store also the additional variables and t,
     4089  // since they for sure have not been eliminated
    37674090  for (jj=anzahlvariablen+numberdeletedvariables-1;jj<=nvars(basering);jj++)
    37684091  {
    37694092    variablen=variablen+var(jj);
    37704093  }
    3771   // if some variables have been eliminated, then pass to a new ring which has less variables,
     4094  // if some variables have been eliminated,
     4095  // then pass to a new ring which has less variables,
    37724096  // but if no variables are left, then we are done
    37734097  def BASERING=basering;
    3774   if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains, all true variables are gone
    3775   {
     4098  if ((numberdeletedvariables>0) and (anzahlvariablen>1)) // if only t remains,
     4099  { // all true variables are gone
    37764100    execute("ring NEURING=("+charstr(basering)+"),("+string(variablen)+"),(dp("+string(size(variablen)-1)+"),lp(1));");
    37774101    ideal i=imap(BASERING,i);
    3778     ideal gesamt_m=imap(BASERING,gesamt_m);
    3779   }
    3780   // now we have to compute a point ww on the tropical variety of the transformed ideal i;
    3781   // of course, we only have to do so, if we have not yet reached the order up to which we
     4102    ideal gesamt_m=imap(BASERING,gesamt_m);   
     4103  }
     4104  // now we have to compute a point ww on the tropical variety
     4105  // of the transformed ideal i;
     4106  // of course, we only have to do so, if we have not yet
     4107  // reached the order up to which we
    37824108  // were supposed to do our computations
    3783   if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, all true variables are gone
    3784   {
     4109  if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
     4110  { // all true variables are gone
    37854111    def PREGFANRING=basering;
    37864112    if (nogfan!=1)
    3787     {
     4113    {     
    37884114      // pass to a ring which has variables which are suitable for gfan
    37894115      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;");
    3790       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;
     4116      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; 
    37914117      phiideal[nvars(PREGFANRING)]=a; // map t to a
    3792       map phi=PREGFANRING,phiideal;
     4118      map phi=PREGFANRING,phiideal; 
    37934119      ideal i=phi(i);
    3794       // homogenise the ideal i with the first not yet used variable in our ring, since gfan
    3795       // only handles homogenous ideals; in principle for this one has first to compute a
    3796       // standard basis of i and homogenise that, but for the tropical variety (says Anders)
     4120      // homogenise the ideal i with the first not yet
     4121      // used variable in our ring, since gfan
     4122      // only handles homogenous ideals; in principle
     4123      // for this one has first to compute a
     4124      // standard basis of i and homogenise that,
     4125      // but for the tropical variety (says Anders)
    37974126      // it suffices to homogenise an arbitrary system of generators
    3798       // i=groebner(i);
     4127      // i=groebner(i); 
    37994128      i=homog(i,maxideal(1)[nvars(PREGFANRING)+1]);
    38004129      // if gfan version >= 0.3.0 is used and the characteristic
     
    38084137        write(":a /tmp/gfaninput","{"+string(i)+"}");
    38094138      }
    3810       else
     4139      else 
    38114140      {
    38124141        // write the ideal to a file which gfan takes as input and call gfan
     
    38294158        string trop=read("/tmp/gfanoutput");
    38304159        setring PREGFANRING;
    3831         intvec wneu=-1;    // this integer vector will store the point on the tropical variety
     4160        intvec wneu=-1;    // this integer vector will store
     4161                           // the point on the tropical variety
    38324162        wneu[nvars(basering)]=0;
    38334163        // for the time being simply stop Singular and set wneu by yourself
    38344164        int goon=1;
    38354165        trop;
    3836         "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
     4166        "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY";
     4167        "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
    38374168        "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -";
    38384169        "THEN TYPE THE FOLLOWING COMMAND IN SINGULAR:   wneu=-3,-4,-1,-5,0,0;";
     
    38404171        "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    38414172        ~
    3842           // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE TROPICAL PREVARIETY
    3843           // test, if wneu really is in the tropical variety
    3844           while (goon==0)
     4173          // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE
     4174          // TROPICAL PREVARIETY
     4175          // test, if wneu really is in the tropical variety   
     4176        while (goon==0)
    38454177        {
    38464178          if (testw(reduce(i,std(gesamt_m)),wneu,anzahlvariablen)==1)
     
    38584190      {
    38594191        system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    3860         // read the result from gfan and store it to a string, which in a later version
     4192        // read the result from gfan and store it to a string,
     4193        // which in a later version
    38614194        // should be interpreded by Singular
    38624195        intvec wneu=choosegfanvector(read("/tmp/gfanoutput"),0)[1];
     
    38704203    }
    38714204  }
    3872   // if we have not yet computed our parametrisation up to the required order and
    3873   // zero is not yet a solution, then we have to go on by calling the procedure recursively;
     4205  // if we have not yet computed our parametrisation
     4206  // up to the required order and
     4207  // zero is not yet a solution, then we have
     4208  // to go on by calling the procedure recursively;
    38744209  // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    38754210  if ((ordnung>1) and (anzahlvariablen>1))
    3876   {
    3877     // we call the procedure with the transformed ideal i, the new weight vector, with the
    3878     // required order lowered by one, and with additional parameters, namely the number of
    3879     // true variables and the maximal ideal that was computed so far to describe the field extension
     4211  {   
     4212    // we call the procedure with the transformed ideal i,
     4213    // the new weight vector, with the
     4214    // required order lowered by one, and with
     4215    // additional parameters, namely the number of
     4216    // true variables and the maximal ideal that
     4217    // was computed so far to describe the field extension
    38804218    list PARALIST=tropicalparametriseNoabs(i,wneu,ordnung-1,gfanold,nogfan,anzahlvariablen,gesamt_m);
    3881     // the output will be a ring, in which the parametrisation lives, and a string, which contains
     4219    // the output will be a ring, in which the
     4220    // parametrisation lives, and a string, which contains
    38824221    // the maximal ideal that describes the necessary field extension
    38834222    def PARARing=PARALIST[1];
     
    38854224    string PARAm=PARALIST[3];
    38864225    setring PARARing;
    3887     // if some variables have been eliminated in before, then we have to insert zeros
     4226    // if some variables have been eliminated in before,
     4227    // then we have to insert zeros
    38884228    // into the parametrisation for those variables
    38894229    if (numberdeletedvariables>0)
     
    38914231      ideal PARAneu=PARA;
    38924232      int k;
    3893       for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits no parametrisation
    3894       {
     4233      for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++) // t admits
     4234      { // no parametrisation
    38954235        if (deletedvariables[jj]!=1)
    38964236        {
     
    39054245    }
    39064246  }
    3907   // otherwise we are done and we can start to compute the last step of the parametrisation
     4247  // otherwise we are done and we can start to compute
     4248  // the last step of the parametrisation
    39084249  else
    39094250  {
    39104251    // we store the information on m in a string
    39114252    string PARAm=string(gesamt_m);
    3912     // we define the weight of t, i.e. in the parametrisation t has to be replaced by t^1/tweight
     4253    // we define the weight of t, i.e. in the parametrisation t
     4254    // has to be replaced by t^1/tweight
    39134255    int tweight=-tw[1];
    3914     // if additional variables were necessary, we introduce them now as parameters;
    3915     // in any case the parametrisation ring will have only one variable, namely t,
    3916     // and its order will be local, so that it displays the lowest term in t first
     4256    // if additional variables were necessary,
     4257    // we introduce them now as parameters;
     4258    // in any case the parametrisation ring will
     4259    // have only one variable, namely t, 
     4260    // and its order will be local, so that it
     4261    // displays the lowest term in t first
    39174262    if (anzahlvariablen+numberdeletedvariables<nvars(basering))
    39184263    {
     
    39244269    }
    39254270    ideal PARA; // will contain the parametrisation
    3926     // we start by initialising the entries to be zero; one entry for each true variable
    3927     // here we also have to consider the variables that we have eliminated in before
     4271    // we start by initialising the entries to be zero;
     4272    // one entry for each true variable
     4273    // here we also have to consider the variables
     4274    // that we have eliminated in before
    39284275    for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++)
    39294276    {
     
    39314278    }
    39324279  }
    3933   // we now have to change the parametrisation by reverting the transformations that we have done
     4280  // we now have to change the parametrisation by
     4281  // reverting the transformations that we have done
    39344282  list a=imap(BASERING,a);
    3935   if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the last time, it does not
    3936   {                     // enter the part, where wneu is defined and the variable t should have
    3937     intvec wneu=-1;     // weight -1
     4283  if (defined(wneu)==0) // when tropicalparametriseNoabs is called for the
     4284  { // last time, it does not enter the part, where wneu is defined and the
     4285    intvec wneu=-1;     // variable t should have weight -1
    39384286  }
    39394287  for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++)
     
    39414289    PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight/ww[1]);
    39424290  }
    3943   // if we have reached the stop-level, i.e. either we had only to compute up to order 1
    3944   // or zero was a solution of the ideal, then we have to export the computed parametrisation
     4291  // if we have reached the stop-level, i.e. either
     4292  // we had only to compute up to order 1
     4293  // or zero was a solution of the ideal, then we have
     4294  // to export the computed parametrisation
    39454295  // otherwise it has already been exported before
    39464296  // note, if all variables were deleted, then i==0 and thus testaufnull==0
    39474297  if ((ordnung==1) or (anzahlvariablen==1))
    3948   {
     4298  {   
    39494299    export(PARA);
    39504300  }
    39514301  // kill the gfan files in /tmp
    39524302  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    3953   // we return a list which contains the parametrisation ring (with the parametrisation ideal)
    3954   // and the string representing the maximal ideal describing the necessary field extension
     4303  // we return a list which contains the
     4304  // parametrisation ring (with the parametrisation ideal)
     4305  // and the string representing the maximal ideal
     4306  // describing the necessary field extension
    39554307  return(list(PARARing,tweight,PARAm));
    39564308}
    39574309
     4310/////////////////////////////////////////////////////////////////////////
     4311
    39584312static proc findzeros (ideal i,intvec w,list #)
    3959   "USAGE:      findzeros(i,w[,#]); i ideal, w intvec, # an optional list
    3960 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and w=(w_0,...,w_n,0,...,0)
    3961              is in the tropical variety of i
    3962 RETURN:      list, l[1] = is polynomial ring containing an associated maximal ideal m of the w-initial
    3963                           ideal of i which does not contain any monomial and where the variables
    3964                           which do not lead to a field extension have already been eliminated,
    3965                           and containing a list a such that the non-zero entries of a correspond
    3966                           to the values of the zero of the associated maximal ideal for the
     4313"USAGE:      findzeros(i,w[,#]); i ideal, w intvec, # an optional list
     4314ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_n+1,...,X_m] and
     4315             w=(w_0,...,w_n,0,...,0) is in the tropical variety of i
     4316RETURN:      list, l[1] = is polynomial ring containing an associated maximal
     4317                          ideal m of the w-initial ideal of i which does not
     4318                          contain any monomial and where the variables
     4319                          which do not lead to a field extension have already
     4320                          been eliminated, and containing a list a such that
     4321                          the non-zero entries of a correspond to the values
     4322                          of the zero of the associated maximal ideal for the
    39674323                          eliminated variables
    39684324                   l[2] = number of variables which have not been eliminated
    3969                    l[3] = intvec, if the entry is one then the corresponding variable has not
    3970                           been eliminated
    3971 NOTE:        the procedure is called from inside the recursive procedure tropicalparametriseNoabs;
    3972              if it is called in the first recursion, the list #[1] contains the t-initial ideal
    3973              of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true
    3974              variables x_1,...,x_n"
    3975 {
    3976   def BASERING=basering;
     4325                   l[3] = intvec, if the entry is one then the corresponding
     4326                                  variable has not been eliminated
     4327NOTE:        the procedure is called from inside the recursive procedure
     4328             tropicalparametriseNoabs;
     4329             if it is called in the first recursion, the list #[1] contains
     4330             the t-initial ideal of i w.r.t. w, otherwise #[1] is an integer,
     4331             one more than the number of true variables x_1,...,x_n"
     4332{
     4333  def BASERING=basering; 
    39774334  // set anzahlvariablen to the number of true variables
    39784335  if (typeof(#[1])=="int")
     
    39804337    int anzahlvariablen=#[1];
    39814338    // compute the initial ideal of i
    3982     // - the last 1 just means that the variable t is the last variable in the ring
     4339    // - the last 1 just means that the variable t is the last
     4340    //   variable in the ring
    39834341    ideal ini=tInitialIdeal(i,w,1);
    39844342  }
     
    39864344  {
    39874345    int anzahlvariablen=nvars(basering);
    3988     ideal ini=#[1]; // the t-initial ideal has been computed in before and was handed over
    3989   }
    3990   // move to a polynomial ring with global monomial ordering - the variable t is superflous
     4346    ideal ini=#[1]; // the t-initial ideal has been computed
     4347                    // in before and was handed over
     4348  }
     4349  // move to a polynomial ring with global monomial ordering
     4350  // - the variable t is superflous
    39914351  ideal variablen;
    39924352  for (int j=1;j<=nvars(basering)-1;j++)
    3993   {
     4353  {   
    39944354    variablen=variablen+var(j);
    39954355  }
     
    39974357  ideal ini=imap(BASERING,ini);
    39984358  // compute the associated primes of the initialideal
    3999   // ordering the maximal ideals shall help to avoid unneccessary field extensions
     4359  // ordering the maximal ideals shall help to avoid
     4360  // unneccessary field extensions
    40004361  list maximalideals=ordermaximalidealsNoabs(minAssGTZ(std(ini)),anzahlvariablen);
    40014362  ideal m=maximalideals[1][1];              // the first associated maximal ideal
    40024363  int neuvar=maximalideals[1][2];           // the number of new variables needed
    4003   intvec neuevariablen=maximalideals[1][3]; // the information which variable leads to a new one
    4004   list a=maximalideals[1][4];               // a_k is the kth component of a zero of m, if it is not zero
    4005   // eliminate from m the superflous variables, that is those ones, which do not lead to
    4006   // a new variable
     4364  intvec neuevariablen=maximalideals[1][3]; // the information which variable
     4365                                            // leads to a new one
     4366  list a=maximalideals[1][4];               // a_k is the kth component of a
     4367                                            // zero of m, if it is not zero
     4368  // eliminate from m the superflous variables, that is those ones,
     4369  // which do not lead to a new variable
    40074370  poly elimvars=1;
    40084371  for (j=1;j<=anzahlvariablen-1;j++)
     
    40134376    }
    40144377  }
    4015   m=eliminate(m,elimvars);
    4016   export(a);
     4378  m=eliminate(m,elimvars); 
     4379  export(a); 
    40174380  export(m);
    40184381  list m_ring=INITIALRING,neuvar,neuevariablen;
     
    40224385
    40234386
     4387/////////////////////////////////////////////////////////////////////////
     4388
    40244389static proc basictransformideal (ideal i,intvec w,list m_ring,list #)
    4025   "USAGE:      basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list
    4026 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k], w=(w_0,...,w_n,0,...,0)
    4027              is in the tropical variety of i, and m_ring contains a ring containing a maximal ideal m needed
    4028              to describe the field extension over which a corresponding associated maximal ideal of the
    4029              initialideal of i, considered in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n],
    4030              has a zero, and containing a list a describing the zero of m, and m_ring contains
    4031              the information how many new variables are needed for m
    4032 RETURN:      list, either l[1] = ideal, i transformed by x_j -> (a_j+x_j)*t^w_j
    4033                           l[2] = list,  a_1,...,a_n a point in V(m)
    4034                           l[3] = ideal, the maximal ideal m
    4035                    or l[1] = ring which contains the ideals i and m, and the list a
    4036 NOTE:        the procedure is called from inside the recursive procedure tropicalparametriseNoabs;
    4037              if it is called in the first recursion, the list # is empty,
    4038              otherwise #[1] is an integer, the number of true variables x_1,...,x_n;
    4039              during the procedure we check if a field extension is necessary to express
    4040              a zero (a_1,...,a_n) of m; if so, we have to introduce new variables and
    4041              a list containing a ring is returned, otherwise the list containing i, a and m
    4042              is returned;
    4043              the ideal m will be changed during the procedure since all variables which reduce
    4044              to a polynomial in X_1,...,X_k modulo m will be eliminated, while the others are
    4045              replaced by new variables X_k+1,...,X_k'"
     4390"USAGE:  basictransformideal(i,w,m_ring[,#]); i ideal, w intvec, m_ring list, # an optional list
     4391ASSUME:  i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k],
     4392         w=(w_0,...,w_n,0,...,0) is in the tropical variety of i, and
     4393         m_ring contains a ring containing a maximal ideal m needed
     4394         to describe the field extension over which a corresponding
     4395         associated maximal ideal of the initialideal of i, considered
     4396         in (Q[X_1,...,X_k]/m_alt)(t)[x_1,...,x_n], has a zero, and
     4397         containing a list a describing the zero of m, and m_ring contains
     4398         the information how many new variables are needed for m
     4399RETURN:  list, either l[1] = ideal, i transformed by x_j -> (a_j+x_j)*t^w_j
     4400                      l[2] = list,  a_1,...,a_n a point in V(m)
     4401                      l[3] = ideal, the maximal ideal m
     4402               or l[1] = ring which contains the ideals i and m, and the list a
     4403NOTE:    the procedure is called from inside the recursive procedure
     4404         tropicalparametriseNoabs;
     4405         if it is called in the first recursion, the list # is empty,
     4406         otherwise #[1] is an integer, the number of true variables x_1,...,x_n;
     4407         during the procedure we check if a field extension is necessary
     4408         to express a zero (a_1,...,a_n) of m; if so, we have to introduce
     4409         new variables and a list containing a ring is returned, otherwise
     4410         the list containing i, a and m is returned;
     4411         the ideal m will be changed during the procedure since all variables
     4412         which reduce to a polynomial in X_1,...,X_k modulo m will be eliminated,
     4413         while the others are replaced by new variables X_k+1,...,X_k'"
    40464414{
    40474415  def BASERING=basering;  // the variable t is acutally the LAST variable !!!
     
    40534421    wdegs[j]=deg(i[j],intvec(w[2..size(w)],w[1]));
    40544422  }
    4055   // how many variables are true variables, and how many come from the field extension
     4423  // how many variables are true variables,
     4424  // and how many come from the field extension
    40564425  // only real variables have to be transformed
    40574426  if (size(#)>0)
     
    40674436  // get the information if any new variables are needed from m_ring
    40684437  int neuvar=m_ring[2];  // number of variables which have to be added
    4069   intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp. of a zero of m a new variable is needed
     4438  intvec neuevariablen=m_ring[3];  // [i]=1, if for the ith comp.
     4439                                   // of a zero of m a new variable is needed
    40704440  def MRING=m_ring[1];   // MRING contains a and m
    4071   list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m
    4072   ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0, otherwise we change the ring anyway
    4073   // if a field extension is needed, then extend the polynomial ring by new variables X_k+1,...,X_k';
     4441  list a=imap(MRING,a);  // (a_1,...,a_n)=(a[2],...,a[n+1]) will be
     4442                         // a common zero of the ideal m
     4443  ideal m=std(imap(MRING,m)); // m is zero, if neuvar==0,
     4444                              // otherwise we change the ring anyway
     4445  // if a field extension is needed, then extend the polynomial
     4446  // ring by new variables X_k+1,...,X_k';
    40744447  if (neuvar>0)
    40754448  {
    4076     // change to a ring where for each variable needed in m a new variable has been introduced
     4449    // change to a ring where for each variable needed
     4450    // in m a new variable has been introduced
    40774451    ideal variablen;
    40784452    // extract the variables x_1,...,x_n
     
    40844458    // map i into the new ring
    40854459    ideal i=imap(BASERING,i);
    4086     // define a map phi which maps the true variables, which are not
     4460    // define a map phi which maps the true variables, which are not 
    40874461    // reduced to polynomials in the additional variables modulo m, to
    4088     // the corresponding newly introduced variables, and which maps
     4462    // the corresponding newly introduced variables, and which maps 
    40894463    // the old additional variables to themselves
    40904464    ideal phiideal;
    40914465    k=1;
    4092     for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the first entry corresponds to t
    4093     {
     4466    for (j=2;j<=size(neuevariablen);j++)  // starting with 2, since the
     4467    { // first entry corresponds to t
    40944468      if(neuevariablen[j]==1)
    40954469      {
     
    40994473      else
    41004474      {
    4101         phiideal[j-1]=0;
     4475        phiideal[j-1]=0; 
    41024476      }
    41034477    }
     
    41064480      phiideal=phiideal,X(1..nvars(BASERING)-anzahlvariablen);
    41074481    }
    4108     map phi=MRING,phiideal;
    4109     // map m and a to the new ring via phi, so that the true variables in m and a are replaced by
     4482    map phi=MRING,phiideal;
     4483    // map m and a to the new ring via phi, so that the true variables
     4484    // in m and a are replaced by
    41104485    // the corresponding newly introduced variables
    41114486    ideal m=std(phi(m));
    41124487    list a=phi(a);
    41134488  }
    4114   // replace now the zeros among the a_j by the corresponding newly introduced variables;
    4115   // note that no component of a can be zero since the maximal ideal m contains no variable!
    4116   // moreover, substitute right away in the ideal i the true variable x_j by (a_j+x_j)*t^w_j
     4489  // replace now the zeros among the a_j by the corresponding
     4490  // newly introduced variables;
     4491  // note that no component of a can be zero
     4492  // since the maximal ideal m contains no variable!
     4493  // moreover, substitute right away in the ideal i
     4494  // the true variable x_j by (a_j+x_j)*t^w_j
    41174495  zaehler=nvars(BASERING)-anzahlvariablen+1;
    4118   for (j=1;j<=anzahlvariablen;j++)
     4496  for (j=1;j<=anzahlvariablen;j++) 
    41194497  {
    41204498    if ((a[j]==0) and (j!=1))  // a[1]=0, since t->t^w_0
    4121     {
     4499    {       
    41224500      a[j]=X(zaehler);
    41234501      zaehler++;
     
    41264504    {
    41274505      if (j!=1) // corresponds to  x_(j-1) --  note t is the last variable
    4128       {
     4506      {       
    41294507        i[k]=substitute(i[k],var(j-1),(a[j]+var(j-1))*t^(-w[j]));
    41304508      }
     
    41384516  for (j=1;j<=ncols(i);j++)
    41394517  {
    4140     if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and we made sure that it is no positive
    4141     {
     4518    if (wdegs[j]<0) // if wdegs[j]==0 there is no need to divide, and
     4519    { // we made sure that it is no positive
    41424520      i[j]=i[j]/t^(-wdegs[j]);
    41434521    }
    41444522  }
    4145   // since we want to consider i now in the ring (Q[X_1,...,X_k']/m)[t,x_1,...,x_n]
    4146   // we can  reduce i modulo m, so that "constant terms" which are "zero" since they
     4523  // since we want to consider i now in the ring
     4524  // (Q[X_1,...,X_k']/m)[t,x_1,...,x_n]
     4525  // we can  reduce i modulo m, so that "constant terms"
     4526  // which are "zero" since they
    41474527  // are in m will disappear; simplify(...,2) then really removes them
    41484528  i=simplify(reduce(i,m),2);
    4149   // if new variables have been introduced, we have to return the ring containing i, a and m
     4529  // if new variables have been introduced, we have
     4530  // to return the ring containing i, a and m
    41504531  // otherwise we can simply return a list containing i, a and m
    41514532  if (neuvar>0)
     
    41634544}
    41644545
     4546/////////////////////////////////////////////////////////////////////////
     4547
    41654548static proc testw (ideal i,intvec w,int anzahlvariablen,list #)
    41664549"USAGE:      testw(i,w,n); i ideal, w intvec, n number
    4167 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and w=(w_0,...,w_n,0,...,0)
    4168 RETURN:      int b, 0 if the t-initial ideal of i considered in Q(X_1,...,X_k)[t,x_1,...,x_n]
    4169                     is monomial free, 1 else
     4550ASSUME:      i is an ideal in Q[t,x_1,...,x_n,X_1,...,X_k] and
     4551             w=(w_0,...,w_n,0,...,0)           
     4552RETURN:      int b, 0 if the t-initial ideal of i considered in
     4553                    Q(X_1,...,X_k)[t,x_1,...,x_n] is monomial free, 1 else
    41704554NOTE:        the procedure is called by tinitialform"
    41714555{
     
    41804564    ideal tin=tInitialIdeal(i,w,1);
    41814565  }
    4182 
     4566 
    41834567  int j;
    41844568  ideal variablen;
     
    42124596  def BASERING=basering;
    42134597  if (anzahlvariablen<nvars(basering))
    4214   {
     4598  {   
    42154599    execute("ring TINRING=("+charstr(basering)+","+string(Parameter)+"),("+string(variablen)+"),dp;");
    42164600  }
     
    42224606  poly monom=imap(BASERING,monom);
    42234607  return(radicalMemberShip(monom,tin));
    4224 }
     4608
     4609
     4610/////////////////////////////////////////////////////////////////////////
    42254611
    42264612static proc simplifyToOrder (poly f)
    42274613"USAGE:      simplifyToOrder(f); f a polynomial
    4228 ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n]
     4614ASSUME:      f is a polynomial in Q(t)[x_1,...,x_n] 
    42294615RETURN:      list, l[1] = t-order of leading term of f
    42304616                   l[2] = the rational coefficient of the term of lowest t-order
     
    42454631}
    42464632
     4633/////////////////////////////////////////////////////////////////////////
     4634
    42474635static proc scalarproduct (intvec w,intvec v)
    42484636"USAGE:      scalarproduct(w,v); w,v intvec
    4249 ASSUME:      w and v are integer vectors of the same length
     4637ASSUME:      w and v are integer vectors of the same length 
    42504638RETURN:      int, the scalarproduct of v and w
    42514639NOTE:        the procedure is called by tropicalparametriseNoabs"
     
    42584646  return(sp);
    42594647}
     4648
     4649/////////////////////////////////////////////////////////////////////////
    42604650
    42614651static proc intvecdelete (intvec w,int i)
     
    42834673}
    42844674
     4675/////////////////////////////////////////////////////////////////////////
     4676
    42854677static proc invertorder (ideal i)
    42864678"USAGE:      intvertorder(i); i ideal
     
    42964688}
    42974689
     4690/////////////////////////////////////////////////////////////////////////
     4691
    42984692static proc ordermaximalidealsNoabs (list minassi,int anzahlvariablen)
    42994693"USAGE:      ordermaximalidealsNoabs(minassi); minassi list
    43004694ASSUME:      minassi is a list of maximal ideals
    4301 RETURN:      list, the procedure orders the maximal ideals in minassi according to how many new
    4302                    variables are needed to describe the zeros of the ideal
     4695RETURN:      list, the procedure orders the maximal ideals in minassi according
     4696                   to how many new variables are needed to describe the zeros
     4697                   of the ideal
    43034698                   l[j][1] = jth maximal ideal
    43044699                   l[j][2] = the number of variables needed
    4305                    l[j][3] = intvec, if for the kth variable a new variable is needed to
    4306                              define the corresponding zero of l[j][1], then the k+1st entry is one
    4307                    l[j][4] = list, if for the kth variable no new variable is needed to
    4308                              define the corresponding zero of l[j][1], then its value is the k+1st entry
     4700                   l[j][3] = intvec, if for the kth variable a new variable is
     4701                                     needed to define the corresponding zero of
     4702                                     l[j][1], then the k+1st entry is one
     4703                   l[j][4] = list, if for the kth variable no new variable is
     4704                                   needed to define the corresponding zero of
     4705                                   l[j][1], then its value is the k+1st entry
    43094706NOTE:        if a maximal ideal contains a variable, it is removed from the list;
    43104707             the procedure is called by findzeros"
     
    43144711  int pruefer;       // is set one if a maximal ideal contains a variable
    43154712  list minassisort;  // will contain the output
    4316   for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort to fix its initial length
     4713  for (j=1;j<=size(minassi);j++){minassisort[j]=0;} // initialise minassisort
     4714                                                    // to fix its initial length
    43174715  list zwischen;     // needed for reordering
    4318   list a;            // (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m
     4716  list a;// (a_1,...,a_n)=(a[2],...,a[n+1]) will be a common zero of the ideal m
    43194717  poly nf;           // normalform of a variable w.r.t. m
    4320   intvec neuevariablen; // ith entry is 1, if for the ith component of a zero of m a new variable is needed
     4718  intvec neuevariablen; // ith entry is 1, if for the ith component of a zero
     4719                        // of m a new variable is needed
    43214720  intvec testvariablen; // integer vector of length n=number of variables
    4322   // compute for each maximal ideal the number of new variables, which are needed to describe
    4323   // its zeros -- note, a new variable is needed if modulo the maximal ideal it does not reduce
     4721  // compute for each maximal ideal the number of new variables,
     4722  // which are needed to describe
     4723  // its zeros -- note, a new variable is needed if modulo
     4724  // the maximal ideal it does not reduce
    43244725  // to something which only depends on the following variables;
    4325   // if no new variable is needed, then store the value a variable reduces to in the list a;
     4726  // if no new variable is needed, then store the value
     4727  // a variable reduces to in the list a;
    43264728  for (j=size(minassi);j>=1;j--)
    43274729  {
    4328     a[1]=poly(0);         // the first entry in a and in neuevariablen corresponds to the variable t,
     4730    a[1]=poly(0);         // the first entry in a and in neuevariablen
     4731                          // corresponds to the variable t,
    43294732    neuevariablen[1]=0;   // which is not present in the INITIALRING
    43304733    neuvar=0;
     
    43334736    {
    43344737      nf=reduce(var(k),minassi[j]);
    4335       // if a variable reduces to zero, then the maximal ideal contains a variable and we can delete it
     4738      // if a variable reduces to zero, then the maximal ideal
     4739      // contains a variable and we can delete it
    43364740      if (nf==0)
    43374741      {
    43384742        pruefer=1;
    43394743      }
    4340       // set the entries of testvariablen corresponding to the first k variables to 1, and the others to 0
     4744      // set the entries of testvariablen corresponding to the first
     4745      // k variables to 1, and the others to 0
    43414746      for (l=1;l<=nvars(basering);l++)
    43424747      {
    43434748        if (l<=k)
    4344         {
     4749        {         
    43454750          testvariablen[l]=1;
    43464751        }
     
    43504755        }
    43514756      }
    4352       // if the variable x_j reduces to a polynomial in x_j+1,...,x_n,X_1,...,X_k modulo m
    4353       // then we can eliminate x_j from the maximal ideal (since we do not need any
    4354       // further field extension to express a_j) and a_j will just be this normalform,
     4757      // if the variable x_j reduces to a polynomial
     4758      // in x_j+1,...,x_n,X_1,...,X_k modulo m
     4759      // then we can eliminate x_j from the maximal ideal
     4760      // (since we do not need any
     4761      // further field extension to express a_j) and a_j
     4762      // will just be this normalform,
    43554763      // otherwise we have to introduce a new variable in order to express a_j;
    43564764      if (scalarproduct(leadexp(nf),testvariablen)==0)
    43574765      {
    4358         a[k+1]=nf;             // a_k is the normal form of the kth variable modulo m
     4766        a[k+1]=nf; // a_k is the normal form of the kth variable modulo m
    43594767        neuevariablen[k+1]=0;  // no new variable is needed
    4360       }
     4768      }   
    43614769      else
    43624770      {
    4363         a[k+1]=poly(0);       // a_k is set to zero until we have introduced the new variable
     4771        a[k+1]=poly(0); // a_k is set to zero until we have
     4772                        // introduced the new variable
    43644773        neuevariablen[k+1]=1;
    4365         neuvar++;             // the number of newly needed variables is raised by one
     4774        neuvar++;       // the number of newly needed variables is raised by one
    43664775      }
    43674776    }
    43684777    // if the maximal ideal contains a variable, we simply delete it
    43694778    if (pruefer==0)
    4370     {
     4779    {     
    43714780      minassisort[j]=list(minassi[j],neuvar,neuevariablen,a);
    43724781    }
    4373     // otherwise we store the information on a, neuevariablen and neuvar together with the ideal
     4782    // otherwise we store the information on a,
     4783    // neuevariablen and neuvar together with the ideal
    43744784    else
    43754785    {
     
    43794789    }
    43804790  }
    4381   // sort the maximal ideals ascendingly according to the number of new variables needed to
     4791  // sort the maximal ideals ascendingly according to
     4792  // the number of new variables needed to
    43824793  // express the zero of the maximal ideal
    43834794  for (j=2;j<=size(minassi);j++)
     
    43854796    l=j;
    43864797    for (k=j-1;k>=1;k--)
    4387     {
     4798    {     
    43884799      if (minassisort[l][2]<minassisort[k][2])
    43894800      {
     
    43984809}
    43994810
     4811/////////////////////////////////////////////////////////////////////////
     4812
    44004813static proc displaypoly(poly p,int N,int wj,int w1)
    44014814"USAGE:  displaypoly(p,N,wj,w1); p poly, N, wj, w1 int
    44024815ASSUME:  p is a polynomial in r=(0,X(1..k)),t,ls
    4403 RETURN:  string, the string of t^-wj/w1*p(t^1/N)
     4816RETURN:  string, the string of t^-wj/w1*p(t^1/N) 
    44044817NOTE:    the procedure is called from displayTropicalLifting"
    44054818{
     
    44194832  {
    44204833    if (koeffizienten[j-ord(p)+1]!=0)
    4421     {
     4834    {     
    44224835      if ((j-(N*wj)/w1)==0)
    44234836      {
     
    44644877  return(dp);
    44654878}
     4879
     4880/////////////////////////////////////////////////////////////////////////
    44664881
    44674882static proc displaycoef (poly p)
    44684883"USAGE:      displaycoef(p); p poly
    4469 RETURN:      string, the string of p where brackets around have been added if they were missing
     4884RETURN:      string, the string of p where brackets around
     4885                     have been added if they were missing
    44704886NOTE:        the procedure is called from displaypoly"
    44714887{
     
    44804896  }
    44814897}
     4898
     4899/////////////////////////////////////////////////////////////////////////
    44824900
    44834901static proc choosegfanvector (string s,int findall)
     
    45324950}
    45334951
     4952/////////////////////////////////////////////////////////////////////////
     4953
    45344954static proc tropicalliftingresubstitute (ideal i,list liftring,int N,list #)
    45354955"USAGE:   tropicalliftingresubstitute(i,L,N[,#]); i ideal, L list, N int, # string
    4536 ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a point in the
    4537           tropical variety of i computed with tropicalLifting;
    4538           t has to be replaced by t^1/N in the lifting; #[1]=m is the string of the maximal
    4539           ideal defining the necessary field extension as computed by tropicalLifting,
    4540           if #[1] is present
     4956ASSUME:   i is an ideal and L[1] is a ring which contains the lifting of a
     4957          point in the tropical variety of i computed with tropicalLifting;
     4958          t has to be replaced by t^1/N in the lifting; #[1]=m is the string
     4959          of the maximal ideal defining the necessary field extension as
     4960          computed by tropicalLifting, if #[1] is present
    45414961RETURN:   string, the lifting has been substituted into i
    45424962NOTE:     the procedure is called from tropicalLifting"
     
    45604980      ideal i=imap(BASERING,i);
    45614981    }
    4562   }
     4982  } 
    45634983  else
    45644984  {
     
    45734993  }
    45744994  // map the resulting i back to LIFTRing;
    4575   // if noAbs, then reduce i modulo the maximal ideal  before going back to LIFTRing
     4995  // if noAbs, then reduce i modulo the maximal ideal 
     4996  // before going back to LIFTRing
    45764997  if ((size(parstr(LIFTRing))!=0) and size(#)>0)
    45774998  {
     
    45895010  for (j=1;j<=ncols(i);j++)
    45905011  {
    4591     SUBSTTEST[j]=displaypoly(i[j],N,0,1);
     5012    SUBSTTEST[j]=displaypoly(i[j],N,0,1); 
    45925013  }
    45935014  return(SUBSTTEST);
    45945015}
    45955016
    4596 ////////////////////////////////////////////////////////////////////////////////////
    4597 /// Procedures used in tropicalLifting when using absolute primary decomposition:
     5017///////////////////////////////////////////////////////////////////////////////
     5018/// Procedures used in tropicalLifting when using absolute primary decomposition
    45985019/// - tropicalparametrise
    45995020/// - eliminatecomponents
    46005021/// - findzerosAndBasictransform
    4601 /// - ordermaximalideals
    4602 ////////////////////////////////////////////////////////////////////////////////////
     5022/// - ordermaximalideals 
     5023///////////////////////////////////////////////////////////////////////////////
    46035024
    46045025static proc tropicalparametrise (ideal i,intvec ww,int ordnung,int gfanold,int findall,int nogfan,list #)
    46055026"USAGE:  tropicalparametrise(i,tw,ord,gf,fa,ng[,#]); i ideal, tw intvec, ord int, gf,fa,ng int, # opt. list
    4606 ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0)
    4607            and (w_0,...,w_n,0) is in the tropical variety of i,
    4608            and ord is the order up to which a point in V(i) over K{{t}} lying over w shall be computed;
    4609          - moreover, @a should be not be there if the procedure is not called recursively;
    4610          - the point in the tropical variety is supposed to lie in the NEGATIVE orthant;
    4611          - the ideal is zero-dimensional when considered in (K(t)[@a]/m)[x_1,...,x_n],
    4612            where m=#[2] is a maximal ideal in K[@a];
     5027ASSUME:  - i is an ideal in Q[t,x_1,...,x_n,@a], tw=(w_0,w_1,...,w_n,0)
     5028           and (w_0,...,w_n,0) is in the tropical variety of i,
     5029           and ord is the order up to which a point in V(i)
     5030           over K{{t}} lying over w shall be computed;
     5031         - moreover, @a should be not be there if the procedure is not
     5032           called recursively;
     5033         - the point in the tropical variety is supposed to lie in the
     5034           NEGATIVE orthant;
     5035         - the ideal is zero-dimensional when considered in
     5036           (K(t)[@a]/m)[x_1,...,x_n], where m=#[2] is a maximal ideal in K[@a];
    46135037         - gf is 0 if version 2.2 or larger is used and it is 1 else
    46145038         - fa is 1 if all solutions should be found
     
    46175041               l[2] = int
    46185042NOTE:    - the procedure is also called recursively by itself, and
    4619            if it is called in the first recursion, the list # is empty,
    4620            otherwise #[1] is an integer, one more than the number of true variables x_1,...,x_n,
    4621            and #[2] will contain the maximal ideal m in the variable @a
    4622            by which the ring K[t,x_1,...,x_n,@a] should be divided to
    4623            work correctly in L[t,x_1,...,x_n] where L=Q[@a]/m is a field
    4624            extension of K
    4625          - the ring l[1] contains an ideal PARA, which contains the parametrisation
    4626            of a point in V(i) lying over w up to the first ord terms;
    4627          - the string m contains the code of the maximal ideal m, by which we have
    4628            to divide K[@a] in order to have the appropriate field extension
     5043           if it is called in the first recursion, the list # is empty,
     5044           otherwise #[1] is an integer, one more than the number of
     5045           true variables x_1,...,x_n, and #[2] will contain the maximal
     5046           ideal m in the variable @a by which the ring K[t,x_1,...,x_n,@a]
     5047           should be divided to work correctly in L[t,x_1,...,x_n] where
     5048           L=Q[@a]/m is a field extension of K
     5049         - the ring l[1] contains an ideal PARA, which contains the
     5050           parametrisation of a point in V(i) lying over w up to the first
     5051           ord terms;
     5052         - the string m contains the code of the maximal ideal m, by which we
     5053           have to divide K[@a] in order to have the appropriate field extension
    46295054           over which the parametrisation lives;
    46305055         - and if the integer l[3] is N then t has to be replaced by t^1/N in the
    4631            parametrisation, or alternatively replace t by t^N in the defining ideal
    4632          - the procedure REQUIRES that the program GFAN is installed on your computer"
     5056           parametrisation, or alternatively replace t by t^N in the defining
     5057           ideal
     5058         - the procedure REQUIRES that the program GFAN is installed
     5059           on your computer"
    46335060{
    46345061  def BASERING=basering;
    46355062  int recursively; // is set 1 if the procedure is called recursively by itself
    46365063  int ii,jj,kk,ll,jjj,kkk,lll;
    4637   if (typeof(#[1])=="int") // this means the precedure has been called recursively
    4638   {
    4639     // how many variables are true variables, and how many come from the field extension
     5064  if (typeof(#[1])=="int") // this means the precedure has been
     5065  { // called recursively
     5066    // how many variables are true variables, and how many come
     5067    // from the field extension
    46405068    // only true variables have to be transformed
    46415069    int anzahlvariablen=#[1];
    46425070    // find the zeros of the w-initial ideal and transform the ideal i;
    4643     // findzeros and basictransformideal need to know how many of the variables are true variables
     5071    // findzeros and basictransformideal need to know
     5072    // how many of the variables are true variables
    46445073    // and do the basic transformation as well
    46455074    list zerolist=#[2];
     
    46485077  else // the procedure has been called by tropicalLifting
    46495078  {
    4650     // how many variables are true variables, and how many come from the field extension
     5079    // how many variables are true variables, and
     5080    // how many come from the field extension
    46515081    // only true variables have to be transformed
    46525082    int anzahlvariablen=nvars(basering);
    4653     list zerolist; // will carry the zeros which are computed in the recursion steps
    4654 
     5083    list zerolist; // will carry the zeros which are
     5084    //computed in the recursion steps   
    46555085    // the initial ideal of i has been handed over as #[1]
    46565086    ideal ini=#[1];
    46575087    // find the zeros of the w-initial ideal and transform the ideal i;
    4658     // we should hand the t-initial ideal ine to findzeros, since we know it already;
     5088    // we should hand the t-initial ideal ine to findzeros,
     5089    // since we know it already;
    46595090    // and do the basic transformation as well
    46605091    list trring=findzerosAndBasictransform(i,ww,zerolist,findall,ini);
    46615092  }
    46625093  list wneulist; // carries all newly computed weight vector
    4663   intvec wneu;   // carries the newly computed weight vector
     5094  intvec wneu;   // carries the newly computed weight vector 
    46645095  int tweight;   // carries the weight of t
    4665   list PARALIST; // carries the result when tropicalparametrise is recursively called
     5096  list PARALIST; // carries the result when tropicalparametrise
     5097                 // is recursively called
    46665098  list eliminaterings;     // carries the result of eliminatecomponents
    4667   intvec deletedvariables; // contains the information which variables have been deleted
     5099  intvec deletedvariables; // contains inform. which variables have been deleted
    46685100  deletedvariables[anzahlvariablen-1]=0; // initialise this vector
    46695101  int numberdeletedvariables;  // the number of deleted variables
     
    46715103  list liftings,partliftings;  // the computed liftings (all resp. partly)
    46725104  // consider each ring which has been returned when computing the zeros of the
    4673   // the t-initial ideal, equivalently, consider each zero which has been returned
     5105  // the t-initial ideal, equivalently, consider
     5106  // each zero which has been returned
    46745107  for (jj=1;jj<=size(trring);jj++)
    46755108  {
    46765109    def TRRING=trring[jj];
    46775110    setring TRRING;
    4678     // check if a certain number of components lead to suitable solutions with zero components;
     5111    // check if a certain number of components lead to suitable
     5112    // solutions with zero components;
    46795113    // compute them all if findall==1
    46805114    eliminaterings=eliminatecomponents(i,m,oldanzahlvariablen,findall,oldanzahlvariablen-1,deletedvariables);
    4681     // consider each of the rings returned by eliminaterings ... there is at least one !!!
     5115    // consider each of the rings returned by eliminaterings ...
     5116    // there is at least one !!!
    46825117    for (ii=1;ii<=size(eliminaterings);ii++)
    46835118    {
    4684       numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2]; // #variables eliminated
    4685       anzahlvariablen=eliminaterings[ii][2];  // #true variables which remain (including t)
    4686       deletedvariables=eliminaterings[ii][3]; // a 1 in this vector says that variable was eliminated
     5119      // #variables which have been eliminated
     5120      numberdeletedvariables=oldanzahlvariablen-eliminaterings[ii][2];
     5121      // #true variables which remain (including t)
     5122      anzahlvariablen=eliminaterings[ii][2]; 
     5123      // a 1 in this vector says that variable was eliminated
     5124      deletedvariables=eliminaterings[ii][3];
    46875125      setring TRRING; // set TRRING - this is important for the loop
    4688       def PREGFANRING=eliminaterings[ii][1];  // pass the ring computed by eliminatecomponents
     5126      // pass the ring computed by eliminatecomponents
     5127      def PREGFANRING=eliminaterings[ii][1]; 
    46895128      setring PREGFANRING;
    46905129      poly m=imap(TRRING,m);        // map the maximal ideal to this ring
    46915130      list zero=imap(TRRING,zero);  // map the vector of zeros to this ring
    4692       // now we have to compute a point ww on the tropical variety of the transformed ideal i;
    4693       // of course, we only have to do so, if we have not yet reached the order up to which we
     5131      // now we have to compute a point ww on the tropical
     5132      // variety of the transformed ideal i;
     5133      // of course, we only have to do so, if we have
     5134      // not yet reached the order up to which we
    46945135      // were supposed to do our computations
    4695       if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains, all true variables are gone
    4696       {
     5136      if ((ordnung>1) and (anzahlvariablen>1)) // if only t remains,
     5137      { // all true variables are gone
    46975138        if (nogfan!=1)
    4698         {
     5139        {         
    46995140          // pass to a ring which has variables which are suitable for gfan
    47005141          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;");
    4701           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;
     5142          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; 
    47025143          phiideal[nvars(PREGFANRING)]=a; // map t to a
    4703           map phi=PREGFANRING,phiideal;
     5144          map phi=PREGFANRING,phiideal; 
    47045145          ideal II=phi(i);
    4705           // homogenise the ideal II with the first not yet used variable in our ring, since gfan
    4706           // only handles homogenous ideals; in principle for this one has first to compute a
    4707           // standard basis of II and homogenise that, but for the tropical variety (says Anders)
     5146          // homogenise the ideal II with the first not yet
     5147          // used variable in our ring, since gfan
     5148          // only handles homogenous ideals; in principle for this
     5149          // one has first to compute a
     5150          // standard basis of II and homogenise that,
     5151          // but for the tropical variety (says Anders)
    47085152          // it suffices to homogenise an arbitrary system of generators
    4709           // II=groebner(II);
     5153          // II=groebner(II); 
    47105154          II=homog(II,maxideal(1)[nvars(PREGFANRING)+1]);
    47115155          // if gfan version >= 0.3.0 is used and the characteristic
     
    47455189            int goon=1;
    47465190            trop;
    4747             "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
     5191            "CHOOSE A RAY IN THE OUTPUT OF GFAN WHICH HAS ONLY";
     5192            "NON-POSITIVE ENTRIES AND STARTS WITH A NEGATIVE ONE,";
    47485193            "E.G. (-3,-4,-1,-5,0,0,0) - the last entry will always be 0 -";
    47495194            "THEN TYPE THE FOLLOWING COMMAND IN SINGULAR:   wneu=-3,-4,-1,-5,0,0;";
     
    47515196            "IF YOU WANT wneu TO BE TESTED, THEN SET goon=0;";
    47525197            ~
    4753             // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY THE TROPICAL PREVARIETY
    4754             // test, if wneu really is in the tropical variety
     5198            // THIS IS NOT NECESSARY !!!! IF WE COMPUTE NOT ONLY
     5199            // THE TROPICAL PREVARIETY
     5200            // test, if wneu really is in the tropical variety   
    47555201            while (goon==0)
    47565202            {
     
    47595205                "CHOOSE A DIFFERENT RAY";
    47605206                ~
    4761                   }
     5207              }
    47625208              else
    47635209              {
     
    47705216          {
    47715217            system("sh","gfan_tropicallifting -n "+string(anzahlvariablen)+" --noMult -c < /tmp/gfaninput > /tmp/gfanoutput");
    4772             // read the result from gfan and store it to a string, which in a later version
     5218            // read the result from gfan and store it to a string,
     5219            // which in a later version
    47735220            // should be interpreded by Singular
    47745221            wneulist=choosegfanvector(read("/tmp/gfanoutput"),findall);
     
    47925239        }
    47935240      }
    4794       // if we have not yet computed our parametrisation up to the required order and
    4795       // zero is not yet a solution, then we have to go on by calling the procedure recursively;
     5241      // if we have not yet computed our parametrisation up to
     5242      // the required order and
     5243      // zero is not yet a solution, then we have to go on
     5244      // by calling the procedure recursively;
    47965245      // if all variables were deleted, then i=0 and thus anzahlvariablen==0
    47975246      lll=0;
    47985247      if ((ordnung>1) and (anzahlvariablen>1))
    4799       {
     5248      { 
    48005249        partliftings=list(); // initialise partliftings
    4801         // we call the procedure with the transformed ideal i, the new weight vector, with the
    4802         // required order lowered by one, and with additional parameters, namely the number of
    4803         // true variables and the maximal ideal that was computed so far to describe the field extension
     5250        // we call the procedure with the transformed
     5251        // ideal i, the new weight vector, with the
     5252        // required order lowered by one, and with
     5253        // additional parameters, namely the number of
     5254        // true variables and the maximal ideal that
     5255        // was computed so far to describe the field extension
    48045256        for (kk=1;kk<=size(wneulist);kk++)
    48055257        {
    48065258          wneu=wneulist[kk];
    48075259          PARALIST=tropicalparametrise(i,wneu,ordnung-1,gfanold,findall,nogfan,anzahlvariablen,zero);
    4808           // the output will be a ring, in which the parametrisation lives, and a string, which contains
     5260          // the output will be a ring, in which the
     5261          // parametrisation lives, and a string, which contains
    48095262          // the maximal ideal that describes the necessary field extension
    48105263          for (ll=1;ll<=size(PARALIST);ll++)
    4811           {
     5264          { 
    48125265            def PARARing=PARALIST[ll][1];
    48135266            tweight=-ww[1]*PARALIST[ll][2];
    48145267            setring PARARing;
    4815             // if some variables have been eliminated in before, then we have to insert zeros
     5268            // if some variables have been eliminated
     5269            // in before, then we have to insert zeros
    48165270            // into the parametrisation for those variables
    48175271            if (numberdeletedvariables>0)
     
    48195273              ideal PARAneu=PARA;
    48205274              kkk=0;
    4821               for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++) // t admits no parametrisation
    4822               {
     5275              for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
     5276              { // t admits no parametrisation
    48235277                if (deletedvariables[jjj]!=1)
    48245278                {
     
    48395293        }
    48405294      }
    4841       // otherwise we are done and we can start to compute the last step of the parametrisation
     5295      // otherwise we are done and we can start
     5296      // to compute the last step of the parametrisation
    48425297      else
    48435298      {
    4844         // we define the weight of t, i.e. in the parametrisation t has to be replaced by t^1/tweight
     5299        // we define the weight of t, i.e. in the
     5300        // parametrisation t has to be replaced by t^1/tweight
    48455301        tweight=-ww[1];
    4846         // if additional variables were necessary, we introduce them now as parameters;
    4847         // in any case the parametrisation ring will have only one variable, namely t,
    4848         // and its order will be local, so that it displays the lowest term in t first
     5302        // if additional variables were necessary,
     5303        // we introduce them now as parameters;
     5304        // in any case the parametrisation ring will
     5305        // have only one variable, namely t, 
     5306        // and its order will be local, so that it
     5307        // displays the lowest term in t first
    48495308        if (anzahlvariablen<nvars(basering))
    48505309        {
     
    48575316        }
    48585317        ideal PARA; // will contain the parametrisation
    4859         // we start by initialising the entries to be zero; one entry for each true variable
    4860         // here we also have to consider the variables that we have eliminated in before
     5318        // we start by initialising the entries to be zero;
     5319        // one entry for each true variable
     5320        // here we also have to consider the variables
     5321        // that we have eliminated in before
    48615322        for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
    48625323        {
     
    48695330        kill PARARing;
    48705331      }
    4871       // we now have to change the parametrisation by reverting the transformations that we have done
     5332      // we now have to change the parametrisation by
     5333      // reverting the transformations that we have done
    48725334      for (lll=1;lll<=size(partliftings);lll++)
    48735335      {
    4874         if (size(partliftings[lll])==2) // when tropicalparametrise is called for the last time, it does not
    4875         {                     // enter the part, where wneu is defined and the variable t should have
    4876           wneu=-1;     // weight -1
     5336        if (size(partliftings[lll])==2) // when tropicalparametrise is called
     5337        { // for the last time, it does not enter the part, where wneu is
     5338          wneu=-1;     // defined and the variable t should have weight -1
    48775339        }
    48785340        else
     
    48885350          PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight/ww[1]);
    48895351        }
    4890         // delete the last entry in zero, since that one has been used for the transformation
     5352        // delete the last entry in zero, since that one has
     5353        // been used for the transformation
    48915354        zeros=delete(zeros,size(zeros));
    4892         // in order to avoid redefining commands an empty zeros list should be removed
     5355        // in order to avoid redefining commands an empty
     5356        // zeros list should be removed
    48935357        if (size(zeros)==0)
    48945358        {
     
    49065370  // kill the gfan files in /tmp
    49075371  system("sh","cd /tmp; /usr/bin/touch gfaninput; /usr/bin/touch gfanoutput; /bin/rm gfaninput; /bin/rm gfanoutput"); 
    4908   // we return a list which contains lists of the parametrisation rings (with the parametrisation ideal)
     5372  // we return a list which contains lists of the parametrisation
     5373  // rings (with the parametrisation ideal)
    49095374  // and an integer N such that t should be replaced by t^1/N
    49105375  return(liftings);
    49115376}
    49125377
     5378/////////////////////////////////////////////////////////////////////////
     5379
    49135380static proc eliminatecomponents (ideal i,ideal m,int anzahlvariablen,int findall,int lastvar,intvec deletedvariables)
    49145381"USAGE:  eliminatecomponents(i,m,n,a,v,d); i,m ideal, n,a,v int, d intvec
    4915 ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0)
    4916          is in the tropical variety of i considered in Q[@a]/m{{t}}[x_1,...,x_n];
    4917          considered in this ring i is zero-dimensional; @a need not be present
     5382ASSUME:  i is an ideal in Q[x_1,...,x_n,@a,t] and w=(-w_1/w_0,...,-w_n/w_0)
     5383         is in the tropical variety of i considered in
     5384         Q[@a]/m{{t}}[x_1,...,x_n];
     5385         considered in this ring i is zero-dimensional; @a need not be present
    49185386         in which case m is zero; 1<=v<=n
    49195387RETURN:  list, L of lists
     
    49215389               L[j][2] = an integer anzahlvariablen
    49225390               L[j][3] = an intvec deletedvariables
    4923 NOTE:    - the procedure is called from inside the recursive procedure tropicalparametrise
    4924          - the procedure checks for solutions which have certain components zero; these are
    4925            separated from the rest by elimination and saturation; the integer deletedvariables
    4926            records which variables have been eliminated; the integer anzahlvariablen records how
    4927            many true variables remain after the elimination
    4928          - if the integer a is one then all zeros of the ideal i are considered and found, otherwise
    4929            only one is considered, so that L has length one"
     5391NOTE:    - the procedure is called from inside the recursive
     5392           procedure tropicalparametrise
     5393         - the procedure checks for solutions which have certain
     5394           components zero; these are separated from the rest by
     5395           elimination and saturation; the integer deletedvariables
     5396           records which variables have been eliminated;
     5397           the integer anzahlvariablen records how many true variables remain
     5398           after the elimination
     5399         - if the integer a is one then all zeros of the ideal i are
     5400           considered and found, otherwise only one is considered, so that L
     5401           has length one"
    49305402{
    49315403  def BASERING=basering;
     
    49345406  // if all solutions have to be found
    49355407  if (findall==1)
    4936   {
     5408  {   
    49375409    list saturatelist,eliminatelist; // carry the solution of the two tests
    4938     // we test first if there is a solution which has the component lastvar zero and
     5410    // we test first if there is a solution which has the component
     5411    // lastvar zero and
    49395412    // where the order of each component is strictly positive;
    4940     // if so, we add this variable to the ideal and eliminate it - which amounts to
    4941     // to projecting the solutions with this component zero to the hyperplane without this component;
    4942     // for the test we compute the saturation with respect to t and replace each variable
    4943     // x_i and also t by zero -- if the result is zero, then 1 is not in I:t^infty
     5413    // if so, we add this variable to the ideal and
     5414    // eliminate it - which amounts to
     5415    // to projecting the solutions with this component
     5416    // zero to the hyperplane without this component;
     5417    // for the test we compute the saturation with
     5418    // respect to t and replace each variable
     5419    // x_i and also t by zero -- if the result is zero,
     5420    // then 1 is not in I:t^infty
    49445421    // (i.e. there is a solution which has the component lastvar zero) and
    4945     // the result lives in the maximal ideal <t,x_1,...,[no x_lastvar],...,x_n> so that
     5422    // the result lives in the maximal
     5423    // ideal <t,x_1,...,[no x_lastvar],...,x_n> so that
    49465424    // there is a solution which has strictly positive valuation
    49475425/*
    49485426    // DER NACHFOLGENDE TEIL IST MUELL UND WIRD NICHT MEHR GAMACHT
    4949     // for the test we simply compute the leading ideal and set all true variables zero;
    4950     // since the ordering was an elimination ordering with respect to (@a if present and) t
    4951     // there remains something not equal to zero if and only if there is polynomial which only
    4952     // depends on t (and @a if present), but that is a unit in K{{t}}, which would show that there
     5427    // for the test we simply compute the leading ideal
     5428    // and set all true variables zero;
     5429    // since the ordering was an elimination ordering
     5430    // with respect to (@a if present and) t
     5431    // there remains something not equal to zero
     5432    // if and only if there is polynomial which only
     5433    // depends on t (and @a if present), but that is
     5434    // a unit in K{{t}}, which would show that there
    49535435    // is no solution with the component lastvar zero;
    4954     // however, we also have to ensure that if there exists a solution with the component lastvar
    4955     // equal to zero then this component has a valuation with all strictly positive values!!!!;
    4956     // for this we can either saturate the ideal after elimination with respect to <t,x_1,...,x_n>
    4957     // and see if the saturated ideal is contained in <t,x_1,...x_n>+m,
    4958     // or ALTERNATIVELY we can pass to the ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)),
    4959     // compute a standard basis of the elimination ideal (plus m) there and check if the dimension 1
    4960     // (since we have not omitted the variable lastvar, this means that we have the ideal
    4961     // generated by t,x_1,...,[no x_lastvar],...,x_n and this defines NO curve after omitting x_lastvar)
     5436    // however, we also have to ensure that if there
     5437    // exists a solution with the component lastvar
     5438    // equal to zero then this component has a
     5439    // valuation with all strictly positive values!!!!;
     5440    // for this we can either saturate the ideal
     5441    // after elimination with respect to <t,x_1,...,x_n>
     5442    // and see if the saturated ideal is contained in <t,x_1,...x_n>+m,
     5443    // or ALTERNATIVELY we can pass to the
     5444    // ring 0,(t,x_1,...,x_n,@a),(ds(n+1),dp(1)),
     5445    // compute a standard basis of the elimination
     5446    // ideal (plus m) there and check if the dimension 1
     5447    // (since we have not omitted the variable lastvar,
     5448    // this means that we have the ideal
     5449    // generated by t,x_1,...,[no x_lastvar],...,x_n
     5450    // and this defines NO curve after omitting x_lastvar)
    49625451    I=std(ideal(var(lastvar)+i));
    49635452    // first test,
    49645453    LI=lead(reduce(I,std(m)));
    4965     for (j=1;j<=anzahlvariablen-1;j++) //size(deletedvariables)=anzahlvariablen(before elimination)
     5454    //size(deletedvariables)=anzahlvariablen(before elimination)
     5455    for (j=1;j<=anzahlvariablen-1;j++)
    49665456    {
    49675457      LI=subst(LI,var(j),0);
     
    49695459    if (size(LI)==0) // if no power of t is in lead(I) (where @a is considered as a field element)
    49705460*/
    4971     I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal polynomial for the test
     5461    I=reduce(sat(ideal(var(lastvar)+i),t)[1],std(m)); // get rid of the minimal
     5462                                                      // polynomial for the test
    49725463    LI=subst(I,var(nvars(basering)),0);
    4973     for (j=1;j<=anzahlvariablen-1;j++) //size(deletedvariables)=anzahlvariablen(before elimination)
     5464    //size(deletedvariables)=anzahlvariablen(before elimination)
     5465    for (j=1;j<=anzahlvariablen-1;j++)
    49745466    {
    49755467      LI=subst(LI,var(j),0);
    49765468    }
    4977     if (size(LI)==0) // the saturation lives in the maximal ideal generated by t and the x_i
    4978     {
     5469    if (size(LI)==0) // the saturation lives in the maximal
     5470    { // ideal generated by t and the x_i
    49795471      // get rid of var(lastvar)
    49805472      I=eliminate(I,var(lastvar))+m; // add the minimal polynomial again
     
    49905482      {
    49915483        string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(simplify(reduce(maxideal(1),std(var(lastvar))),2))+"),(";
    4992       }
    4993       if (anzahlvariablen<nvars(basering)) // if @a was present, the ordersting needs an additional entry
    4994       {
     5484      }   
     5485      if (anzahlvariablen<nvars(basering)) // if @a was present, the
     5486      { // ordersting needs an additional entry
    49955487        elring=elring+"dp(1),";
    49965488      }
    49975489      elring=elring+"lp(1));";
    4998       execute(elring);
     5490      execute(elring);     
    49995491      ideal i=imap(BASERING,I); // move the ideal I to the new ring
    5000       // if not yet all variables have been checked, then go on with the next smaller variable,
    5001       // else prepare the elimination ring and the neccessary information for return
     5492      // if not yet all variables have been checked,
     5493      // then go on with the next smaller variable,
     5494      // else prepare the elimination ring and the neccessary
     5495      // information for return
    50025496      if (lastvar>1)
    50035497      {
     
    50115505      setring BASERING;
    50125506    }
    5013     // next we have to test if there is also a solution which has the variable lastvar non-zero;
    5014     // to do so, we saturate with respect to this variable; since when considered over K{{t}}
    5015     // the ideal is zero dimensional, this really removes  all solutions with that component zero;
     5507    // next we have to test if there is also a solution
     5508    // which has the variable lastvar non-zero;
     5509    // to do so, we saturate with respect to this variable;
     5510    // since when considered over K{{t}}
     5511    // the ideal is zero dimensional, this really removes 
     5512    // all solutions with that component zero;
    50165513    // the checking is then done as above
    50175514    i=std(sat(i,var(lastvar))[1]);
    50185515    I=reduce(i,std(m)); // "remove" m from i
    5019     // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then
    5020     // we know that i has no longer a point in the tropical variety with all components negative
     5516    // test first, if i still is in the ideal <t,x_1,...,x_n> -- if not, then
     5517    // we know that i has no longer a point in the tropical
     5518    // variety with all components negative
    50215519    LI=subst(I,var(nvars(basering)),0);
    5022     for (j=1;j<=anzahlvariablen-1;j++) // set all variables t,x_1,...,x_n equal to zero
    5023     {
     5520    for (j=1;j<=anzahlvariablen-1;j++) // set all variables
     5521    { // t,x_1,...,x_n equal to zero
    50245522      LI=subst(LI,var(j),0);
    50255523    }
    50265524    if (size(LI)==0) // the entries of i have not constant part
    5027     {
    5028       // check now, if the leading ideal of i contains an element which only depends on t
     5525    {     
     5526      // check now, if the leading ideal of i contains an element
     5527      // which only depends on t
    50295528      LI=lead(I);
    5030       for (j=1;j<=anzahlvariablen-1;j++) //size(deletedvariables)=anzahlvariablen(before elimination)
     5529      //size(deletedvariables)=anzahlvariablen(before elimination)
     5530      for (j=1;j<=anzahlvariablen-1;j++)
    50315531      {
    50325532        LI=subst(LI,var(j),0);
    50335533      }
    5034       if (size(LI)==0) // if no power of t is in lead(i) (where @a is considered as a field element)
    5035       {
    5036         // if not yet all variables have been tested, go on with the next smaller variable
     5534      if (size(LI)==0) // if no power of t is in lead(i)
     5535      { // (where @a is considered as a field element)
     5536        // if not yet all variables have been tested, go on with the
     5537        // next smaller variable
    50375538        // else prepare the neccessary information for return
    50385539        if (lastvar>1)
     
    50415542        }
    50425543        else
    5043         {
     5544        {   
    50445545          execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");");
    50455546          ideal i=imap(BASERING,i);
     
    50525553    return(eliminatelist+saturatelist);
    50535554  }
    5054   else // only one solution is searched for, we can do a simplified version of the above
    5055   {
    5056     // check if there is a solution which has the n-th component zero and with positive valuation,
    5057     // if so, then eliminate the n-th variable from sat(i+x_n,t), otherwise leave i as it is;
    5058     // then check if the (remaining) ideal has as solution where the n-1st component is zero ...,
     5555  else // only one solution is searched for, we can do a simplified
     5556  { // version of the above
     5557    // check if there is a solution which has the n-th component
     5558    // zero and with positive valuation,
     5559    // if so, then eliminate the n-th variable from
     5560    // sat(i+x_n,t), otherwise leave i as it is;
     5561    // then check if the (remaining) ideal has as
     5562    // solution where the n-1st component is zero ...,
    50595563    // and procede as before; do the same for the remaining variables;
    5060     // this way we make sure that the remaining ideal has a solution which has no component zero;
    5061     ideal variablen;            // will contain the variables which are not eliminated
     5564    // this way we make sure that the remaining ideal has
     5565    // a solution which has no component zero;
     5566    ideal variablen; // will contain the variables which are not eliminated
    50625567    for (j=anzahlvariablen-1;j>=1;j--)  // the variable t is the last one !!!
    50635568    {
    50645569      I=sat(ideal(var(j)+i),t)[1];
    50655570      LI=subst(I,var(nvars(basering)),0);
    5066       for (k=1;k<=size(deletedvariables);k++) //size(deletedvariables)=anzahlvariablen-1(before elimination)
     5571      //size(deletedvariables)=anzahlvariablen-1(before elimination)
     5572      for (k=1;k<=size(deletedvariables);k++)
    50675573      {
    50685574        LI=subst(LI,var(k),0);
    50695575      }
    5070       if (size(LI)==0) // if no power of t is in lead(I) (where the X(i) are considered as field elements)
    5071       {
    5072         // get rid of var(j)
     5576      if (size(LI)==0) // if no power of t is in lead(I)
     5577      { // (where the X(i) are considered as field elements)
     5578        // get rid of var(j)   
    50735579        i=eliminate(I,var(j));
    50745580        deletedvariables[j]=1;
    5075         anzahlvariablen--;         // if a variable is eliminated, then the number of true variables drops
     5581        anzahlvariablen--; // if a variable is eliminated,
     5582                           // then the number of true variables drops
    50765583      }
    50775584      else
     
    50815588    }
    50825589    variablen=invertorder(variablen);
    5083     // store also the additional variable and t, since they for sure have not been eliminated
     5590    // store also the additional variable and t,
     5591    // since they for sure have not been eliminated
    50845592    for (j=size(deletedvariables)+1;j<=nvars(basering);j++)
    50855593    {
    50865594      variablen=variablen+var(j);
    50875595    }
    5088     // if there are variables left, then pass to a ring which only realises these variables
    5089     // else we are done
     5596    // if there are variables left, then pass to a ring which
     5597    // only realises these variables else we are done
    50905598    if (anzahlvariablen>1)
    50915599    {
     
    50955603    {
    50965604      string elring="ring ELIMINATERING=("+charstr(basering)+"),("+string(variablen)+"),(";
    5097     }
    5098     if (size(deletedvariables)+1<nvars(basering)) // if @a was present, the ordersting needs an additional entry
    5099     {
     5605    }   
     5606    if (size(deletedvariables)+1<nvars(basering)) // if @a was present,
     5607    { // the ordersting needs an additional entry
    51005608      elring=elring+"dp(1),";
    51015609    }
    51025610    elring=elring+"lp(1));";
    5103     execute(elring);
     5611    execute(elring);     
    51045612    ideal i=imap(BASERING,i);
    51055613    ideal m=imap(BASERING,m);
     
    51105618}
    51115619
     5620/////////////////////////////////////////////////////////////////////////
     5621
    51125622static proc findzerosAndBasictransform (ideal i,intvec w,list zerolist,int findall,list #)
    5113 "USAGE:      findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list
    5114 ASSUME:      i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0)
    5115              is in the tropical variety of i; @a need not be present;
    5116              the list 'zero' contains the zeros computed in previous recursion steps;
    5117              if 'f' is one then all zeros should be found and returned, otherwise only one
    5118 RETURN:      list, each entry is a ring corresponding to one conjugacy class of zeros of the t-initial
    5119                    ideal inside the torus; each of the rings contains the following objects
    5120                    ideal i    = the ideal i, where the variable @a (if present) has
    5121                                 possibly been transformed according to the new minimal polynomial,
    5122                                 and where itself has been submitted to the basic transform
    5123                                 of the algorithm given by the jth zero found for the t-initial ideal;
    5124                                 note that the new minimal polynomial has already been added
    5125                    poly m     = the new minimal polynomial for @a (it is zero if no @a is present)
    5126                    list zero  = zero[k+1] is the kth component of a zero the t-initial ideal of i
    5127 NOTE:     -  the procedure is called from inside the recursive procedure tropicalparametrise;
    5128              if it is called in the first recursion, the list #[1] contains the t-initial ideal
    5129              of i w.r.t. w, otherwise #[1] is an integer, one more than the number of true
    5130              variables x_1,...,x_n
    5131           -  if #[2] is present, then it is an integer which tells whether ALL zeros should be
    5132              found or not"
     5623"USAGE:  findzerosAndBasictransform(i,w,z,f[,#]); i ideal, w intvec, z list, f int,# an optional list
     5624ASSUME:  i is an ideal in Q[t,x_1,...,x_n,@a] and w=(w_0,...,w_n,0)
     5625         is in the tropical variety of i; @a need not be present;
     5626         the list 'zero' contains the zeros computed in previous recursion steps;
     5627         if 'f' is one then all zeros should be found and returned,
     5628         otherwise only one
     5629RETURN:  list, each entry is a ring corresponding to one conjugacy class of
     5630               zeros of the t-initial ideal inside the torus; each of the rings
     5631               contains the following objects
     5632               ideal i    = the ideal i, where the variable @a (if present) has
     5633                            possibly been transformed according to the new
     5634                            minimal polynomial, and where itself has been
     5635                            submitted to the basic transform of the algorithm
     5636                            given by the jth zero found for the t-initial ideal;
     5637                            note that the new minimal polynomial has already
     5638                            been added