Suppose $X$ is a nonempty set and $S$ is the sigma-algebra on $X$ consisting of all subsets of $X$ that are either countable or have a countable complement in $X$. Give a characterization of $S$ measurable real-valued functions on X.
I have been thinking about this problem and reached the conclusion that a function $f:X \rightarrow \mathbb{R}$ is $S$ measurable if and only if $f$ is constant except in a countable number of values. Here is my proof.
$( \rightarrow )$
$\forall a \in \mathbb{R}$ $f^{-1}((a, \infty)) \in S$ this means that $f^{-1}((a, \infty))$ is countable or $f^{-1}((-\infty, a])$ is countable, because
$$f^{-1}((-\infty, a]) = f^{-1}(\mathbb{R} \setminus (a, \infty)) = X \setminus f^{-1}((a, \infty))$$
Now we can consider
$$c = \inf \{a \in \mathbb{R}: f^{-1}((a, \infty)) \quad \text{is countable} \}$$
$$b = \sup \{a \in \mathbb{R}: f^{-1}((-\infty, a]) \quad \text{is countable} \}$$
If the sets of the set of the infimum is not bounded it means that $X$ is countable and theres nothing more to do (likewise for the supremum).
In another case, if $b < c$ then there is a $d \in \mathbb{R}$ such that $b < d < c$. In this case $f^{-1}((d, \infty))$ and $f^{-1}((-\infty ,d))$ are both uncountable, so we conclude that $b = c$. This means that $f$ is equal to $b$ or $c$ except in countable many values.
$(\leftarrow)$
Suppose $z \in \mathbb{R}$ is the constant value of the image of most of the function except in countable many values.
Consider $f^{-1}((a, \infty)$, then if $z \leq a$ we have that $f^{-1}((a, \infty)$ is countable.
On the other hand if $z \gt a$, then the complement of $f^{-1}((a, \infty)$ is countable, because $X \setminus f^{-1}((a, \infty)) = f^{-1}((-\infty, a))$.
Is this correct? Any suggestions?