Let $(\Omega ,\mathcal F,\mathbb P)$ a probability space and $X:\Omega \to \mathbb R$ a random variable. Let $A$ being $\sigma (X)-$measurable. I'm having a problem to find a function $h:\mathbb R\to \mathbb R$ s.t. $$h(X(\omega ))=1_A(\omega ).$$
In somehow, I would like to set $$h(x)=1_{X(A)}(x),$$ but the problem it's that it can happen that $X^{-1}(X(A))\supsetneq A$, and thus, we can have $X(\omega )\in X(A)$ but $\omega \notin A$. So, is there a way to define $h$ properly or not really ?