I want to know if my proof of a compact subset $A$ in a metric space being closed is correct please. Especially one step.
My idea was to assume that $A$ is open and to consider the following open cover of $A$
$$ \bigcup_{x\in A} B\left(x,\frac{1}{n_x}\right) $$
Where $B(x,r)$ is the open ball centered in $x$ with radius $r$ and $n_x$ is the least integer such that $B(x,\frac{1}{n_x})\subset A$.
Then, since $A$ is compact, there exists $ 1,…,N$ such that
$$ A\subseteq\bigcup_{i=1}^{N}B\left(x_{i},\frac{1}{n_{x_{i}}}\right) $$
But $\bigcup_{i=1}^{N}B\left(x_{i},\frac{1}{n_{x_{i}}}\right)\subset A$, hence a contradiction.
I would like to know if my conclusion is not rushed. I do not see any problem so far but I have not seen this proof in my book thus I have some doubts.
Thank you a lot !
This proof is not correct for a few reasons, as pointed out in the comments, but there is a proof which uses a sort of similar approach:
Assume $A$ is not closed. Then there is some boundary point of $A$, $x_0$ which is not in $A$.
Then define the open cover for $A$
$$G= \left( B\left(x,\frac{d(x,x_0)}{2}\right)\right)_{x\in A} $$
And then by compactness, there is a finite subset of $A$,
$$ A' = \{x_1,...,x_n\}$$
Such that $$G' = \left( B\left(x,\frac{d(x,x_0)}{2}\right)\right)_{x\in A'} $$
Still covers $A$. However, if we let $x_1$ be the closest point to $x_0$, then there is some point $y$ in $A$ satisfying
$$ d(x_0,y) < \frac{d(x_0,x_1)}{2} $$
Which is then not covered by $G'$, a contradiction. (You should fill in the details for this step)