# If the graph of a function $f: A \rightarrow \mathbb R$ is compact, is $f$ continuous where $A$ is a compact metric space?

I have seen answers to this question, which go beyond my understanding of compactness and continuity. I was wondering whether we can cook up a proof using sequential compactness and certain equivalent definitions of continuity such as the inverse image of any closed set is closed.

Here is what I have been able to conjure up so far.

Assume that the graph of $f$ is compact. This means that it is also closed and bounded. The graph is a closed and bounded subset of $A \times f(A)$. All we need to show is that $f(A)$ is compact, and we are are home free, right? (since continuous functions take compact sets to compact sets).

Question is: how do we show that $f(A)$ using the fact that the graph is compact. Can we claim that $f(A)$ is closed and bounded (since by Heine-Borel, any closed and bounded subset of $\mathbb R$ is compact)?

I feel like I am really close. Can anyone help me out?

-
I'm not convinced that showing $f(A)$ compact will suffice, since we can construct noncontinuous functions that take a particular compact set to a compact set. –  Eric Stucky Nov 7 '12 at 0:30
You have the logic backwards: if $f$ is continuous, then $f[A]$ is compact, but the converse isn’t true in general. –  Brian M. Scott Nov 7 '12 at 0:31
But if I can show that $f(A)$ is compact and A is already given to be compact, can't I conclude that $f$ is continuous? –  user43901 Nov 7 '12 at 1:37

First, to answer the question in your comment, it seems that you claim:

If $A$ is a compact metric space, for all functions $f:A\to\Bbb R$, $f(A)$ compact implies $f$ continuous.

This claim is false. For example, consider $A=[-1,1]$ as a metric subspace of $\Bbb R$ and define $f:A\to\Bbb R$ by $$f(x)=\begin{cases} 1&\text{if } x\gt 0\\ -1&\text{otherwise}\end{cases}.$$ Thus $f(A)$ is the compact set $\{-1,1\}$ but $f$ is not continuous.

Second, I'll give a proof using sequential compactness, something equivalent to continuity, namely sequential continuity, something else.

Proof.

Assume then that $(A,d)$ is a compact metric space, and $f:A\to\Bbb R$ is a function such that $$G=\{(x,f(x)):x\in A\}$$ is compact in $(A\times\Bbb R,D)$ where $D$ is the usual product metric (one of the usual metrics) given by $$D((u,x),(v,y))=d(u,v)+|y-x|.$$

Since we are dealing with metric spaces, it is enough to show that $f$ is sequentially continuous.

Then, consider a sequence $(x_n)$ in $A$ with $$\lim_{n\to\infty} x_n=x\in A.$$

We must show that $$\lim_{n\to\infty} f(x_n)=f(x).$$

As says the "abstract thing" stated here, it is enough to show that every subsequence $(f(x_{n_k}))_{k\in\Bbb N}$ has a subsequence $(f(x_{n_{k_j}}))_{j\in\Bbb N}$ converging to $f(x)$.

So, consider $(f(x_{n_k}))_{k\in\Bbb N}$ a subsequence of $(f(x_n))_{n\in\Bbb N}$. We will prove that this subsequence has a subsequence converging to $f(x)$.

Since $G$ is a compact metric space, $G$ is sequentially compact, thus, the sequence $((x_{n_k},f(x_{n_k})))_{k\in\Bbb N}$ in $G$ must have a convergent subsequence, say $((x_{n_{k_j}},f(x_{n_{k_j}})))$ with $$\lim_{j\to\infty} (x_{n_{k_j}},f(x_{n_{k_j}}))=(y,f(y))\in G.$$

Notice that for each $j\in\Bbb N$ we have $$D((x_{n_{k_j}},f(x_{n_{k_j}})),(y,f(y)))\geq d(x_{n_{k_j}},y)\geq 0,$$ so $$\lim_{j\to\infty} d(x_{n_{k_j}},y)=0$$ i.e. $$\lim_{j\to\infty} x_{n_{k_j}}=y.\tag{1}$$ By similar arguments it follows that $$\lim_{j\to\infty} f\left(x_{n_{k_j}}\right)=f(y).\tag{2}$$ Since convergent sequences can have at most one limit, $(1)$ says $$x=y,$$ therefore by $(2)$ $$\lim_{j\to\infty} f\left(x_{n_{k_j}}\right)=f(x)$$ as we wanted.

-

Suppose that $f$ is not continuous. Then there are a point $x\in A$ and a sequence $\langle x_n:n\in\Bbb N\rangle$ in $A$ converging to $x$ such that $\langle f(x_n):n\in\Bbb N\rangle$ does not converge to $f(x)$. Let $G$ be the graph of $f$. Then $\big\langle\langle x_n,f(x_n)\rangle:n\in\Bbb N\big\rangle$ is a sequence in the compact metric space $G$, so it has a convergent subsequence $\big\langle\langle x_{n_k},f(x_{n_k})\rangle:k\in\Bbb N\big\rangle$.

1. Show that the limit of this subsequence must be of the form $\langle x,\alpha\rangle$ for some $\alpha\in\Bbb R$. (Recall that $x$ is the limit of $\langle x_n:n\in\Bbb N\rangle$.)

2. Show that $\alpha\ne f(x)$. Conclude that $\langle x,\alpha\rangle\notin G$.

This contradicts the compactness of $G$; how?

-
can we not go for a more direct route? Since G is compact, then for every sequence $(x_n,f(x_n))$ there exists a subsequence $(x_{n_k},f(x_{n_k}))$ that converges to the ordered pair say $(x, y) \in A\times f(A)$. $(x_{n_k},f(x_{n_k})$ converges iff each of the component sequences converges in $A$ and $f(A)$ respectively. $(x_{n_k}) \rightarrow x$ and $(f(x_{n_k}))\rightarrow f(x)=y$ Thus, any convergent sequence in $A$ is mapped to a convergent sequence in $f(A)$, limits being mapped to limits under $f$. Hence, $f$ is continuous. –  user43901 Nov 8 '12 at 21:11
@user43901: You argument is circular: when you say that the $f(x_{n_k})$ converge to $f(x)$, you’re already assuming that $f$ is continuous. –  Brian M. Scott Nov 8 '12 at 21:15
A function is continuous iff it sends every convergent sequence in the domain to a convergent sequence in the range, limits being sent to limits. The sequence in G by definition is the ordered pair (a, f(a)); hence, how is it circular? If a_n converges to a, then can I not claim the argument? On a related note, if I can show that each of A and f(A) is compact, then using the fact that continuous functions map compact sets to compact sets, I can claim that since f(A) is the map under f, f is continuous, right? –  user43901 Nov 9 '12 at 2:13
@user43901: No, of course you can’t assume that the $f(X_{n_k})$ converge to $f(x)$: that’s what you’re trying to prove! The answer to your second question is also no, as I pointed out in the comments under your original post. Continuous functions preserve compactness, but functions that preserve compactness are not necessarily continuous. Look at the function $f:\Bbb R\to\Bbb R$ defined by $f(x)=1$ if $x\ge 0$ and $f(x)=0$ if $x<0$. –  Brian M. Scott Nov 9 '12 at 14:49
I think I understand, but the example you gave: is both the domain and range compact? What I am trying to argue is, if both the domain and the image of f is compact, then f must be continuous. –  user43901 Nov 9 '12 at 15:34