In PR #13204 I am proposing the following change to how Piecewise
conditions behave:
```
Booleans can contain Piecewise elements:
>>> cond = (x < y).subs(x, Piecewise((2, x < 0), (3, True))); cond
Piecewise((2, x < 0), (3, True)) < y
The folded version of this results in a Piecewise whose
expressions are Booleans:
>>> folded_cond = piecewise_fold(cond); folded_cond
Piecewise((2 < y, x < 0), (3 < y, True))
When a Boolean containing Piecewise (like cond) or a Piecewise
with Boolean expressions (like folded_cond) is used as a condition,
it is converted to an equivalent ITE object:
>>> Piecewise((1, folded_cond))
Piecewise((1, ITE(x < 0, y > 2, y > 3)))
When a condition is an ITE, it will be converted to a simplified
Boolean expression:
>>> piecewise_fold(_)
Piecewise((1, ((x >= 0) | (y > 2)) & ((y > 3) | (x < 0))))
```
Technically, there is no need to convert the Piecewise-conditional to
ITE. It is good, however, to write the condition as an arbitrary
BooleanFunction after folding so this step doesn't have to be done in any
routine that uses folding to get an expression into shape for integration
or solving, etc...
Does anyone have an objection to writing the condition of a Piecewise as a
Boolean (ITE)?
/c
--
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/8f8b2334-6075-4879-824c-b022e4cae90b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.