Show that function $f$ has a continuous extension to $[a,b]$ iff $f$ is uniformly continuous on $(a,b)$ Let $E \subset F \subset X$ and $f:E\rightarrow Y$. We say that the function $g:F\rightarrow Y$ is an extension of $f$ if $g(x) = f(x)$ for all $x \in E$. 
Let $f: (a, b) \rightarrow \mathbb{R}$. Show that $f$ has a continuous extension to $[a, b]$ if and only if $f$ is uniformly continuous on $(a, b)$. 
$(X,d)$ is a metric space.
Hint: To prove $\Leftarrow$ start by showing that $f$ maps Cauchy sequences to Cauchy sequences. Then how should you define $g(a)$ and $g(b)$?
The $\Rightarrow$ part of the proof was quite simple, but even with the hint, the other way seems a bit difficult. Doesn't the first part of the "hint" follow from the way we defined $f$? If so, how do I prove this? Help/Hints appreciated!

Much more is true: if $D$ is a dense subset of a metric space $X$, $Y$ is a complete metric space and $f\colon D\to Y$ is uniformly continuous, then $f$ admits a (unique) extension to a (uniformly) continuous map $\hat{f}\colon X\to Y$.
This is a key result in the theory of metric spaces, which has several applications. For example, a continuous linear map from a dense subspace of a Banach space $X$ to a Banach space $Y$ can be extended to a continuous linear map from $X$ to $Y$; so, for instance, one can define an element of the topological dual of $X$ by just defining it on a dense subspace.
The proof consists, as in Brian M. Scott's answer, in noting that if $f\colon D\to Y$ is uniformly continuous, then it maps Cauchy sequences to Cauchy sequences. So the extension is naturally defined and all it's needed is to show that the extension is continuous.
So these are the steps:


*

*If $x\in X$, there is a sequence $(x_n)$ in $D$ converging to $x$; then $(f(x_n))$ is a Cauchy sequence in $Y$ and so it converges to some point $y$.

*If $(x'_n)$ is another sequence in $D$ converging to $x$, then both $(f(x_n))$ and $(f(x'_n))$ converge to $y$.

*We can define $\hat{f}(x)=y$ because of the preceding results.

*If $x\in D$, then $\hat{f}(x)=f(x)$, by considering the constant sequence.

*$\hat{f}$ is continuous at $x$.
Uniqueness is obvious, because two extensions must coincide on a dense subset. Uniform continuity of $\hat{f}$ is also easy to show.
