1\chapter{GROEBNER: A Gr\"obner basis package} 2\label{GROEBNER} 3\typeout{{GROEBNER: A Gr\"obner basis package}} 4 5{\footnotesize 6\begin{center} 7Herbert Melenk \& Winfried Neun \\ 8Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\ 9Takustra\"se 7 \\ 10D--14195 Berlin--Dahlem, Germany \\[0.05in] 11e--mail: melenk@zib.de \\[0.05in] 12and \\[0.05in] 13H.M. M\"oller \\ 14Fernuniversit\"at Hagen FB Math und Informatik\\ 15Postfach 940 \\ 16D--58084 Hagen, Germany\\[0.05in] 17e--mail: Michael.Moeller@fernuni-hagen.de 18\end{center} 19} 20 21\ttindex{GROEBNER} 22 23Gr\"obner bases are a valuable tool for solving problems in 24connection with multivariate polynomials, such as solving systems of 25algebraic equations and analysing polynomial ideals. 26 27\index{GROEBNER package}\index{Buchberger's Algorithm} 28The GROEBNER package calculates Gr\"obner bases using the 29Buchberger algorithm. It can be used over a variety of different 30coefficient domains, and for different variable and term orderings. 31 32\section{} 33\subsection{Term Ordering} \par 34In the theory of Gr\"obner bases, the terms of polynomials are 35considered as ordered. Several order modes are available in 36the current package, including the basic modes: 37\index{LEX ! term order}\index{GRADLEX ! term order} 38\index{REVGRADLEX ! term order} 39 40\begin{center} 41LEX, GRADLEX, REVGRADLEX 42\end{center} 43 44All orderings are based on an ordering among the variables. For each 45pair of variables $(a,b)$ an order relation must be defined, {\em 46e.g.\ } ``$ a\gg b $''. The greater sign $\gg$ does not represent a 47numerical relation among the variables; it can be interpreted only in 48terms of formula representation: ``$a$'' will be placed in front of 49``$b$'' or ``$a$'' is more complicated than ``$b$''. 50 51The sequence of variables constitutes this order base. So the notion 52of 53\[ 54\{x1,x2,x3\} 55\] 56 57as a list of variables at the same time means 58\[ 59x1 \gg x2 \gg x3 60\] 61with respect to the term order. 62 63If terms (products of powers of variables) are compared with LEX, 64that term is chosen which has a greater variable or a higher degree 65if the greatest variable is the first in both. With GRADLEX the sum of 66all exponents (the total degree) is compared first, and if that does 67not lead to a decision, the LEX method is taken for the final decision. 68The REVGRADLEX method also compares the total degree first, but 69afterward it uses the LEX method in the reverse direction; this is the 70method originally used by Buchberger. 71Note that the LEX ordering is identical to the standard \REDUCE{} 72kernel ordering, when KORDER is set explicitly to the sequence of 73variables. 74 75\index{default ! term order} 76LEX is the default term order mode in the GROEBNER package. 77 78\section{The Basic Operators} 79\subsection{Term Ordering Mode} 80 81\begin{description} 82\ttindex{TORDER} 83\item [{\it TORDER}]($vl$,$m$,$[p_1,p_2,\ldots]$); 84 85where $vl$ is a variable list (or the empty list if 86no variables are declared explicitly), 87$m$ is the name of a term ordering mode LEX, GRADLEX, 88REV\-GRAD\-LEX (or another implemented mode) and 89$[p_1,p_2,\ldots]$ are additional parameters for the 90term ordering mode (not needed for the basic modes). 91 92TORDER sets variable set and the term ordering mode. 93The default mode is LEX. The previous description is returned 94as a list with corresponding elements. Such a list can 95alternatively passed as sole argument to TORDER. 96 97If the variable list is empty or if the TORDER declaration 98is omitted, the automatic variable extraction is activated. 99 100\ttindex{GVARS} 101\item[{\it GVARS}] ({\it\{exp$1$, exp$2$, $ \ldots$, exp$n$\}}); 102 103 where $\{exp1, exp2, \ldots , expn\}$ is a list of expressions or 104equations. 105 106GVARS extracts from the expressions $\{exp1, exp2, \ldots , expn\}$ 107the kernels, which can play the role of variables for a Gr\"obner 108calculation. This can be used {\em e.g.\ } in a TORDER declaration. 109\end{description} 110 111\subsection{GROEBNER: Calculation of a Gr\"obner Basis} 112\begin{description} 113\ttindex{GROEBNER} 114\item[{\it GROEBNER}] $\{exp1, exp2, \ldots , expm\}; $ 115 116where $\{exp1, exp2, \ldots , expm\}$ is a list of 117expressions or equations. 118 119GROEBNER calculates the Gr\"obner basis of the given set of 120expressions with respect to the current TORDER setting. 121 122The Gr\"obner basis $\{1\}$ means that the ideal generated by the 123input polynomials is the whole polynomial ring, or equivalently, that 124the input polynomials have no zeros in common. 125 126As a side effect, the sequence of variables is stored as a \REDUCE\ list 127in the shared variable \ttindex{gvarslast}{\tt gvarslast}. 128\end{description} 129 130\example \index{GROEBNER package ! example} 131\begin{verbatim} 132 torder({},lex)$ 133 groebner{3*x**2*y + 2*x*y + y + 9*x**2 + 5*x - 3, 134 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x + 3, 135 x**3*y + x**2*y + 3*x**3 + 2*x**2 }; 136 137 2 138 {8*X - 2*Y + 5*Y + 3, 139 140 3 2 141 2*Y - 3*Y - 16*Y + 21} 142\end{verbatim} 143 144 145The operation of GROEBNER can be controlled by the following 146switches: 147\begin{description} 148\ttindex{GROEBOPT} 149\item[GROEBOPT] -- If set ON, the sequence of variables is optimized 150with respect to execution speed; note that the final list of variables 151is available in\ttindex{GVARSLAST} GVARSLAST. 152 153An explicitly declared dependency supersedes the 154variable optimization. 155By default GROEBOPT is off, conserving the original variable 156sequence. 157 158\ttindex{GROEBFULLREDUCTION} 159\item[GROEBFULLREDUCTION] -- If set off, the reduction steps during 160the \linebreak[4] GROEBNER operation are limited to the pure head 161term reduction; subsequent terms are reduced otherwise. 162By default GROEBFULLREDUCTION is on. 163 164\ttindex{GLTBASIS} 165\item[GLTBASIS] -- If set on, the leading terms of the result basis are 166extracted. They are collected in a basis of monomials, which is 167available as value of the global variable with the name GLTB. 168 169\end{description} 170 171\subsection{GZERODIM?: Test of $\dim = 0$} 172\begin{description} 173\ttindex{GZERODIM?} 174\item[{\it GZERODIM}!?] $bas$ \\ 175where {\it bas} is a Gr\"obner basis in the current setting. 176The result is {\it NIL}, if {\it bas} is the basis of an ideal of 177polynomials with more than finitely many common zeros. 178If the ideal is zero dimensional, {\em i.e.\ } the polynomials of the 179ideal have only finitely many zeros in common, the result is an 180integer $k$ which is the number of these common zeros (counted with 181multiplicities). 182\end{description} 183 184\subsection{GDIMENSION, GINDEPENDENT\_SETS} 185The following operators can be used to compute the dimension 186and the independent variable sets of an ideal which has the 187Gr\"obner basis {\it bas} with arbitrary term order: 188\begin{description} 189\ttindex{GDIMENSION}\ttindex{GINDEPENDENT\_SETS} 190\ttindex{ideal dimension}\ttindex{independent sets} 191\item[Gdimension]$bas$ 192\item[Gindependent\_sets]$bas$ 193{\it Gindependent\_sets} computes the maximal 194left independent variable sets of the ideal, that are 195the variable sets which play the role of free parameters in the 196current ideal basis. Each set is a list which is a subset of the 197variable list. The result is a list of these sets. For an 198ideal with dimension zero the list is empty. 199{\it GDimension} computes the dimension of the ideal, 200which is the maximum length of the independent sets. 201\end{description} 202 203\subsection{GLEXCONVERT: Conversion to a Lexical Base} 204\begin{description} 205\ttindex{GLEXCONVERT} 206\item[{\it GLEXCONVERT}] $ \left(\{exp,\ldots , expm\} \left[,\{var1 207\ldots , varn\}\right]\right.$ \\ 208$\left. \left[,MAXDEG=mx\right] \left[,NEWVARS=\{nv1, \ldots , nvk\}\right]\right) $ \\ 209where $\{exp1, \ldots , expm\}$ is a Gr\"obner basis with 210$\{var1, \ldots , varn\}$ as variables in the current term order mode, 211$mx$ is an integer, and 212$\{nv1, \ldots , nvk\}$ is a subset of the basis variables. 213For this operator the source and target variable sets must be specified 214explicitly. 215\end{description} 216 217GLEXCONVERT converts a basis of a zero-dimensional ideal (finite number 218of isolated solutions) from arbitrary ordering into a basis under {\it 219lex} ordering. During the call of GLEXCONVERT the original ordering of 220the input basis must be still active. 221 222NEWVARS defines the new variable sequence. If omitted, the 223original variable sequence is used. If only a subset of variables is 224specified here, the partial ideal basis is evaluated. For the 225calculation of a univariate polynomial, NEW\-VARS should be a list 226with one element. 227 228MAXDEG is an upper limit for the degrees. The algorithm stops with 229an error message, if this limit is reached. 230 231A warning occurs if the ideal is not zero dimensional. 232 233GLEXCONVERT is an implementation of the FLGM algorithm. Often, the 234calculation of a Gr\"obner basis 235with a graded ordering and subsequent conversion to {\it lex} is 236faster than a direct {\it lex} calculation. Additionally, GLEXCONVERT 237can be used to transform a {\it lex} basis into one with different 238variable sequence, and it supports the calculation of a univariate 239polynomial. If the latter exists, the algorithm is even applicable in 240the non zero-dimensional case, if such a polynomial exists. 241 242\begin{verbatim} 243 torder({{w,p,z,t,s,b},gradlex) 244 245 g := groebner { f1 := 45*p + 35*s -165*b -36, 246 35*p + 40*z + 25*t - 27*s, 15*w + 25*p*s +30*z -18*t 247 -165*b**2, -9*w + 15*p*t + 20*z*s, 248 w*p + 2*z*t - 11*b**3, 99*w - 11*s*b +3*b**2, 249 b**2 + 33/50*b + 2673/10000}; 250 251 G := {60000*W + 9500*B + 3969, 252 253 1800*P - 3100*B - 1377, 254 255 18000*Z + 24500*B + 10287, 256 257 750*T - 1850*B + 81, 258 259 200*S - 500*B - 9, 260 2 261 10000*B + 6600*B + 2673} 262 263 glexconvert(g,{w,p,z,t,s,b},maxdeg=5,newvars={w}); 264 265 2 266 100000000*W + 2780000*W + 416421 267 268 glexconvert(g,{w,p,z,t,s,b},maxdeg=5,newvars={p}); 269 270 2 271 6000*P - 2360*P + 3051 272 273\end{verbatim} 274 275\subsection{GROEBNERF: Factorizing Gr\"obner Bases} 276 277If Gr\"obner bases are computed in order to solve systems of equations 278or to find the common roots of systems of polynomials, the factorizing 279version of the Buchberger algorithm can be used. The theoretical 280background is simple: if a polynomial $p$ can be represented as a 281product of two (or more) polynomials, {\em e.g.\ } $h= f*g$, then $h$ 282vanishes if and only if one of the factors vanishes. So if during the 283calculation of a Gr\"obner basis $h$ of the above form is detected, 284the whole problem can be split into two (or more) disjoint branches. 285Each of the branches is simpler than the complete problem; this saves 286computing time and space. The result of this type of computation is a 287list of (partial) Gr\"obner bases; the solution set of the original 288problem is the union of the solutions of the partial problems, 289ignoring the multiplicity of an individual solution. If a branch 290results in a basis $\{1\}$, then there is no common zero, {\em i.e.\ }no 291additional solution for the original problem, contributed by this 292branch. 293 294\subsubsection{GROEBNERF Call} 295\ttindex{GROEBNERF} 296The syntax of GROEBNERF is the same as for GROEBNER. 297\[ 298\mbox{\it GROEBNERF}(\{exp1, exp2, \ldots , expm\} 299 [,\{\},\{nz1, \ldots nzk\}); 300\] 301where $\{exp1, exp2, \ldots , expm\} $ is a given list of expressions or 302equations, and $\{nz1, \ldots nzk\}$ is 303an optional list of polynomials known to be non-zero. 304 305GROEBNERF tries to separate polynomials into individual factors and 306to branch the computation in a recursive manner (factorisation tree). 307The result is a list of partial Gr\"obner bases. If no factorisation can 308be found or if all branches but one lead to the trivial basis $\{1\}$, 309the result has only one basis; nevertheless it is a list of lists of 310polynomials. If no solution is found, the result will be $\{\{1\}\}$. 311Multiplicities (one factor with a higher power, the same partial basis 312twice) are deleted as early as possible in order to speed up the 313calculation. The factorising is controlled by some switches. 314 315As a side effect, the sequence of variables is stored as a \REDUCE\ list in 316the shared variable 317\begin{center} 318gvarslast . 319\end{center} 320If GLTBASIS is on, a corresponding list of leading term bases is 321also produced and is available in the variable GLTB. 322 323The third parameter of GROEBNERF allows one to declare some polynomials 324nonzero. If any of these is found in a branch of the calculation 325the branch is cancelled. This can be used to save a substantial amount 326of computing time. The second parameter must be included as an 327empty list if the third parameter is to be used. 328 329\begin{verbatim} 330 torder({x,y},lex)$ 331 groebnerf { 3*x**2*y + 2*x*y + y + 9*x**2 + 5*x = 3, 332 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x = -3, 333 x**3*y + x**2*y + 3*x**3 + 2*x**2 }; 334 335 336 {{Y - 3,X}, 337 338 2 339 {2*Y + 2*X - 1,2*X - 5*X - 5}} 340\end{verbatim} 341%} 342 343It is obvious here that the solutions of the equations can be read 344off immediately. 345 346All switches from GROEBNER are valid for GROEBNERF as well: 347\ttindex{GROEBOPT} \ttindex{GLTBASIS} 348\ttindex{GROEBFULLREDUCTION}\ttindex{GROEBSTAT}\ttindex{TRGROEB} 349\ttindex{TRGROEBS}\ttindex{TRGROEB1} 350\begin{center} 351\begin{tabular}{l} 352GROEBOPT \\ 353GLTBASIS \\ 354GROEBFULLREDUCTION \\ 355GROEBSTAT \\ 356TRGROEB \\ 357TRGROEBS \\ 358TRGROEB1 359\end{tabular} 360\end{center} 361 362\subsubsection{Restriction of the Solution Space} 363In some applications only a subset of the complete solution set 364of a given set of equations is relevant, {\em e.g.\ } only 365nonnegative values or positive definite values for the variables. 366A significant amount of computing time can be saved if 367nonrelevant computation branches can be terminated early. 368 369Positivity: If a polynomial has no (strictly) positive zero, then 370every system containing it has no nonnegative or strictly positive 371solution. Therefore, the Buchberger algorithm tests the coefficients of 372the polynomials for equal sign if requested. For example, in $13*x + 37315*y*z $ can be zero with real nonnegative values for $x, y$ and $z$ 374only if $x=0$ and $y=0$ or $ z=0$; this is a sort of ``factorization by 375restriction''. A polynomial $13*x + 15*y*z + 20$ never can vanish 376with nonnegative real variable values. 377 378Zero point: If any polynomial in an ideal has an absolute term, the ideal 379cannot have the origin point as a common solution. 380 381By setting the shared variable 382\ttindex{GROEBRESTRICTION} 383\begin{center} GROEBRESTRICTION \end{center} 384GROEBNERF is informed of the type of restriction the user wants to 385impose on the solutions: 386\begin{center} 387\begin{tabular}{l} 388{\it GROEBRESTRICTION:=NONEGATIVE;} \\ 389\hspace*{+.5cm} only nonnegative real solutions are of 390interest\vspace*{4mm} \\ 391{\it GROEBRESTRICTION:=POSITIVE;} \\ 392\hspace*{+.5cm}only nonnegative and nonzero solutions are of 393interest\vspace*{4mm} \\ 394{\it GROEBRESTRICTION:=ZEROPOINT;} \\ 395\hspace*{+.5cm}only solution sets which contain the point 396$\{0,0,\ldots,0\}$ are or interest. 397\end{tabular} 398\end{center} 399 400If GROEBNERF detects a polynomial which formally conflicts with the 401restriction, it either splits the calculation into separate branches, or, 402if a violation of the restriction is determined, it cancels the actual 403calculation branch. 404 405 406\subsection{GREDUCE, PREDUCE: Reduction of Polynomials} 407 408\subsubsection{Background} \label{GROEBNER:background} 409Reduction of a polynomial ``p'' modulo a given sets of polynomials 410``B'' is done by the reduction algorithm incorporated in the 411Buchberger algorithm. 412 413% Subsection 3.5.2 414\subsubsection{Reduction via Gr\"obner Basis Calculation} 415\ttindex{GREDUCE} 416\[ 417\mbox{\it GREDUCE}(exp, \{exp1, exp2, \ldots , expm\}]); 418\] 419where {\it exp} is an expression, and $\{exp1, exp2,\ldots , expm\}$ is 420a list of any number of expressions or equations. 421 422GREDUCE first converts the list of expressions $\{exp1, \ldots , 423expn\}$ to a Gr\"obner basis, and then reduces the given expression 424modulo that basis. An error results if the list of expressions is 425inconsistent. The returned value is an expression representing the 426reduced polynomial. As a side effect, GREDUCE sets the variable {\it 427gvarslast} in the same manner as GROEBNER does. 428 429 430\subsubsection{Reduction with Respect to Arbitrary Polynomials} 431\ttindex{PREDUCE} 432\[ 433 PREDUCE(exp, \{exp1, exp2,\ldots , expm\}); 434\] 435where $ exp $ is an expression, and $\{exp1, exp2, \ldots , 436expm \}$ is a list of any number of expressions or equations. 437 438PREDUCE reduces the given expression modulo the set $\{exp1, 439\ldots , expm\}$. If this set is a Gr\"obner basis, the obtained reduced 440expression is uniquely determined. If not, then it depends on the 441subsequence of the single reduction steps 442(see~\ref{GROEBNER:background}). PREDUCE does not check whether 443$\{exp1, exp2, \ldots , expm\}$ is a Gr\"obner basis in the actual 444order. Therefore, if the expressions are a Gr\"obner basis calculated 445earlier with a variable sequence given explicitly or modified by 446optimisation, the proper variable sequence and term order must 447be activated first. 448 449\example (PREDUCE called with a Gr\"obner basis): 450\begin{verbatim} 451 torder({x,y},lex); 452 gb:=groebner{3*x**2*y + 2*x*y + y + 9*x**2 + 5*x - 3, 453 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x + 3, 454 x**3*y + x**2*y + 3*x**3 + 2*x**2}$ 455 preduce (5*y**2 + 2*x**2*y + 5/2*x*y + 3/2*y 456 + 8*x**2 + 3/2*x - 9/2, gb); 457 458 2 459 Y 460\end{verbatim} 461 462 463\section{Ideal Decomposition \& Equation System Solving} 464Based on the elementary Gr\"obner operations, the GROEBNER package offers 465additional operators, which allow the decomposition of an ideal or of a 466system of equations down to the individual solutions. Details of the 467operators\ttindex{GROESOLVE}\ttindex{GROEBNERF} 468\ttindex{IDEALQUOTIENT}GROESOLVE, GROEBNERF and IDEALQUOTIENT can be 469found in the full documentation, with associated functions. 470 471