4

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.

glS
  • 7,623
  • 1
  • 21
  • 61

1 Answers1

3

The function Refine does what you want

Assuming[x ∈ Reals, Refine[Element[x, Reals]]]
(* True *)

Assuming[x > 0, Refine[Element[x, Reals]]]
(* True *)
mikado
  • 16,741
  • 2
  • 20
  • 54
  • well this is kind of embarrassing, I was sure I checked whether Refine did the job, and somehow convinced myself it didn't. Anyway, I guess we can say that the function elementQ[x_, dom_] := Refine[Element[x, dom]] === True is the solution. Or more generally, checkAssumption[assumption_] := Refine[assumption] === True. Thanks for the answer! – glS Sep 16 '16 at 21:14