Let $f$ be a real-valued function on $\mathbb{R}$. Show $f$ is continuous if and only if $f$ is both upper and lower semi-continuous, using the definition of continuity and semi-continuity based on open set.
It's difficult for me to be rigourous here. For example for necessity. Let $O=\{f(x) : f(x) > a, x \in \mathbb{R}\}$ with $a$ real. By continuity, if $O$ is open then the pre-image of $O$ is open whence $f$ is lower semi-continuous. Is $O$ open? If so why? This point blocks me.
I think I can do sufficiency correctly though. Suppose $f$ is both upper and lower semi-continuous. Let $O$ be an open set. Since any open set in $\mathbb{R}$ can be expressed as a union of open sets of the form $(a,b)$, then $O=\cup (a_n,b_n)$ for some open sets $(a_n,b_n)$. Since each $(a_n,b_n)$ can be written has $(a_n,\infty) \cap (-\infty,b_n)$, by semi-continuity, the pre-image of each $(a_n,b_n)$ is open. Since $f^{-1}(O)=f^{-1}(\cup(a_n,b_n))=\cup f^{-1}(a_n,b_n)$, then the pre-image of $O$ is open anf $f$ is continuous.
Definition: A function is continuous if and only if the pre-image of any open set is open. A function is lower semi-continuous if and only if the set $\{x \in \mathbb{R} : f(x) > a\}$ is open for any $a$ real. A function is upper semi-continuous if and only if the set $\{x \in \mathbb{R} : f(x) < a\}$ is open for any $a$ real.