TITLE: $\{(x,f(x)): x\in E\}$ is compact in $\mathbb R^2 \implies f:E\to\mathbb R$ is continuous
QUESTION [11 upvotes]: Given $f: E\to\mathbb R$, define $G: E\to\mathbb R^2$ by $G(x) = (x,f(x))$ for all $x\in E$. $E$ is a compact subset of $\mathbb R$. The following are equivalent:

$f$ is continuous.
$G$ is continuous.
The graph of $f$ is a compact subset of $\mathbb R^2$.



First, let $E = [a,b]$. I have shown $1\implies 2$ and $2\implies 3$. Proving $3\implies 1$ would help me complete the argument full circle. Please let me know if the following makes sense (point out errors if any), and help me complete the proof.
$[1\implies 2]$: If $x_n\to x$ and $f$ is continuous, then $f(x_n)\to f(x)$, and hence $G(x_n)\to G(x)$ meaning $G$ is continuous. Does this need more argument?
$[2\implies 3]:$ The continuous image of a compact set is compact. Hence, $G([a,b])$, i.e. the graph of $f$ is compact in $\mathbb R^2$.

I found the following for $[3\implies 1]$:

Let $G([a,b])$ be compact and $x_n\rightarrow x$ be a convergent sequence in $[a,b]$. We show that $f(x_n)$ converges to $f(x)$. Since the graph is compact, $f(x_n)$ has a convergent subsequence,

Q1. $G([a,b])$ is compact, so $(x_n,f(x_n))$ has a convergent subsequence. How does this tell us that $f(x_n)$ has a convergent subsequence? I feel we need to add some details here.

i.e. $f(x_{n_j})\rightarrow y$. That is $(x_{n_j}, f(x_{n_j}))\rightarrow (x, y)$. The graph is closed. That is, the limit of every convergent sequence in $G([a,b])$ is again in $G([a,b])$. Therefore $(x,y)\in G([a,b])$, i.e. $y=f(x)$. Since this is true for every convergent subsequence, we showed that $f(x)$ is the only limit point of $f(x_n)$, i.e. $f(x_n)$ converges to $f(x)$.

Q2. How is the last sentence concluded? We choose an arbitrary convergent subsequence $f(x_{n_j}) \to y$, and found $y = f(x)$. What now?

My attempt for $[3\implies 1]$:
Suppose $G_f = \{(x,f(x)): x\in [a,b]\}$ is compact in $\mathbb R^2$. Define $\phi_1(x,y) = x, \phi_2(x,y) = y$. Suppose $S\subset\mathbb R$ is an arbitrary closed set in $\mathbb R$. $$f^{-1}(S) = \{x\in [a,b]: f(x) \in S\}$$
We can write $$f^{-1}(S) = \phi_1(G_f \cap \phi_2^{-1}(S))$$
The above expression seems good intuitively but I need help establishing it by showing $\subseteq$ and $\supseteq$ inclusions. Next, $S\subset \mathbb R$ is closed tells us that $\phi_2^{-1}(S) \subset \mathbb R^2$ is closed - since $\phi_1,\phi_2$ are continuous. $G_f \cap \phi_2^{-1}(S)\subset G_f$, and $G_f \cap \phi_2^{-1}(S)$ is closed. So, $G_f \cap \phi_2^{-1}(S)$ is compact. $\phi_1$ is continuous, which means $f^{-1}(S)$ is compact. Hence, $f^{-1}(S)$ is closed. Done!

Please help me fill in the gaps in my attempt, and let me know if you've any other ideas to solve the problem, such as $[3\implies 2]$ and $[2\implies 1]$. I'd also like to understand the proof posted above my attempt. Thank you!

REPLY [2 votes]: I will help you with your attempt for $[3 \implies 1].$ Your proof is quite interesting due to its versatility. You could use it to prove it for most topological spaces (the Hausdorff ones)!
Lemma: $ f^{-1}(S) = \phi_{1}(G_f \ \cap\ \phi_{2}^{-1}(S))$ for all set S.
Let $S$ be a set. We must prove two inclusions $ f^{-1}(S) \subset \phi_{1}(G_f \ \cap\ \phi_{2}^{-1}(S)) $ and $ \phi_{1}(G_f \ \cap\ \phi_{2}^{-1}(S)) \subset f^{-1}(S). $

$ f^{-1}(S) \subset \phi_{1}(G_f \ \cap\ \phi_{2}^{-1}(S)).$

Let $x \in E$ be such that $f(x) \in S,$ i.e., $x\in f^{-1}(S).$ Note that $(x,f(x))$ belongs to $G_f$ and $\phi_{2}(x,f(x))=f(x) \in S$ which yields $(x,f(x)) \in G_f \ \cap\ \phi_2^{-1}(S)$. Consequently, $x \in \phi_1 ( G_f \ \cap\ \phi_2^{-1}(S)).$

$ \phi_{1}(G_f \ \cap\ \phi_{2}^{-1}(S)) \subset f^{-1}(S) $

Let $x \in \phi_{1}(G_f \ \cap\ \phi_{2}^{-1}(S)),$ there must exist an $y \in G_f \ \cap\ \phi_{2}^{-1}(S)$ such that $\phi_1 (y) = x.$ Since $y \in G_f,$ there must exist $x'\in E$ such that $y = (x', f(x'))$ and, due to $y \in G_f \ \cap\ \phi_{2}^{-1}(S)$, $\phi_2(y)=\phi_{2}(x',f(x')) = f(x') \in S$. Hence, $x' \in f^{-1}(S),$ but, since $y = (x', f(x'))$, we have $ x' = \phi_1(x',f(x')) = \phi_1(y) = x $. Hence,  $x \in f^{-1}(S). $
Proposition: $\{(x,f(x)): x\in E\}$ is compact in $\mathbb R^2 \implies f:E\to\mathbb R$ is continuous
Suppose $G_f = \{(x,f(x)): x\in E \}$ is compact. Define $\phi_1(x,y) = x, \phi_2(x,y) = y$ for all $x \in E$ and $y \in \mathbb{R}$. It's enough to show that inverse image (of $f$) of closed set is closed.
Suppose $S\subset\mathbb R$ is an arbitrary closed set in $\mathbb R$. We have that $$f^{-1}(S) = \{x\in E: f(x) \in S\}$$ and we can write $$f^{-1}(S) = \phi_1(G_f \cap \phi_2^{-1}(S)),  $$ due the above lemma.  Now, the continuity of $\phi_2$ implies that $\phi_2^{-1}(S)$ is closed. Since $\phi_2^{-1}(S)$ is closed and intersection of closed set with a compact is compact, $G_f \cap \phi_2^{-1}(S)$ is compact. Since $\phi_1$ is continuous, it maps compact set to compact set, which means $f^{-1}(S)$ is compact. Hence, the inverse image of closed set is always closed, as desired.