Finite union of compact sets is compact

Let $(X,d)$ be a metric space and $Y_1,\ldots,Y_n \subseteq X$ compact subsets. Then I want to show that $Y:=\bigcup_i Y_i$ is compact only using the definition of a compact set.

My attempt: Let $(y_n)$ be a sequence in $Y$. If $\exists 1 \leq i \leq n\; \exists N \in \mathbb N \; \forall j \geq N\; y_j \in Y_i$ then $(y_n)$ has a convergent subsequence because $Y_i$ is compact. Otherwise, $$ \forall 1 \leq i \leq n \; \forall N \in \mathbb N\; \exists j \geq N\; y_j \notin Y_i $$ Assuming for the moment that $n = 2$ and using induction later we have that $$ \forall N \in \mathbb N \; \exists j \geq N \; y_j \in Y_1 \backslash Y_2 $$ With this we can make a subsequence $\bigl(y_{n_j}\bigr)_{j=0}^\infty$ in $Y_1 \backslash Y_2$. This sequence lies in $Y_1$ and thus has a convergent subsequence. This convergent subsequence of the subsequence will then also be a convergence subsequence of the original sequence. Now we may use induction on $n$.


Let $\mathcal{O}$ be an open cover of $Y$. Since $\mathcal{O}$ is an open cover of each $Y_i$, there exists a finite subcover $\mathcal{O}_i \subset \mathcal{O}$ that covers each $Y_i$. Then $\bigcup_{i=1}^n \mathcal{O}_i \subset \mathcal{O}$ is a finite subcover. That's it; no need to deal with sequences.


It looks like your definition of compactness is that every sequence has a convergent subsequence. There is something you need to be cautious about, here: you are using $n$ for two different things! You use it first as the highest index of your $Y_i$s, and then as the index variable of your arbitrary sequence. Instead, let's go with $Y_1,...,Y_k$ as your compact sets.

Now, your proof gets the job done, but your detour into the "all but finitely many $y_n$ lie in some $Y_i$" possibility (how you start your proof) is unnecessary, as is induction. We can get there more simply if we recall that a union of finitely-many finite sets is again a finite set.

For $1\le i\le k,$ let $$\mathcal I_i=\{n\in\Bbb N:y_n\in Y_i\}.$$ (That is, $\mathcal I_i$ is the set of indices of sequence elements lying in $Y_i$.) Since the $y_n$ are all in $Y=\bigcup_{i=1}^kY_i,$ then $\bigcup_{i=1}^k\mathcal I_i=\Bbb N,$ whence at least one of the $\mathcal I_i$ is infinite (by the fact we recalled earlier). Without loss of generality, suppose $\mathcal I_1$ is infinite, so that the points $y_n$ lying in $Y_1$ form a subsequence of $\{y_n\}_{n=0}^\infty.$ Then we can proceed as you did.