$f: X \to \mathbb R$, and $X$ a metric space
Prove that:
$f$ continuous $\iff \forall a \in \mathbb R$: $f^{-1}(]-\infty,a[)$ and $f^{-1} (]a,\infty[)$ are open sets.
My thoughts so far:
"$\Longleftarrow$" Since $f^{-1}(]-\infty,a[)$ and $f^{-1} (]a,\infty[)$ and $]-\infty,a[, ]a,\infty[$ are open sets themselves.
Then $f^{-1}(]-\infty,a[) \cup f^{-1}(]a, \infty[)$ as well as $]-\infty,a[\cup]a, \infty[$ as a union is open. We now know that for set $S \subset \mathbb R$, whereby $S:=\{a\}$ that it is closed (since its complement is open).
And in a previous lesson we proved that if $S$ is a closed set and then prove that $f^{-1}(S)$ is a closed set then f is continuous over $f^{-1}(S)$. Therefore continuous. Is that sufficient?
"$\Longrightarrow$" I'm stumped on this direction.