Yes, I know about simplify_logic(), and it should be made smarter. But
the problem is that it only simplifies things as pure predicates.
ITE(x < 0, y > 2, y > 3) would be simplified as ITE(p, q, r). There
is an additional predicate that is always true, namely, Implies(y > 3,
y > 2), which could potentially result in a further simplification,
which might not be valid for the general ITE(p, q, r).
In logic, a set of expressions that are assumed to be true for a given
calculation are called a "model". Simplifying conditionals based on
models would require use of the assumptions system. The assumptions
system, particularly the new assumptions and satask, basically boils
down to building up a "model" of mathematically true facts which are
then used to possibly reduce a given predicate to "true" or "false".
ask(Q.real(x), Q.positive(x)) gives True because
Implies(Q.positive(x), Q.real(x)) is a predicate in the model. However
even if something doesn't reduce to "true" or "false", you could
potentially rewrite it, hopefully in a way that simplifies it. For
example And(x > 2, x > 3) can be rewritten as just x > 3 because
Implies(x > 3, x > 2) is true in a given model. It's been awhile since
I've studied this logic stuff so I can't say what the best
algorithm(s) are for doing this. For inequalities, we don't even have
support for them in ask() yet (they aren't part of the model), so that
would be the place to start.
This is a difficult problem, but one which I think would really help
many parts of SymPy (especially simplifying Piecewise conditionals).
Aaron Meurer
>
https://groups.google.com/d/msgid/sympy/9c15cf3a-33dc-41bb-b3d9-24f4d0caf025%40googlegroups.com.