In the Euclidean spaces compact sets are always closed.
This is not true for general topological spaces. Can we characterise when it is possible?
Is it true for metric spaces?
In the Euclidean spaces compact sets are always closed.
This is not true for general topological spaces. Can we characterise when it is possible?
Is it true for metric spaces?
As mentioned by John in the comments, in Hausdorff (T2) spaces, compact subsets are always closed.
Suppose $X$ is Hausdorff, and $K \subseteq X$ is compact. To show that $K$ is closed, it suffices to show that $X \setminus K$ is open; that is, show that each $x \in X \setminus K$ has an open neighbourhood $U$ with $U \subseteq X \setminus K$. So given $x \in X \setminus K$, by Hausdorffness for each $y \in K$ there are disjoint open neighbbourhoods $U_y , V_y$ of $x,y$, respectively. Clearly $\{ V_y : y \in K \}$ is an open cover of $K$, and so there are finitely many $y_1 , \ldots , y_n \in K$ such that $K \subseteq V_{y_1} \cup \cdots \cup V{y_n}$. It is not too difficult to show that $U = U_{y_1} \cap \cdots \cap U_{y_n}$ has the desired property.
As metric spaces are Hausdorff, it follows that compact subsets of metric spaces are closed.
A space in which every compact subset is closed is called a KC space. It is easy to show that every KC space is T1 (since finite subsets are always compact, in a KC space all finite subsets are closed which is equivalent to being T1). So we have implications $$\text{T}_2 \Longrightarrow \text{KC} \Longrightarrow \text{T}_1.$$ However neither of these arrows reverse.
Example 1. Let $X$ be an uncountable set with the co-countable topology (i.e., the open sets are $\varnothing$ and all $A \subseteq X$ such that $X \setminus A$ is countable). Since every two nonempty open sets have nonempty intersection, it follows that $X$ is not T2. Note that $X$ is clearly T1. Suppose that $A \subseteq X$ is infinite. Taking a countably infinite subset $A_0 = \{ a_i : i \in \mathbb{N} \} \subseteq A$, note that for each $n$ the set $U_n = X \setminus \{ a_i : i \neq n \}$ is open. Clearly $A \subseteq \bigcup_{n=1}^\infty U_n$, however as $U_n \cap A_0 = \{ a_n \}$ for each $n$ it follows that no finite subcollection (in fact, no proper subcollection) of the $U_n$ covers $A$. Thus the only compact subsets are the finite subsets, which are closed. Therefore, $X$ is a KC space.
Example 2. Let $X$ be an infinite set with the co-finite topology (i.e., the open sets are $\varnothing$ and all $A \subseteq X$ such that $X \setminus A$ is finite). Since every finite subset is closed, it follows that $X$ is T1. However every subset of $X$ is compact: given any nonempty family $\mathcal{U}$ of nonempty open subsets of $X$, picking $U \in \mathcal{U}$ as $X \setminus U$ is finite we need only take finitely many more $V_1 , \ldots , V_n \in \mathcal{U}$ so that $U \cup V_1 \cup \cdots \cup V_n = \bigcup \mathcal{U}$. As any proper infinite subset of $X$ is not closed, $X$ is not a KC space.