I saw the following question:
Denote $\overline{\mathbb{R}}=\mathbb{R}\cup\{\pm\infty\}$, the open sets containing $x\in\mathbb{R}$ are the open sets in $\mathbb{R}$ containing $x$. The open sets containing $\pm\infty$ are the sets of the form $V\cup\{\infty\}$ or $V\cup\{-\infty\}$ accordingly.
Let $(X,S)$ be a measurable space. Prove that $f:\, X\to\overline{\mathbb{R}}$ is measurable iff the following conditions hold:
$f^{-1}(\{\infty\}),f^{-1}(\{-\infty\})\in S$
$f$ is measurable as a function $f^{-1}(\mathbb{R})\to\mathbb{R}$
My work:
I started with assuming that both conditions hold and I took some $B\in\mathcal{B}(\overline{\mathbb{R}})$ and I wanted to prove that $f^{-1}(B)\in S$, but the problem I have here that I don't really understand how those sets $B\in\mathcal{B}(\overline{\mathbb{R}})$ look like.
So I thought that if I will understand what $S'$ generates $\mathcal{B}(\overline{\mathbb{R}})$ I could use that. I know that the open rays of the form $(-\infty,a)$ or $(a,\infty)$ generate $\mathcal{B}(\mathbb{R})$, and it seems that the sets of the form $(-\infty,a)\cup\{\infty\}$ plus the sets of the form $(a,\infty)\cup\{\infty\}$.
Since $f^{-1}((-\infty,a)\cup\{\infty\})=f^{-1}((-\infty,a))\cup f^{-1}(\{\infty\})$ and I know that $f^{-1}(\{\infty\})\in S$ and since its a $\sigma-$algebra I need to prove that $f^{-1}((-\infty,a))\in S$.
I'm guessing this follows from the second condition somehow, but I don't understand how being measurable in $\mathcal{B}(\overline{\mathbb{R}})$ have anything to do with being in $S$ which is a collection of subsets of some space $X$.
Can someone please help me with this question ? am I even on the right track ?