--==================================================================-- -- Tutorial 5: Monomial Orders and Groebner Bases -- --==================================================================-- -- Use C-x 2 to get a horizontally split window or -- Use C-x 3 to get a vertically split window. -- Select the lower (or right) window and Hit F12 to start M2. -- Hit F11 to send code from this screen to M2. -- for help with M2 type (works in version 1.1) viewHelp ---------------------------------------------------------------------- -- Monomial Orderings -- ---------------------------------------------------------------------- -- Lex Orderings ----------------------------------------------------- -- Consider the ring: R = ZZ/2[x_1..x_4]; -- Give the above ring the Lex ordering with -- x_1 > x_2 > x_3 > x_4. -- Show off that you have the correct ordering with some examples of -- polynomials with ordered terms. (When a ring has a specified -- monomial ordering, Macaulay 2 will always use that ordering when -- returning polynomials) -- Now keep the ring above, but give it the Lex ordering with --x_4 > x_3 > x_2 > x_1 -- GLex (GrLex) Orderings -------------------------------------------- -- Consider R = ZZ/2[x_1..x_4]; -- Give the above ring the GLex ordering with -- x_1 > x_2 > x_3 > x_4. -- Show off that you have the correct ordering with some examples of -- polynomials with ordered terms. -- GRevLex Orderings ------------------------------------------------- -- The default monomial ordering in Macaulay 2 is the GRevLex -- ordering. R = ZZ/2[x_1..x_4]; -- Show off the GRevLex ordering of the above ring with some examples. -- Comparative Ring Theory ------------------------------------------- -- Now take the following three rings: A = ZZ/2[x_1..x_4] -- Equip this ring with the Lex ordering B = ZZ/2[y_1..y_4] -- Equip this ring with the GLex ordering C = ZZ/2[z_1..z_4] -- Let this ring have the GRevLex ordering -- Find a f(t_1..t_4) such that the lead terms of -- f(x_1..x_4), f(y_1..y_4), and f(z_1..z_4) -- are all different. -- Product Orderings ------------------------------------------------- -- A special type of ordering is called a Product ordering. Here are -- two rings. The second one has a Product ordering on it. Try some -- "test" polynomials to see if you can figure out what the Product -- ordering is doing. When you get done, confer with your neighbor -- and see if you can come to an agreement. A = ZZ/2[x_1..x_4] B = ZZ/2[y_1..y_4,MonomialOrder=>{1,3}] -- What about this Product ordering? A = ZZ/2[x_1..x_4] B = ZZ/2[y_1..y_4,MonomialOrder=>{2,2}] -- What about this Product ordering? A = ZZ/2[x_1..x_4] B = ZZ/2[y_1..y_4,MonomialOrder=>{1,1,1,1}] ---------------------------------------------------------------------- -- Groebner Bases -- ---------------------------------------------------------------------- -- You compute Groebner bases in Macaulay 2 using the command "gb" A = ZZ/2[x_1..x_4] I = ideal (x_1^3-x_2*x_3^4,x_1*x_2*x_3) gb I -- OK, maybe that doesn't tell you much. To get the generators of a -- gb use "gens" gens gb I -- OK, that gives you a matrix. Though it is a little hard to see -- what the generators of the Groebner basis are. Use transpose to -- make this more clear. -- When computing Groebner bases, the monomial order matters a lot. -- Consider the following ring: n = 4; A = ZZ/2[a_1..a_(2*n),b_1..b_(4*(n-1)),c_1..c_(4*(n-2)),d_1..d_(4*(n-3))] -- Now construct two matrices, X and Y: X = matrix{{a_1,b_1,b_5,b_9},{b_3,a_3,c_1,c_5},{b_7,c_3,a_5,d_1},{b_11,c_7,d_3,a_7}} Y = matrix{{a_2,b_2,b_6,b_10},{b_4,a_4,c_2,c_6},{b_8,c_4,a_6,d_2},{b_12,c_8,d_4,a_8}} -- Consider the following ideal, which is generated by the entries of -- the matrix X*Y-Y*X: I = ideal(X*Y-Y*X); -- Try to compute a Groebner basis of I: -- When you think Macaulay 2 has had enough, kill Macaulay 2. Try to -- do it without closing this window. -- Now consider the following ring with the following Product order: n = 4; A = ZZ/2[a_1..a_(2*n),b_1..b_(4*(n-1)),c_1..c_(4*(n-2)),d_1..d_(4*(n-3)),MonomialOrder=>{8,12,8,4}] -- Again use these matrices: X = matrix{{a_1,b_1,b_5,b_9},{b_3,a_3,c_1,c_5},{b_7,c_3,a_5,d_1},{b_11,c_7,d_3,a_7}} Y = matrix{{a_2,b_2,b_6,b_10},{b_4,a_4,c_2,c_6},{b_8,c_4,a_6,d_2},{b_12,c_8,d_4,a_8}} -- Can you describe a relationship between the matrices above and the -- Product order chosen? -- Now take the same ideal: I = ideal(X*Y-Y*X); -- Compute a Groebner basis of I. Wait for it... -- If you think this is neat, check out: -- F. Hreinsdottir "A Case Where Choosing a Product Order Makes the -- Calculation of a Groebner Basis Much Faster" Journal of Symbolic -- Computation (1994) 18, 373-378. -- and -- F. Hreinsdottir "An improved term ordering for the ideal of -- commuting matrices" Journal of Symbolic Computation (2006) 41, -- 999-1003. ---------------------------------------------------------------------- -- Counting Monomials -- ---------------------------------------------------------------------- -- Start by restarting! restart -- In the paper we consider the ring: R = k[x_1, x_2, x_1^(-1), x_2^(-1)]. -- Set k = ZZ/2 and build R in Macaulay 2. R = -- Now build S as in the paper. S = -- As a gesture of friendship, we've typed in the set M for you: M = {x_1^2*x_2, x_1*x_2^2, x_1^(-1)*x_2^2, x_1^(-2)*x_2, x_1^(-2)*x_2^(-1), x_1^(-1)*x_2^(-2), x_1*x_2^(-2), x_1^2*x_2^(-1)} -- Use Macaulay 2 to construct the map Psi : S -> R mapping the y's to -- the elements of M Psi = -- Now compute the kernel of Psi, call it k k = -- At this point, we need to know if k is a binomial ideal. Since k -- has many elements, we should use a routine to do it for us. isBinomial = f -> # terms f <= 2; isBinomialIdeal = I -> ( L := flatten entries gens gb I; i := 0; while isBinomial L_i and i + 1 < #L do if isBinomial L_i then (i = i + 1) else break; isBinomial L_i); -- Check it out, you should get "true" out. isBinomialIdeal(k) -- Now we have a somewhat complex routine. Someone has commented the -- first three lines of the routine. Read through the routine and -- comment the last 4 lines. homogeneousPart = I -> ( A := ring I; -- allows us to work with the ring of I t :=local t; -- gives us a "safe" variable to use B := coefficientRing A [t_0..t_(# gens A),MonomialOrder=> Eliminate 1,Degrees => prepend({1},degrees A)]; -- gives us a ring to eliminate with i := map(B,A,{t_1..t_(# gens A)}); Ih := homogenize(i I,t_0); j := map(A,B,flatten{0,gens A}); j ideal selectInSubring(1, gens gb Ih) ); -- Now we can continue to follow the paper with: H = homogeneousPart k -- Now compute the reduced Hilbert series of H, the Hilbert polynomial -- of H, and the Hilbert function of H. From this Hilbert function -- you have your function "f" from the paper. -- To finish, all you need to do is compute the ideal of lead terms of -- k. Call it ink: ink = -- Now compute the reduced Hilbert series of ink, the Hilbert -- polynomial of ink, and the Hilbert function of ink. From this -- Hilbert function, you have the function "g" from the paper. --==================================================================-- -- FIN -- --==================================================================--