Exercise 10, Chapter 2, of Baby Rudin I was hoping someone could look over my proposed proof of the last part of exercise 2.10 in Rudin. I'm all set with proving that the given set is a metric space, but would like to know if I have adequately identified and proven which sets are open and which are compact.

Let $X$ be an infinite set. For $p \in X$ and $q \in X$, define
$$
d(p,q) = \begin{cases} 1, & \text{(if $p \neq q$)} \\ 0, & \text{(if $p = q$)}. \end{cases}
$$
Prove that this is a metric. Which subsets of the resulting metric space are open? Which are closed? Which are compact?

Here's my attempted proof of everything except the fact that $d$ is a metric. I've written a few questions below within the proof as well.

Consider the neighborhood $N_r (p)$, which is the set of points $q \in \mathbb{R}$ such that $d(x,p) < r$. By theorem 2.19 in Rudin, every neighborhood is an open set.

Question: is there a difference here between an open ball and a neighborhood? Can I state this result in terms of open balls, or must I use neighborhoods? My understanding is that neighborhood is a more general term, whereas an open ball requires that we be defining a topology on a set, such as $\mathbb{R}^n$, where open intervals are open. Neighborhoods, on the other hand, are just open sets containing the point.

If we take any value of $r < 1$, including $r = \frac{1}{2}$, we have that $N_{\frac{1}{2}} (p) = \{p\}$, since the only way that two points can have a distance less than $1$ between them with this metric is if they are the same point. As we can define a neighborhood in this way, any singleton set, $\{p\}$, where $p\in X$ is open. Furthermore, we can take any nonempty subset $S \subset X$ and write $S = \bigcup\limits_{p \in S} \{p\}$. Since an arbitrary union of open sets is open, any subset of $X$, including the entire set, is open. By the axioms of topology, of course $X$ and $\emptyset$ are also open.

(Question: am I correct that I only assert this when $S \neq \emptyset$?)

Furthermore, by the axioms of topology, if $S \subset X$ is open, then $S^c$ is open. But $S = (S^c)^c$, so $S$ is the complement of an open set, meaning that $S$ is closed. Thus, every subset of $S$ is simultaneously open and closed.

(Question: does this mean that the empty set is open and closed? The entire set is open, and $X^c = \emptyset$, so the empty set would be simultaneously open and closed, right? Or does the above result I just gave only extend to non-empty sets?)

Finally, we consider which sets are compact. A set is compact if and only if every open cover has a finite cover. Consider an infinite subset $S \subset X$. Then, we can write $S$ as an infinite union of singleton sets, i.e., $S = \bigcup\limits_{p \in S} \{p\}$. That is, this infinite union of singletons represents an open cover of $S$. No finite subcover could possibly exist because removing even one of these sets, $\{p\}$, would cause us to fail to cover $S$. Thus, no infinite subset of $X$ is compact.
Alternatively, suppose $A$ is finite, so $|A| = k$ and we have $A = \{a_1, a_2, \ldots, a_k\}$. Then, let $U$ be an open cover of $A$, where we can write $U$ as an arbitrary union, $U = \bigcup U_j$, of subsets $U_j \in X$. Since $U$ is an open cover, for all $a_i \in A$, there exists a $j$ such that $a_i \in U_j$. There may exist more than one such $j$, but we know there exists at least one. Rename these sets $B_1, B_2, \ldots, B_n$. Then, $B = \bigcup\limits_{i=1}^n B_i$ represents a finite subcover of $A$. Thus, any finite set, $A$, is compact.

Question: I struggled a bit with formalizing this fact. Would it be better to write a function $f: U \to A$ with $U_j \mapsto a_i$ and argue that, because this function is onto, there is a finite cover?
And, as a final question: is the empty set compact? I am not sure if I need to make clear that when I write $A$ as an infinite union of sets whether I need to make clear that $A$ can be nonempty.
Any help and insights would be greatly appreciated.
 A: 
Question: is there a difference here between an open ball and a neighborhood? Can I state this result in terms of open balls, or must I use neighborhoods? My understanding is that neighborhood is a more general term, whereas an open ball requires that we be defining a topology on a set, such as $\mathbb{R}^n$, where open intervals are open. Neighborhoods, on the other hand, are just open sets containing the point.

I haven't read Baby Rudin, but it sounds like, according to his definition, neighbourhoods are precisely open balls. The neighbourhood $N_r(p)$ is the open ball, radius $r$, centred at $p$. There is no difference in this context.
More typically, a "neighbourhood of a point $p$" is a set which contains $p$ in the interior. Neighbourhoods don't necessarily have to be open (e.g. $[0, 2]$ is a neighbourhood of $1$ in $\Bbb{R}$).
Compactness (in the sense of finite open sub-covers) cannot be done with sets of non-empty interior; the covers must be with open sets. However, if $S$ is a basis for the topology, it is allowable to assume without loss of generality that the open sets in question belong to $S$ (indeed, the same is true even if $S$ is a subbasis, by the Alexander subbasis theorem). So, in the case of a metric space, since the open balls form a basis for the topology, you can assume that the covers in question are with open balls, rather than general open sets.

(Question: am I correct that I only assert this when $S\neq\emptyset$?)

You're not incorrect; the result indeed holds for $S \neq \emptyset$. It is not unusual to define the empty union, i.e. $\bigcup_{\alpha \in \emptyset} S_\alpha$, to be empty. That is, the union of an empty family of sets, is always empty. If $S = \emptyset$, then under this convention,
$$\bigcup_{p \in S} \{p\} = \emptyset = S$$
as usual. This still counts as an arbitrary union of open sets, and under this convention, the empty union will still be an open set (i.e. the empty set).
That said, while common, this convention is not universal. It's probably better to deal with the $S = \emptyset$ case separately.

(Question: does this mean that the empty set is open and closed? The entire set is open, and $X^c=\emptyset$, so the empty set would be simultaneously open and closed, right? Or does the above result I just gave only extend to non-empty sets?)

The empty set is indeed open and closed, and this is true in every topology. It's open axiomatically, and closed because its complement, $X$, is also axiomatically open. So, you're right, it holds for all sets.

Question: I struggled a bit with formalizing this fact. Would it be better to write a function $f: U \to A$ with $U_j \mapsto a_i$ and argue that, because this function is onto, there is a finite cover?

No, I prefer what you have already. The one thing I would do (though this is primarily stylistic preference) is not rename the sets in the subcover. You know that, because $a_i \in A \subseteq \bigcup_j U_j$, there must be some $j_i$ in the index set such that $a_i \in U_{j_i}$. This holds for all $i = 1, \ldots, k$, so
$$A = \{a_1, \ldots, a_k\} \subseteq U_{j_1} \cup \ldots \cup U_{j_k},$$
proving there is a finite subcover.

And, as a final question: is the empty set compact? I am not sure if I need to make clear that when I write $A$ as an infinite union of sets whether I need to make clear that $A$ can be nonempty.

Yes, the empty set is indeed compact. Take any open cover of the empty set (i.e. any family open sets, since the union will inevitably contain $\emptyset$ as a subset), and then take any finite subfamily (again, $\emptyset$ will inevitably be a subset of its union). You can even take the empty subfamily, since, according to the convention, the union of this family is $\emptyset$, which contains $\emptyset$ as a subset.
In terms of proving it, it again depends on whether you adopt this empty union convention. It might be safest to deal with the empty set as its own case (precisely as I did above).
