Is this correct?

23 views
Skip to first unread message

Juan Francisco Puentes Calvo

unread,
Oct 26, 2022, 7:09:39 AM10/26/22
to sympy
Something as simple as below:

import sympy as sp;
U1, red, green = sp.symbols("U1, red, green");
sp.ask(sp.Ne(U1,red), assumptions=sp.Eq(U1,green));

Returns None, but.

sp.ask(sp.Eq(U1,green), assumptions=sp.Eq(U1,green));

Returns True.

What I are doing wrong?

Oscar Benjamin

unread,
Oct 26, 2022, 9:54:13 AM10/26/22
to sy...@googlegroups.com
I don't know what you are doing wrong. Presumably you intended for
these operations to mean something different from what they actually
are because if you understood what ask is supposed to do then these
outputs are both obviously correct.

Your use of odd symbols names makes this somewhat confusing for me so
I'm just going to use x, y and z for the symbols. This is your first
query:

In [1]: print(ask(Ne(x, y), assumptions=Eq(x, z)))
None

Here you have asked if x != y based on the assumption that x == z.
Clearly the assumption gives no information to answer the query so you
get None which is the correct response because it just means
maybe/don't know in this context.

In [2]: print(ask(Eq(x, y), assumptions=Eq(x, y)))
True

Now you have asked if x == y given that x == y. Clearly the assumption
implies that the query is True and so you get True.

--
Oscar

Aaron Meurer

unread,
Oct 26, 2022, 4:25:46 PM10/26/22
to sy...@googlegroups.com
Just to be clear, what you probably want is sp.ask(sp.Ne(U1, red),
assumptions=sp.Eq(U1, green) & Ne(red, green)). Unfortunately, ask()
does not yet know how to do any sorts of deductions based on
equalities, so this also returns None. Note that None in the SymPy
assumptions means "don't know". It could be because the result can be
either true or false, or it could be because SymPy just doesn't have
the algorithms to determine whether something is true or false.

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxRO2BoZtKw9DwO9izhAWpJEA39ZB4pExcD0FVj2416Bew%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages