Status: Accepted
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 3067 by [email protected]: assumptions ntheory handler
http://code.google.com/p/sympy/issues/detail?id=3067
Something special is going to have to be done to get the new assumptions
system to answer queries about expressions. Consider the following very
simple expression:
ask(Q.even(Add(S(2), S(2), evaluate=0)))
False
The ntheory AskEvenHandler gets called for expressions like this 2 + 2
expression, not for numbers when queried like ask(Q.even(2)). It tries to
do the test by calculating 1 significant figure (which is wrong, but even
if that is corrected the problem is that...) then the integer of that is
compared with the original expression. The int will never compare equal to
the expression so this will (I believe) always return False.
What can be done instead is to see if the evaluation of the expression,
less the calculated integer value, is zero. This will fail, in master, also:
(Add(S(2), S(2), evaluate=0) - 4).n()
.0e-125
This is where I see something like equals() being used. After the
as_content_primitive step it would have determined that the expression is a
zero:
(Add(S(2), S(2), evaluate=0) - 4).as_content_primitive()
0
For more complicated expressions, other methods are used. And if numerical
is enabled (as implemented in pull request 1036), it is possible to detect
an expression that is zero regardless of the magnitude of the numbers
involved in the expression.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" 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/sympy-issues?hl=en.