Episode 8's submarine moved by the same whole number every turn. Now let its position on turn be given by any program at all, one charge a turn, and a miss still tells you nothing.
Can you still guarantee to sink it?
Call a submarine describable if there is a program that, given a turn , always finishes and prints where the submarine is. A program that runs for ever on some turn does not say where anything is, so it does not describe a submarine.
Both halves are the same move, aimed in opposite directions. Neither can be checked by running every program. What a script can check is a real language small enough to run exhaustively, and that is the worked case below.
This is the film's first route. Write out every string of characters, shortest first and then alphabetically, and cross out the ones that do not describe a submarine. Number what is left: . Make a table with one row per program and one column per turn, and drop on its diagonal:
If the submarine follows , then on turn the charge is at , and so is the submarine. This is proof three of episode 8 again: any family that can be put in a list is caught by its diagonal.
The catch is in the crossing out. It has two parts. Strings that are not programs at all can be crossed out by a parser, mechanically. Programs that run for ever on some turn cannot. In general, no program can tell whether another will finish: that is Turing's halting problem, from 1936. So the list the hunter needs exists, since every string either describes a submarine or does not, but nobody has been shown a way to write it out. Half two says nobody ever will.
This is the film's second route, stated for any hunter. Suppose some program , given , prints the turn- drop. Then
is a program too: run , and add one. It always finishes, because does, so is a describable submarine. On every turn it is one place above the charge, so never sinks it. No program is a winning hunter.
The film runs the same move on its own list. If were program number , then on turn it would have to satisfy . So is on no list, and the diagonal hunter is not a program. The narration calls "three lines of code". That is true only if the hunter is code, and that is exactly what the argument rules out. The hunter exists, but you cannot write it down.
Put the two halves together. If some program could write out the list of programs that always finish, the diagonal would be a program too: to find , list as far as the -th and run it on . Half one makes that a winning hunter, and half two says no program is one. So no program can list exactly the programs that always finish. This cousin of the halting problem falls straight out of the submarine, and it is why the crossing out above cannot be done mechanically.
The film makes the list for real in a toy language. A program is an arithmetic expression in , built from digits (with no leading zeros), , , , and brackets, with unary minus: 16 characters in all. Every expression in it finishes, so here the crossing out is mechanical, and nothing about halting is being dodged.
Up to 4 characters there are 69,904 strings. 18,266 of them are programs and 51,638 are crossed out. The list starts with the ten constant submarines, and itself is program 11. Many programs describe the same submarine, such as , , and . The 18,266 programs describe 11,415 different paths.
The film's submarine moves . On the list it is program 1,375, so on turn 1,375 the charge is where it is, at 1,890,625. That position has 7 digits, and no earlier charge lands on it. The film's second submarine, , has five characters and is program 204,999, sunk at −42,024,589,992. Guaranteed is not the same as soon.
Not every submarine waits for its own turn. A charge aimed at an earlier program can land on it by luck, and 7,008 of the 18,266 (38%) are sunk before their own turn that way.
Here the hunter is a program, just not one in the language. The script that checks this page computes the toy hunter, so it is plainly a program. It is not a toy program, though, and the reason is half two in miniature. The toy language is closed under adding one: if is a toy program, so is . A toy hunter would therefore be dodged by a toy submarine. The hunter has to sit outside what it hunts. Here it sits one step outside, in a language that can read a string and run it.
The jumping submarine is not in the toy language. The film's third opening submarine is at on most turns but at on every third one. Every toy program is a polynomial in , and one that agrees with on infinitely many turns is , which is not on turn 3. The film keeps it in so that "any program" is never quietly narrowed to "any arithmetic expression".
Type a submarine of up to 5 characters, in the toy language. The lab writes out the list exactly as above, finds the submarine's place on it, and runs the diagonal hunter against it.
| Submarine | Place | At | Sunk on |
|---|---|---|---|
0 | 1 | 0 | its own turn |
t | 11 | 11 | its own turn |
-t | 112 | −112 | its own turn |
t*t | 1,375 | 1,890,625 | its own turn |
9-t*t | 204,999 | −42,024,589,992 | its own turn |
t*t*t | 210,499 | 9,327,174,694,881,499 | its own turn |
2*t+1 | 63,158 | 126,317 | turn 39,020, by luck |
Counting by hand stops at five characters, but the grammar can be counted without listing. Each string parses in only one way, so counting parse trees counts programs. The count agrees with the brute-force list at every length up to 5:
| Length | Strings | Programs | Share |
|---|---|---|---|
| 1 | 11 | 68.8% | |
| 2 | 101 | 39.5% | |
| 3 | 1,375 | 33.6% | |
| 4 | 16,779 | 25.6% | |
| 5 | 210,862 | 20.1% | |
| 6 | 2,628,964 | 15.7% | |
| 7 | 32,859,455 | 12.2% | |
| 8 | 410,515,935 | 9.6% | |
| 9 | 5,130,624,926 | 7.5% | |
| 10 | 64,131,247,112 | 5.8% |
Programs become a smaller share of the strings as the length grows, but there is no last one. The list never ends, and every program is somewhere on it.
The film's ladder has four rungs, and two facts decide all of them.
The last rung, any path at all, needs neither. No hunter of any kind, program or not, catches every path: whatever drops a hunter makes, the path dodges them all. The film says that there the list runs out. That is true, as the last section shows, but the reason no hunter works is this one line.
The film's table matches families of numbers with families of submarines:
Each family of numbers on the left of the first three rows can be listed: the ratios, the roots of whole-number polynomials, and Turing's computable numbers from 1936, which include and . The real numbers cannot be listed, so almost every real number is on none of these lists. Being irrational was never a property of a number on its own. It means not being a ratio of whole numbers, and being uncomputable means not being on the list of programs. A speed of escapes episode 8's family and is caught by a longer list, as episode 8's page shows.
More charges. With two charges a turn, or a hundred, the hunter is still beaten if it is a program: put the evader one above the highest charge.
Tossing coins. A hunter that chooses its drops at random cannot be sure of every path either. Its turn- drop is a random whole number, and some position has a chance of at most of being chosen. A path through such positions is hit with chance at most in total, and can be as small as you like. Whether a coin-tossing program can be sure, with probability one, of every describable submarine is a subtler question that this page does not take up.
A submarine that watches. If the submarine sees each charge before it moves, it just moves away, as in episode 8. Everything here assumes the path is fixed before the hunt begins.
Every describable submarine is described by some string, so they can be listed. All the paths together cannot be listed. Given any list of paths , the path is on it nowhere. That is the same move a third time, and it is Cantor's diagonal argument from 1891.
So the describable submarines are a sliver of the possible ones. Make "almost every" precise by letting the submarine step or each turn on the toss of a fair coin. Each single path then has probability 0, since its first steps have probability . A list of probability-0 events has probability 0 together. So with probability 1 the submarine's path is not describable. That is a theorem, not something a script can check, and it does not mean such a submarine is never caught: any one path is caught by the hunter that follows it. It means no list of descriptions ever holds it.
scripts/deep.mjs reads the film's deep.json and rebuilds the toy language's list from scratch: the counts, the film's sieve of the first 48 strings, the first 9 rows of the table, the window that ends on , and 's place, catch and path. Any disagreement stops the build. Then it checks the rest of what the page says about the toy language.
What is not checked. Everything about all programs: that the programs which always finish cannot be listed by a program, Turing's halting problem, and that almost every path is undescribable. These are theorems, and the proofs above are complete. The toy language is a stand-in in which the finite cases can be run, and the film is careful to call it that.
Program 11, after the ten constants 0 to 9. On turns 1 to 10 the charges go on the constants' positions, 0 to 9, which is one behind every time. Turn 11 sinks it at 11.
Let be one more than the higher of the two turn- charges. It is a program that always finishes, so it is a describable submarine, and it is above both charges on every turn.
Because whatever it does, it is a program that prints one drop a turn, so half two applies: its drops plus one are a describable submarine it never hits. Running programs side by side, called dovetailing, does let one program eventually see every answer that ever comes back. What it cannot do is know which programs will never answer, and the hunter would need to know that to drop on time.