68
$\begingroup$

Show that the set of all finite subsets of $\mathbb{N}$ is countable.

I'm not sure how to do this problem. I keep trying to think of an explicit formula for 1-1 correspondence like adding all the elements in each subset and sending that sum to itself in the natural numbers, but that wouldn't be 1-1 because, for example, the set {1,2,3} would send to 6 and so would the set {2,4}. Multiplying all the elements in each subset and sending that product to itself in the natural numbers wouldn't work either since, for example, {2,3} would send to 5 and so would the set {1,5}. Any ideas?

  • 6
    $2\times3\not=5$ :)2012-09-21
  • 3
    [Set of Finite Subsets of Countable Set is Countable](http://www.proofwiki.org/wiki/Set_of_Finite_Subsets_of_Countable_Set_is_Countable) at ProofWiki. See also [this question](http://math.stackexchange.com/questions/179568/some-elementary-questions-about-cardinality) for a generalization of your question ($\mathbb N$ is replaced by arbitrary infinite set $X$ and it is shown that set of all finite subset of $X$ has the same cardinality as $X$).2012-09-22
  • 0
    You're right, an explicit bijection would be a neat proof. **Hint**: think like a computer scientist.2015-07-17

7 Answers 7

6

If $S$ is the set of all finite subsets of $\mathbb{N}$, define $f:S\rightarrow \mathbb{Q}$ by

$f(A)=.x_1x_2x_3x_4\cdots$ where $x_{i}=\begin{cases}1 &\mbox{, if }i\in A\\0 &\mbox{, if } i\not\in A \end{cases}$.

Then $f$ is clearly injective, so $S$ is countable since $\mathbb{Q}$ is countable and any subset of a countable set is countable.

72

Define three new digits: $$\begin{align} \{ &= 10 \\ \} &= 11\\ , &= 12 \end{align}$$ Any finite subset of $\mathbb{N}$ can be written in terms of $0,1,\cdots,9$ and these three characters, and so any expression of a subset of $\mathbb{N}$ is just an integer written base-$13$. For instance, $$\{1,2\} = 10 \cdot 13^4 + 1 \cdot 13^3 + 12 \cdot 13^2 + 2 \cdot 13^1 + 11 \cdot 13^0 = 289873$$

So for each finite $S \subseteq \mathbb{N}$, take the least $n_S \in \mathbb{N}$ whose base-$13$ expansion gives an expression for $S$. This defines an injection into $\mathbb{N}$.


More generally, any set whose elements can be written as finite strings from some finite (or, in fact, countable) alphabet, is countable.

  • 13
    **+1** Really nice answer.2013-09-02
  • 0
    The user [@TimothySwan](http://math.stackexchange.com/users/177920/timothy-swan) tried to edit your question to add a comment, I have copied his comment here since the user can't comment himself. He commented: However, this proof is not correct since there must be an injection from $\mathbb N$.2014-09-22
  • 2
    Thanks @Darksonn. (For the benefit of anyone else reading, that's not true; every infinite set has an injection from $\mathbb{N}$ into it!)2014-09-22
  • 0
    (+1 a while ago) Not that it will be relevant to most users, but depending on the axioms one is working with, it may be possible for an infinite set to have no injection from $\Bbb N.$2015-05-10
  • 0
    @CameronBuie: Well-definedness is immediate from the well-ordering principle and the fact that we take the least such $n_S$ - perhaps that's what you meant by "some care must be taken".2015-12-08
  • 0
    Yes, that works perfectly well. I managed to misread "take the least" as "there is some." Clearly it's time for me to stop mathing for the day.2015-12-08
  • 0
    What do you mean For example - $S_1 = \{1,2,3\} , S_2 = \{1,2\}$ $S_1,S_2 \subseteq \mathbb{N}.$ $S_1,S_2$ have the same "least" Can you explain yourself ? And one more question, how can you prove it injection into $\mathbb{N}$ ? Thanks.2016-07-23
  • 0
    @Noam: $n_S$ is not the least element of $S$, rather $n_S$ is the least natural number whose base-13 representation is a string defining $S$ according to the above assignment of digits.2016-07-24
62

Consider an enumeration of the (positive) prime numbers by $n\mapsto p_n$. Then if you're given the set $\{n_1,...,n_k\}$, map that to $$p_{n_1}\cdots p_{n_k}.$$ For example, if we've enumerated the primes increasingly ($p_1=2$, $p_2=3$, and so on), then $$\{1,3,4\}\mapsto 70=2\cdot 5\cdot 7=p_1\cdot p_3\cdot p_4,$$ and $$\{1,3\}\mapsto 10=2\cdot 5=p_1\cdot p_3.$$

You'll need the fact that there are countably infinitely many prime numbers, and uniqueness of prime factorization. From there, it shouldn't be hard to prove this is an injection from the set of finite subsets of $\Bbb N$ into $\Bbb N$, so there are at most countably many such subsets. To show that there are at least (and so exactly) countably many finite subsets of $\Bbb N$, you need only find an injection from $\Bbb N$ into the set of finite subsets of $\Bbb N$, which should be easy.

Added: The described map "should" send $\emptyset$ to $1,$ the "empty product."

  • 0
    So if I was given a set {1,3} and a set {1,3,4}, you're saying to map that to 1,3 and 1,2^2,3? Am I understanding correctly?2012-09-21
  • 0
    Not quite. I'll include an example to clarify.2012-09-21
  • 0
    It's ok I think I get it now from reading the other answer! :) Thanks though!2012-09-21
  • 0
    I cannot help but wonder why the powers are there. $\{a_i\} \mapsto \prod p_{a_i}$ would've worked just as well.2015-05-10
  • 0
    @Lord_Farin: I'm not sure why I put those in there, off the top of my head, but you're right. They really aren't necessary.2015-05-10
  • 0
    @Lord_Farin: I think I was originally planning on the map as Marlu described, but I wanted to get rid of the need to write the set a certain way, so I went with $p_{n_1}^{n_1}\cdots p_{n_k}^{n_k}$ instead of $p_1^{n_1}\cdots p_k^{n_k}$ as a quick fix.2015-05-10
  • 0
    I really can't grasp the last part. If one has already found a bijection from some set into $\mathbb{N}$, isn't the inverse also a bijection, now from $\mathbb{N}$ to that set?2016-02-12
  • 1
    @Diego: Yes. However, the given map is *not* a bijection with $\Bbb N.$ For example, there is no finite subset of $\Bbb N$ that is mapped to $4.$ Rather, the map is an *injection* into $\Bbb N.$2016-02-12
  • 0
    But there exists a bijection between the range of the map and $\Bbb N$, because the first is a subset of the naturals.2016-02-12
  • 1
    @Diego: Your reasoning is a bit faulty. After all, $\{1\}$ is a subset of $\Bbb N,$ too, and we certainly can't conclude that there exists a bijection between $\{1\}$ and $\Bbb N$! In order to conclude that a subset of $\Bbb N$ is in bijection with $\Bbb N,$ we have to know that it is an *infinite* subset. The last part is aimed at proving that the range of the map is, indeed, infinite.2016-02-12
45

Alternatively, just use base $2$, so send $\{a_1,...,a_n\}$ to $2^{a_1}+\cdots+2^{a_n}$. (Assuming your $\mathbb N$ includes $0$, this is $1-1$ and onto.)

  • 5
    +1 Put in other way: any finite subset of positive integers can be represented as a binary string (with a finite number of ones), which in turn can be interpreted as a binary number which correspond to a positive integer.2014-03-17
  • 2
    In my opinion, this is the best possible proof because the bijection is very, very explicit.2015-07-17
  • 0
    Any base worked, right?(the base being an integer)2016-02-12
  • 4
    Any base gives you a $1-1$ function. Base $2$ is onto. @Diego2016-02-12
  • 0
    @MartinBrandenburg: Since the set {a1,...an} isn't an ordered one, we have several base 2 numbers mapping to the same set. How's a bijection best constructed here, then? The accepted answer is also just an injection, no?2017-03-08
  • 0
    @NikolajK What "several base 2 numbers" get mapped to the same set? Presumably, you can try to enumerate a single example. It would help to see those examples, to see where your confusion lies.2017-03-08
  • 0
    @ThomasAndrews: I figured it out, thanks. Basically I oversaw that you can always e.g. write $2^7+2^5$ as $2^5+2^7$ and thus have a normal form on the right hand side too. It works well because here you always have $p_2=2$ as base while in the other examples you have different $p_k$'s which are pre-ordered.2017-03-08
27

The other answers give some sort of formula, like you were trying to do. But, the simplest way to see that the set of all finite subsets of $\mathbb{N}$ is countable is probably the following.

If you can list out the elements of a set, with one coming first, then the next, and so on, then that shows the set is countable. There is an easy pattern to see here. Just start out with the least elements.

$$\emptyset, \{1\}, \{2\}, \{1, 2\}, \{3\}, \{1, 3\}, \{2, 3\}, \{1, 2, 3\}, \{4\}, \ldots$$

In other words, first comes $\{1\}$, then comes $\{2\}$. Each time you introduce a new integer, $n$, list all the subsets of $[n] = \{1, 2, \ldots, n\}$ that contain $n$ (the ones that don't contain $n$ have already showed up). Therefore, all subsets of $[n]$ show up in the first $2^{n}$ elements of this sequence.

  • 2
    In other words: List the elements of $P(\emptyset)$. List the elements of $P(\{1\}) \setminus P(\emptyset)$. List the elements of $P(\{1,2\}) \setminus P(\{1\})$. List the elements of $P(\{1,2,3\}) \setminus P(\{1,2\})$. And so on.2015-07-17
  • 0
    The lazy approach is a 'surjective' listing, $PL([0,1]),PL([0,2]),PL([0,3]),\dots,PL([0,n]),\dots$ where $PL$ is powerset listing (with commas) and $[0,n]$ is the initial segment.2017-08-18
  • 0
    how do you actually show this is surjective and injective?2018-09-05
19

I'm surprised nobody else has said this, so I worry that I've missed the point of the question. But I would argue as follows: Let $N_i$ be the family of all subsets of $\Bbb N$ with exactly $i$ elements. $N_0$ is finite, and $N_1$ is countable. $N_2$ is countable also, since it's a subset of $\Bbb N\times \Bbb N$. There's an easy induction argument that $N_i$ is countable for all $i>0$, since it's contained in the product $\Bbb N\times N_{i-1}$ of two countable sets.

Then, since the set you want, $\bigcup N_i$, is a countable union of countable sets, it is countable.

  • 2
    Well, a countable union of countable sets needn't be countable. It depends on your axioms.2012-09-29
  • 2
    What axioms would those be?2012-09-29
  • 2
    Set theoretic axioms--which you need at least some of before you can talk about sets, countability, unions, etc. For example, there are models of ZF in which $\Bbb R$ is a countable union of countable sets. If one takes countable choice (or stronger) as an axiom, then countable unions of countable sets are countable (that's a strictly weaker statement than countable choice). Now, it's worth noting that countable unions of *enumerated* sets (countable sets with a given bijection with $\Bbb N$) *are* countable, with no need for choice principles.2012-09-29
12

Let $p_1,p_2,\ldots$ the sequence of primes. Then map each finite subset $\{a_1,\ldots,a_n\} \subset \mathbb N$ to $p_1^{a_1}\cdots p_n^{a_n}$ where $a_1 < \ldots < a_n$. This gives an injective map from the set of finite subsets of $\mathbb N$ to $\mathbb N$.

Alternatively, notice that for every $s$ there are only finitely many finite subsets of $\mathbb N$ whose sum is $\leq s$. Let $A_s$ be the set of those subsets, then $\mathbb N = \bigcup_{s} A_s$ is a countable union of finite sets, hence countable.

  • 0
    You beat me to the post ... slightly different, but the same important idea - You can show that the set $C_N$ of subsets of $\mathbb N$ whose members sum to $N$ is finite for each $N\in\mathbb N$. Then each finite subset of $\mathbb N$ has a finite sum $N$ and hence is in one of the $C_N$, and the union of the $C_N$ is a countable union of finite sets, hence is countable.2012-09-21
  • 0
    @Mark: Not that it's probably relevant to the OP, but a countable union of finite sets needn't be countable in general without sufficient Choice. Here, of course, we're dealing with well-ordered finite sets, so it works out.2014-07-31