Knaph

What a Machine Can Decide18 of 243 min read

The Diagonal Trick

Write a list. The first item is an endless row of 0s and 1s. So is the second, and the third, and on without end. A friend says: whatever list you write, I can make a row that is not on it, and I do not need to see the whole list. How can that be? That is the question of this lesson.

An endless list of endless rows

An endless row is a string of 0s and 1s that never ends, like 0 1 0 0 1 .... A list of them has a first row, a second row, a third row, and so on, one for each counting number (see natural numbers). Here are the first five rows of some list.

A list of five endless rows of 0s and 1s, numbered 1 to 5, each with three dots at the end. Row 1 is 0 1 0 0 1, row 2 is 1 1 0 1 0, row 3 is 0 0 0 1 1, row 4 is 1 0 1 1 0, row 5 is 1 1 0 0 0.

Walk the diagonal and flip

Now build a new row. Look at place 1 of row 1: it is 0. Look at place 2 of row 2: it is 1. Place 3 of row 3: 0. Place 4 of row 4: 1. Place 5 of row 5: 0. These places run down a diagonal. Flip each digit: 0 becomes 1, and 1 becomes 0. The new row starts 1 0 1 0 1, and goes on in the same way down the whole list.

The same five rows, with the diagonal digits circled: 0, 1, 0, 1, 0. Below the list is the new row 1 0 1 0 1, each digit the flip of the circled one above it.

Is the new row on the list? It is not row 1: at place 1 it has 1, and row 1 has 0. It is not row 2: at place 2 it has 0, and row 2 has 1. In general, it differs from row n at place n. So it is not row n, for any n. The list misses it. And the list was any list we liked. So no list of endless rows holds them all.

What it shows, and where it returns

Georg Cantor found this in 1891. Counting numbers can be put in a list, and so can the even numbers. But the endless rows of 0s and 1s cannot. Some endless collections are bigger than the counting numbers. Be careful: this does not say every endless collection is bigger. It says this one is.

The trick is more than a fact about rows. Take everything on a list, walk the diagonal, change each item. It returns three times later in this course: in a program that no one can write, in a set that cannot exist, and in a sentence about its own proof.

A box labelled the diagonal trick, with three arrows to three boxes: a program that cannot exist, a set that cannot exist, and a sentence that says it cannot be proved.

Careful

The trick shows that this collection cannot be listed. It does not say every endless collection is too big to list.

Try it at home

  1. Write four rows of four digits. Walk the diagonal, flip it, and write the new row. Check it differs from each row.
  2. Change one row of your list, but not the diagonal digit. Does the new row change?
  3. Write the counting numbers 1, 2, 3 ... next to the even numbers 2, 4, 6 ... Can you pair each with one? Why is that a list?

Words to know

  • endless row - a string of 0s and 1s that never ends
  • diagonal - place 1 of row 1, place 2 of row 2, place 3 of row 3, and so on
  • flip - change 0 to 1 and 1 to 0

Big idea

Walk the diagonal and flip each digit: the new row differs from every row on the list, so no list holds all endless rows.

Test your understanding

Sign in to test your understanding of this lesson and track your progress.