#12802: test containment of ideals in class MPolynomialIdeal
--------------------------------------------------+-------------------------
Reporter: mariah | Owner: AlexGhitza
Type: enhancement | Status:
needs_review
Priority: minor | Milestone: sage-5.1
Component: algebra | Resolution:
Keywords: sd40.5, groebner bases, ideals | Work issues:
documentation
Report Upstream: N/A | Reviewers: Andrey
Novoseltsev
Authors: John Perry | Merged in:
Dependencies: | Stopgaps:
--------------------------------------------------+-------------------------
Changes (by john_perry):
* status: needs_work => needs_review
Old description:
> 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
> }}}
>
> The patch supplied gives a solution via Groebner bases, and also fixes
> #12839.
>
> '''Apply''':
>
> * [attachment:trac_12802_and_12839.patch]
New description:
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
}}}
The patch supplied gives a solution via Groebner bases, and also fixes
#12839.
'''Apply''':
1. [attachment:trac_12802_and_12839.patch]
1. [attachment:trac_12802_additional_changes.patch]
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12802#comment:19>
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.