#13814: LazyFamily.__eq__ gives false positives.
------------------------------------+---------------------------------------
       Reporter:  cnassau           |         Owner:  sage-combinat
           Type:  defect            |        Status:  needs_review 
       Priority:  major             |     Milestone:  sage-5.6     
      Component:  combinatorics     |    Resolution:               
       Keywords:                    |   Work issues:               
Report Upstream:  N/A               |     Reviewers:               
        Authors:  Christian Nassau  |     Merged in:               
   Dependencies:                    |      Stopgaps:               
------------------------------------+---------------------------------------

Comment (by nthiery):

 Hi!

 Replying to [ticket:13814 cnassau]:
 > `LazyFamily.__eq__` occasionally returns false positives, because it
 only compares function names, not values.

 Yikes. This is indeed definitely a bug!

 Thanks for catching it, and sorry for commenting on it after you have
 implemented a first proposal of solution.

 > I think `__eq__` should _never_ give false positives for classes that
 might be hashed.

 +1!

 > In this case `LazyFamily.__eq__` should
 >
 >    * test function equality if the index sets are finite of the same
 size
 >    * return `False` if one of the indexing sets is infinite

 I would much prefer to stick as much as possible to the default
 equality rule for composite objects: namely to compare their
 components for equality. A Family is composed of an indexing set `I`
 and a mapping `f`. Thus, ideally, two families should be equal if
 their indexing sets are equal and their mappings are equal.  How two
 sets (infinite or not) compare for equality is not Family's decision
 to take.

 Now, we have the problem that comparing mappings is delicate; first
 because two functions with the same code are not considered as equal,
 and anyway because two functions with different code might implement
 the same mapping, but that's undecidable.

 So at this point it seems to me that the best approximation would be
 as follow:

 - For comparing two FiniteFamily's, compare the underlying indexing
   set and dictionary for equality (the mapping has already been
   computed on all the indexing set, so we might as well use it, even
   though this comparison will have a cost).

 - For comparing other families: test whether the two indexing sets and
   the two mappings compare to equal.

 Potential issue: that upon pickling unpickling we get back an equal
 object.

 Thanks again for investigating this,

 Best,
                               Nicolas

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