# symbolic ring comparisons return strange results

Greetings,

bool(abs(-1+sqrt(2)) != abs(1-sqrt(2)))

erroneously returns True (I'm running SageMath-8.0 on a mac laptop, for what it's worth).

Is this a bug?

Thanks

edit retag close merge delete

it looks like a bug to me, and also why it does this:

sage: x = SR.var('x')
sage: bool(abs(1-x) == abs(x-1))
True
sage: bool(abs(1-x) != abs(x-1))
True

( 2017-10-06 05:41:00 +0200 )edit

Sort by ยป oldest newest most voted

In order to establish if two expressions are equal, sage performs a "default wash machine program" and in case there is a proof for the True value, it returns this True. Else it returns False.

In such cases, one should help sage to find the truth.

In our case:

sage: expression = abs(-1+sqrt(2)) != abs(1-sqrt(2))
sage: bool(expression)
True
sage: bool(expression.simplify_full())
False


Just tell sage to perfom a simplification of the expression!

Note: One can find many "bugs" like the posted one, just try for instance:

sage: bool( abs(-1+sqrt(2)) != abs(1-sqrt(2)) )
True
sage: bool( abs(-1+sqrt(2)) == abs(1-sqrt(2)) )
True

more

1

Yeah, I sort of understood the issue of returning False in case it can't really verify truth. But this is returning True when the statement is in fact False.

( 2017-10-04 22:29:16 +0200 )edit

Most probably this is because a != b is first converted to not (a == b) before evaluation.

( 2017-10-07 11:19:26 +0200 )edit