#12802: test containment of ideals in class MPolynomialIdeal
--------------------------------------------------+-------------------------
       Reporter:  mariah                          |         Owner:  AlexGhitza  
                  
           Type:  enhancement                     |        Status:  
needs_review                  
       Priority:  minor                           |     Milestone:  sage-5.3    
                  
      Component:  commutative algebra             |    Resolution:              
                  
       Keywords:  sd40.5, groebner bases, ideals  |   Work issues:  Patch 
commit messages         
Report Upstream:  N/A                             |     Reviewers:  Andrey 
Novoseltsev, Simon King
        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''':
>
>  1. [attachment:trac_12802_and_12839.patch]
>  1. [attachment:trac_12802_additional_changes.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_no_whitespace.patch]

--

Comment:

 I reworked the patches into one, which lacks whitespace. Two notes:

 1. I'm working with sage 5.0.1 here; I haven't downloaded 5.1 yet on any
 of my machines. I think this should work all the same. I'll download 5.1
 next week and try it.
 1. I have not yet tested all of sage. I did run tests on all the files
 that have been modified; these were the only ones that had problems in the
 past. I am running doctests now, but if anyone sees a problem before I do,
 please do say.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12802#comment:49>
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.

Reply via email to