Suppose there are a number of assumptions attached to a certain symbol.
How do we query Mathematica to see if a given assumption holds?
To be more precise, how can we define a function elementQ
such that
Block[{$Assumptions = Element[x, Reals]}, elementQ[x, Reals]]
(* True *)
Assuming[Element[x, Reals], elementQ[x, Reals]]
(* True *)
elementQ[x, Reals]
(* False *)
In some circumstances this is automatically given by Element
itself: for example Element[Pi, Reals]
correctly returns True
. However, the same technique does not work when querying for user-defined assumptions on symbols:
Assuming[Element[z, Reals], Element[z, Reals]]
(* Element[z, Reals] *)
The matter is of course also complicated by the fact that there are several ways to set assumptions.
Such functions should both check the content of $Assumptions
and if there are assumptions set up by the use of some Assuming
or similar function.