Example of a non-constant random variable that is independent of itself In his blog on probability theory, Terence Tao states that
 Show that a random variable $X$ is independent of itself (i.e. $X$ and $X$ are independent) if and only if $X$ is almost surely equal to a constant.
But what about the function
$$X: \{1,2\} \to \{1,2\}, \quad X(\omega) = \omega$$
on the trivial algebra $\{\emptyset, \{1,2\}\}$? We have $X^{-1}(\emptyset) = \emptyset$ and $X^{-1}(\{1,2\}) = \{1,2\}$ although $X$ takes on two values, 1 and 2 with probability $1/2$.
Don't we need some additional assumption on $X$, for instance that it is real-valued? If yes, what is the weakest assumption that we need to make?
 A: If you define a random variable to a measurable function from $(\Omega,\mathcal F)$ to $(\mathbb R,\mathcal B(\mathbb R))$, then it is true that every random variable independent of itself is constant.
The problem with your example is that the phrase "$X$ is almost surely constant" is not even well-defined. To say that $X$ is constant is to say that there exists $c$ such that $P(X=c)=1$. However, for your example, you cannot even speak of $P(X=1)$ or $P(X=2)$, since the events $\{X=1\}$ and $\{X=2\}$ are not measurable. In order for the problem to be well defined, the sigma-algebra of the "value space" needs to contain all singleton sets.
Is this modification sufficient? That is,

Let $(S,\mathcal S)$ be a measurable space such that $\mathcal S$ contains all singletons and let $X:(\Omega,\mathcal F,P)\to (S,\mathcal S)$ be a measurable function such that $P(X\in E)=\text{0 or 1}$ for all $E\in \mathcal S$. Can we conclude that there exists $s\in S$ such that $P(X=s)=1$?

The answer to the above is certainly yes if we additionally assume $S$ is countable. In this case, we have $P(X\in S)=\sum_s P(X=s)$, so there must be exactly one summand for which $P(X=s)=1$. Without this assumption, it is not true in general. A counterexample is given by
$$
\begin{align}
\Omega=S&=\text{any uncountable set}
\\
\mathcal F=\mathcal S&=\text{\{countable subsets of $\Omega$\} $\cup$ \{complements of countable subsets\}}
\\
P&=0\text{ for countable subsets, 1 for co-countable subsets}
\end{align}
$$
Finally, consider $X:(\Omega,\mathcal F,P)\to (\Omega,\mathcal F)$ defined by $X(\omega)=\omega$. This is independent of itself, since $P(X\in A)$ is always $0$ or $1$ by design. However, $P(X=c)$ is always $0$ regardless of the constant $c$, so $X$ is not constant.
To summarize,

*

*The problem is only well-defined if the state space contains all singletons.


*If the state space is countable, or if the state space is $(\mathbb R^n,\mathcal B(\mathbb R^n))$, then self-independence $\implies$ constant.


*There exists an uncountable state space $S$ with a non-constant self-independent $S$-valued random variable.
