Title

ECS 120 Theory of Computation
Sizes of Sets: Part 2
Julian Panetta
University of California, Davis

Review: Comparing sizes of sets

Definition: For any sets \(A\) and \(B\), we write \(|A| \ge |B|\) if and only if
there is \(f: A \stackrel{\text{onto}}{\to} B\). Also equivalent to:
there is \(g: B \stackrel{\text{1-1}}{\to} A\). (Also \(|A|=|B|\iff \exists h: A \stackrel{\text{1-1,onto}}{\to} B\).)

D R f 1 - 1, not onto: no two arrows “collide” onto, not 1 - 1: all elements of R are “covered” 1 - 1 and onto:

\(|\N|\) vs. \(|\Q|\)

  • Let’s now consider the rational numbers \(\Q\). \[ \Q = \setbuild{\frac{n}{d}}{n \in \Z, d \in \N^+ } \]

    It looks like there are way more of these!

  • We’ll start out with just the positive rationals \(\Q^+\).

  • Clearly \(|\Q^+| \ge |\N^+|\) since \(\N^+ \subsetneq \Q^+\), and thus \(|\Q^+| \ge |\N|\).

  • But what about finding an onto \(f : \N \to \Q^+\)?
  • How can we enumerate \(\Q^+\)?
    • The following won’t work: \[ \frac{1}{1}, \; \fragment{\frac{1}{2},} \; \fragment{\frac{1}{3},} \; \fragment{\frac{1}{4}, \; \cdots,} \; \fragment{\frac{2}{1}, \; \frac{2}{2}, \; \frac{2}{3}, \; \frac{2}{4}, \; \cdots, \; \frac{3}{1}, \; \frac{3}{2}, \; \frac{3}{3}, \; \frac{3}{4}, \; \cdots} \hspace{20em} \]

      Larger numerators aren’t reached at any finite step! Numerator and denominator must change together!

\(|\N|\) vs. \(|\Q|\)

  • Let’s now consider the rational numbers \(\Q\). \[ \Q = \setbuild{\frac{n}{d}}{n \in \Z, d \in \N^+ } \]

    It looks like there are way more of these!

  • We’ll start out with just the positive rationals \(\Q^+\).

  • Clearly \(|\Q^+| \ge |\N^+|\) since \(\N^+ \subsetneq \Q^+\), and thus \(|\Q^+| \ge |\N|\).

  • But what about finding an onto \(f : \N \to \Q^+\)?
  • How can we enumerate \(\Q^+\)?
    • We can list them in order of \(n + d\)!
    • \(\fragment{\overbrace{\frac{1}{1}}^{n+d=2}, \quad } \; \fragment{\overbrace{\frac{1}{2}, \; \frac{2}{1}}^{n+d=3},} \quad \; \fragment{\overbrace{\frac{3}{1}, \; \frac{2}{2}, \; \frac{1}{3}}^{n+d=4}, \quad} \; \fragment{\overbrace{\frac{4}{1}, \; \frac{3}{2}, \; \frac{2}{3}, \; \frac{1}{4}}^{n+d=5}, \; \quad \cdots}\)
    • This way every positive rational is eventually reached.
1 2 3 4
1 1/1 2/1 3/1 4/1
2 1/2 2/2 3/2 4/2
3 1/3 2/3 3/3 4/3
4 1/4 2/4 3/4 4/4

\(|\N|\) vs. \(|\Q|\)

  • We’ve now shown the existence of an onto function \(f: \N \to \Q^+\).
  • Therefore \(|\N| \ge |\Q^+|\) (and thus \(|\N| = |\Q^+|\)).
  • What about \(|\Q|\)?
    • We can use \(f\) to construct a new onto function \(g: \N \to \Q\). (Similar to trick we used for \(f: \N \stackrel{\text{onto}}{\to} \Z\).) \[ \begin{aligned} g(0) &= 0, \\ g(1) &= \phantom{-}f(0), \\ g(2) &= -f(0), \\ g(3) &= \phantom{-}f(1), \\ g(4) &= -f(1), \\ g(5) &= \phantom{-}f(2), \\ g(6) &= -f(2), \\ \vdots & \\ \end{aligned} \quad \quad \fragment{ g(n) = \begin{cases} 0 & \text{ if } n = 0 \\ f\left(\frac{n+1}{2}\right) & \text{ if } n \text{ is odd} \\ -f\left(\frac{n}{2}\right) & \text{ if } n \text{ is even} \end{cases}} \]
  • Since \(f\) maps onto every positive rational, \(g\) maps onto every rational number.
  • Hence \(|\N| \ge |\Q|\) (thus \(|\N| = |\Q|\)).

\(|\N|\) vs. \(|\binary^*|\)

  • We can also compare sizes of sets don’t just contain numbers!
  • For example: let’s compare \(\N\) with the set of all binary strings \(\binary^*\).
  • Recall we can do this by enumerating the binary strings.
  • We’ve already seen this enumeration! It’s the length-lexicographic ordering: \[ \emptystring, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, 0000, 0001, \ldots \]
  • We conclude that \(|\N| \ge |\binary^*|\).
  • The enumeration above actually represents a bijection so in fact \(|\N| = |\binary^*|\).

Did our earlier enumeration of \(\Q\) correspond to a bijection?

  • Yes
  • No

\(|\binary^*|\) vs. {all Turing machines}

  • Let \(T\) be the set of all Turing machines.
  • Each TM can be represented as a binary string, e.g., the bits of the Unicode symbols you type into the TM simulator.
  • Thus \(|\binary^*| \ge |T|\), since there is an onto function \(f: \binary^* \to T\) defined by \(g(x) = M\) if \(x\) encodes a TM (and \(M_0\) for some fixed TM otherwise).
    • Equivalently, there is a 1-1 function \(g:T \to \binary^*\), defined by \(g(M) =\) binary encoding of \(M\), also showing \(|\binary^*| \ge |T|\).
  • Similarly, if \(S\) is any set of “finitely describable” objects (e.g., Python programs, finite graphs, DFAs, Boolean formulas, etc.), then \(|\binary^*| \ge |S|\).
    • If you can encode the objects as binary strings, then they are countable (cardinality at most that of \(\N\)).

\(|\R|\) vs. (open) unit interval \((0, 1)\)

  • Now let’s consider some huge sets:
    • The set of all real numbers \(\R\).
    • The open unit interval \((0, 1) \subsetneq \R\).
  • Clearly \(|(0, 1)| \le |\R|\) since \((0, 1) \subsetneq \R\).
  • Surprisingly, there are the same number of real numbers in \(\R\) and in \((0, 1)\)!
  • We first show the easier fact that \(|(0, 1)| \ge |\R^+|\).
    • What function can we use? One example: \(g(x) = \frac{1}{x} - 1\)
      data/images/decidability/unit_interval_to_positive_reals_func.svg
    • Note that for any \(y \in \R^+\), we can solve the following for \(x \in (0, 1)\): \[ g(x) = y \quad \iff \quad x = \frac{1}{y + 1}. \]

\(|\R|\) vs. (open) unit interval \((0, 1)\)

  • Now let’s consider some huge sets:
    • The set of all real numbers \(\R\).
    • The open unit interval \((0, 1) \subsetneq \R\).
  • Clearly \(|(0, 1)| \le |\R|\) since \((0, 1) \subsetneq \R\).
  • Surprisingly, there are the same number of real numbers in \(\R\) and in \((0, 1)\)!
  • We first show the easier fact that \(|(0, 1)| \ge |\R^+|\).
  • Second, we show that \(|\R^+| \ge |\R|\):
    • What function can we use? One example: \(f(x) = \log(x)\)
      data/images/decidability/positive_reals_to_reals_func.svg
    • Note that for any \(y \in \R\), we can solve the following for \(x \in \R^+\): \[ f(x) = y \quad \iff \quad x = e^y. \]

We conclude that \(|(0, 1)| \ge |\R^+| \ge |\R|\) and so \(|(0, 1)| = |\R|\).

(Open) unit interval \((0, 1)\) vs. \(\{0,1\}^\infty\)

  • \(\{0,1\}^\infty\) is the set of all one-way infinite binary sequences.
  • “Almost” bijection \(f:\{0,1\}^\infty \to (0,1)\): \(\quad f(S) = 0.S\)
    • \(S\) is the binary expansion of a real number in \((0,1)\),
    • For example, \(\frac{17}{32} = 2^{-1} + 2^{-4} = 0.\overbrace{1}^{2^{-1}}00\overbrace{1}^{2^{-4}}0000000000000000 \dots\).
  • Problem: some reals have two binary expansions
    • example above: \(\frac{17}{32} = \begin{array}{cc}0.10010000000000000000\dots&=\\ 0.10001111111111111111\dots&\end{array}\), the so-called dyadic rationals).
    • So \(f\) is not 1-1.
  • \(f\) is onto, so \(|\{0,1\}^\infty| \ge |(0, 1)|\).
  • To see \(|(0, 1)| \ge |\{0,1\}^\infty|\), what’s an onto function \(g:(0,1) \to \{0,1\}^\infty\)?
    • For \(x \in (0,1)\), let \(g(x)\) be a binary expansion of \(x\) (choose the one ends in all 0s if it is a dyadic rational).
  • Thus \(|\{0,1\}^\infty| = |(0, 1)| \fragment{= |\R|.}\)

\(\{0,1\}^\infty\) vs. \(\mathcal{P}(\N)\)

  • Bijection \(h: \{0,1\}^\infty \to \mathcal{P}(\N)\)? (subsets of \(\N\))
  • For \(S \in \{0,1\}^\infty\), define \(h(S) = \setbuild{n \in \N}{\text{the } n^\text{th} \text{ bit of } S \text{ is } 1}\).
  • \(S\) is known as the characteristic sequence of the set \(h(S) \subseteq \N\).
  • For example, \(S = 0 0 \overbrace{1}^2 \overbrace{1}^3 0 \overbrace{1}^5 0 \overbrace{1}^7 0 0 0 \overbrace{1}^{11} 0 \overbrace{1}^{13} 0 0 0 \overbrace{1}^{17} 0 \dots\) is the characteristic sequence of the prime numbers.
  • Thus \(|\{0,1\}^\infty| = |\mathcal{P}(\N)|\).
  • Recall we showed \(|\N| = |\binary^*|\) earlier, so \(|\{0,1\}^\infty| = |\mathcal{P}(\{0,1\}^*)|\) also.