#12802: test containment of ideals in class MPolynomialIdeal
---------------------------+------------------------------------------------
Reporter: mariah | Owner: AlexGhitza
Type: enhancement | Status: new
Priority: minor | Milestone: sage-5.0
Component: algebra | Keywords:
Work issues: | Report Upstream: N/A
Reviewers: | Authors:
Merged in: | Dependencies:
Stopgaps: |
---------------------------+------------------------------------------------
There seems to be no way to test containment of ideals in the class
MPolynomialIdeal in {{{sage.rings.polynomial.multi_polynomial_ideal}}}.
One might expect the comparison operators (e.g. {{{I<J}}} ) to do this,
but in fact what they do is to compare the Groebner bases as sequences of
polynomials, which is counterintuitive.
For example:
{{{
sage: R.<x,y> = PolynomialRing(QQ)
sage: I=(x*y)*R; J=(x,y)*R; I<J
False
sage: I=(y+1)*R; J=(x,y)*R; I<J
True
}}}
This is implemented in the {{{__cmp__}}} method, which is not up to the
task of doing subset comparison, since {{{__cmp__}}} is only suitable for
total orderings.
To do it right would seem to require implementing Python's "rich
comparison" methods, {{{__lt__}}}, {{{__gt__}}}, etc.
For example:
{{{
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
def IsSubset(I,J):
for g in I.gens()
if not g in J: return False
return True
def IsSuperset(I,J):
return IsSubset(J,I)
def IsProperSubset(I,J):
return I!=J and IsSubset(I,J)
def IsProperSuperset(I,J):
return I!J and IsSuperset(I,J)
setattr(MPolynomialIdeal,'__le__',IsSubset)
setattr(MPolynomialIdeal,'__lt__',IsProperSubset)
setattr(MPolynomialIdeal,'__ge__',IsSuperset)
setattr(MPolynomialIdeal,'__gt__',IsProperSuperset)
}}}
With these we now get the expected behavior:
{{{
sage: R.<x,y> = PolynomialRing(QQ)
sage: I=(x*y)*R; J=(x,y)*R; I<J
True
sage: I=(y+1)*R; J=(x,y)*R; I<J
False
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12802>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.