A simple implementation of the Extended First Criterion Implementation by John Perry, 2007; developed at the University of Southern Mississippi. This implementation is for demonstration purposes only; there are some interesting questions regarding how best to apply the criterion. Some documentation & commentary provided, but please read it carefully. The reader may also be interested in an implementation of F5, available from http://www.math.usm.edu/perry/research.html. Comments are welcome and earnestly desired. Contact me at john dot perry at delete-this-hyphenated-phrase usm dot edu. Released under the GNU public license. See below. restart:
<Text-field style="Heading 1" layout="Heading 1">Description of the criterion</Text-field> Notation. Let \356\224\275 be a field, and F=(f1,f2,...,fm)\342\210\210\356\224\275[x1,x2,...,xn]m. Let \342\211\272 be an admissible ordering on the terms of \356\224\275[x1,x2,...,xn]. Let f,g\342\210\210\356\224\275[x1,x2,...,xn]. Denote by lt(f) the leading term of f with respect to \342\211\272. We write S(f,g) for the S-polynomial of f and g with respect to \342\211\272. That is, S(f,g) = \317\203f,g f - \317\203g,f g where \317\203f,g = lt(g)/gcd(lt(f),lt(g)). We say that S(f,g) has an S-representation with respect to F if there exist h1,h2,...,hm\342\210\210\356\224\275[x1,x2,...,xn] such that S(f,g) = h1f1 + h2f2 + \342\213\257 + hmfm; and for all i=1,...,m, hi=0 or lt(hi)lt(fi) \342\211\272 lcm(lt(f),lt(g)). An S-representation is also known as a t-representation for some t\342\211\272lcm(lt(f),lt(g)). (See Gr\303\266bner Bases by Becker, Weispfenning, and Kredel (BWK93).) It is well-known that F is a Gr\303\266bner basis iff for all i,j such that 1\342\211\244i<j\342\211\244m, S(fi,fj) has an S-representation with respect to F. The following theorem describes the Extended First Criterion. Theorem. Suppose that the S-polynomials S(f1,f2), S(f2,f3), ..., S(fm-1,fm) have S-representations with respect to F. Then (A)\342\207\222(B) where: (A) (EDiv) and (EVar) where (EDiv) gcd(t1,tm) divides gcd(ti) for all i=2,...,m-1; (EVar) For all x\342\210\210{x1,x2,...,xn} (V1) or (V2) where (V1) degx(t1)=0 or degx(tm)=0; (V2) LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkobWZlbmNlZEdGJDYmLUYjNiYtSSVtc3ViR0YkNiUtSSNtaUdGJDYlUSRkZWdGJy8lJ2l0YWxpY0dRJmZhbHNlRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLUYjNiQtRjQ2JVEieEYnL0Y4USV0cnVlRicvRjtRJ2l0YWxpY0YnRjovJS9zdWJzY3JpcHRzaGlmdEdRIjBGJy1JI21vR0YkNi1RIn5GJ0Y6LyUmZmVuY2VHRjkvJSpzZXBhcmF0b3JHRjkvJSlzdHJldGNoeUdGOS8lKnN5bW1ldHJpY0dGOS8lKGxhcmdlb3BHRjkvJS5tb3ZhYmxlbGltaXRzR0Y5LyUnYWNjZW50R0Y5LyUnbHNwYWNlR1EmMC4wZW1GJy8lJ3JzcGFjZUdGZ24tRjE2JS1GNDYlUSJ0RidGQkZELUYjNiQtRjQ2JVEiaUYnRkJGREY6RkZGOkY6LyUlb3BlbkdRInxmckYnLyUmY2xvc2VHUSJ8aHJGJy1GNDYlUSFGJ0ZCRkQtSShtc3Vic3VwR0YkNictSSdtc3BhY2VHRiQ2Ji8lJ2hlaWdodEdRJjAuMGV4RicvJSZ3aWR0aEdRJjAuMGVtRicvJSZkZXB0aEdGZXAvJSpsaW5lYnJlYWtHUSVhdXRvRictRiM2KUZhby1GSjYtUSI9RidGOkZNRk9GUUZTRlVGV0ZZL0ZmblEsMC4yNzc3Nzc4ZW1GJy9GaW5GZHEtSSNtbkdGJDYkUSIxRidGOi1GYXA2JkZjcEZmcEZpcC9GXHFRKG5ld2xpbmVGJ0ZgcEZqb0Y6LUYjNiQtRjQ2JVEibUYnRkJGREY6LyUxc3VwZXJzY3JpcHRzaGlmdEdGSEZGRjo= is monotonic. (B) S(f1,fm) has an S-representation with respect to F. If the terms t1,...,tm satisfy item (A) of the theorem, then we say that they satisfy the Extended First Criterion. A proof is available on request. Relationship with other well-known criteria. If the terms u and v satisfy Buchberger's First Criterion, then they also satisfy the Extended First Criterion, because they satisfy (EDiv) and (EVar) easily. In fact, the Extended First Criterion essentially detects some instances of Buchberger's First Criterion that are ``hidden'' by multiplication. Terms that satisfy Buchberger's Second Criterion may satisfy the Extended First Criterion, but do not have to, and vice-versa. The same holds in relation to Faug\303\250re's two criteria for F5 (see related worksheet). The module below implements an algorithm that uses the Extended First Criterion during the computation of a Gr\303\266bner basis. The algorithm is based on a simple implementation of Buchberger's Second Criterion ("GR\303\226BNERNEW1" in BWK93). It is more difficult to use the Extended First Criterion with the Gebauer-M\303\266ller version of the algorithm, because it is harder to guess the representation of an S-polynomial detected by Buchberger's Second Criterion in this algorithm. We include a version of the Gebauer-M\303\266ller algorithm to show how the Extended First Criterion detects redundant S-polynomials that G-M does not detect, but this is a straightforward implementation of the version found in BWK93 ("GR\303\226BNERNEW2").
<Text-field style="Heading 1" layout="Heading 1">Module implementing the algorithm</Text-field> efc_buchberger := module() # For Compute_Basis and Tagged_Reduction, see below. # reduced_pairs is a list of S-polynomials computed and reduced # by the algorithm, in the order listed. export # procedures Compute_Basis, Tagged_Reduction, # data Report_Reduced_Pairs, Report_BC_Skips, Report_EFC_Skips, Report_BC1_Pairs, Report_BC2_Pairs, Report_EFC_Pairs, # Gebauer-Moeller sort_normal_strategy, Basis_GM, Update_GM, is_gb: option package: local # procedures update_pairs, update_pairs_efc, EFC, Find_Connection, Build_Connection, sort_ascending, sort_descending, missorted, sort_pairs, reduced_pairs, lts, ordering, skips_from_bc1, skips_from_bc2, skips_from_efc, bc1_pairs, bc2_pairs, efc_pairs, ModuleLoad: # Vanity, O Vanity! ModuleLoad:=proc() printf("A simple implementation of the Extended First Criterion\134n"): printf("Copyright 2007 John Perry\134n"): printf("Developed at the University of Southern Mississippi\134n"): printf("This implementation is highly unoptimized,\134n"): printf("and is provided for the purpose of demonstrating\134n"): printf("how the criterion can be applied naively in any\134n"): printf("algorithm to compute a Groebner basis.\134n"): printf("Released under the GNU General Public License, available at\134n"): printf("http://www.gnu.org/licenses/gpl.html"): end: # ModuleLoad # This is the general algorithm. It implements only a very simple # version of the Buchberger criteria. # Parameters: # F: a generators of a polynomial ideal, for which a Gr\303\266bner basis is desired # tord: a term ordering for computing a Gr\303\266bner basis of F # bc_skips: an optional, unevaluated name that, if used, # will record the number of S-polynomials skipped by # Buchberger's criteria # efc_skips: an optional, unevaluated name that, if used, # will record the number of S-polynomials skipped by # the Extended First Criterion Compute_Basis:=proc(F::list(polynom), tord::{MonomialOrder,ShortMonomialOrder}) # DESCRIPTION OF LOCAL VARIABLES # crit_pairs: the list of critical pairs # cp: a loop variable for critical pairs # checked_pairs: critical pairs that have been checked # G: the working Gr\303\266bner basis, with respect to tord # lts: leading terms of G, with respect to tord # spoly: an S-polynomial # reduction_tags: tags from an S-polynomial reduction # skips_from_bc: pairs skipped by Buchberger's criteria # skips_from_efc: pairs skipped by the Extended First Criterion # old_size: used to compute previous two local crit_pairs, cp, checked_pairs, G, lts, spoly, reduction_tags, old_size: # intialization G := F: reduced_pairs :=table(): lts := table([seq(Groebner[LeadingMonomial](G[ctr],tord) *Groebner[LeadingCoefficient](G[ctr],tord),ctr=1..nops(G))]): crit_pairs := [op(combinat[choose]({seq(ctr,ctr=1..nops(G))},2))]: checked_pairs := {}: bc1_pairs := table(): bc2_pairs := table(): efc_pairs := table(): skips_from_bc1 := 0: skips_from_bc2 := 0: skips_from_efc := 0: # loop until no critical pairs left while crit_pairs <> [] do # Apply Buchberger's Criteria crit_pairs,checked_pairs := update_pairs(crit_pairs, checked_pairs, lts, tord): # Apply the Extended First Criterion crit_pairs, checked_pairs := update_pairs_efc(crit_pairs, checked_pairs,lts): # If the criteria did not eliminate all critical pairs (and # usually they won't!) then compute & reduce their S-polynomials if crit_pairs <> [] then # Take the first critical pair in the list, compute its # S-polynomial, reduce it, and record it as checked. cp := crit_pairs[1]: crit_pairs := crit_pairs[2..-1]: reduced_pairs := [op(reduced_pairs),cp]: spoly := Groebner[SPolynomial](G[min(op(cp))], G[max(op(cp))],tord): spoly := Tagged_Reduction(spoly,G,tord,'reduction_tags'): if spoly<>0 then # If the S-polynomial didn't reduce to zero, then the tags # need to reflect that we had to add another polynomial to # the basis. reduction_tags := reduction_tags union {nops(G)+1}: end if: checked_pairs := checked_pairs union {[cp,reduction_tags]}: # If the S-polynomial didn't reduce to zero, then we have to # add it to the working basis, and add its leading term to the # list of leading terms of the basis. if spoly<>0 then G := [op(G),spoly]: lts[nops(G)] := Groebner[LeadingMonomial](spoly,tord) *Groebner[LeadingCoefficient](spoly,tord): crit_pairs := [op(crit_pairs), seq({ctr,nops(G)},ctr=1..nops(G)-1)]: end if: end if: end do: return G: end: # Compute_Basis # This implements a tagged reduction--that is, not only does it # return the remainder from a set reduction algorithm, but it # returns also the indices of the polynomials that were used to # find the remainder. These indices are the tags. # Parameters: # poly: the polynomial to be reduced, modulo... # F: a list of polynomials that generate an ideal, with respect to... # tord: a term ordering # tags: a name of an unevaluated variable, # used to store the reduction tags # Note that the tags name is not optional. If you didn't want the # tags, you really ought to be using Groebner[Reduce]. But that # won't work with EFC. Tagged_Reduction:=proc(poly::polynom,F::list(polynom), tord::{MonomialOrder,ShortMonomialOrder},tags::name) local i,remainder,lts,ts,t,internal_tags, reduced,reduced_on_this_round: # DESCRIPTION OF LOCAL VARIABLES # i is a looped variable # remainder is the result of the reduction process # lts contains the leading terms of F (monomial*coefficient) # ts contains the terms of remainder # internal_tags contains the tags: indices of the polynomials that # reduced poly # reduced is a boolean that indicates whether poly reduced # reduced_on_this_round is a boolean that indicates whether # poly was reduced by a particular polynomial remainder := poly: reduced := true: # An obvious optimization would be to pass the leading terms # as a parameter along with F, avoiding the following computation. lts := [seq(Groebner[LeadingMonomial](F[ctr],tord) *Groebner[LeadingCoefficient](F[ctr],tord),ctr=1..nops(F))]: internal_tags := {}: while reduced and remainder <>0 do reduced := false: for i from 1 to nops(lts) do reduced_on_this_round := false: ts := {op(remainder)} minus {0}: for t in ts do ts := ts minus {t}: if divide(t,lts[i]) then reduced := true: reduced_on_this_round := true: internal_tags := internal_tags union {i}: remainder := simplify(remainder - (t/lts[i])*F[i]): ts := {op(remainder)} minus {0}: end if: end do: if reduced_on_this_round then # This way we reduce by smaller polynomials first. # (Assuming F is sorted with ascending leading terms, # which may not be the smartest assumption!) # We could do ensure this in Compute_Basis if we wanted. i := 0: end if: end do: end do: tags := internal_tags: return remainder: end: # Tagged_Reduction # This updates the list of critical pairs, using a very basic # implementation of Buchberger's criteria. We do not apply the # criteria as revised by Gebauer & Moller (1988), nor the criteria # as revised by Caboara, Kreuzer, & Robbiano (2002). # Parameters: # crit_pairs: list of critical pairs remaining for computation of the basis # checked_pairs: list of critical pairs already checked # lts: list of leading terms of the working basis # tord: term ordering # The last parameter is used to call sort_pairs() to sort the pairs by # ascending lcm. Better design might put that somewhere else, and # eliminate the term ordering from this procedure, as it is otherwise # unnecessary. update_pairs:=proc(crit_pairs::list(set(posint)), checked_pairs::set([set(posint),set(posint)]), lts::table,tord) local j, cp, new_crit, new_checked, lcm_pair, t, B, divisor_found, lower_found, upper_found, p, new_tags: # DESCRIPTION OF LOCAL VARIABLES # j is a loop counter # cp is a critical pair # new_crit is a list of new critical pairs, those that Buchberger's # Criteria did not reject # new_checked is a list of checked pairs # lcm_pair is the lcm of the leading terms indexed by cp # t is a leading term: does it divide lcm_pair? # B is a working set of checked pairs # Note that B here is not the same B as is usually used # in writeups of the algorithm to compute Groebner bases. # Usually that would be crit_pairs. # I'm not sure why I did this, and I'll change it sometime. # divisor_found is a boolean whose meaning should be obvious # lower_found and upper_found are used to find a critical pair # and obtain its tags (there has to be a better way to do this) # p is a loop variable for checked_pairs # new_tags is a set of tags for a polynomial new_crit := convert(crit_pairs,set): new_checked := checked_pairs: B := {seq(checked_pairs[ctr][1],ctr=1..nops(checked_pairs))}: for cp in crit_pairs do if gcd(lts[min(op(cp))],lts[max(op(cp))])=1 then # Buchberger's first criterion satisfied new_crit := new_crit minus {cp}: skips_from_bc1 := skips_from_bc1 + 1: bc1_pairs[skips_from_bc1] := cp: new_checked := new_checked union {[cp,cp]}: else lcm_pair := lcm(lts[min(op(cp))],lts[max(op(cp))]): divisor_found := false: for j from 1 to nops(lts) while not divisor_found do # Check each of the leading terms to see # whether it divides the lcm. t := lts[j]: if divide(lcm_pair,t) and {max(op(cp)),j} in B and {min(op(cp)),j} in B then # Buchberger's second criterion satisfied divisor_found := true: new_crit := new_crit minus {cp}: skips_from_bc2 := skips_from_bc2 + 1: bc2_pairs[skips_from_bc2] := cp: B := B union {cp}: # I have to find {min(op(cp)),j} in B, to obtain the tags. lower_found := false: for p in new_checked while not lower_found do if p[1]={min(op(cp)),j} then lower_found := true: new_tags := p[2]: end if: end do: # I also have to find {max(op(cp)),j} in B, to obtain tags. upper_found := false: for p in new_checked while not upper_found do if p[1]={max(op(cp)),j} then upper_found := true: new_tags := new_tags union p[2]: end if: end do: new_checked := new_checked union {[cp,new_tags]}: end if: end do: end if: end do: new_crit := sort_pairs(convert(new_crit,list),lts,tord): return new_crit,new_checked: end: # update_pairs # This applies the Extended First Criterion by looping through # each critical pairs, and calling EFC on each pair and the set # of checked critical pairs. # Parameters: # crit_pairs: list of critical pairs remaining for computation of the basis # checked_pairs: list of critical pairs already checked # lts: list of leading terms of the working basis update_pairs_efc:=proc(crit_pairs::list(set(posint)), checked_pairs::set([set(posint),set(posint)]), lts::table) local i,p,chain,new_crit,new_checked: # DESCRIPTION OF LOCAL VARIABLES # i is a loop counter # p is a critical pair # chain is an EFC chain for p (if one exists) # new_crit is the set of critical pairs that EFC could not reject # new_checked is the set of checked_pairs new_crit := {}: new_checked := checked_pairs: # Check whether any of the critical pairs can be discarded. for p in crit_pairs do chain:=EFC(p,checked_pairs,lts): # Did we find a chain for this critical pair? if chain<>[] then # EFC satisfied! new_checked := new_checked union {[p,p]}: skips_from_efc := skips_from_efc + 1: efc_pairs[skips_from_efc] := p: else new_crit := new_crit union {p}: end if: end do: return convert(new_crit,list), new_checked: end: # update_pairs_efc # This procedure tries to find a chain for the extended first # criterion for the current critical pair (current_pair) over the # given set of checked critical pairs. # It might not find some chains that exist, because the reduction # process may have chosen a reduction path that does not guarantee # a chain, even when one exists. # Calls Find_Connection to find an actual chain. # Parameters: # current_pair: a critical pair for which we'd like to find a chain # checked_pairs: critical pairs that the algorithm has already checked # terms: the leading terms of the working basis EFC:=proc(current_pair::set(posint), checked_pairs::set([set(posint),set(posint)]), terms::table) local mins,maxes,p,p1,p2,tag_p1,tag_p2,kappa: # DESCRIPTION OF LOCAL VARIABLES # mins stores the checked pairs that might start a chain. # maxes stores the checked pairs that might complete a chain. # p, p1, p2 are critical pairs # tag_p1, tag_p2 are the reduction tags for p1, p2 # kappa is an EFC chain (if one exists) mins := {}: maxes := {}: kappa := []: for p in checked_pairs do if min(op(current_pair)) in p[1] then mins := mins union {p}: elif max(op(current_pair)) in p[1] then maxes := maxes union {p}: end if: end do: # p for p1 in mins while kappa = [] do tag_p1 := p1[2]: for p2 in maxes while kappa = [] do tag_p2 := p2[2]: kappa := Find_Connection( min(op(current_pair)),max(op(current_pair)), p1[1],tag_p1,p2[1],tag_p2,{seq(pl[1],pl in checked_pairs)}, terms); end do: # p2 end do: # p1 return kappa: end: # EFC # Attempts to find a chain for the S-polynomial generated by # the polynomials indexed by start_conn and stop_conn, starting # and ending the connection at p1 and p2. Find_Connection only # checks whether the reduction tags incorporate polynomials # that satisfy the gcd divisibility test of the Extended First Criterion. # It calls Build_Connection to build an actual chain. # Parameters: # start_conn: index of polynomial to start a chain # stop_conn: index of polynomial to end a chain # p1: a checked critical pair containing start_conn # tag_p1: the reduction tag for p1 # p2: a checked critical pair containing stop_conn # tag_p2: the reduction tag for p2 # checked_pairs: all checked critical pairs # terms: leading terms of the working basis Find_Connection:=proc(start_conn::posint,stop_conn::posint, p1::set(posint),tag_p1::set(posint), p2::set(posint),tag_p2::set(posint), checked_pairs::set(set(posint)),terms::table) local tags,m,g,vars,var,gcd_divisibility,i,tag_list,lambda, kappa,connected_pairs: # DESCRIPTION OF LOCAL VARIABLES # tags are the reduction tags of p1 and p2, less start&stop # m is the number of tags in tags # g is the gcd of the lts of the polys indexed by start_conn # and stop_conn # gcd_divisibility is a boolean that tests EC_div (see below) # vars are the variables of g # var is a variable that divides g # i is a loop placeholder # tag_list is a list of tags for a possible EFC chain # lambda is a sorting of tag_list # kappa is an EFC chain (if one exists) # connected_pairs consists of the critical pairs necessary to # satisfy EFC tags := (tag_p1 union tag_p2) minus {start_conn,stop_conn}: # EFC consists of two subcriteria: # - EC_div (gcd divisibility) # - EC_var (degrees of variables of gcd # follow a monotonic sequence in the chain) # Here we test for EC_div g := gcd(terms[start_conn],terms[stop_conn]): gcd_divisibility := true: for i in tags while gcd_divisibility do if not divide(terms[i],g) then gcd_divisibility := false: end if: end do: # i if gcd_divisibility then # A possible chain! Set up to check EC_var. vars:=convert(indets(g),list): var:=vars[1]: m := nops(tags): tag_list:=[start_conn,op(tags),stop_conn]: # We sort the terms according to the first variable here. if (degree(term_list[1],var)<=degree(term_list[2],var)) then lambda := sort_ascending(tag_list,terms,vars,1): else lambda := sort_descending(tag_list,terms,vars,1): end if: kappa := Build_Connection(lambda,terms,vars,g): connected_pairs := {seq({kappa[ctr],kappa[ctr+1]}, ctr=1..nops(kappa)-1)}: # Even if we obtain a chain, it may not have the correct # indices at the beginning and end. if (not connected_pairs subset checked_pairs) or (not {start_conn,stop_conn} = {kappa[1],kappa[-1]}) then kappa := []: end: else kappa := []: end if: return kappa: end: # Find_Connection # Build_Connection tries to build a connection on the indeterminates # of g (the gcd used for gcd divisibility in the Extended First # Criterion) to order the reduction tags in a way that satisfies EFC. # If it cannot do that, it returns an empty list. # Parameters: # lambda: indices of polynomials in the working basis that might # make an EFC chain # terms: leading terms of the polynomials in the working basis # vars: variables of the gcd # g: the gcd Build_Connection:=proc(lambda::list(posint),terms::table, vars::list(name),g::monomial) local i,var,result: # DESCRIPTION OF LOCAL VARIABLES # i is a loop counter # var is a placeholder for elements of vars # result is an EFC chain, if one exists result := lambda: for i from 2 to nops(vars) while result<>[] do var := vars[i]: # Try to sort for a monotonic chain. if degree(g,var)<>0 and degree(terms[lambda[1]],var)<=degree(terms[result[2]],var) and degree(terms[lambda[2]],var)<=degree(terms[result[m]],var) then result := sort_ascending(result,terms,vars,i) elif degree(g,var)<>0 and degree(terms[result[1]],var)>=degree(terms[result[2]],var) and degree(terms[result[2]],var)>=degree(terms[result[m]],var) then result := sort_descending(result,terms,vars,i) elif degree(g,var)<>0 then result := []: end if: # If sorting broke an earlier sort, then we can't build a chain. if missorted(result,terms,vars,g,i) then result := []: end if: end do: return result: end: # Build_Connection # Given a list of reduction tags, leading terms, variables, and # an index, sort_ascending sorts the tags according to ascending # degree in the indexed variable. # Parameters: # tags: the indices of the chain (from reduction tags) # terms: leading terms of the working basis # vars: variables for sorting # index: which variable to use for this sort sort_ascending:=proc(tags::list(posint),terms::table, vars::list(name),index::posint) local sorter: sorter:=proc(a,b) return degree(terms[a],vars[index])<degree(terms[b],vars[index]): end: return sort(tags,sorter): end: # sort_ascending # Given a list of reduction tags, leading terms, variables, and # an index, sort_ascending sorts the tags according to descending # degree in the indexed variable. # Parameters: # tags: the indices of the chain (from reduction tags) # terms: leading terms of the working basis # vars: variables for sorting # index: which variable to use for this sort sort_descending:=proc(tags::list(posint),terms::table, vars::list(name),index::posint) local sorter: sorter:=proc(a,b) return degree(terms[a],vars[index])>degree(terms[b],vars[index]): end: return sort(tags,sorter): end: # sort_descending # Sorts the critical pairs according to the normal strategy: # - critical pairs with higher lcm are placed later in the list, and # - critical pairs with identical lcm are ordered according to the # smallest leading term of a polynomial indexed by the critical # pair. # Parameters: # pairs: the list of critical pairs # lts: the leading terms of the working basis, referenced by pairs # tord: the current term ordering sort_pairs:=proc(pairs::list(set(integer)),lts::table,tord) local i,pair_lcm,midpoint,upper,lower,other_pairs,other_lcm,bigger: # setup for quicksort midpoint := trunc(nops(pairs)/2); if midpoint = 0 then return pairs: end if: pair_lcm := lcm( lts[min(op(pairs[midpoint]))], lts[max(op(pairs[midpoint]))] ): upper := []: lower := []: # quicksort other_pairs := {seq(ctr,ctr=1..nops(pairs))} minus {midpoint}: for i in other_pairs do # Compare the lcms. other_lcm := lcm(lts[min(op(pairs[i]))],lts[max(op(pairs[i]))]): if other_lcm = pair_lcm then # If equal, sort by index with smallest leading term. bigger := Groebner[LeadingMonomial]( lts[min(op(pairs[i]))]+lts[min(op(pairs[midpoint]))] ,tord): if bigger<>lts[min(op(pairs[midpoint]))] then upper := [op(upper),pairs[i]]: else bigger := Groebner[LeadingMonomial]( lts[max(op(pairs[i]))]+lts[max(op(pairs[midpoint]))] ,tord): if bigger<>lts[max(op(pairs[midpoint]))] then upper := [op(upper),pairs[i]]: else lower := [op(lower),pairs[i]]: end if: end if: elif Groebner[LeadingMonomial](other_lcm+pair_lcm,tord) =other_lcm then upper := [op(upper),pairs[i]]: else lower := [op(lower),pairs[i]]: end if: end do: return [op(sort_pairs(lower,lts,tord)), pairs[midpoint], op(sort_pairs(upper,lts,tord))]: end: # sort_pairs # missorted checks whether sort_ascending or sort_descending have # broken an EFC chain by misordering an earlier indexed variable of # the gcd. # Parameters: # lambda: the working chain # terms: the leading terms of the working basis # vars: variables by which the chain must be sorted to satisfy EC_var # g: the gcd # stop_point: the most recently ordered index, # which may have broken previous orderings missorted:=proc(lambda::list(posint),terms::table, vars::list(name),g::monomial,stop_point::posint) local i,j,var,t1,tm,result: # setup t1:=terms[1]: tm:=terms[nops(terms)]: result:=false: # We loop through variables of lower index, checking to ensure that # they have retained their monotonicity. # (There may be a way to do this while sorting, which could speed # things up a little.) for i from 1 to stop_point-1 while result=false do var:=vars[i]: if degree(g,var)<> 0 and degree(t1,var)<degree(tm,var) then for j from 1 to nops(lambda)-1 while result=false do if degree(terms[lambda[j]],var) >degree(terms[lambda[j+1]],var) then result := true: end if: end do: # j elif degree(g,var)<>0 and degree(t1,var)>degree(tm,var) then for j from 1 to nops(lambda)-1 while result=false do if degree(terms[lambda[j]],var) <degree(terms[lambda[j+1]],var) then result := true: end if: end do: elif degree(g,var)<>0 then for j from 1 to nops(lambda)-1 while result=false do if degree(terms[lambda[j]],var) <>degree(terms[lambda[j+1]],var) then result := true: end if: end do: end if: end do: # i return result: end: # missorted sort_normal_strategy:=proc(pair1, pair2) local t1, t2: t1 := lcm(lts[pair1[1]],lts[pair1[2]]): t2 := lcm(lts[pair2[1]],lts[pair2[2]]): return Groebner[TestOrder](t2,t1,ordering): end: Basis_GM:=proc(F::list(polynom), tord::{MonomialOrder,ShortMonomialOrder}) local G, crit_pairs, checked_pairs, f, pair, h, i, j, nG, reducers, num_red_pairs: ordering := tord: G := table(): lts := table(): crit_pairs := heap[new](sort_normal_strategy): checked_pairs := {}: num_red_pairs := 0: reduced_pairs := table(): skips_from_bc1 := 0: skips_from_bc2 := 0: skips_from_efc := 0: bc1_pairs := table(): bc2_pairs := table(): efc_pairs := table(): nG := nops(F): for i from 1 to nG do G[i] := F[i]: lts[i] := Groebner[LeadingMonomial](G[i],tord): crit_pairs, checked_pairs := Update_GM(i,crit_pairs, checked_pairs): end do: while not heap[empty](crit_pairs) do pair := heap[extract](crit_pairs): num_red_pairs := num_red_pairs + 1: reduced_pairs[num_red_pairs] := pair: i, j := op(pair): reducers := [seq(G[ctr],ctr=1..nG)]: h := Groebner[NormalForm](Groebner[SPolynomial](G[i],G[j],tord),reducers,tord): if h<>0 then nG := nG + 1: G[nG] := h: lts[nG] := Groebner[LeadingMonomial](h,tord): crit_pairs, checked_pairs := Update_GM(nG, crit_pairs, checked_pairs): end if: end do: return [seq(G[ctr],ctr=1..nG)]; end: Update_GM:=proc( n::posint, crit_pairs::heap, checked_pairs::set([set(posint),set(integer)])) local C, D, E, new_pairs, new_checked, pair, i, j, k, div_test_first, div_test_second: new_pairs := heap[new](sort_normal_strategy): new_checked := checked_pairs: C := {seq(ctr_g,ctr_g=1..n-1)}: D := {}: while C <> {} do i := C[1]: C := C minus {i}: if gcd(lts[i],lts[n])=1 then D := D union {i}: else div_test_first := false: for j in C while not div_test_first do div_test_first := div_test_first or divide(lcm(lts[n],lts[i]),lts[j]): end do: if div_test_first then new_checked := new_checked union {[{n,i},{-(j-1)}]}: skips_from_bc2 := skips_from_bc2 + 1: bc2_pairs[skips_from_bc2] := {i,n}: end if: div_test_second := false: for j in D while not (div_test_first or div_test_second) do div_test_second := div_test_second or divide(lcm(lts[n],lts[i]),lts[j]): end do: if div_test_second then new_checked := new_checked union {[{n,i},{-(j-1)}]}: skips_from_bc2 := skips_from_bc2 + 1: bc2_pairs[skips_from_bc2] := {i,n}: end if: if not (div_test_first or div_test_second) then D := D union {i}: end if: end if: end do: # C E := {}: while D <> {} do i := D[1]: D := D minus {i}: if gcd(lts[i],lts[n])<>1 then E := E union {i}: else new_checked := new_checked union {[{i,n},{i,n}]}: skips_from_bc1 := skips_from_bc1 + 1: bc1_pairs[skips_from_bc1] := {i,n}: end if: end do: # D while not heap[empty](crit_pairs) do i,j := op(heap[extract](crit_pairs)): if not divide(lcm(lts[i],lts[j]),lts[n]) or lcm(lts[i],lts[n])=lcm(lts[i],lts[j]) or lcm(lts[j],lts[n])=lcm(lts[i],lts[j]) then heap[insert]({i,j},new_pairs): elif lcm(lts[i],lts[n])<>lcm(lts[i],lts[j]) then new_checked := new_checked union {[{i,j},{-n}]}: skips_from_bc2 := skips_from_bc2 + 1: bc2_pairs[skips_from_bc2] := {i,j}: elif lcm(lts[j],lts[n])<>lcm(lts[i],lts[j]) then new_checked := new_checked union {[{i,j},{-n}]}: skips_from_bc2 := skips_from_bc2 + 1: bc2_pairs[skips_from_bc2] := {i,j}: end if: end do: for i in E do heap[insert]({i,n},new_pairs): end do: return new_pairs, new_checked: end: # Diagnostic Procedure is_gb:=proc(F,tord) local i,j,Sij,Rij,bad_cps: bad_cps := {}: for i from 1 to nops(F)-1 do for j from i+1 to nops(F) do Sij := Groebner[SPolynomial](F[i],F[j],tord): Rij := Groebner[NormalForm](Sij,F,tord): if Rij<>0 then bad_cps := bad_cps union {[i,j]}; end if: end do: # i end do: # j if bad_cps = {} then return true; else return false,bad_cps; end: end: # is_gb Report_Reduced_Pairs:=proc() return convert(reduced_pairs,list): end: # Report_Reduced_Pairs Report_BC1_Pairs:=proc() return convert(bc1_pairs,list): end: # Report_BC1_Pairs Report_BC2_Pairs:=proc() return convert(bc2_pairs,list): end: # Report_BC2_Pairs Report_BC_Skips:=proc() return skips_from_bc1+skips_from_bc2: bc2_pairs[skips_from_bc2] := {i,j}: : end: # Report_BC_Skips Report_EFC_Pairs:=proc() return convert(efc_pairs,list): end: # Report_EFC_Pairs Report_EFC_Skips:=proc() return skips_from_efc: end: # Report_EFC_Skips end: # module efc_buchberger
<Text-field style="Heading 1" layout="Heading 1">Examples</Text-field> with(efc_buchberger); F:=[x0*x1+x0,x0*x2+x0,x0*x3+x0]: pairs:=[{1,2},{1,3},{2,3}]: tord1:=plex(x0,x1,x2,x3): tord2:=plex(x3,x2,x1,x0): efc_buchberger[Compute_Basis](F,tord1); efc_buchberger[Report_BC_Skips](), efc_buchberger[Report_EFC_Skips](); efc_buchberger[Report_EFC_Pairs](); F:=[ x0^10*x1^12+x0^10+2*x0^8*x1^12+2*x0^8-21*x0^4*x1^12-21*x0^4+12*x0^3*x1^12+12*x0^3+2*x1^12+2, x1^12*x2^10+x2^7-3*x2^4+2*x2^3+x2^2-8*x2-1, x0^10*x3^8+x0^10+2*x0^8*x3^8+2*x0^8-21*x0^4*x3^8-21*x0^4+12*x0^3*x3^8+12*x0^3+2*x3^8+2, x3^8*x4^10+x4^8+1 ]: tord1:=plex(x4,x3,x2,x1,x0): FBasis:=Compute_Basis(F,tord1): nops(FBasis); Report_BC_Skips(),Report_EFC_Skips(); Report_BC1_Pairs();Report_BC2_Pairs();Report_EFC_Pairs(); Report_Reduced_Pairs(); Mileage on the above may vary. On two different worksheets I have seen both 7,1 and 6,3 for num_bc,num_efc. (The paper had 6,3) The critical pairs reduced would be (in this order!): 7,1: (1,2), (2,5), (1,3), (3,5), (3,4), (1,6), (5,6) 6,3: (1,2), (1,5), (1,3), (3,4), (1,6), (4,6) The code was identical between the two worksheets, so the difference may be due to Maple's implementation of sets. The reader will notice that critical pairs (1,5) and (2,5) have the same lcm, so when using the normal strategy, the pair that the algorithm picks first can very well depend on how Maple orders its sets. I believe I have managed to make things consistent by having sort_pairs() order pairs with equal lcms by which has a smaller leading term.
<Text-field style="Heading 1" layout="Heading 1"><Font encoding="UTF-8">Result of Gebauer-M\303\266ller algorithm</Font></Text-field> Compute_Basis uses a simple check of Buchberger's Second Criterion (compare with Table 5.6 on p. 226 of Becker, Weispfenning, and Kredel's Gr\303\266bner Bases). We can also show that the Extended First Criterion detects redundant S-polynomials not detected by the Gebauer-M\303\266ller algorithm. The following computation calls Basis_GM, which implements their algorithm (compare with Tables 5.7 and 5.8 of BWK). F:=[ x0^10*x1^12+x0^10+2*x0^8*x1^12+2*x0^8-21*x0^4*x1^12-21*x0^4+12*x0^3*x1^12+12*x0^3+2*x1^12+2, x1^12*x2^10+x2^7-3*x2^4+2*x2^3+x2^2-8*x2-1, x0^10*x3^8+x0^10+2*x0^8*x3^8+2*x0^8-21*x0^4*x3^8-21*x0^4+12*x0^3*x3^8+12*x0^3+2*x3^8+2, x3^8*x4^10+x4^8+1 ]: tord1:=plex(x4,x3,x2,x1,x0): G:=efc_buchberger[Basis_GM](F,tord1): efc_buchberger[Report_BC1_Pairs](); efc_buchberger[Report_BC2_Pairs](); efc_buchberger[Report_Reduced_Pairs](); In the above report we see that 8 S-polynomials were reduced; this corresponds to the first result cited above. However, EFC indicates that {4,6} is unnecessary. efc_buchberger[Report_BC_Skips](); nops(G); efc_buchberger[is_gb](G,tord1); stopat(efc_buchberger[Basis_GM]); stopat(efc_buchberger[sort_normal_strategy]);
<Text-field style="Heading 1" layout="Heading 1">Save module on system</Text-field> Insert the name of your save library between quotes. These have been commented out to avoid accidental execution (e.g., Edit->Execute->Worksheet) ## example from my system: ##savelibname := "/Users/JackPerry/Library/maplelibs/mylibs.lib"; #savelibname := "/Users/JackPerry/Library/maplelibs/mylibs.lib"; # uncomment next line only if you do not have a library already # march('create',savelibname); # savelib('efc_demonstration'); # uncomment next line if you wish to delete it from your system ## march('delete',savelibname[2],"efc_demonstration.m"); Execute the following two lines only if you wish to test that the module saved successfully. restart; ## to avoid having to do this automatically, place it into your ## Maple initialization file (maple.ini, .mapleinit; see Maple's ## documentation for details) #libname := libname, savelibname; #with(efc_buchberger); savelibname;
<Text-field style="Heading 1" layout="Heading 1">License (GPL)</Text-field> GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS