New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ntheory.AskEvenHandler.Mul is order-dependent #9127
Comments
I spoke too soon - preparing the test case revealed that all permutations work with the old More analysis is needed. |
Did you know about sorting?
Or not count this as a bug at all. If something work differently in non-canonical form, i.e. for unevaluated Mul like
How sorted results looks now? I think, if they look differently from |
unsubscribed. mention me, if you want reply |
Didn't have to do more detailed analysis, renaming |
I admit, this looks as a bug for me. And same "works" for old assumptions. Fixing wouldn't require checking all terms - you should do care only about special ones, i.e. Add instances.
I'm sure you know that Python uses eager evaluation rules. So, constructor for Mul must be called before Q.even. Mul have some canonicalization logic in it's constructor (i.e. Mul.flatten and so on) and that include sorting. |
ask(Q.even(x*y*(y + z)), Q.integer(x) & Q.integer(y) & Q.odd(z))
is supposed to giveTrue
(the ability to infer thaty*(y+z)
for oddz
was introduced in e91f8f0 by @skirpichev).However, some permutations of
x
,y
, and(y + z)
will fail because the code will not recognize thaty
and(y + z)
combine in a relevant fashion if it seesx
between the two.Fixing this would require checking all combinations of two terms.
That's O(N^2) for N = number of terms.
So either N needs to be limited, or the list of term combinations to check would need to exclude those that cannot contribute to the answer.
The text was updated successfully, but these errors were encountered: