SymPy's test_closed_group(expr, assumptions, key): whether every
argument of expr satisfies the predicate key (fuzzy, with SymPy's
rule that at most one argument may fail), as used by the handlers of
ask() for sums and products.
Arguments
- expr
An expression.
- assumptions
Assumptions, as for
ask().- key
A predicate such as
Q$positive, or its name.
Examples
x <- Symbol("x")
test_closed_group(x + 1, Q$positive(x), Q$positive)
#> [1] TRUE