Any example for a function having domain and range as subset of real line that is NOT Borel function?

Suppose there is a function $f:A\to B$ where $A,\,B\subseteq\mathbb{R}$, is there any example for this function being NOT Borel function?

Well the question came up to be when I was reading the probability theory and it states that the two random variable is independent if and only if $\mathbb{E}[f(X)g(Y)] = \mathbb{E}[f(X)]\,\mathbb{E}[g(Y)]$ for any $f,\,g$ being Borel function. This is not hard to proof but I cannot think of any function that is not Borel when the function takes real value and also provides real value. Any comment is extremely welcomed :)

• This may be of interest. – David Mitra Apr 30 '13 at 20:35

There are only $\mathfrak c$ Borel functions whose domain and range are contained in $\mathbb R$ (because Borel functions have Borel graphs, and there are only $\mathfrak c$ Borel subsets of $\mathbb R^2$). List them as $(f_\alpha\mid \alpha<\mathfrak c)$, list $\mathbb R$ as $(x_\alpha\mid\alpha<\mathfrak c)$, and, for each $\alpha<\mathfrak c$, define $f(x_\alpha)=0$ or $1$, whichever is different from $f_\alpha(x_\alpha)$ (including the possibility that $x_\alpha$ is not in the domain of $f_\alpha$). In this example, $f$ only takes the values $0$ and $1$, so it is the characteristic function of a (necessarily, non-Borel) set.
We can also produce an injective example, by letting $f(x_\alpha)=x_\beta$, where $\beta$ is least such that $x_\beta\notin\{f_\alpha(x_\alpha)\}\cup\{f(x_\tau)\mid \tau<\alpha\}$. Since at each stage only fewer than $\mathfrak c$ values have been excluded, $x_\beta$ is defined.
• For the fact that there are only $\mathfrak c$ Borel sets: math.stackexchange.com/q/70880/462. The fact that Borel functions have Borel graphs is due to Sierpiński, see for example page 124 of A second course on real functions, by A.C.M. van Rooij and W.H. Schikhof, books.google.com/… – Andrés E. Caicedo Apr 30 '13 at 22:58