Is a random variable constant a.e. iff it is trivial sigma-algebra-measurable? In the following question
Is a random variable constant iff it is trivial sigma-algebra-measurable?,
whose answer I copy here it is proven that


If $F=\{\emptyset, A\}$, then $f$ is $F$-measurable $\iff f$ is a constant

If $f==c$ is constant it is ALWAYS measurable (for any sigma-algebra).
This holds as $f^{-1}[C]$ is $X$ if $c \in C$ and empty if $c \notin
> C$. And both sets are in any sigma-algebra.
On the other hand, if $f$ is $F$-measurable and non-constant, then it
assumes at least two values $c_1$ and $c_2$. The set $f^{-1}[{c_1}]$
must be in $F$ (by being $F$-measurable, as ${c_1}$ is a closed set)
but this set is non-empty (as $c_1$ IS a value of $f$) and not $X$ (as
the points $x$ where $f$ assumes the value $c_2$ are not in it). So
this set cannot be in $F$, and so $f$ must be constant.

However in my probability lecture this property was given like this
$F=\{\emptyset, A\}$, then $f$ is $F$-measurable $\iff f$ is an a.e (almost everywhere) constant,
f being a random variable
Is this a generalization? How do I prove it? I ended up proving it without the a.e, just as in the reference question, and I don't know how to deal with the a.e to make it more general.
For instance in the converse: If $f=c$ a.e  then there should be sets $N$ with null measure for wich the function  is not equal to c, So when I take a borel set B and do the preimage $f^{-1}(B)$ what happens if N \subset B?  this leads to the additional question of what is the preimage of a negligible set?
 A: The almost-everywhere version is false: it's indeed the case that a function $f:X\to \Bbb R$ is constant if and only if it's $\{\emptyset,X\}$-measurable.
If you have a measure space $(X,\mathcal E,\mu)$ and a map $f:X\to \Bbb R$, it is true that $f$ is equal almost everywhere to a $\{\emptyset,X\}$-measurable function if and only if $f$ is almost everywhere constant, but it's hard to say if this was the intention of the claim, or if the statement you cite is just an error.
A: [This is a long comment]

$F=\{\emptyset, A\}$, then $f$ is $F$-measurable $\iff f$ is an a.e (almost everywhere) constant,  f being a random variable

We have $\Rightarrow$, but not $\Leftarrow$, as explained in the accepted answer. This question is settled.
However, I was thinking about what I believe to be the unspoken essence of your question, based on this comment. Here is how I'd phrase it:

For most practical purposes, we don't distinguish between a.e. equal variables. For example, between a constant $c$ and an a.e. constant $C\stackrel{\text{a.e.}}{=}c$. However, $c$ qualifies as a candidate for $E[X]$, but $C$ does not, because it is not $F$-measurable, unless $C\equiv c$. Why do we disqualify a.e. equal random variables from conditional expectation candidates?

More generally,

Why not defining random variables as equivalence classes?

The answer to the linked question is given therein: it has something to do with stochastic processes indexed by uncountable sets.
See also:

*

*Why keeping a disctinction between almost surely equal elements in probability theory?

*Are as constant but not constant random variables trivial sigma-algebra-measurable? Converse?.

