90 CHAPTER 4. ALGORITHMS FOR STABLE IDEALSIndeed, the expansion <strong>of</strong> x 0 x 2 in I 1 just replaces the monomial generator x 0 x 2 by x 0 x 2 2,which provides the ideal (x 2 0, x 0 x 1 , x 0 x 2 2, x 3 1).(ii) The expansion <strong>of</strong> x 0 in I 2 can be computed as follows:MuPAD>> compute_expansion([[1,0,0,0,0],[0,5,0,0,0],[0,4,3,0,0],[0,4,2,6,0]],>> [1,0,0,0,0], 4);Output[[2, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 0, 1, 0, 0], [1, 0, 0, 1, 0],[0, 5, 0, 0, 0], [0, 4, 3, 0, 0], [0, 4, 2, 6, 0]]As expected, the ideal obtained is (x 2 0, x 0 x 1 , x 0 x 2 , x 0 x 3 , x 5 1, x 4 1x 3 2, x 4 1x 2 2x 6 3).(iii) The expansion <strong>of</strong> x 4 1x 2 2x 6 3 in I 2 should increase the exponent <strong>of</strong> x 3 by 1:MuPAD>> compute_expansion([[1,0,0,0,0],[0,5,0,0,0],[0,4,3,0,0],[0,4,2,6,0]],>> [0,4,2,6,0], 4);Output[[1, 0, 0, 0, 0], [0, 5, 0, 0, 0], [0, 4, 3, 0, 0], [0, 4, 2, 7, 0]]As we see, the monomial x 4 1x 2 2x 6 3 has been replaced by x 4 1x 2 2x 7 3, such that we obtain the theideal (x 0 , x 5 1, x 4 1x 3 2, x 4 1x 2 2x 7 3).Similar to 4.9, we will now give the source code to compute the contraction <strong>of</strong> a monomialin a stable ideal. As in 4.9, the code is simply based on the definition <strong>of</strong> a contraction.Again, we will have to check if the set <strong>of</strong> minimal generators <strong>of</strong> a given stable ideal is stilla set <strong>of</strong> minimal generators after the contraction <strong>of</strong> some monomial. If this is not the case,we have to remove those monomials, which are divisible by other monomials in the set <strong>of</strong>generators.MuPAD Source Code 4.11. As in 4.9, let M denote the set <strong>of</strong> minimal generators <strong>of</strong>some stable ideal ordered in descending lexicographic order, m the monomial to be contractedand n the index <strong>of</strong> the last variable in R. The procedure below expects M, m,and n as input and returns a list <strong>of</strong> lists encoding the new set <strong>of</strong> minimal generators inlexicographic order.Input for the procedure compute contraction.◦ M — a list <strong>of</strong> lists encoding the set <strong>of</strong> generators <strong>of</strong> some stable ideal in lexicographicorder
4.4. COMPUTING EXPANSIONS AND CONTRACTIONS 91◦ m — a list encoding the monomial to be contracted◦ n — the index <strong>of</strong> the last variable <strong>of</strong> the polynomial ring ROutput <strong>of</strong> the procedure compute contraction.◦ M — a list <strong>of</strong> lists, representing the set <strong>of</strong> minimal generators <strong>of</strong> the input ideal inlexicographic order after the contraction <strong>of</strong> the monomial mcompute_contraction:= proc(M, m, n)local last, mon, Ind, del, v, i, ind, j;begin/* Determine the index ’last’ <strong>of</strong> the last variableoccurring in m */for i from n+1 downto 0 doif m[i] 0 thenlast:= i;break;end_if;end_for;mon:= m;mon[last]:= mon[last] + 1;M[contains(M, mon)]:= m;for i from last+1 to n domon:= m;mon[i]:= mon[i] + 1;v:= contains(M, mon);if v > 0 thenM[v]:= null();end_if;end_for;/* Testing for minimality, i.e. removing all monomials,which are no longer minimal generators <strong>of</strong> the ideal */v:= contains(M, m);Ind:= {};del:= {};for j from 1 to last-1 d<strong>of</strong>or i from 1 to n+1 do