Processing math: 0%

Lecture 6: relations

Countability

We started with a coda on countability.

is countable

Claim: the set of rational numbers (i.e. fractions, written ) is countable.

Proof: In fact, we will show that the set of positive rationals, ℚ^+, is countable. The countability of follows without too much more effort.

We can draw a table containing all of the rational numbers:

1 2 3 4 \cdots
1 1/1 2/1 3/1 4/1 \cdots
2 1/2 2/2 3/2 4/2 \cdots
3 1/3 2/3 3/3 4/3 \cdots
\vdots \ddots

Note that every positive rational number is contained at least once in the table.

Now we can define a surjection f from to ℚ^+ by tracing each lower-left to upper-right diagonal, and listing the elements as we pass them. For example, the first few rational numbers would be:

n f(n)
0 1/1
1 1/2
2 2/1
3 1/3
4 2/2
5 3/1
6 1/4

For any rational number y, y appears somewhere in the table, which means it lies on some diagonal, which means that eventually it will be output by f. In other words, there exists some n with f(n) = y; so f is surjective. Therefore |ℕ| \geq |ℚ|, so ℚ^+ is countable.

Note: this technique is (confusingly) not called diagonalization. Diagonalization refers to the technique we use in the following proof:

is uncountable

Claim: The set of real numbers is uncountable.

Proof: in fact, we will show that the set of real numbers between 0 and 1 is uncountable; since this is a subset of , the uncountability of follows immediately.

We proceed by contradiction. Suppose that were countable. Then there would exist a surjection f : ℕ → ℝ. We could expand the digits of f in a table; for example, if f(0) = 0, f(1) = 1/2, f(2) = π - 3, f(3) = φ - 1, then the table would look as follows:

n f(n) digits of f(n)
0 0 0.00000\cdots
1 1/2 0.50000\cdots
2 π - 3 0.14159\cdots
3 φ - 1 0.61803\cdots

Given such a table, we can form a real number x_D that is not in the table by changing the ith digit of the ith number; perhaps by adding 5 (wrapping around, so that 7 + 5 = 2, for example).

In the example, x_D = 0.5565\cdots.

Now x_D cannot be in the table, because x_D differs from f(i) in the ith digit. But this contradicts the fact that f is surjective, thus completing the proof.

Note: this technique is called diagonalization.

What good is countability?

Relations

Definitions

Definition: a relation on the sets A_1, A_2, \dots, A_n is a subset of A_1 \times A_2 \times \cdots \times A_n. In other words, it is a set of n-tuples. A binary relation on A is a subset of A \times A.

Notation: if R is a binary relation on A, and x and y are in A, then "x R y" means (x,y) \in R.

Examples

Properties

If R is a binary relation on a set A, then R is

These properties describe the properties people implicitly assume when working with equality. They are important to check whenever redefining equality. For example, many programming languages let you define an "equals" function (__eq__ in python, .equals() in Java, (=) in OCaml); if you ever do this, you should check that your definition has these properties. Otherwise, your program will almost certainly develop bugs, because you will use the properties without thinking about them. It is actually very hard to get this right when redefining equals in the presence of subclasses.

Here are some examples of the properties; you should check these for yourself: