Discussion 6A

Cardinality

For two sets AA and BB, A=B|A| = |B| if and only if there exists a bijection between AA and BB.

Examples

  • The set {1,a"}\{ 1, ``a" \} has the same cardinality as the set {f",g"}\{ ``f", ``g" \}
  • The set of natural numbers N\mathbb{N} has the same cardinality as the set of even numbers 2N={0,2,4,}2 \mathbb{N} = \{ 0, 2, 4, \cdots \}
  • The set of natural numbers N\mathbb{N} has the same cardinality as the set of positive integers {1,2,}\{ 1, 2, \cdots \}
  • The set of natural numbers N\mathbb{N} has the same cardinality as the set of integers Z\mathbb{Z}
  • The set [0,1)[0, 1) has the same cardinality as the set [1,2)[1, 2)

You can demonstrate that a bijection exists/that A=B|A| = |B| by 
  • finding a function f:ABf : A \to B for which an inverse f1:BAf^{-1} : B \to A exists
  • showing both AB|A| \leq |B| and AB|A| \geq |B| (injection and surjection)

Countability

A set is countable if its cardinality is less than or equal to that of the natural numbers.
  • Sets with a finite number of elements are countable
  • Sets that are bijective with N\mathbb{N} are countably infinite
If the elements of a set can be listed or enumerated such that any element in the set will appear eventually in the list, then the set is countable.

Cartesian Product

The Cartesian product of two sets AA and BB is the set of tuples containing elements from AA and BB, A×B={(a,b)aAbB}A \times B = \{ (a, b) | a \in A \land b \in B \}.
  • If AA and BB are countable, then A×BA \times B is countable.
  • This is why the set of rational numbers is countable

Cantor’s Diagonalization

The set [0,1)[0, 1) is uncountable.
Proof
Suppose it is countable. Then we can list all the numbers
0
0.1343592…
1
0.1872882…
2
0.4921423…
With this list, it turns out there are some real numbers missing. We can construct one, digit by digit. To make it different from the first number,  0.1343592...0.1343592 ..., we pick a different tenths digit, such as 22. To make it different from the second number, 0.1872882...0.1872882..., we pick a different hundredths digit, such as 99. Continuing down, we construct a real number that is not included in the list, which means we’ve reached a contradiction.
So the set [0,1)[0, 1) is uncountable, and R\mathbb{R} contains [0,1)[0, 1) so it is uncountable as well.

The Halting Problem

No program can determine whether another program will halt or loop forever.
The program TestHalt(P, x) = Yes if P halts for input x, No otherwise does not exist.

Proof

Suppose TestHalt(P, x) exists. Then we can define the program
Turing(P):
    if TestHalt(P, P) = Yes
        loop forever
    else
        exit
Then the behavior of Turing(P) is to loop forever if P called on input P halts, and to exit if P called on input P loops.
It turns out that calling Turing(Turing) leads to a contradiction. It neither halts nor loops forever.
  1. Suppose it loops forever. Then that means the first branch must have been taken in the control flow (if TestHalt(P, P) = Yes). This means TestHalt(Turing, Turing) returns Yes, so Turing halts on input Turing. Contradiction
  1. Suppose it halts. Then that means the second branch must have been taken (if TestHalt(P, P) does not equal Yes). This means TestHalt(Turing, Turing) returns No, meaning Turing loops forever on input Turing. Contradiction

Reductions

A problem AA reduces to problem BB if a solution to BB could be used to solve AA.
If AA reduces to BB then BB is at least as hard as AA, i.e. AA could not be solved by the solution to an easier problem; otherwise AA would actually be easier to solve.