Discrete Mathematics and Proof

Matching two sets one to one

Without counting, how can you tell that two collections are the same size, and what does “same size” mean when neither collection ever runs out?

Where you are 4 in Infinite sets

Why this exists

A child who sets one cup in front of each chair knows there are as many cups as chairs without knowing how many of either (One-to-one correspondence). Counting is a special case of the same move: to count a set is to match it with \{1, 2, \dots, n\} (Cardinality of a finite set).

A set that never runs out, such as \mathbb{N} = \{0, 1, 2, \dots\}, has no last number to count to, but matching still makes sense. Taken as the definition of “same size”, it leads at once to a surprise: an infinite set can be the same size as a part of itself. Galileo, in his Two New Sciences (1638), noticed that the perfect squares pair off with all the positive integers though most positive integers are not squares, and concluded that “equal”, “greater” and “less” should not be applied to infinite collections. The definition below keeps “equal” and accepts the surprise.

Definition

Sets A and B have the same size (the same cardinality) when there is a bijection f : A \to B. We write

\lvert A \rvert = \lvert B \rvert,

and \lvert A \rvert \neq \lvert B \rvert when there is no bijection at all. For infinite sets, read \lvert A \rvert = \lvert B \rvert as one statement about the pair; no number called \lvert A \rvert has been defined.

A bijection is exactly a matching: no member of B is used twice (injective) and none is left out (surjective).

Intuition

0 0 1 2 2 4 3 6 4 8 5 10 6 12 … …
\mathbb{N}
E
Figure 1The rule n \mapsto 2n pairs every natural number with exactly one even natural number, and every even natural number receives exactly one arrow.

Figure 1 matches \mathbb{N} with the even natural numbers E = \{0, 2, 4, \dots\}. Every number in the top row has its partner below, and every number in the bottom row receives one arrow. Yet E is a proper subset of \mathbb{N}, missing 1, 3, 5, \dots. For a finite set that cannot happen (Result 3).

Results

1. Matching agrees with counting. If A and B are finite, there is a bijection A \to B if and only if A and B have the same number of members.

2. Same size behaves like equality. For all sets A, B, C: \lvert A \rvert = \lvert A \rvert (reflexive); if \lvert A \rvert = \lvert B \rvert then \lvert B \rvert = \lvert A \rvert (symmetric); if \lvert A \rvert = \lvert B \rvert and \lvert B \rvert = \lvert C \rvert then \lvert A \rvert = \lvert C \rvert (transitive).

3. Only infinite sets match a proper part. A finite set is never the same size as a proper subset of itself. Equivalently, a set that is the same size as one of its proper subsets is infinite.

Result 1 says the definition changes nothing for finite sets. Result 2 lets a chain of matchings be joined, as in Example 6.

Why it is true

Result 1. Proof. Let A have m members and B have n. If f : A \to B is a bijection, it is injective, so m \le n, and surjective, so m \ge n, by the size results of One-to-one, onto and bijective functions; hence m = n. Conversely, suppose m = n. List A = \{a_1, \dots, a_n\} and B = \{b_1, \dots, b_n\} without repeats and put f(a_i) = b_i. If a_i \neq a_j then i \neq j, so b_i \neq b_j: f is injective. Each b_j equals f(a_j): f is surjective. \square

Result 2. Proof. The identity function a \mapsto a is a bijection A \to A. If f : A \to B is a bijection, its inverse f^{-1} : B \to A is a bijection, and if also g : B \to C is a bijection, the composite g \circ f : A \to C is a bijection; both facts are proved in Composing functions between sets, and when an inverse exists. \square

These are the reflexive, symmetric and transitive properties of Relations and their properties: reflexive, symmetric, antisymmetric, transitive.

Result 3. Proof. Let A be finite with n members and let B be a proper subset of A. Some a \in A is not in B, so B \subseteq A \setminus \{a\}, a set of n - 1 members, and B has at most n - 1 members. Suppose, for contradiction, that f : A \to B is a bijection. Then f sends n members into at most n - 1 places, so by the pigeonhole principle two different members of A share an output, and f is not injective, a contradiction. The second sentence is the contrapositive. \square

Worked examples

Example 1

Matching two finite families without counting them

Let S = \{1, 2, 3, 4, 5, 6\}. Show that the set of 2-member subsets of S and the set of 4-member subsets of S have the same size, without listing either.

Solution

Send each 2-member subset X to its complement c(X) = S \setminus X. Removing 2 members from the 6 in S leaves 4, so c(X) is a 4-member subset and c is a function between the two families. Taking the complement twice gives back the set you started with: S \setminus (S \setminus X) = X.

Proof that c is a bijection. Injective: if c(X) = c(Y), take complements of both sides to get X = Y. Surjective: for a 4-member subset Z, the set S \setminus Z has 2 members and c(S \setminus Z) = Z. \square

By Result 1 the counts agree, and indeed \binom{6}{2} = \binom{6}{4} = 15.

Example 2

The natural numbers and the even natural numbers

Prove that \lvert \mathbb{N} \rvert = \lvert E \rvert, where E = \{0, 2, 4, \dots\} is the set of even natural numbers.

Solution

Use the matching of Figure 1, f : \mathbb{N} \to E, f(n) = 2n, which lands in E.

Proof. Injective: if 2a = 2b, dividing by 2 gives a = b. Surjective: a member m of E is even, so m = 2k for some integer k, and k \ge 0 because m \ge 0. Then k \in \mathbb{N} and f(k) = m. \square

So \mathbb{N} is the same size as its proper subset E.

Example 3

A full hotel takes one more guest

A hotel has one room for each natural number, numbered 0, 1, 2, \dots, and every room is occupied. Mizuki arrives and asks for a room. Show that everyone can be housed, one guest to a room, and conclude that \mathbb{N} is infinite.

Solution

Ask each guest to move from room n to room n + 1. This is the function s : \mathbb{N} \to \mathbb{N} \setminus \{0\}, s(n) = n + 1, and n + 1 \ge 1, so every guest lands in a room other than 0.

Proof that s is a bijection. Injective: if a + 1 = b + 1 then a = b, so no two guests share a room. Surjective: each room m \ge 1 receives the guest from room m - 1, which is a natural number. \square

Room 0 is free for Mizuki. So \lvert \mathbb{N} \rvert = \lvert \mathbb{N} \setminus \{0\} \rvert, and by Result 3 the set \mathbb{N} is infinite. A hotel with 50 full rooms cannot do this: 50 guests moved into the 49 rooms numbered 1 to 49 would put two in one room.

Example 4

Any two closed intervals

Show that \lvert [0, 1] \rvert = \lvert [0, 5] \rvert, and more generally that \lvert [a, b] \rvert = \lvert [c, d] \rvert whenever a < b and c < d.

Solution

The map x \mapsto 5x stretches [0, 1] onto [0, 5]. In general, slide and stretch:

g(x) = c + \frac{d - c}{b - a}\,(x - a).

Proof. Into [c, d]: if a \le x \le b then \displaystyle 0 \le \frac{x - a}{b - a} \le 1, and multiplying by d - c > 0 and adding c gives c \le g(x) \le d. Injective: if g(x_1) = g(x_2) then \displaystyle \frac{d - c}{b - a}(x_1 - x_2) = 0, and the factor \displaystyle \frac{d - c}{b - a} is not zero, so x_1 = x_2. Surjective: given y \in [c, d], solve g(x) = y to get

x = a + \frac{b - a}{d - c}\,(y - c).

As before \displaystyle 0 \le \frac{y - c}{d - c} \le 1, so a \le x \le b, and substituting gives g(x) = c + (y - c) = y. \square

With a = 0, b = 1, c = 0, d = 5 the formula is g(x) = 5x. Size by matching is not length.

Example 5

A bounded interval and an unbounded one

Prove that \lvert (0, 1) \rvert = \lvert (0, \infty) \rvert.

Solution

As x falls toward 0, \displaystyle \frac{1}{x} grows without bound, which suggests \varphi : (0, 1) \to (0, \infty), \displaystyle \varphi(x) = \frac{1}{x} - 1.

Proof. Into: if 0 < x < 1 then \displaystyle \frac{1}{x} > 1, so \varphi(x) > 0. Injective: if \displaystyle \frac{1}{x_1} - 1 = \frac{1}{x_2} - 1 then \displaystyle \frac{1}{x_1} = \frac{1}{x_2}, so x_1 = x_2. Surjective: given t > 0, put \displaystyle x = \frac{1}{1 + t}. Since 1 + t > 1, we have 0 < x < 1, and \varphi(x) = (1 + t) - 1 = t. \square

Example 6

The open interval and the whole line

Prove that \lvert (0, 1) \rvert = \lvert \mathbb{R} \rvert, and give one explicit bijection (0, 1) \to \mathbb{R}.

Solution

By Example 5 and transitivity (Result 2) it is enough to match (0, \infty) with \mathbb{R}. Try k : (0, \infty) \to \mathbb{R}, \displaystyle k(t) = t - \frac{1}{t}.

Proof that k is a bijection. Fix y \in \mathbb{R}. For t > 0, multiplying by t (allowed both ways, since t \neq 0) shows

t - \frac{1}{t} = y \quad\text{if and only if}\quad t^2 - yt - 1 = 0.

The discriminant is y^2 + 4 > 0, so there are two real roots, and their product is -1, so one is positive and one is negative. Hence exactly one t > 0 has k(t) = y, namely \displaystyle t = \frac{y + \sqrt{y^2 + 4}}{2}. At least one such t for every y makes k surjective; at most one makes it injective. \square

So \lvert (0, 1) \rvert = \lvert (0, \infty) \rvert and \lvert (0, \infty) \rvert = \lvert \mathbb{R} \rvert, and transitivity gives \lvert (0, 1) \rvert = \lvert \mathbb{R} \rvert. The composite k \circ \varphi is an explicit bijection, and with \displaystyle \varphi(x) = \frac{1 - x}{x},

k(\varphi(x)) = \frac{1 - x}{x} - \frac{x}{1 - x} = \frac{1 - 2x}{x(1 - x)}.

Check: \displaystyle x = \frac{1}{2} goes to 0, and \displaystyle x = \frac{1}{3} goes to \displaystyle \frac{1/3}{2/9} = \frac{3}{2} = k(2), with \displaystyle \varphi(\frac{1}{3}) = 2.

Example 7

Removing one endpoint

Prove that \lvert [0, \infty) \rvert = \lvert (0, \infty) \rvert, and conclude that \lvert [0, \infty) \rvert = \lvert \mathbb{R} \rvert.

Solution

Run the hotel of Example 3 on the natural numbers inside [0, \infty) and leave every other point where it is:

h(x) = \begin{cases} x + 1 & \text{if } x \in \mathbb{N}, \\ x & \text{if } x \notin \mathbb{N}. \end{cases}

Proof. Into: for x \in \mathbb{N}, h(x) \ge 1 > 0; for x \notin \mathbb{N} with x \ge 0, we have x \neq 0, so h(x) = x > 0. Injective, by cases: if x, y \in \mathbb{N} then x + 1 = y + 1 gives x = y; if neither is in \mathbb{N} then h(x) = h(y) says x = y; if x \in \mathbb{N} and y \notin \mathbb{N}, then h(x) \in \mathbb{N} and h(y) = y \notin \mathbb{N}, so h(x) \neq h(y). Surjective: let y > 0. If y \in \mathbb{N} then y \ge 1 and y - 1 \in \mathbb{N} has h(y - 1) = y. If y \notin \mathbb{N} then h(y) = y. \square

With Example 6, transitivity gives \lvert [0, \infty) \rvert = \lvert \mathbb{R} \rvert.

Boundaries

One failed function proves nothing. n \mapsto n + 1 is not onto \mathbb{N}, yet \lvert \mathbb{N} \rvert = \lvert \mathbb{N} \rvert. To prove \lvert A \rvert \neq \lvert B \rvert you must show that every function A \to B fails, which needs a new idea (Uncountable sets and the diagonal argument).

A proper subset is smaller only for finite sets. Result 3 is exactly where “a part is smaller than the whole” stops being true.

Endpoints matter to the formula, not to the size. A map x \mapsto px + q with p \neq 0 sends endpoints to endpoints, so it never matches [0, \infty) with (0, \infty); Example 7 needed another idea.

Not a relation on one set. There is no set of all sets, so Result 2 lists the three properties rather than calling “same size” a relation on some set.

Where this goes next

Sets the same size as \mathbb{N} are the countable ones. The real numbers are not among them (Uncountable sets and the diagonal argument), so infinite sets come in more than one size, and Cantor's theorem: no set matches its power set shows there is no largest.

Exercises

Finite sets

  1. Prove that f(n) = n - 3 is a bijection from \{1, 2, 3, 4, 5\} to \{-2, -1, 0, 1, 2\}.
  2. Is there a bijection from \{1, 2, 3, 4, 5, 6\} to the set of positive divisors of 12? To the set of positive divisors of 16?
  3. Let S = \{1, 2, 3, 4, 5\}. For X \subseteq S, let t(X) = X \setminus \{5\} if 5 \in X and t(X) = X \cup \{5\} if 5 \notin X. Prove that t matches the subsets of S with an even number of members with those with an odd number.

Matching with the natural numbers

  1. Prove that f(n) = -n - 1 is a bijection from \mathbb{N} to the negative integers \{-1, -2, -3, \dots\}.
  2. The hotel of Example 3 is full and four new guests arrive. Give a rule for moving the guests already there, and prove it is a bijection \mathbb{N} \to \mathbb{N} \setminus \{0, 1, 2, 3\}.
  3. Let Q = \{0, 1, 4, 9, \dots\} be the set of squares of natural numbers. Prove that \lvert \mathbb{N} \rvert = \lvert Q \rvert.
  4. Let T = \{7, 17, 27, 37, \dots\}, the natural numbers whose last digit is 7. Prove that \lvert \mathbb{N} \rvert = \lvert T \rvert.
  5. Use Example 2, Exercise 7 and Result 2 to write a formula for a bijection E \to T.

Intervals of real numbers

  1. Prove that x \mapsto 8x - 3 is a bijection [0, 1] \to [-3, 5].
  2. Find a bijection [2, 6] \to [0, 1] that sends 2 to 1, and prove it is one.
  3. Prove that \displaystyle x \mapsto \frac{1}{x} is a bijection (0, 1) \to (1, \infty).
  4. Prove that \displaystyle x \mapsto 1 - \frac{1}{x} is a bijection (0, 1) \to (-\infty, 0).
  5. Adapt Example 7 to prove that \lvert \mathbb{R} \rvert = \lvert \mathbb{R} \setminus \{0, 1\} \rvert.

Reasoning

  1. Prove that [0, 1] is infinite by matching it with a proper subset of itself.
  2. Find the flaw: “g : \mathbb{N} \to \mathbb{N}, g(n) = 3n, is one to one and misses 1, so \mathbb{N} is not the same size as its set M = \{0, 3, 6, \dots\} of multiples of 3.”
  3. Prove: if A \cap B = \varnothing, C \cap D = \varnothing, \lvert A \rvert = \lvert C \rvert and \lvert B \rvert = \lvert D \rvert, then \lvert A \cup B \rvert = \lvert C \cup D \rvert.
  4. Prove: if \lvert A \rvert = \lvert B \rvert, then \lvert A \times C \rvert = \lvert B \times C \rvert for every set C (Cartesian product).
  5. Let f : A \to B be a bijection and a_0 \in A. Prove that f, with domain A \setminus \{a_0\}, is a bijection onto B \setminus \{f(a_0)\}.
Answers
  1. Into: 1 \le n \le 5 gives -2 \le n - 3 \le 2. Injective: a - 3 = b - 3 gives a = b. Surjective: for m in the target, n = m + 3 lies in \{1, \dots, 5\} and f(n) = m.
  2. Yes for 12: its divisors 1, 2, 3, 4, 6, 12 are six, so Result 1 gives one (for example list both in order). No for 16: its divisors 1, 2, 4, 8, 16 are five, and 6 \neq 5.
  3. t changes the number of members by one, so it sends even-size subsets to odd-size ones and back. Applying t twice gives back X. Injective: t(X) = t(Y) gives X = t(t(X)) = t(t(Y)) = Y. Surjective: an odd-size Z has t(Z) even and t(t(Z)) = Z. Both families have 16 members.
  4. Into: n \ge 0 gives -n - 1 \le -1. Injective: -a - 1 = -b - 1 gives a = b. Surjective: for m \le -1, n = -m - 1 \ge 0 and f(n) = m.
  5. Move from room n to room n + 4. Into: n + 4 \ge 4. Injective: a + 4 = b + 4 gives a = b. Surjective: room m \ge 4 receives the guest from room m - 4 \in \mathbb{N}. Rooms 0 to 3 are free.
  6. f(n) = n^2. Surjective by the definition of Q. Injective: a^2 = b^2 gives (a - b)(a + b) = 0; if a + b = 0 with a, b \ge 0 then a = b = 0, and otherwise a = b. This is Galileo’s pairing.
  7. f(n) = 10n + 7. Injective: 10a + 7 = 10b + 7 gives a = b. Surjective: a member of T is 10k + 7 with k \in \mathbb{N}, and f(k) is that member.
  8. The inverse of n \mapsto 2n is \displaystyle m \mapsto \frac{m}{2}, a bijection E \to \mathbb{N}; composing with n \mapsto 10n + 7 gives \displaystyle m \mapsto 10 \cdot \frac{m}{2} + 7 = 5m + 7. So 0 \mapsto 7, 2 \mapsto 17, 4 \mapsto 27.
  9. Into: 0 \le x \le 1 gives -3 \le 8x - 3 \le 5. Injective: 8x_1 = 8x_2. Surjective: for y \in [-3, 5], \displaystyle x = \frac{y + 3}{8} \in [0, 1] and 8x - 3 = y.
  10. \displaystyle x \mapsto \frac{6 - x}{4}. Into: 2 \le x \le 6 gives 0 \le 6 - x \le 4. Injective: 6 - x_1 = 6 - x_2. Surjective: for y \in [0, 1], x = 6 - 4y \in [2, 6]. It sends 2 to 1 and 6 to 0.
  11. Into: 0 < x < 1 gives \displaystyle \frac{1}{x} > 1. Injective: \displaystyle \frac{1}{x_1} = \frac{1}{x_2} gives x_1 = x_2. Surjective: for y > 1, \displaystyle x = \frac{1}{y} lies in (0, 1) and \displaystyle \frac{1}{x} = y.
  12. Into: \displaystyle \frac{1}{x} > 1, so \displaystyle 1 - \frac{1}{x} < 0. Injective as in 11. Surjective: for u < 0, \displaystyle x = \frac{1}{1 - u} has 1 - u > 1, so 0 < x < 1, and \displaystyle 1 - \frac{1}{x} = 1 - (1 - u) = u.
  13. h(x) = x + 2 for x \in \mathbb{N} and h(x) = x otherwise. Into: x \in \mathbb{N} gives h(x) \ge 2; x \notin \mathbb{N} means x \neq 0, 1. Injective by the three cases of Example 7. Surjective: if y \in \mathbb{N} and y \neq 0, 1, then y \ge 2 and h(y - 2) = y; if y \notin \mathbb{N}, h(y) = y.
  14. Proof. \displaystyle x \mapsto \frac{x}{2} is a bijection \displaystyle [0, 1] \to [0, \frac{1}{2}] (Example 4 with c = 0, \displaystyle d = \frac{1}{2}), and \displaystyle [0, \frac{1}{2}] is a proper subset since 1 is not in it. By Result 3, [0, 1] is infinite. \square
  15. One function that is not a bijection says nothing about other functions. The same rule with codomain M, n \mapsto 3n, is a bijection \mathbb{N} \to M (each member of M is 3k for exactly one k \in \mathbb{N}), so \lvert \mathbb{N} \rvert = \lvert M \rvert.
  16. Proof. Take bijections f : A \to C and g : B \to D, and let h = f on A and h = g on B; this defines one output for each member of A \cup B because A \cap B = \varnothing. Injective: two inputs in A, use f; two in B, use g; one in each, the outputs lie in C and in D, which share nothing. Surjective: a member of C is f(a) and a member of D is g(b). \square
  17. Proof. Take a bijection f : A \to B and put F(a, c) = (f(a), c). Injective: equal pairs give f(a) = f(a') and c = c', so a = a'. Surjective: for (b, c), choose a with f(a) = b; then F(a, c) = (b, c). \square
  18. Proof. Into: for x \neq a_0, injectivity gives f(x) \neq f(a_0). Injective: inherited from f. Surjective: for y \in B with y \neq f(a_0), some x has f(x) = y, and x \neq a_0 since f(x) \neq f(a_0). \square
kg1128 · updated 2026-10-22 · CC-BY-SA-4.0