Monotone Real Function with Everywhere Dense Image is Continuous

Theorem
Let $I$ and $J$ be real intervals.

Let $f: I \to J$ be a monotone real function.

Let $f \left[{ I }\right]$ be everywhere dense in $J$, where $f \left[{ I }\right]$ denotes the image of $I$ under $f$.

Then $f$ is continuous on $I$.

Proof
Suppose $f$ is increasing.

Suppose $f$ is discontinuous at $c \in I$.

Let $L^{-}$, $L$, and $L^{+}$ denote $\displaystyle \lim_{ x \to c^{-} } f \left({ x }\right)$, $f \left({ c }\right)$, and $\displaystyle \lim_{ x \to c^{+} } f \left({ x }\right)$, respectively.

From Discontinuity of Monotonic Function is Jump Discontinuity, $L^{-}$ and $L^{+}$ are finite.

Since $f$ is increasing:
 * $ L^{-} \leq L \leq L^{+}$

Let $S = \left({ L^{-}, \,.\,.\, L^{+} }\right)$

If $ L^{-} = L = L^{+}$, then $c$ is not a discontinuity, a contradiction.

Thus $S$ is non-degenerate.

From Non-Degenerate Real Interval is Infinite, $S$ is infinite.

From Relative Difference between Infinite Set and Finite Set is Infinite, $S \setminus \left\{ { L } \right\}$ is non-empty.

From Finite Subset of Metric Space is Closed, $\left\{ { L } \right\}$ is closed.

From Open Set minus Closed Set is Open, $S \setminus \left\{ { L } \right\}$ is open.

Lemma
From the Lemma:
 * $ S \cup f \left[{ I }\right] \subseteq \left\{ { L } \right\}$

Thus:

Thus, there exists a non-empty  open  subset of $f \left[{ I }\right]$ that is  disjoint from $Y$.

From Open Set Characterization of Denseness, $f \left[{ I }\right]$ is not everywhere dense in $J$.

This contradicts the hypothesis that $f \left[{ I }\right]$ is everywhere dense in $J$.

Therefore $I$ contains no discontinuities, by Proof by Contradiction.

The same argument, mutatis mutandis, proves the case where $f$ is  decreasing

Hence the result, by Proof by Cases.