# Proving compactness for the graph of a continuous function from a compact metric space to a metric space

I have the following problem: Let $X$ be a compact metric space, $Y$ any metric space, and suppose $f: X \rightarrow Y$ is continuous. Let $G \subset X \times Y, G = \{(x,f(x)) : x \in X\}$. If $G$ is compact, prove it. Otherwise show why $G$ is not compact.

This is what I have so far: We know that the continuous image of a compact metric space is compact, so therefore $f(X) \in Y$ is compact. Also note that because of the way $G$ is defined, $G \subset X \times f(X)$. Given a sequence $\{(x_n,f(x_n))\} \in G$, by the compactness of $X$ and $f(X)$, we know that any sequences $\{x_n\}$ and $\{f(x_n)\}$ will have convergent subsequences, so therefore $\{(x_n,f(x_n))\}$ will have a convergent subsequence.

Does this logic actually work? The main thing I'm iffy on is if the sequence would be defined as $\{(x_n,f(x_n))\}$, or if it would be something like $\{(x_n,f(x_k))\}$ instead. Also, I was initially planning on showing that $G$ was closed, because I know that the closed subset of a compact set is compact, but this method seemed slightly less cumbersome.

If you take that approach, you need to work a little harder to get the convergent sequence. First, $\langle x_n:n\in\Bbb N\rangle$ is a sequence in the compact space $X$, so it has a convergent subsequence $\langle x_{n_k}:k\in\Bbb N\rangle$. Then the sequence $\langle f(x_{n_k}):k\in\Bbb N\rangle$ in the compact space $f[X]$ has a convergent subsequence $\langle f(x_{n_{k_\ell}}):\ell\in\Bbb N\rangle$, so the sequence $\big\langle\langle x_{n_{k_\ell}},f(x_{n_{k_\ell}})\rangle:\ell\in\Bbb N\big\rangle$ converges in $X\times f[X]$. However, you’re not done at this point: you still have to show that the limit is in $G$. That’s where you’ll need the continuity of $f$, which you might note that you haven’t used yet.
Your initial idea is a bit easier, and the one that I would have used. It’s a standard result (and not hard to prove) that if $f:X\to Y$ is continuous, and $Y$ is Hausdorff, then the graph of $f$ is closed in $X\times Y$. If you’ve not seen the result and get stuck proving it, you’ll find a proof here.
Hint: $G$ is a continuous image of $X$ (with respect to any of the usual metrics you might put on $G \subseteq X \times Y$).
• Wait, is that all I have to do? State that $G$ is a continuous image of $X$ and then I'm done? – Student Sep 22 '15 at 23:14
• Well you need to know what the continuous mapping from $X$ to $G$ is, know what metric on $X \times Y$ you are using and know why the mapping is continuous. But, yes, then you're done. – Rob Arthan Sep 22 '15 at 23:24
• Your argument isn't quite detailed enough. To do it your way, you'd need to pick a convergent subsequence $x_{n_i}$ of the $x_n$ and then pick a convergent subsequence of the $f(x_{n_i})$. (And you'd still need to explain what metric you are using on $X \times Y$.) So your initial plan was better but with "compact" in place of "closed". – Rob Arthan Sep 22 '15 at 23:48
• @John: There is no need to deal with any metric on $X\times Y$. And your initial plan was fine; in fact, it’s what I would have done. All you need is the fact that a continuous function into a Hausdorff space has a closed graph, which is not hard to prove. – Brian M. Scott Sep 22 '15 at 23:52