Non-closed compact subspace of a non-hausdorff space I have a topology question which is:
Give an example of a topological (non-Hausdorff) space X and a a non-closed compact subspace.
I've been thinking about it for a while but I'm not really getting anywhere. I've also realised that apart from metric spaces I don't really have a large pool of topological spaces to think about (and a metric sapce won't do here-because then it would be hausdorff and any compact set of a metric space is closed)
Is there certain topological spaces that I should know about (i.e. some standard and non-standard examples?)
Thanks very much for any help 
 A: Any topology with finitely many open sets must have the property that all sets are compact, simply because any open cover is already finite.
Here is a much less trivial example:
Let $(\mathbb R,\tau)$ be the real numbers with the co-finite topology, namely a set is closed if and only if it is finite; and a set is open if and only if its complement is finite.
Consider the natural numbers as a subset of the real line, this is an infinite set, but it is clearly not co-finite so it is neither open nor closed. Suppose that $\{U_i\mid i\in I\}$ is an open cover of $\mathbb N$. There is some $i_0\in I$ such that $0\in U_{i_0}$, and since $U_{i_0}$ is open it means that it contains everything except finitely many points, in particular it must contain all the natural numbers, except maybe finitely many of them. For every $n\in\mathbb N\setminus U_i$ we can find some $U_{i_n}$. We found, therefore, a finite subcover of this open cover, and so $\mathbb N$ is compact.
Exercise: Prove that in fact every set of real numbers is compact in this topology.
A: Here are some examples that work nicely.


*

*The indiscrete topology on any set with more than one point: every non-empty, proper subset is compact but not closed. (The indiscrete topology isn’t good for much, but as Qiaochu said in the comments, it’s a nice, simply example when it actually works.)

*In the line with two origins, the set $[-1,0)\cup\{a\}\cup(0,1]$ is compact but not closed: $b$ is in its closure.

*The set $\{1\}$ in the Sierpiński space is compact but not closed.

*For each $n\in\Bbb N$ let $V_n=\{k\in\Bbb N:k<n\}$; then $\{V_n:n\in\Bbb N\}\cup\{\Bbb N\}$ is a topology on $\Bbb N$, in which every non-empty finite set is compact by not closed.

*Let $\tau$ be the cofinite topology on an infinite set $X$. Then every subset of $X$ is compact, but the only closed subsets are $X$ and the finite subsets of $X$.
In terms of the common separation axioms: (1) is not even $T_0$; (2) and (5) are $T_1$; and (3) and (4) are $T_0$ but not $T_1$.
A: Since Qiaochu's example is almost too trivial to give much intuition, here is another good example to think about.
Take the real line minus the origin. Now take a disjoint union with 2 points and declare the neighborhoods of both points to be exactly the neighborhoods of the origin. This topological space should be thought of as "the real line with 2 origins". It is definitely not Hausdorff.
Now take $x \in \mathbb{R} - \{0\}$ and consider the subspace $[-x, 0) \cup (0, x] \cup *$, where $*$ is one of the origins.
This is a compact subspace because it is basically the space $[-x,x] \subseteq \mathbb{R}$, but it isn't closed (the other origin is isolated in the complement).
A: As Qiaochu points out, the easiest example is to take the indiscrete topology on any set with at least two elements. Any indiscrete space is automatically compact, and any subspace of an indiscrete space is again indiscrete.
Of course, in some sense indiscrete spaces are too trivial. So here is a large family of $T_0$ (indeed, sober) examples. Let $A$ be a commutative ring. The prime spectrum of $A$ is the topological space $\operatorname{Spec} A$ whose points are the prime ideals of $A$, and the open subsets of $\operatorname{Spec} A$ are those of the form
$$D(I) = \{ \mathfrak{p} \in \operatorname{Spec} A : I \nsubseteq \mathfrak{p} \}$$
where $I$ is any ideal of $A$. It can be shown that any open subset of the form $D((f))$ for any element $f$ in $A$ is compact, and in general $D((f))$ will also be non-closed. For example, for $A = \mathbb{Z}$, the prime spectrum consists of the points
$$\{ (p) : p \text{ is a prime number} \} \cup \{ (0) \}$$
and the non-empty open subsets are those that contain all but finitely many of the ideals $(p)$. This is very nearly the cofinite topology, but $(0)$ is not a closed point in $\operatorname{Spec} \mathbb{Z}$. It is straightforward to verify that all the non-empty open subsets of $\operatorname{Spec} \mathbb{Z}$ are compact and dense.
We can even find $T_1$ examples: as hinted above, any infinite set with the cofinite topology will have the property that all its non-empty open subsets are compact and dense. Another source of $T_1$ examples is classical algebraic geometry: if $k$ is any algebraically closed field, then $\mathbb{A}^n (k)$ is the topological space whose points are $n$-tuples of elements of $k$, and the open subsets of $\mathbb{A}^n (k)$ are those of the form
$$D(I) = \{ (a_1, \ldots, a_n) \in \mathbb{A}^n (k) : \forall f \in I . f (a_1, \ldots, a_n) \ne 0 \}$$
where $I$ is any ideal of the polynomial ring $k[x_1, \ldots, x_n]$. Again, it can be shown that any non-empty open subset of the form $D((f))$ for any polynomial $f$ is compact and dense in $\mathbb{A}^n (k)$.
A: There is a meta-example: given a compact space (or any space at all, actually) $X$, we can find an embedding $X\subsetneq X'$ such that $X$ is open dense in $X'$, and if $X$ is $T_1$ and has at least two points, we can choose $X'$ as such.
This is rather simple: just take a point $y\notin X$ and let $X'=X\cup \{y\}$ with topology given by the union of the toplogy on $X$ and the entirety of $X'$, so that points of $X$ have the same neighbourhoods as in $X$, in addition to $X'$, while $y$ has only one neighbourhood which is $X'$.
The previous example is not $T_1$, but it can easily be augmented to such if $X$ is $T_1$ and has at least two points: just add to the topology on $X'$ for any open $A\subseteq X$ the set $A'=A\cup \{y\}$. Then clearly the witnesses for $T_1$-ness of $X$ will provide witnesses for $T_1$-ness of $X'$.
