No, the deduction of even/odd on Add isn't implemented yet. But the
implication Implies(Q.odd(d + 1), Q.even(d)) is always true, so you
can add it to the assumed facts unconditionally.

Aaron Meurer

On Tue, May 30, 2017 at 3:43 PM, mike <[email protected]> wrote:
> Thank you Aaron, your response is very helpful.
>
> Q.odd(d + 1) & Q.even(d) are deduced assumptions. It seems if I use the
> current method, Sympy can not get the conclusion "d is even" from "if (d+1)
> is odd" directly.
>
>
> 在 2017年5月29日星期一 UTC-6下午9:59:11,Aaron Meurer写道:
>>
>> None in this case means that SymPy doesn't know how determine the
>> fact. It looks like the sathandlers has an even/odd fact for Mul but
>> not for Add
>> https://github.com/sympy/sympy/blob/71eb404921a4596b9fe42a7a4a0ccfa7d63a62c0/sympy/assumptions/sathandlers.py#L339.
>> If I remember correctly, it's because the corresponding fact for Add
>> requires counting, and I wasn't sure how to do that efficiently
>> (without adding an exponential number of clauses for large Adds).
>>
>> You can always tell SymPy the facts that it needs to know to deduce
>> things, in this case
>>
>> >>> with assuming(Q.positive(c), Q.integer(c), Q.positive(d),
>> >>> Q.integer(d), Q.odd(c*(d + 1)), Q.odd(d + 1) >> Q.even(d)):
>> ...     print(ask(Q.odd(d)))
>> False
>>
>> here >> means "implies" (you could also use Implies(Q.odd(d + 1),
>> Q.even(d))).
>>
>> Aaron Meurer
>>
>>
>> On Mon, May 29, 2017 at 9:45 PM, mike <[email protected]> wrote:
>> > Hi,
>> >
>> > I am new to learn sympy. This is a very simple question but I do not
>> > know
>> > how to deal with it.
>> >
>> > The question is: both c and d are positive integers, is c*d even if
>> > c*(d+1)
>> > is odd.
>> >
>> > my code:
>> >
>> > from sympy import Symbol
>> > from sympy.assumptions import assuming, Q, ask
>> > c = Symbol('c')
>> > d = Symbol('d')
>> > with assuming(Q.positive(c), Q.integer(c), Q.positive(d), Q.integer(d)):
>> >     with assuming(Q.odd(c*(d +1))):
>> >         print(ask(Q.odd(c)))
>> >         print(ask(Q.odd((d+1))))
>> >
>> > This code works. c is odd and (d+1) is odd, but how to evaluate d is odd
>> > or
>> > even.
>> > I run the code
>> > ask(Q.odd(d)),
>> > but the result is "NONE"
>> >
>> > Ask for help.
>> > Thanks,
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "sympy" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [email protected].
>> > To post to this group, send email to [email protected].
>> > Visit this group at https://groups.google.com/group/sympy.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/sympy/5206e651-feeb-4cd9-a4c5-ba85f17ec6f0%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/2d41dd13-587e-4fca-996f-e3892b9fe792%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6Ju6_044Loxh7JVi8mhV00tFZJXrdXG5AYC%2B-z5FWUiYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to