Countable Sets
How many integers are there, compared to natural numbers? A first instinct says "twice as many." Yet a careful pairing shows the two collections match up perfectly, element for element. This surprising fact — that an infinite set can be placed in exact correspondence with a proper subset of itself — is the gateway to the modern theory of cardinality. Countable sets are the infinite sets that are, in a precise sense, the smallest kind of infinite: no bigger than the natural numbers ℕ. The idea matters because it draws a sharp, provable line inside the world of infinite collections. Not all infinities behave alike. Some sets, as later results show, are strictly larger than ℕ. But a remarkably wide class of familiar sets, including ℤ and ℚ, turn out to be exactly the same size as ℕ. This is not a philosophical opinion; it is a theorem. It is proved by exhibiting explicit bijections or injections. The big picture is a toolkit: once you know ℕ is countable, you get ℤ, ℚ, finite unions of countable sets, countable unions of countable sets, and finite products of countable sets all "for free." This happens via a handful of closure theorems. These closure properties are the engine behind an enormous amount of downstream mathematics. They range from the enumerability of algebraic numbers to the countability of the set of finite-length strings over a finite alphabet, which underlies computability theory. This article gives the precise definition of countability, and proves the central closure theorems with full rigor. It works through nontrivial examples (including the classical Cantor pairing enumeration of ℚ). It also shows exactly where the argument breaks if a hypothesis is dropped. This sets the stage for the discovery, via Uncountable Sets and Cantors Diagonal Argument, that not every infinite set is countable.
- A set is countable if it is finite or admits a bijection with ℕ; countably infinite means the latter.
- Equivalently, a nonempty set is countable iff there is a surjection , or (for infinite ) an injection .
- ℤ and ℚ are countably infinite, despite naive intuition suggesting they are "bigger" than ℕ.
- Countable unions of countable sets are countable (using the Axiom of Countable Choice, or an explicit enumeration when one is given).
- Finite (and countable) Cartesian products of countable sets are countable, proved via the Cantor pairing function.
- Key idea: infinite size is measured by bijections, not by subset inclusion — a set can be in bijection with a proper subset of itself.
Where this lives today
Countability underlies computability theory: the set of all finite strings over a finite alphabet is countable (a countable union, over string lengths , of the finite sets of length- strings), which is why Turing machines, programs, and provable theorems can all be Gödel-numbered — assigned distinct natural number codes — a fact essential to the undecidability results of Turing and the incompleteness results of Gödel. In algebra and number theory, the countability of the algebraic numbers (roots of polynomials with integer coefficients) versus the uncountability of the reals gives, non-constructively, the existence of transcendental numbers without exhibiting a single one. In probability and measure theory, countable additivity of measures depends on countable (not arbitrary) unions of events being well-behaved, directly paralleling the closure theorem's index-set hypothesis. In topology and analysis, countable dense subsets (like ) underlie the notion of separability, used throughout functional analysis. In cryptography and coding theory, the countability of the set of finite bit-strings guarantees that any countable message space can be injectively encoded into natural numbers, a prerequisite for hashing and enumeration schemes.
Ask the tutor: Why does the diagonal argument fail to show is uncountable, yet succeed for ?
Let be a set.
- is finite if or there is a bijection for some .
- is countably infinite (or denumerable) if there is a bijection .
- is countable if is finite or countably infinite.
- is uncountable if is not countable.
Here . Equivalently (and this equivalence is proved as Lemma: Injection Characterization below), is countable if and only if there exists an injection ; and a nonempty set is countable if and only if there exists a surjection . This is a special case of the general notion of Comparing Cardinalities: is countable exactly when .
Intuition
The naive way to compare two infinite collections is to check whether one contains the other. By that measure , so "should" be bigger. But cardinality compares sets by matching, not by containment: if every element of can be paired with exactly one element of and vice versa, with nothing left over on either side, then and have the same size, full stop — regardless of whether one happens to sit inside the other as a subset. This is exactly what happens with . Send , and then alternate: , , , , and so on, zig-zagging outward from . Every integer gets hit exactly once. The set "," despite stretching infinitely in two directions, is not too big for a single one-directional list to capture. is more surprising still, since between any two rationals there are infinitely many others — is dense, while is not. Cantor's trick is to stop thinking of as an ordered line and instead arrange all pairs on a two-dimensional grid, then snake through the grid diagonal by diagonal. Density is irrelevant to counting; only the existence of some systematic listing matters.
Central results
Let be a set. Then is countable if and only if there is an injective function .
() Suppose is countable. If is finite, either , in which case the empty function is (vacuously) an injection , or there is a bijection ; composing with the inclusion gives an injection . If is countably infinite, by definition there is a bijection ; its inverse is a bijection, hence in particular an injection.
() Suppose is injective. If is finite, is countable by definition, and we are done. So assume is infinite. The image is then an infinite subset of (since is injective, is in bijection with , hence infinite). We first show:
Claim. Every infinite subset is countably infinite. Proof of claim. Define recursively using well-ordering of : let , and having defined , let
which exists because is infinite, so is nonempty, and every nonempty subset of has a least element (well-ordering of ). By construction is strictly increasing, hence injective (if then by an easy induction on using strict monotonicity at each step, so ). For surjectivity, suppose toward a contradiction some is never hit. Since is strictly increasing, for all (proved by induction: trivially; if then , so ). Hence for , , so ; more precisely, since is increasing and for all , the only candidates for are . There are only finitely many such (), and by construction each for was chosen as a minimum of a set excluding all previously chosen elements; if none of equals , consider that (since by assumption), so . Combined with from the previous paragraph, , contradicting the assumption that is never hit. Hence is surjective, and being also injective, is a bijection . This proves the claim. (claim) Now, by the claim, is countably infinite, so there is a bijection . Since is a bijection (injective by hypothesis, surjective onto its own image by definition), is a composition of bijections, hence a bijection. Thus is countably infinite, in particular countable.
∎A nonempty set is countable if and only if there exists a surjection .
() If is countable and nonempty, either is finite nonempty, say with bijection ; extend to by for and otherwise — this is a surjection since already hits everything. Or is countably infinite with bijection , and itself is a surjection.
() Suppose is surjective and . Define by
which exists by well-ordering of since is nonempty (as is surjective). This is injective: if , then and since was chosen as an element of both preimages, forcing . By Lemma: Injection Characterization, is countable.
∎1. (Subsets) If is countable and , then is countable. 2. (Finite unions) If are each countable, then is countable. 3. (Countable unions) If is a countable index set and is a family of countable sets, then is countable. 4. (Finite products) If and are countable, then is countable. Consequently, is countable whenever each is countable.
We use the technique of explicit encoding into , combined with the Lemma: Injection Characterization and its corollary, throughout.
(1) Subsets. If is countable there is an injection (Lemma). Restricting to gives an injection (a restriction of an injective function is injective, since injectivity is a universally quantified statement about pairs of inputs, and restricting the domain only removes potential pairs to check). By the Lemma, is countable.
(2) Finite unions. By induction on it suffices to prove the case ; the general case follows by writing and applying the case repeatedly. If or the claim is immediate from countability of the other set (a union with doesn't change the set), so assume both nonempty. By the Corollary there are surjections and . Define by
This is surjective: given , either , so for some , or , so for some ; either way . By the Corollary, is countable.
(3) Countable unions. Let be countable and, for each , let be countable. If the union is , countable trivially. Otherwise, since is countable and nonempty, fix a surjection (Corollary). We may discard indices with , since they contribute nothing to the union; so assume without loss of generality for every under consideration (formally, replace by , which is a subset of a countable set, hence countable by (1); if the union is empty and we are done, otherwise proceed with in place of ). For each choose, using the Corollary, a surjection . (This selection of one surjection for each simultaneously is exactly an application of the Axiom of Countable Choice: for each the set of surjections is nonempty, and we choose one from each of countably many such nonempty sets.) Now define by
This is well-defined since and . It is surjective onto : given in the union, for some ; since is surjective, for some ; since is surjective onto , for some . Finally, compose with a bijection — the Cantor pairing function
which is a bijection (verified explicitly in part (4) below) — to get , a surjection (composition of a bijection followed by a surjection is a surjection). By the Corollary, is countable.
(4) Finite products. First we handle itself, then transfer to general countable via injections. Step 1: , , is a bijection. Group pairs by their "antidiagonal index" . For fixed , the pairs with are exactly , a total of pairs. Order all pairs first by increasing , and within each antidiagonal by increasing (equivalently decreasing ). The number of pairs with antidiagonal index strictly less than is
So the pair with , sitting in position (0-indexed) within its antidiagonal, receives overall index
matching the formula. Since every natural number falls into a unique antidiagonal — there is a unique with , because is strictly increasing in and these intervals partition — and within that antidiagonal a unique position with , giving , the map has a well-defined inverse recoverable by this procedure. Hence is a bijection. Step 2: general countable . By Lemma: Injection Characterization, fix injections and . Define by
This is injective: if , then since is a bijection (in particular injective), , so and ; since are injective, and . By the Lemma, is countable. For factors, induct: via the evident associativity bijection , and if is countable by inductive hypothesis, then its product with the countable set is countable by the case just proved; a bijective image of a countable set is countable (transport the enumeration bijection through the associativity bijection).
∎Worked examples
Example 1: is countably infinite, via an explicit closed-form bijection. Define by
So Injectivity. Suppose . If are both even, gives . If both odd, gives . If even and odd, then while (since when odd and ), so , contradiction — this case cannot occur. Hence have the same parity and . Surjectivity. Given : if , take (even, and ); if , take (check parity: is even so is odd, and since gives ; then ). So every integer is hit. Hence is a bijection, and is countably infinite. Notice this also illustrates part (2) of the closure theorem directly: , a union of two countably infinite sets, so countability of also follows abstractly from the closure theorem — the explicit above is one concrete instantiation of that abstract argument.
Example 2: is countably infinite, via Cantor's grid argument, done carefully with signs. We show is countable using the closure theorem rather than reinventing an ad hoc bijection. Step 1. (positive integers) is countable, being in bijection with via , and is countable by part (4) of the closure theorem (via the pairing function ). Step 2. Define (positive rationals) by . This is surjective: every positive rational equals for some positive integers (by definition of as ratios of integers). It is far from injective (), but surjectivity alone suffices: by the Corollary, since there is a surjection (Step 1, composed appropriately) and then a surjection , the composite is a surjection . Hence is countable. Step 3. is countable, being the image of the countable set under the bijection (a bijective image of a countable set is countable — restrict the enumerating bijection of and post-compose with negation). Step 4. is a union of three countable sets ( finite, hence countable), so by part (2) of the closure theorem (extended trivially from 2 to 3 sets by associativity), is countable. Since is visibly infinite (it contains the infinite set ), is countably infinite: there exists a bijection . (Existence of some bijection follows abstractly: we exhibited an injection via the surjection-to-injection construction in the Corollary's proof, and combined with the trivial injection , a Schwarz–Cantor–Bernstein-style argument — the content of Comparing Cardinalities — upgrades the pair of injections to a genuine bijection.)
The closure theorem requires the index set itself to be countable. Drop that hypothesis and the conclusion can fail. Let (uncountable — a fact established via Uncountable Sets and Cantors Diagonal Argument), and for each let , a single-point set, certainly countable (indeed finite). Then
which is uncountable. So a union of countably many — here, even a union of finite — sets indexed by an uncountable set need not be countable. The proof of part (3) of the closure theorem crucially used a surjection to enumerate the index set; no such surjection exists when , and the entire construction of collapses at that step. This shows the hypothesis " countable" in part (3) is not a technical nicety but load-bearing.
Scope, edge cases & common traps
| Situation | Status | Why | |
|---|---|---|---|
| Countable (finite) | Vacuously satisfies the finite case of the definition | ||
| Countably infinite | Explicit bijections/surjections constructed above | ||
| , | Uncountable | Diagonal argument — see Uncountable Sets and Cantors Diagonal Argument | |
| Countable union of countable sets, countable index | Countable | [[Central results | Closure Theorem]] part 3 |
| Uncountable union of nonempty (even singleton) sets | Can be uncountable | Counterexample above | |
| Finite product of countable sets | Countable | Closure Theorem part 4, via Cantor pairing | |
| Countably infinite product () of countable sets, | Generally uncountable | Diagonal argument applies; this is not covered by the theorem, which is stated only for finite products |
The mathematician behind it
Origins · 1 minGeorg Cantor and how this was discovered
Georg Cantor developed the theory of transfinite cardinal numbers in the 1870s–1880s, against considerable resistance from contemporaries such as Leopold Kronecker. His 1874 paper proving that the algebraic numbers are countable while the real numbers are not — the seed of the diagonal argument — marked the beginning of set theory as a mathematical discipline in its own right, rather than a mere convenience of language.
Is every infinite subset of a countable set countably infinite?
Yes, and this is exactly the key claim proved inside the Lemma: Injection Characterization: every infinite subset of is countably infinite, constructed via the strictly increasing "take the next smallest unused element" function. Since any countable set injects into , an infinite subset of a countable set injects into an infinite subset of , hence is countably infinite by the same reasoning transported across the injection. This is part of why "countable" is such a robust, easy-to-use notion — subsets never cause surprises, unlike with uncountable sets where subsets can be countable, uncountable, or anything in between.
Does ℕ have the same cardinality as a proper subset of itself, and is that a contradiction?
Yes, and no — this is a defining feature of infinite sets, not a paradox. The even numbers are a proper subset of , yet is a bijection . Richard Dedekind in fact defined infinite sets as precisely those that can be placed in bijection with a proper subset of themselves — finite sets can never do this, since a bijection between a finite set and a proper subset would force the subset to have both fewer and equally many elements, which contradicts basic counting. So this "paradox" is really the theorem that distinguishes infinite from finite.
If A and B are both countably infinite, must A ∪ B be countably infinite, or could it be finite?
If and are both countably infinite, is always countably infinite (never finite), because and a set containing an infinite subset is itself infinite; combined with the closure theorem showing is countable, and infinite plus countable forces countably infinite by definition. The only way to get something finite from a union is if both original sets were finite to begin with.
Why does the Cantor pairing function need to be a bijection, rather than just a surjection or injection, for the product theorem?
Technically the full closure theorem only strictly needs to be injective (to build an injection by composing with injections , ). Proving it is a full bijection is slightly more work but gives a stronger, cleaner, and independently useful fact: it shows and are not just comparable in size but exactly the same size, which is needed elsewhere, e.g. when one wants an actual enumeration (not just an injective code) of pairs, as in explicitly listing rational numbers or Turing machine configurations.
Is the set of all finite subsets of ℕ countable?
Yes. For each , the set of -element subsets of injects into (list the elements in increasing order to get an -tuple), and is countable by finite products (Closure Theorem, part 4, extended to factors). So each is countable. The set of all finite subsets of is , a countable union (indexed by , which is countable) of countable sets, hence countable by part (3) of the Closure Theorem. Note this is a genuinely different, much smaller set than , the set of all subsets (finite and infinite), which is uncountable.
Does this article's closure theorem tell us anything about ℝ or 𝒫(ℕ)?
Only indirectly, by contrast. Nothing in the Closure Theorem produces uncountable sets — quite the opposite, it shows how surprisingly hard it is to escape countability using unions and finite products of countable pieces. The existence of uncountable sets like or requires a fundamentally different argument, the diagonal argument, covered in Uncountable Sets and Cantors Diagonal Argument. That article shows no surjection can exist, which is precisely the failure of the Corollary's condition for countability.
How does countability connect to cardinal arithmetic more generally?
Countability is the arithmetic statement , where is the smallest infinite cardinal. The closure theorems proved here are special cases of general cardinal arithmetic facts: (finite unions), (finite products via pairing), and for any countable index set (countable unions). These identities look bizarre compared to finite arithmetic — doubling or squaring an infinite quantity leaves it unchanged — and they are explored more systematically, alongside operations like , in Cardinal Arithmetic.