Change of logic regarding symbolic expressions in Sage 6.10.beta7

48 views
Skip to first unread message

Eric Gourgoulhon

unread,
Dec 6, 2015, 9:35:44 AM12/6/15
to sage-devel
Hi,

In Sage 6.10.beta7:
sage: bool(x == 0)
False
sage
: bool(x != 0)
True
sage
: x = SR.var('x', domain='real')
sage
: bool(x == 0)
False
sage
: bool(x != 0)
False
The latest output differs from what one would get from Sage 6.10.beta6 (and any previous version of Sage), which would have been True, i.e. consistent with the second output.
It seems that this change has been introduced in #19312. This introduces a kind of non-binary logic for undecidable expressions. A priori I am not against it, but IMHO this should be fully advertised, since having x != 0 different from not (x==0), i.e. having
sage: bool(x != 0) is bool(not (x == 0))
False
may break a lot of codes (for sure it broke mine!). Also it is quite annoying that the last output is not consistent with the second one, simply because x has been declared real. Note that declaring x complex does not restore the consistency:
sage: forget()
sage
: x = SR.var('x', domain='complex')
sage
: bool(x != 0)
False
Only having domain equal to None does:
sage: forget()
sage
: x = SR.var('x')
sage
: bool(x != 0)
True
From the discussion in #19312 and in #19040, I understand that this change of logic is a feature and not a bug, and I can easily fix my code by replacing x != 0 by not (x==0). However, such an important change may surprise many users and IMHO  it should be stressed during the release of Sage 6.10.

Eric.
Reply all
Reply to author
Forward
0 new messages