Show a function is continuous if and only if it is both upper and lower semi-continuous 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.
 A: What you want is use the $\varepsilon$-$\delta$ definition of continuity/semi-continuity 
$$
\forall \varepsilon > 0, \quad \exists \delta > 0 \quad \text{s.t.} \quad |x-x_0| < \delta \quad \Longleftrightarrow \quad |f(x) - f(x_0)| < \varepsilon.
$$
Since $|f(x) - f(x_0)| < \varepsilon$ is equivalent to $f(x_0) - \varepsilon < f(x) < f(x_0) + \varepsilon$, this statement is equivalent to
$$
\forall \varepsilon > 0, \quad \exists \delta > 0 \quad \text{s.t.} \quad |x-x_0| < \delta \quad \Longleftrightarrow \quad f(x_0) - \varepsilon < f(x) < f(x_0) + \varepsilon
$$
which means continuity is equivalent to upper and lower semi-continuity.
ADDED : I'll assume the definition of semi-continuity is the following, i.e. that the preimage of an open set of the form $\{ y \, | \, y > a \}$ is open for any upper semi-continuous function, and that the preimage of an open set of the form $\{ y \, | \, y < a \}$ is open for any lower semi-continuous function. If this is not the definition you have, let me know. I'm just guessing those definitions from the $\varepsilon$-$\delta$ definitions of continuity.
We show that continuity $\Longleftrightarrow$ upper and lower semi-continuity.
$(\Longrightarrow)$ This one is clear, since if the pre-image of any open set is open, then in particular are the pre-images of those of the form $(a, \infty)$ and $(-\infty,a)$.
$(\Longleftarrow)$ If $f^{-1}((a,\infty))$ and $f^{-1}((-\infty,b))$ are open sets, then since $f^{-1}((a,b)) = f^{-1}((a,\infty)) \cap f^{-1}((-\infty,b))$ and that the intersection of two open sets is open, then $f^{-1}((a,b))$ is open. Now any open set $\mathcal O$ in $\mathbb R$ is of the form 
$$
\bigcup_{n=0}^{\infty} (a_n, b_n)
$$ 
where all the intervals $(a_n,b_n)$ are pairwise disjoint and $a_n \in \mathbb R \cup \{-\infty\}$, $b_n \in \mathbb R \cup \{\infty\}$. But 
$$
f^{-1} \left( \bigcup_{i \in I} \mathcal O_i\right) = \bigcup_{i \in I} f^{-1} (\mathcal O_i)
$$
for any collection of sets indexed by any set $I$ (prove this trivially by the definition of pre-images and show $\subseteq$/$\supseteq$), thus, 
$$
f^{-1}(\mathcal O) = \bigcup_{n=0}^{\infty} f^{-1}((a_n,b_n))
$$
which is an open set.
Hope that helps,
