Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I think it is a mixture of boolean and symbolics that is going on here. If I am not wrong, this is what is happening to your expression, say, (x==1) or (x==-3):

  1. First, the part of the expression before or is evaluated. So, most probably bool(x==1) is being run to find out if it evaluates to True or False.
  2. Now, bool(x==1) will always return False, so the result of the expression becomes the result of whatever (x==-3) is.
  3. x is a symbolic variable and Sage by default does not evaluate an expression like x==-3 to give the truth value of the expression. What Sage does is keep the expression unmodified.

This also goes into the behavior of or and and in Python itself. In particular, read the Note at the end of the section here. Notice how it says that and and or return the last evaluated argument and their output may not be restricted to True or False.