Compactness of intersection of a compact set and an open set

If $$K \subset E_1 \cup E_2$$, where $$K$$ is compact and $$E_1, E_2$$ are disjoint open subsets of a topological space, is $$K \cap E_1$$ compact? Is that always the case if $$E_1, E_2$$ are not disjoint?

I've seen other threads that have this, so I was wondering why the solution I thought of is incorrect:

Let $$U_{\alpha}$$ be an open covering of $$K$$. Then because $$K$$ is compact, there is a finite subcovering $$U_1, U_2, \ldots, U_N \in U_{\alpha}$$ that cover $$K$$. But then $$U_1, \ldots, U_N, E_1$$ is a finite collection of open sets that covers $$K$$ and $$E_1$$, so it covers $$K \cap E_1$$, and so $$K \cap E_1$$ must be compact.

• If $E_1$ and $E_2$ are not disjoint, you might as well take $E_2=X$ (the whole space); so you're just asking, if $K$ is compact and $E_1$ is open, is $K\cap E_1$ compact? – bof Nov 14 '18 at 8:05
• If $E_1,E_2$ don't have to be disjoint, here is a counterexample: $K=[0,1]$, $E_1=(0,1)$, $E_2=\mathbb R$. $E_1$ and $E_2$ are open subsets of the space $\mathbb R$, $K$ is a compact subset of $E_1\cup E_2$, but $K\cap E_1=E_1$ is not compact. – bof Nov 14 '18 at 8:08
• If your argument were correct (which it is not), it would prove that any subset of a compact set is compact. – bof Nov 14 '18 at 8:09
• Yes, I realize the conclusion of this "proof" is incorrect, but I was wondering where the flaw was that led to this false conclusion. – user386867 Nov 14 '18 at 8:10
• To prove that $K\cap E_1$ is compact, you have to show that any open cover of $K\cap E_1$ has a finite subcover. Proving that an open cover of $K$ has a finite subcover doesn't do it. – bof Nov 14 '18 at 8:11

Assuming that your space is Hausdorff $$K\setminus E_2=K\cap E_1$$ and $$K\setminus E_2$$ is compact. On second thoughts you don't need Hausdorff property!.
• Where do you think you need Hausdorff? If $E_1$ and $E_2$ are disjoint and $K\subseteq E_1\cup E_2$ then $K\cap E_1=K\setminus E_2$ is just set theory. If $K$ is compact and $E_2$ is open then $K\setminus E_2$ is compact in any topological space. – bof Nov 14 '18 at 8:15
Your proof should start with a cover $$\mathcal{U}$$ (WLOG by open sets of $$X$$) of $$K \cap E_1$$, and produce a finite subcover of that:
Add the one set $$E_2$$ to $$\mathcal{U}$$ and we have an open cover of $$K$$ (any set in $$K$$ lies in $$E_1$$ or $$E_2$$ and the first ones are covered by $$\mathcal{U}$$ the other by $$E_2$$..) and so $$\mathcal{U} \cup \{E_2\}$$ has a finite subcover $$\mathcal{U}'$$ and then $$\mathcal{U}'\setminus \{E_2\}$$ is still finite (smaller than the finite $$\mathcal{U}'$$) and a subcover of $$\mathcal{U}$$. So $$K \cap E_1$$ is compact.
Alternatively note that $$K\cap E_1 = K \cap (X\setminus E_2)$$ and thus is a closed subset of the compact $$K$$ and hence compact too.