Is every set in a separable metric space the union of a perfect set and a set that is at most countable?

I'm reading Baby Rudin and exercise 28 of chapter 2 reads "Prove that every closed set in a separable metric space is the union of a (possibly empty) perfect set and a set which is at most countable." I don't understand why the set must be closed in order for this to be true. My proof is as follows, and I don't make any reference to the closedness of the set:

Let $E$ be a set in a separable metric space. Let $B$ be a countable base of that metric space. Let $P$ be the set of condensation points of $E$. I claim that $P$ is perfect and $E-P$ is at most countable.

If $p$ is a limit point of $P$, then every neighborhood of $p$ includes at least one point $q$ of P. For a neighborhood $N_{p}$ of $p$, choose a neighborhood $N_{q} \subset N_{p}$ of $q$. Since $q$ is a condensation point of $E$, uncountably many points of $E$ are in $N_{q}$, and thus in $N_{p}$. So $p\in P$ and $P$ is closed.

If $p \in P$, then $p$ is a condensation point of $E$, so every neighborhood $N_{p}$ of $p$ must include uncountably many points of $E$. If $p$ is not a limit point of $P$, then there exists a neighborhood $N_{p}$ of $p$ such that $N_p$ includes no condensation points of $E$ except for $p$. This means that every point $q\in N_{p}-\{p\}$ must have a neighborhood $N_{q}$ that does not have uncountably many points of $E$. For each $b_{k}\in B \cap \mathscr{P}(N_{p})$, choose such a neighborhood $N_{q_{k}} \supset b_{k}$ of some point $q\in N_{p}-\{p\}$. Now $\{N_{q_{k}}\}$ covers $N_{p}$, and $\bigcup_{k=1}^{\infty}N_{q_{k}}\supset N_{p}$ has at most countably many points of $E$, for it is a union of countably many sets that have at most countably many points of $E$. This contradicts the assumption that $p\in P$. So $P$ is perfect.

Let $S=E-P$. There are no condensation points in $S$. So there exists an open cover $\{N_s\}$, where each $N_s$ is a neighborhood of $s \in S$ with at most countably many elements of $S$. For each $b_{k}\in B \cap \mathscr{P}(S)$, choose such a neighborhood $N_{s_{k}} \supset b_{k}$ of some point $s\in S$. Then we have a countable subcover $\{N_{p_{k}}\}$ of $S$. As $N_{p_{k}} \cap S$ is at most countable for all $k$, $S$ must be at most countable.

So what am I doing wrong? Or is Rudin's assumption of closedness extraneous?

• If $E$ is not closed, then in general $P \not \subset E$. – Daniel Fischer Aug 16 '13 at 19:09
• oh ok. That's what I did wrong. So $E$ must be closed to ensure that $P \subset E$. – Joshua Meyers Aug 16 '13 at 19:18
• Right. Now, of course you can regard $E$ as a metric space in its own right, and as a subspace of a separable metric space, it is separable too. And of course it's closed then. The set of condensation points is then $P_E = P \cap E$, which is perfect (as a subset of $E$, not in general as a subset of $X$, since perfect sets are by definition closed), and $E \setminus P_E$ is countable. – Daniel Fischer Aug 16 '13 at 19:29
• In your proof, why does p belong to $\cup N_{q_{k}}$? I think you just want a countable cover of $N_{p}-\{p\}$ – SihOASHoihd Jul 13 '17 at 18:02
• Also, I dont think it's true that every basis element in $N_{p}$ is contained in some $N_{q_{k}}$. – SihOASHoihd Jul 13 '17 at 18:17

As is customary, Rudin’s definition of perfect set includes the requirement that the set be closed. Your argument would be correct if that requirement were not included in the definition, though I think that it’s a little easier to make it the other way round: let $$E=\{x\in S:x\text{ has an open nbhd }B\text{ such that }B\cap S\text{ is countable}\}\;,$$ show that $E$ is countable, and show that every point of $S\setminus E$ is a condensation point of $S\setminus E$.
Following Brian's answer: If you do that for $E=\mathbb R\setminus\mathbb Q$, then $P=E$, which is not closed.