Proof verification: A compact metric space must be closed. I am learning real analysis on metric space, and I find that all texts in my hand prove the fact "A compact subspace $K$ of metric space $X$ is closed" in an indirect way, mostly with resort to some equivalences of compactness, such as Bolzano-Weierstrass theorem of metric space, or even the totally bounded condition. It seemed to me there is a more direct proof using only the definition of compactness. But after I reread it, I became less sure if it is right. So I write it down here. I would be more than grateful if anyone could verify it for me.
Proof:
Assume $K$ is not closed. Then there is some point $x \notin K$ with $B(x, n^{-1}) \cap K \neq \emptyset$ for all $n \in \mathbb N$. There must be some $n_0$ with $K\setminus \bar B(x, n_0^{-1}) \neq \emptyset$, since if not, $K \subset \bar B(x,n^{-1})$ for all $n$, which follows $K = \{x\}$, contradicting $x \notin K$. Without a loss of generality one can assume $n_0 = 1$.
Fix an $n$. For each $y \in K \setminus \bar B(x, n^{-1})$, choose $r_y > 0$ with $B(y, r_y) \cap \bar B(x,n^{-1}) = \emptyset$. Let $$G_n = \bigcup_{y \in K \setminus \bar B(x, n^{-1})} B(y, r_y)$$
which is open and does not intersect with $\bar B(x, n^{-1})$. Moreover, for each point $z \in K$, there is some $n_z$ such that $z \notin \bar B(x, n_z^{-1})$, that is, $z \in G_{n_z}$. Hence, $\mathcal G = \{G_n\}$ is an open cover of $K$. But any finite subset $\mathcal H$ of $\mathcal G$ does not cover $K$, because $\bar B(x,n_{\mathcal H}^{-1})$ is not covered by any member of $\mathcal H$, where $n_{\mathcal H} = \{\max n: G_n \in \mathcal H\}$. In other words, $K$ is not compact.
edit: I agree with Mr. Martin R's comment that this proof is nothing but a twisted version of this answer. I did not realize that $G_n$ is essentially the same as $K \setminus \bar B(x, n^{-1})$, and I also abused some notations.
 A: I think it’s too complicated as you wrote and I’m not so sure it’s correct.
I suggest this other version, if you are interested in :).
Any compact subspace  $K$ of an Hausdorff space $X$ is closed.
Take a point $x$ in the closure of $K$. Suppose by contradiction that $x\not \in K$. Then for any $y\in K$ let $U_{y}$ and $V_{y}$ two open neighbourhoods of $x$ and $y$ respectively such that $U_y\cap V_y$ is empty. Observe that $\{V_y\cap K\}_y$ is an open cover of $K$, so that it admits a finite open subcover $\{V_{y_1}\cap K, \cdots, V_{y_s}\cap K\}$. Then $U:= \cap_{i=1}^sU_{y_i}$ cannot intersect $K$ and it’s an open neighbourhood of $x$. This contradicts the fact that $x$ is in the clousure of $K$.
Thus $x\in K$ and so $K$ is a closed set.
Sometimes the key of a proof is to subtract structure of your objects, in order to leave only the properties that you need to prove the statement. In this case, for example, you can talk just about an Hausdorff space instead of a metric one.
A: As any metric space is necessarily Hausdorff, one could argue that any compact subset of a Hausdorff space need be closed.
Let $X$ be a Hausdorff space, and let $Y \subset X$ be compact subspace. We show $X \setminus Y$ is open forcing $Y \subset X$ to be closed.
Then let $x \in X \setminus Y$, then for each $y \in Y$ by the Hausdorff property one can find disjoint open sets in $X$, call them $U_y,V_y$ with
$$U_y \ni x, V_y \ni y.$$
Then clearly $\{V_y\}_{y \in Y}$ is an open cover for $Y$ so there exists a finite subset (by compactness of $Y$) $A \subset Y$ such that
$$Y \subset \bigcup_{y \in A} V_y:=V$$
Then take the open set for $x$ to be
$$x \in \bigcap_{y \in A} U_y:=U$$
Then clearly
$$U \cap Y = \emptyset$$
as $U \cap V = \emptyset$. And we have thus found a neighborhood of $x$ disjoint from $Y$ thus $X \setminus Y$ is open forcing $Y$ to  be closed, as needed.
