Polynomials and Gröbner Bases

Alice Feldmann January 13, 2015

Abstract This report is intended to elaborate the topics covered in the presentation on December 16, 2014 about polynomials and Gröbner held by Alice Feldmann in the student seminar in com- binatorics on mathematical software in the autumn semester 2014 at ETH Zurich. The concept of polynomials and Gröbner bases is a typical subject in computational algebra. First of all, this report gives a short introduction into computational algebra. Then, after providing the math- ematical background and explaining related notions, it explains Buchberger’s algorithm for the construction of Gröbner bases. Finally some mathematical software tools are presented, which are widely used for problems in computational algebra, whereby a focus lays on the software Singular.

1 Introduction: Computational Algebra

Computational algebra has developed a lot during the second half of the 20th century. It describes the process of tackling and studying algebraic problems with algorithmic methods using computational help of appropriate software tools. An easy example students get to know very early is solving an inhomogenous system of linear equations. There are many efficient implementations of the famous Gauss algorithm. Using matrices as the underlying algebraic notion, the system can be transformed into an equation of the form Ax = b n n n with A F ⇥ and b F 0 for a field F .Oneexperiencesthatacomputerhelpsalotinthis 2 2 \{ } case due to an efficient implementation of the computation of the determinant: there exists a unique solution for an inhomogenous system, if and only if det(A) =0. 6 A widely spread topic in computational algebra is the effient calculation of Gröbner bases, which can be used in various applications. They provide solutions to basic problems in ring theory like the membership problem: “Let R be a ring and I an ideal of R.Givenr R,isr I?”. Furthermore they 2 2 come up with an approach for solving systems of non-linear equations by the reduction of the number of variables.

2 Polynomials and Gröbner Bases 2.1 Mathematical Background: Algebraic Construction First of all, we want to repeat some basic algebraic definitions and concepts.

Basic definitions:

A over a collection of variables x1,x2,...,xn is defined as the product of powers ↵i • ↵1 ↵2 ↵n ↵ (for i =1,...,n) of these variables: x1 x2 xn =: x .Wecandeterminethetotaldegreeof n ··· the monomial x↵:deg(x↵)= ↵ =: ↵ . i=1 i | | P

1 A term is a product of a non-zero element c of a field F and a monomial. Hence, a polynomial p • can be written as a finite sum of terms with coefficients in F ,suchasp = c x↵ for c F ↵. ↵ ↵ ↵ 2 8 Let F [x ,...,x ] denote the , which is the set of all polynomialsP in n variables • 1 n x1,...,xn with coefficients in F .NotethatF [x1,...,xn] is a commutative ring with addition and multiplication of polynomials defined as usual. Furthermore, define the field of rational functions as F (x ,...,x ):= f f,g F [x ,...,x ] and g=0 . 1 n g | 2 1 n 6 n o An ideal I F [x ,...,x ] of a polynomial ring is a non-empty subset such that f + g I for • ⇢ 1 n 2 f,g I and furthermore pf I for an arbitraty polynomial p F [x ,...,x ]. Ideals can be gen- 2 2 2 1 n erated by a set of s polynomials, say f ,...,f F [x ,...,x ].Denotetheidealgeneratedby { 1 s}⇢ 1 n this set of functions by f ,...,f := p f + ...+ p f p F [x ,...,x ] for i = 1,...,s . h 1 si { 1 1 s s | i 2 1 n { }} We remark that f ,...,f is the smallest ideal which contains all the polynomials f ,...,f . h 1 si 1 s Example: Consider the polynomials f := x2 + z2 1,f:= x2 + y2 +(z 1)2 4 and p := x2 + 1 y2z z 1. 1 2 2 Note that f1,f2,p R [x, y, z]. We want to check whether p lies in the ideal f1,f2 generated by 2 h i f1 and f2.Observethatp can be written as a sum of terms as follows: 1 1 1 p = x2 + y2z z 1= z +1 x2 + z2 1 + z x2 + y2 +(z 1)2 4 2 2 2 ✓ ◆ ✓ ◆ ⇣ ⌘ 1 1 = z +1 f + z f = ↵ f + ↵ f 2 1 2 2 1 1 2 2 ✓ ◆ ✓ ◆ 1 1 with ↵1 = z +1and ↵2 = z, both in R [x, y, z].Weconcludethatp f1,f2 . 2 2 2h i

The Hilbert basis theorem and the division algorithm We want to remind the reader of the famous Hilbert basis theorem at this point: it states that every ideal I in F [x1,...,xn] has a finite generating set. This means that for any given ideal I,thereexists afinitesetofpolynomials f ,...,f F [x ,...,x ] such that I = f ,...,f . We will see later { 1 s}⇢ 1 n h 1 si that this theorem is of quite a big importance.

The division algorithm in F [x] Furthermore, we know a division algorithm in the polynomial ring F [x] in one variable x which works in the following way: assume that we are given two polynomials f,g F [x].Wecandividef by g 2 producing a unique quotient q F [x] and a unique remainder r F [x] such that f = qg + r,andit 2 2 is either r =0,orr has a degree strictly smaller than the degree of g. Since we often have to operate with functions in more than one variable the question arises, if there exists an equivalent division algorithm for polynomials in many variables? To answer this question, we first have to introduce the notion of monomial orders.

Definition: monomial orders ↵ AmonomialorderonF [x1,...,xn] is any relation > on the set of x in F [x1,...,xn] satisfying:

2 1. > is a total (linear) ordering relation,i.e.itisantisymmetric(a b and b a a = b),   ) transitive (a b and b c a c)andtotal(weeitherhavea b or b a for two distinc   )    elements a, b F [x ,...,x ]). 2 1 n 2. > is compatible with multiplication in F [x1,...,xn],i.e.ifa is a well-ordering,i.e.everynon-emptycollectionofmonomialshasasmallestelementunder>.

The two most common monomial orders are the and the graded reverse lexico- graphic order, which are defined as follows:

Lexicographic order ↵ ↵ Let x and x be monomials in F [x1,...,xn].Wesayx >lex x ,iftheleft-mostentryinthe difference ↵ Zn is positive. 2 Graded reverse lexicographic order ↵ ↵ n n Let x and x be monomials in F [x1,...,xn].Wesayx >grevlex x ,ifeither i=1 ↵i > i=1 i, or in case the sums are equal, the right-most entry in the difference ↵ Zn is negative. 2 P P We want to illustrate these monomial orders with some easy examples. We naturally always assume that x>y>z.

We have that x3y2z> x2y6z12.Lookingatthedifferencevector(3, 2, 1) (2, 6, 12) = • lex (1, 4, 11) shows that the left-most entry is positive. Hence the term x3y2z is greater than x2y6z12 in the lexicographic order. It is also true that x2y2z2 > xy4z,becausewehave(2, 2, 2) (1, 4, 1) = (1, 2, 1). • lex However, we get x2y6z12 > x3y2z in this case, because the total degree (equal to 20)of • grevlex the term x2y6z12 is greater than the total degree (equal to 6)oftheotherterm. Furthermore, looking at the terms from the second example using the graded reverse lexicographic • 4 2 2 2 order, we obtain xy z>grevlex x y z ,becausethemonomialshaveequaltotaldegrees,butthe difference vector is equal to (1, 4, 1) (2, 2, 2) = ( 1, 2, 1) and we need the right-most entry to be negative. The examples show that two polynomials can be ordered in several ways depending on how one defines the monomial ordering. This is a very important aspect, because different orderings yield different results.

Definition: leading term of a polynomial

Before we finally get to explain the division algorithm in the polynomial ring F [x1,...,xn],weneedto ↵ define what the leading term of a polynomial is. Let f := ↵ c↵x be a polynomial in F [x1,...,xn]. ↵ Fix an arbitrary monomial order >. The leading term of f with respect to > is the product c↵x , P where x↵ is the largest monomial appearing in the ordering >.Denotetheleadingtermofpolynomial f by LT>(f).

3 Example: Consider the polynomial f =3x3y2 + x2yz3 Q [x, y, z].Observethatwehavedifferentleadingterms 2 3 2 depending on the choice of the monomial order. We get LT>lex (f)=3x y for the lexicographic order, 2 3 whereas LT>grevlex (f)=x yz for the graded reverse lexicographic order.

The division algorithm in F [x1,...,xn]

Fix any monomial order > in F [x1,...,xn] and let P := (p1,...,ps) be an ordered s-tuple of polyno- mials in F [x ,...,x ]. Then every f F [x ,...,x ] can be written as 1 n 2 1 n

f = a1p1 + ...+ asps + r, where a ,r F [x ,...,x ],andeitherr =0,orr is a linear combination of monomials, of which none i 2 1 n is divisible by any of the leading terms LT>(p1),...,LT>(ps) of the polynomials in P . We want to point out, that - analogously to the division algorithm in the polynomial ring F [x] - r is called the remainder of f on division by P .Wesometimesusethenotationr = f¯P . Furthermore, note that the division algorithm allows us to divide f by an s-tuple of polynomials. This is due to the fact that if we regard f as a polynomial generated by the polynomials in P ,wewant to divide it by more than one polynomial to see whether it can be written as a linear combination of exactly those s polynomials. As a last remark, we again want to bring the reader’s attention to the fact that the outcome of the division depends on the choice of the monomial order.

2.2 Gröbner Bases Motivation By applying the division algorithm, one can decide whether a given polynomial f F [x ,...,x ] is a 2 1 n member of a given ideal I = f ,...,f .Iftheremainderr = f¯P of f on division by P := (p ,...,p ) h 1 si 1 s is zero, i.e. f¯P =0,thenwehavef = a p +...+a p ,andbydefinitionitistruethatf p ,...,p . 1 1 s s 2h 1 si Now, recall one of our previous examples: define p := x2 + 1 y2z z 1 and I = f ,f = 2 h 1 2i x2 + y2 1,x2 + y2 +(z 1)2 4 .Wehavealreadyshowedthatp I.However,ifwedividep 2 Dby P =(f1,f2) using our division algorithmE (assume we have fixed the lexicographic order), we obtain P 1 2 2 anon-zeroremainderp¯ = 2 y z z z .Thereasonisthatnoneoftheleadingtermsoff1 or f2 2 P 1 2 (LT(f1)=LT(f2)=x )dividestheleadingtermoftherestofp (LT p¯ = 2 y z)afterthefirststep (which is the division of p by f ). 1 Gröbner bases will help us to solve this problem by gernerating a new basis for the same ideal. Then it is guaranteed that the division algorithm works when dividing by the corresponding Gröbner basis.

Definition: Gröber basis Fix a monomial order > on F [x ,...,x ] and let I F [x ,...,x ] be an ideal. A Gröbner basis for 1 n ⇢ 1 n I with respect to > is a finite collection of polynomials G = g ,...,g I with the property that { 1 t}⇢ for every non-zero polynomial f I,theleadingtermLT (f) of f is divisible by the leading term 2 > LT>(gi) of some gi for some i. We call a Gröbner Basis G for an ideal I ... reduced,ifnomonomialappearinginp G is a multiple of the leading term LT (q) of any other • 2 > monomial q G. 2

4 monic,ifitisreducedandiftheleadingcoefficientofallpolynomialsis1. • Note that a Gröbner basis G is indeed a basis for I,i.e.I = g ,...,g as we will see later. Moreover, h 1 ti if G is a Gröbner basis for I and we have a polynomial f I,thentheremainderoff on division 2 by G is zero due to the construction of the Gröbner basis, i.e. f I f¯G =0.Beforecomingto 2 , Buchberger’s algorithm, one last remark should be that the remainder obtained through division by polynoimals of a Gröbner basis for an ideal is unique.

2.3 Buchberger’s Algorithm Motivation We have seen before that Gröbner bases promise better results when it comes to various problems, for example the ideal membership problem. Hence it is desirable to work with Gröbner bases instead of arbitrary bases. Buchberger’s algorithm takes an arbitrary generating set f ,...,f of an ideal { 1 s} I = f ,...,f as input and produces a Gröbner basis G for I from it. Buchberger developed his h 1 si algorithm in the 1970s and by now it has become one of the most powerful tools in computational algebra.

How it works... Let f,g F [x ,...,x ] be non-zero polynomials. Fix a monomial order and let LT (f)=cx↵ and 2 1 n LT (g)=dx be the leading terms of f and g, respectively, where c, d F. Furthermore, define 2 x := lcm x↵,x as the least common multiple of the monomials in the leading terms. Now, define the S-polynomial of f and g as follows: x x S (f,g):= f g LT (f) · LT (g) · and observe that S (f,g) f,g . 2h i Now, apply Buchberger’s criterion: G AfinitesetG = g ,...,g I is a Gröbner basis of I if and only if S (g ,g ) =0for all pairs i and { 1 t}⇢ i j j with i = j. 6 Buchberger’s Algorithm Input: F = f ,...,f { 1 s} Output: a Gröbner basis G = g ,...,g for the ideal I = F with F G { 1 t} h i ⇢ G := F REPEAT G0 := G FOR each pair p = q in G0 DO 6 G0 S := S (p, q) IF S=0 THEN G := G S 6 [{ } UNTIL G = G0

Analysis of the Algorithm We now want to explain that the algorithm is correct: first of all, G is indeed a basis for I,because the algorithm simply adjoins polynomials lying in the ideal I to our set G. This means that the core of the basis, i.e. F = f ,...,f , is still kept and no new generators are added. Hence G is a basis { 1 s} for I as well.

5 Further, we observe that only polynomials with leading terms different from the leading terms of the current basis are added to the set. These leading terms have a smaller total degree than any of the other terms by construction of the division algorithm and since we just look at polynomials of finite degree, one eventually reaches the point when the leading term of every polynomial occuring in the ideal can be divided by the leading term of a polynomial in the set. Then, the set forms a Gröbner basis by definition and we have reached our goal. It follows that the algorithm terminates at some point and hence the running time is finite. Note that in this version of Buchberger’s algorithm, the resulting Gröbner bases are not reduced. However, this can be implemented as well with some effort.

Example We want to apply Buchberger’s Algorithm to an easy example. Consider the polynomials f = x3y 2x2y2 + x and g =3x4 y.Fixthemonomialordertobethelexicographicorder> .Firstof lex all, note that we have LT (f)=x3y and LT (g)=3x4 in the lexicographic order. Hence, we get by definition x = lcm x3y, x4 = x4y.NowcomputetheS-polynomial:

y y2 S (f,g)=xf g = 2x3y2 + x2 + 3 3 ⇣ ⌘ and divide it by F =(f,g) . Note that the leading term of S (f,g) is divisible by the leading term of f. The division algorithm yields the remainder

F y2 S (f,g) = 4x2y3 + x2 +2xy + . 3

F Now observe that the leading term of the remainder LT S (f,g) = 4x2y3 is not divisible by any F of the leading terms of f or g anymore. Hence, adjoin h⇣:= S (f,g)⌘ to our set F of polynomials and consider the two new S-polynoimals S (f,h) and S (g, h). Continue with this procedure and adjoin the remainders of further divisions, if they are non-zero.

Conclusion In this chapter, the reader was introduced to the mathematical basics needed in computation aleg- bra. We have motivated the notion of Gröbner bases and explained the functioning of Buchberger’s algorithm. In fact, there exist many implementations of Buchbgerger’s algorithms in various software packages nowadays and the application of it is made really easy for the user.

3 Mathematical Software in Computational Algebra

During the second half of the 20th century, many advancements have been achieved to make the work with computers possible and highly useful in different areas. We now want to introduce the reader to some mathematical software tools for studying problems in computational algebra.

3.1 Singular Singular was started in 1984 in Berlin, Germany, and is now settled at the University of Kaiserslautern. It is a computer algebra system for polynomial computations with emphasis on commutative algebra, algebraic geometry and singularity theory.

6 The main operating objects are ideals and modules in polynomial rings over fields or quotient rings. Singular features algorithms for the computation of Gröbner bases (implementations of Buch- berger’s and Mora’s algorithm) and polynomial factorizaton, for instance. Furthermore it is possible to classify singularities and to perform resultant, characteristic set and gcd (greatest common divisor) calculations. It works as a free and open-source software under the GNU General Public Licence. The kernel of Singular is written in C. For more details and examples of implementations see Chapter 4 of this report.

3.2 CoCoA CoCoA was originally initiated in Genova in 1987 to perfom calculations using Buchberger’s algo- rithm. The name is a shortcut for Computations in Commutative Algebra. CoCoA puts emphasis on computations in multivariate polynomial rings over rational integers and on their ideals and modules. Similarly to Singular, it is available as a free software and also features CoCoALib - an open- source GPL library. Hence it enables users to work with already written templates and also to further develop the software. The library contains source codes for applications in various areas, for example in statistics or integer programming. A huge advantage of CoCoA is its efficiency: it performs calculations with very big integers and rational numbers reliably and delivers implementations of Buchberger’s algorithm using different orderings. The kernel of CoCoA is written in C, whereas users write in a Pascal-like syntax.

3.3 Gfan The origins of Gfan are in 2003 in Aarhus, Denmark, where it has been written and developed by A. N. Jensen. Gfan is a special sofware package for computing Gröbner fans of polynomial ideals in Q [x1,...,xn] and tropical varieties based on Buchberger’s algorithm. Hence, the emphasis is clearly on tropical and polyhedral geometry in combination with algebraic methods. Gfan features highly efficient implementations and with the help of various subprograms it enables fast computations and an easy handling. The kernel of Gfan is written in C++.

4 Implementation in Singular

Programming basics When working with Singular, one experiences that the language is very similar to C respectively C++, for example: all inputs must be terminated by a semicolon, there exist types for variables which are just like the ones in C/C++, the user can write loops and functions and much more. However, different from standard software, when operating with non-trivial algorithms, the definition of an underlying ring is always required at the beginning: Singular uses the ring syntax ring name =(coefficients ), (names of ring variables), (ordering). Singular also provides already implemented functions for basic operations on ideals, polynomi- als and matrices, like the factorization of polynomials into irreducible factors (implementation of the Cantor-Zassenhaus algorithm), the computation of the determinant of a square matrix and the calcula- tion of the greatest common divisor of polynomials. However, the most interesting feature of Singular is probably the generation of Gröbner bases out of standard bases. Furthermore, there exist basic operations like a type-characterization command (typeof variable) and the possibility of converting types. The user can include libraries with the command lib library- name. It is also possible to specify the monomial ordering when it comes to determining the leading term, for example. Hereby, dp stands for the grevlex ordering and lp denotes the lex ordering. Sometimes it is also useful to apply block ordering. Another important feature is the execution of the

7 division algorithm (with respect to a specific ordering). Using the appropriate commands will return the (unique) quotient and remainder of a division.

Implementation examples First of all, we want to start with some basic calculations and the introduction of various objects of different types. Note that the second command shows that every statement must be terminated with asemicolon.

The following code segment shows a basic operation on matrices, namely the calculation of the determinant, and a typical type membership request.

Now, we want to define several rings - see code below and note how the syntax works. Since we want to operate in our ring r,weneedtoexplicitlystatethisagainusingthecommandsetring ringname, see below:

8 Look at the next code segment to see how we can define a polynomial f in our ring and request the number of monomials and its degree.

We now want to define an ideal I which is generated by f,respectivelybyf and g.

We can use the command subst to set the values of our variables to specific numbers. In this example, we set x =1and y =2.Wecanusethisforexampletoevaluatefunctionsf and g at a specific point, in this case we set (x, y)=(1, 2).

9 Note that we have defined our function f and our ideal I in the ring r. Ifwesetadifferent ring as our domain, we will see that f is undefined in this ring.

Hence, we need to set our ring to r again - and we can ensure with some quick variable calls that our previously defined objects still exist. We now want to factorize our functions f and g.Observethatthefirstpartoftheoutputyields the factors and the second part gives us the corresponding powers. We can tell from the result that f is already irreducible in ring r,butg = x4 + x2 can be factorized into irreducible polynomials in the following way: g = x2 x2 +1 . Therefore the greatest common divisor of f and g is 1.

Last but not least we want to see how to compute the Gröbner basis of a given ideal I.Singular provides a command just for that purpose.

10 Conclusion The examples above show that Singular’s syntax is very intuitive and that basic and important op- erations with algebraic objects can be done without much effort. This makes Singular a very useful software tool to work with.

5 References

Computational algebra Computational Algebra K. G. Fischer, P. Loustaunau, J. Shapiro, E. L. Green, D. Farkas: Lecture Notes in Pure and Applied Mathematics – Computational Algebra (1994)

Algebraic background David A. Cox, John Little, Donal O‘Shea: Graduate Texts in Mathematics - Using Algebraic Geometry (2005) Ralf Fröberg: An Introduction to Gröbner Bases (1997)

Software http://www.singular.uni-kl.de http://cocoa.dima.unige.it/flyer4.html http://home.math.au.dk/jensen/software/gfan/gfan.html http://en.wikipedia.org/wiki/List_of_computer_algebra_systems

Implementation Groebner Bases – Statistics and Software Systems. Takayuki Hibi, Springer Japan, 2013 Singular Manual (online)

11