Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
add documentation and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saliola committed Oct 6, 2019
1 parent 0d90888 commit 59b3215
Showing 1 changed file with 51 additions and 9 deletions.
60 changes: 51 additions & 9 deletions src/sage/rings/polynomial/multi_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2992,16 +2992,31 @@ def _groebner_basis_macaulay2(self, strategy=None):
ALGORITHM:
Computed using Macaulay2. A big advantage of Macaulay2 is that
it can compute the Groebner basis of ideals in polynomial
rings over the integers.
Compute the Groebner basis using the specified strategy in Macaulay2.
With no strategy option, the Macaulay2 ``gb`` command is used; other
possible strategies are "f4" and "mgb", which correspond to the "F4"
and "MGB" strategies in Macaulay2.
A big advantage of Macaulay2 is that it can compute the Groebner basis
of ideals in polynomial rings over the integers.
INPUT:
- ``strategy`` -- (default: ``'gb'``) argument specifying the strategy
to be used by Macaulay2; possiblities: ``'f4'``, ``'gb'``, ``'mgb'``.
EXAMPLES::
sage: R.<x,y,z,w> = PolynomialRing(ZZ, 4)
sage: I = ideal(x*y-z^2, y^2-w^2)
sage: I.groebner_basis('macaulay2') # indirect doctest; optional - macaulay2
[z^4 - x^2*w^2, y*z^2 - x*w^2, x*y - z^2, y^2 - w^2]
sage: I.groebner_basis('macaulay2:gb') # indirect doctest; optional - macaulay2
[z^4 - x^2*w^2, y*z^2 - x*w^2, x*y - z^2, y^2 - w^2]
sage: I.groebner_basis('macaulay2:f4') # indirect doctest; optional - macaulay2
[z^4 - x^2*w^2, y*z^2 - x*w^2, x*y - z^2, y^2 - w^2]
sage: I.groebner_basis('macaulay2:mgb') # indirect doctest; optional - macaulay2
[z^4 - x^2*w^2, y*z^2 - x*w^2, x*y - z^2, y^2 - w^2]
The Groebner basis can be used to compute in
`\ZZ/n\ZZ[x,\ldots]`.
Expand All @@ -3015,18 +3030,31 @@ def _groebner_basis_macaulay2(self, strategy=None):
sage: I = ideal([y^2*z - x^3 - 19^2*x*z, y^2, 19^2])
sage: I.groebner_basis('macaulay2') # optional - macaulay2
[x^3, y^2, 361]
sage: I.groebner_basis('macaulay2:f4') # optional - macaulay2
[x^3, y^2, 361]
sage: I.groebner_basis('macaulay2:mgb') # optional - macaulay2
[x^3, y^2, 361]
TESTS::
sage: R.<x,y,z> = ZZ[]
sage: I = ideal([y^2*z - x^3 - 19*x*z, y^2, 19^2])
sage: I.groebner_basis('macaulay2:gibberish') # optional - macaulay2
Traceback (most recent call last):
...
ValueError: unsupported Macaulay2 strategy
"""
from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence

I = self._macaulay2_()
if strategy is None:
if strategy == "gb" or strategy is None:
m2G = I.gb().generators()
elif strategy == 'f4':
m2G = I.groebnerBasis('Strategy=>F4')
elif strategy == 'mgb':
m2G = I.groebnerBasis('Strategy=>MGB')
else:
raise ValueError("Wrong M2 option")
raise ValueError("unsupported Macaulay2 strategy")
G = str(m2G.external_string()).replace('\n','')
i = G.rfind('{{')
j = G.rfind('}}')
Expand Down Expand Up @@ -3813,6 +3841,12 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal
'macaulay2:gb'
Macaulay2's ``gb`` command (if available)
'macaulay2:f4'
Macaulay2's ``GroebnerBasis`` command with the strategy "F4" (if available)
'macaulay2:mgb'
Macaulay2's ``GroebnerBasis`` command with the strategy "MGB" (if available)
'magma:GroebnerBasis'
Magma's ``Groebnerbasis`` command (if available)
Expand Down Expand Up @@ -3920,10 +3954,18 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal
sage: gb == gb.reduced()
True
::
Here we use Macaulay2 with three different strategies.::
sage: I = sage.rings.ideal.Katsura(P,3) # regenerate to prevent caching
sage: I.groebner_basis('macaulay2:gb') # optional - macaulay2
sage: I.groebner_basis('macaulay2:gb') # optional - macaulay2
[a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c]
sage: I = sage.rings.ideal.Katsura(P,3) # regenerate to prevent caching
sage: I.groebner_basis('macaulay2:f4') # optional - macaulay2
[a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c]
sage: I = sage.rings.ideal.Katsura(P,3) # regenerate to prevent caching
sage: I.groebner_basis('macaulay2:mgb') # optional - macaulay2
[a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c]
::
Expand Down Expand Up @@ -4208,8 +4250,8 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal
if prot == "sage":
warn("The libsingular interface does not support prot='sage', reverting to 'prot=True'.")
gb = self._groebner_basis_libsingular(algorithm[len('libsingular:'):], deg_bound=deg_bound, mult_bound=mult_bound, prot=prot, *args, **kwds)
elif algorithm == 'macaulay2:gb':
gb = self._groebner_basis_macaulay2(*args, **kwds)
elif algorithm.startswith("macaulay2:"):
gb = self._groebner_basis_macaulay2(strategy=algorithm.split(":")[1], *args, **kwds)
elif algorithm == 'magma:GroebnerBasis':
gb = self._groebner_basis_magma(prot=prot, deg_bound=deg_bound, *args, **kwds)
elif algorithm == 'toy:buchberger':
Expand Down

0 comments on commit 59b3215

Please sign in to comment.