#1163: [with patch, needs work] assume seems to have some undesired side-effects
----------------------+-----------------------------------------------------
 Reporter:  zimmerma  |       Owner:  gfurnish  
     Type:  defect    |      Status:  assigned  
 Priority:  major     |   Milestone:  sage-4.1.2
Component:  calculus  |    Keywords:            
 Reviewer:            |      Author:            
   Merged:            |  
----------------------+-----------------------------------------------------
Changes (by kcrisman):

 * cc: burcin, robertwb (added)


Comment:

 Okay, the following patch (which depends on #7084, I think), resolves
 '''most''' of the issues in this ticket.  See below for the one it
 doesn't, and comments.
 {{{
 sage: assume(x<=1)
 sage: assume(x>=1)
 sage: assumptions()
 [x <= 1, x >= 1]  # so far, so good
 sage: b = x!=1
 sage: b.__nonzero__()
 True # WRONG
 sage: bool(b)
 True # WRONG
 sage: bool(x==1)
 True # right!
 sage: forget()
 sage: var('x,y,z')
 (x, y, z)
 sage: assume(x>=y,y>=z,z>=x)
 sage: assumptions()
 [x >= y, y >= z, z >= x]
 sage: bool(x==z)
 True # right!
 sage: forget()
 sage: assume(x>0)
 sage: bool(x<>1) # NO!
 True
 sage: bool(x!=1) # NO!  And note that Python considers <> and != to be
 identical
 True
 sage: bool(x==1)
 False # right!
 }}}
 I've narrowed the problem down to the fact that __nonzero__ has the
 following lines:
 {{{
             res = relational_to_bool(self._gobj)
             if res:
                 return True
 }}}
 If you put this code after determining whether you need assumptions,
 practically every evaluation of bool() yields an infinite loop.  But for
 some reason the function relational_to_bool (like all these Ginac
 functions, completely unsearchable because they live somewhere outside of
 devel/sage) doesn't send (at least) != to the assumptions.  Here is the
 wrapper code, in c_lib/include/ginac_wrap.h:
 {{{
 bool relational_to_bool(const ex& e) {
     if (ex_to<relational>(e))
         return 1;
     else
         return 0;
 }
 }}}
 Now what?  The documentation of ex_to in Ginac, even when I found it on
 their website, really only will make sense to someone with good C++
 knowledge.

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