{"version":1,"lectureId":"01M14TXEZX293E70GEK3H8CACX","attempt":0,"publication":{"slug":"halting-problem-undecidability","title":"The Halting Problem Is Undecidable","subject":"computer-science","summary":"No program can decide whether an arbitrary program halts, and this lecture builds that result until it feels forced rather than clever. We warm up with Cantor's diagonal argument on the real numbers, so the shape of the technique is familiar before it matters. Then we lay out the infinite table of programs against inputs, assume a halting decider fills in every cell, and build the contrary program that consults the decider and deliberately does the opposite. The contradiction lands on the diagonal cell where it has to. We then separate undecidability from mere expense, using a bounded halting question and an open problem about a three line program, and close by reducing the halting problem to totality, so that the technique is visibly reusable rather than a single trick.","metaDescription":"Cantor's diagonal, the table of programs against inputs, and the contrary program that proves no halting decider can exist.","transcript":"Here is a claim that ought to sound impossible. There is a question about computer programs, a completely precise question with a yes or no answer, that no computer program can answer. Not a slow one. Not one with more memory than any machine ever built. None. The question is this one. You are handed the text of a program P, and an input x. Does P eventually stop when you run it on x, or does it run forever? Call a program that answers that H. H always returns. It never runs forever itself, and it never says maybe. For every program and every input it hands back halts or loops, and it is right. The theorem we are heading for is that H does not exist. I want that to feel forced rather than clever, so we are going to practise the move first on something else. Something with no programs in it at all. The real numbers. Here is a list of real numbers between zero and one, written out as decimals. I have drawn four rows; you should imagine infinitely many. And here is the supposition we are going to break. This list is complete. Now I am going to build a number that is not on this list, and I am going to build it out of the list itself. Take the first digit of the first number. It is a one. Take the second digit of the second number, and that is a three. The third digit of the third number is a seven. The fourth digit of the fourth is a zero. Those four entries lie along the diagonal of the table, and the diagonal is where the whole argument lives. The rule for the new number is this. Take each diagonal digit and add one to it. If a diagonal digit happens to be a nine, write a one instead, so that we never finish with a tail of nines or a tail of zeros. One becomes two. Three becomes four. Seven becomes eight. And zero becomes one. Call the result d. So d is zero point two four eight one, and it carries on forever, one fresh digit for every row of the list. Now the only question that matters. Is d on the list? It cannot be the first number, because d was built to differ from the first number in the first decimal place. Two, not one. It cannot be the second number either, because they differ in the second place. Four against three. And not the third, and not the fourth, for exactly the same reason. And for any row number n at all, d differs from row n in the n-th decimal place, because that is precisely what the rule was built to do. So d is a real number between zero and one, missing from a list that was supposed to contain every real number between zero and one. That is a contradiction, so the supposition was wrong. No list of real numbers can be complete. There are strictly more reals than there are rows to put them in. Strip that argument down to its bones, because we are about to run it again on something completely different. Step one, assume a complete table, with one row for every object. Step two, read the entries down the diagonal. Step three, build a new object that disagrees with row n at position n, for every n at once. Step four, notice that this new object cannot be any row at all, so the table was never complete. The diagonal is doing all of the work there. It is the one place where a single new object can be made to disagree with every row of an infinite table, using just one entry from each row. Start with programs. A program is a finite string of characters, and that is the only fact about programs we are going to need. So write out every finite string, shortest first, alphabetically within each length, and cross out every string that is not a valid program. What survives is a list. P one, P two, P three, P four, and on forever. Every program you will ever write sits on it, at a definite finite position, and nothing sits on it twice. Unlike Cantor's list of reals, this list is not a supposition. We can actually construct it. Inputs are finite strings too, so there is nothing to stop us handing a program the text of another program. Or the text of itself. So along the top I will put that same list again, this time as inputs. That gives us a table. The entry in row i, column j records what program P i does when you run it on the text of P j. It either stops eventually, and I will write a one, or it runs forever, and I will write a zero. Here is a corner of it. Row P one, run on the text of P one, stops, so that entry is a one. Row P one on P two runs forever, so a zero. Fill in the rest of the table the same way. Every cell has an entry. Not an entry we know: an entry. Run P three on its own text and either it stops or it does not, and that is settled, whether or not anybody ever finds out which. The table is completely determined before we ask how to compute it. Now assume the decider exists. H takes a program and an input, and returns the correct entry of this table, in finite time. Feed it a row and a column and it hands you back that cell. Always. That is exactly what decidable means. Not that the answer exists, which we have already agreed it does, but that one single program computes it, for every pair, and finishes. If H exists, this whole infinite table is on tap. Now look at the diagonal. Each of these cells asks what one program does when you run it on a copy of its own text. P one on itself, P two on itself, P three on itself, and so on down. There is nothing paradoxical about that yet. A program is a string, and a string is a perfectly ordinary thing to feed to a program. Compilers do it every day of the week. And now we build the contrary program, exactly the way Cantor built his number. Call it D. D takes one input, a program P, and the first thing it does is ask H whether P halts when you run it on its own text. And then D does the opposite of whatever it hears. If H says P halts on itself, D deliberately drops into an infinite loop. If H says P loops on itself, D stops immediately. D is not exotic. It is a call and a branch, perhaps five lines long. If the decider exists then this program exists too, and there is no sleight of hand anywhere in the construction. So let us fill in D's row. Column one asks what D does on the text of P one. The diagonal entry there is a one, meaning P one halts on itself, so D does the opposite and runs forever. I write a zero. Column two: the diagonal entry is a one again, so D loops, and I write a zero. Column three: another one, so another zero. Column four: the diagonal entry is a zero, P four never stops on its own text, so D halts. And there is the pattern. D's row is the diagonal with every entry flipped. Where the diagonal says one, D says zero, and where it says zero, D says one. D disagrees with the diagonal everywhere, and it does so deliberately. Now the same question Cantor asked. Is D on the list? It has to be. D is a program, and the list contains every program, so D appears on it somewhere. Call its position k. D is P k. That means two things at the same time. D has a row of its own, row k, and that row is the one we have just filled in. And D has a column of its own, column k, because the text of D is a legitimate input like any other. So look at where that row meets that column. Cell k, k. It sits on the diagonal, and it sits in D's row, and it has to answer exactly one question. Does D halt when you run it on a copy of its own text? Suppose the answer is one. D halts on its own text. But D's row was built to disagree with the diagonal, and this cell is on the diagonal, so D's row says zero there. D halts and D does not halt. Suppose instead the answer is zero. Then H reports that D loops on its own text, so D, by its own definition, does the opposite and halts immediately. Which makes the cell a one after all. Again both. And there is no third option. The cell is a one or it is a zero, because the run either stops or it does not, and we have just shown that both are impossible. Cell k, k is not equal to itself. So one of our assumptions is false, and it is worth checking which ones we made. That programs can be listed: true, we constructed the list. That every cell has an entry: true, every run either stops or it does not. That D can be built from H: true, it is a call and a branch. The only thing left is H, so H is what has to go. There is no program that takes an arbitrary program and an arbitrary input and always reports, correctly and in finite time, whether it halts. The halting problem is undecidable. Before we go any further I want to separate two things that get run together constantly. Undecidable does not mean hard. It does not mean expensive, or exponential, or out of reach of current hardware. Compare two questions. Here is the first. Does this program halt within a billion steps? That question is decidable, and the algorithm for it is embarrassing. Simulate a billion steps. If it stopped, say yes. If it is still running, say no. That may take a week. It may take longer than the universe has been going. None of that matters here. The procedure is finite, it always terminates, and it always gives the correct answer. That question is about cost. Here is the second. Does this program halt, ever? Run the very same procedure. Simulate a billion steps, and it is still running. What do you conclude? Nothing whatsoever. It might stop on the next step. There is no number of steps at which silence turns into an answer. Simulation buys you exactly one thing. If the program halts, you will eventually find out. If it does not, you wait forever, and waiting forever is not an algorithm. Here is what that feels like from the inside. This program takes a whole number and repeats one rule. If the number is even, halve it. If it is odd, triple it and add one. Stop when you reach one. Start it at twenty seven and follow the value along. It wanders up and down for a hundred and eleven steps, climbing above nine thousand on the way, and then it falls to one and stops. Now the question. Is there a starting number for which this program never stops? Nobody knows. It has been checked for every start below two to the sixty eight, and checking is not proving. And notice how little our theorem actually claims. It does not say we cannot analyse programs. Compilers prove termination of particular loops all day long. It says no single procedure works for every program and every input, and one bad case is enough to sink it. So keep the two ideas apart. Complexity asks how long a procedure takes. Computability asks whether a procedure exists at all. Our proof never mentioned time, or memory, or the speed of the machine. Give H a faster processor, and D still contradicts itself. Give it a thousand years and unlimited memory, and D still contradicts itself. The obstruction is logical, not economic. One theorem on its own is a curiosity. What makes this a technique is that you only ever have to run the diagonal once. Everything after it arrives by reduction, and I want to do one so that you can see the shape of it. Here is a second question. Given a machine M, does M halt on every input? Not on one particular input. On all of them. That is called the totality problem, and it is the question a compiler would love to answer about your loops. It looks harder than halting rather than easier, since it asks about infinitely many runs at once. Suppose all the same that it is decidable. So there is a program T which takes a machine and always tells you, correctly and in finite time, whether it halts on everything. Watch what we can do with T. Take any program P and any input x, the pair we would like to answer the halting question about. Out of those two pieces we build a new machine, and here is the machine. It takes an input y, throws y away without looking at it, and runs P on x. That is the whole of it. Building the thing is pure text manipulation: you are pasting P and x into a template, and that always finishes. So what does this machine do? Because it ignores its input, it behaves identically on every input, which leaves only two cases, and they are exactly the two cases we care about. If P halts on x, then M halts on y, whatever y happens to be. So M halts on every input, which is to say M is total. If P runs forever on x, then M runs forever on every input, so M halts on nothing at all. So hand M to the totality decider. If T says yes, then P halts on x. If T says no, then P does not halt on x. Either way you have a correct answer to the halting question, in finite time. Now put the two pieces inside one box. That box takes a program and an input, builds M, asks T, and reports whether the program halts. Correctly, always, in finite time. That box is H. And we spent the last ten minutes proving that H cannot exist. So the assumption that manufactured it is the thing that is false. There is no totality decider, and the totality problem is undecidable too. Notice what we did not have to do there. We did not diagonalise again. We took the one impossible object we already had, and showed that a totality decider would manufacture it, so the totality decider goes the same way the first one went. That is a reduction, and it is the standard move. Does this machine ever print the word hello? Do these two programs compute the same function? Is there any input at all that this machine accepts? Same argument, every time. Almost every interesting question about what a program does, as opposed to what its text looks like, turns out to be undecidable. And all of it traces back to one table, one flipped row, and one cell that cannot decide what it is.","watch":{"version":1,"scenes":[{"title":"A List That Cannot Be Complete","start":0,"end":231.28431249999997,"objects":{"card":"a Title that says \"Theory of Computation — The Halting Problem Is Undecidable\"","cells":"a Math [text] that says \"$1$\" drawn in sheet","cells_10":"a Math [text] that says \"$3$\" drawn in sheet","cells_11":"a Math [text] that says \"$7$\" drawn in sheet","cells_12":"a Math [text] that says \"$0$\" drawn in sheet","cells_13":"a Math [text] that says \"$7$\" drawn in sheet","cells_14":"a Math [text] that says \"$1$\" drawn in sheet","cells_15":"a Math [text] that says \"$0$\" drawn in sheet","cells_16":"a Math [text] that says \"$5$\" drawn in sheet","cells_17":"a Math [text] that says \"$0$\" drawn in sheet","cells_18":"a Math [text] that says \"$0$\" drawn in sheet","cells_19":"a Math [text] that says \"$0$\" drawn in sheet","cells_2":"a Math [text] that says \"$4$\" drawn in sheet","cells_20":"a Math [text] that says \"$0$\" drawn in sheet","cells_3":"a Math [text] that says \"$1$\" drawn in sheet","cells_4":"a Math [text] that says \"$5$\" drawn in sheet","cells_5":"a Math [text] that says \"$9$\" drawn in sheet","cells_6":"a Math [text] that says \"$3$\" drawn in sheet","cells_7":"a Math [text] that says \"$3$\" drawn in sheet","cells_8":"a Math [text] that says \"$3$\" drawn in sheet","cells_9":"a Math [text] that says \"$3$\" drawn in sheet","claim":"a Text [text] that says \"Every real number between 0 and 1 is somewhere on this list.\"","decider":"a Math [text] that says \"$H(P, x) = upright(\"halts\") quad upright(\"or\") quad upright(\"loops\")$\"","divider":"a Line [gray] drawn in sheet (start=(0.7, 1.55), end=(7.8, 1.55), dashed=True)","guide":"a Line [yellow] drawn in sheet (start=(2.55, 5.85), end=(5.95, 2.45), dashed=True)","head_check":"a Heading that says \"Is the New Number on the List?\"","head_list":"a Heading that says \"Suppose the List Is Complete\"","head_plan":"a Heading that says \"The Question We Are Asking\"","head_shape":"a Heading that says \"The Shape of the Argument\"","m1":"a Math [text] that says \"$d eq.not r_1$\"","m2":"a Math [text] that says \"$d eq.not r_2$\"","m3":"a Math [text] that says \"$d eq.not r_n quad upright(\"for every \") n$\"","more_rows":"a Math [gray] that says \"$dots$\" drawn in sheet","new_cells":"a Math [red] that says \"$2$\" drawn in sheet","new_cells_2":"a Math [red] that says \"$4$\" drawn in sheet","new_cells_3":"a Math [red] that says \"$8$\" drawn in sheet","new_cells_4":"a Math [red] that says \"$1$\" drawn in sheet","new_label":"a Math [red] that says \"$d$\" drawn in sheet","new_point":"a Math [red] that says \"$0.$\" drawn in sheet","new_tail":"a Math [red] that says \"$dots$\" drawn in sheet","plan":"a Panel that says \"No program computes $H$. Not a slow one, not a clever one, not one with a bigger machine underneath it. None at all.\"","row_labels":"a Math [gray] that says \"$r_1$\" drawn in sheet","row_labels_2":"a Math [gray] that says \"$r_2$\" drawn in sheet","row_labels_3":"a Math [gray] that says \"$r_3$\" drawn in sheet","row_labels_4":"a Math [gray] that says \"$r_4$\" drawn in sheet","row_points":"a Math [text] that says \"$0.$\" drawn in sheet","row_points_2":"a Math [text] that says \"$0.$\" drawn in sheet","row_points_3":"a Math [text] that says \"$0.$\" drawn in sheet","row_points_4":"a Math [text] that says \"$0.$\" drawn in sheet","row_tails":"a Math [gray] that says \"$dots$\" drawn in sheet","row_tails_2":"a Math [gray] that says \"$dots$\" drawn in sheet","row_tails_3":"a Math [gray] that says \"$dots$\" drawn in sheet","row_tails_4":"a Math [gray] that says \"$dots$\" drawn in sheet","rule":"a Math [text] that says \"$d_n = r_(n n) + 1, quad 9 arrow.r 1$\"","sheet":"a Figure (x_range=(0.4, 8.2), y_range=(0.4, 6.2), aspect=(7.8, 5.8))","steps":"a Block [text] that says \"Assume a complete table, one row per object. Read the entries down the diagonal. Build a new object that disagrees with row $n$ at position $n$. The new object is on no row, so the table was never complete.\""},"beats":[{"start":0,"say":"Here is a claim that ought to sound impossible. There is a question about computer programs, a completely precise question with a yes or no answer, that no computer program can answer. Not a slow one. Not one with more memory than any machine ever built. None.","live":[],"does":[[0,"card is shown on the screen, written out."],[1.5,"card: enter:write-left-to-right."],[17.2055,"card is hidden from the screen — left the board."]]},{"start":18.4055,"say":"The question is this one. You are handed the text of a program P, and an input x. Does P eventually stop when you run it on x, or does it run forever? Call a program that answers that H.","live":null,"does":[[18.4055,"head_plan is shown on the screen, written out."],[30.561,"decider is shown on the screen, written out."]]},{"start":32.09,"say":"H always returns. It never runs forever itself, and it never says maybe. For every program and every input it hands back halts or loops, and it is right. The theorem we are heading for is that H does not exist.","live":["decider","head_plan"],"does":[[41.32,"decider (the \"upright(\"halts\")\" part) is emphasized."],[42.121,"decider (the \"upright(\"halts\")\" part) is no longer emphasized."],[42.121,"decider (the \"upright(\"loops\")\" part) is emphasized."],[45.291000000000004,"plan is shown on the screen, written out."],[47.48500000000001,"decider (the \"upright(\"loops\")\" part) is no longer emphasized."]]},{"start":49.060500000000005,"say":"I want that to feel forced rather than clever, so we are going to practise the move first on something else. Something with no programs in it at all. The real numbers.","live":["decider","plan","head_plan"],"does":[[50.291000000000004,"plan (the \"None at all\" part) is emphasized."],[58.859,"plan (the \"None at all\" part) is no longer emphasized."],[59.776500000000006,"decider is hidden from the screen — left the board."],[59.776500000000006,"head_plan is hidden from the screen — left the board."],[59.776500000000006,"plan is hidden from the screen — left the board."]]},{"start":60.9765,"say":"Here is a list of real numbers between zero and one, written out as decimals. I have drawn four rows; you should imagine infinitely many. And here is the supposition we are going to break. This list is complete.","live":[],"does":[[60.9765,"head_list is shown on the screen, written out."],[60.9765,"sheet is shown on the screen, written out."],[64.79599999999999,"row_labels is shown on the screen, written out."],[64.79599999999999,"row_points is shown on the screen, written out."],[64.79599999999999,"cells is shown on the screen, written out."],[64.79599999999999,"cells_2 is shown on the screen, written out."],[64.79599999999999,"cells_3 is shown on the screen, written out."],[64.79599999999999,"cells_4 is shown on the screen, written out."],[64.79599999999999,"cells_5 is shown on the screen, written out."],[64.79599999999999,"row_tails is shown on the screen, written out."],[65.14599999999999,"row_labels_2 is shown on the screen, written out."],[65.14599999999999,"row_points_2 is shown on the screen, written out."],[65.14599999999999,"cells_6 is shown on the screen, written out."],[65.14599999999999,"cells_7 is shown on the screen, written out."],[65.14599999999999,"cells_8 is shown on the screen, written out."],[65.14599999999999,"cells_9 is shown on the screen, written out."],[65.14599999999999,"cells_10 is shown on the screen, written out."],[65.14599999999999,"row_tails_2 is shown on the screen, written out."],[65.49599999999998,"row_labels_3 is shown on the screen, written out."],[65.49599999999998,"row_points_3 is shown on the screen, written out."],[65.49599999999998,"cells_11 is shown on the screen, written out."],[65.49599999999998,"cells_12 is shown on the screen, written out."],[65.49599999999998,"cells_13 is shown on the screen, written out."],[65.49599999999998,"cells_14 is shown on the screen, written out."],[65.49599999999998,"cells_15 is shown on the screen, written out."],[65.49599999999998,"row_tails_3 is shown on the screen, written out."],[65.84599999999998,"row_labels_4 is shown on the screen, written out."],[65.84599999999998,"row_points_4 is shown on the screen, written out."],[65.84599999999998,"cells_16 is shown on the screen, written out."],[65.84599999999998,"cells_17 is shown on the screen, written out."],[65.84599999999998,"cells_18 is shown on the screen, written out."],[65.84599999999998,"cells_19 is shown on the screen, written out."],[65.84599999999998,"cells_20 is shown on the screen, written out."],[65.84599999999998,"row_tails_4 is shown on the screen, written out."],[66.19599999999997,"more_rows is shown on the screen, written out."],[74.05000000000001,"sheet moves to a new place on the board."],[74.05000000000001,"claim is shown on the screen, written out."]]},{"start":75.6015,"say":"Now I am going to build a number that is not on this list, and I am going to build it out of the list itself. Take the first digit of the first number. It is a one. Take the second digit of the second number, and that is a three.","live":["claim","sheet","head_list","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows"],"does":[[82.56700000000001,"cells is indicated — a transient flash."],[86.793,"cells_7 is indicated — a transient flash."]]},{"start":90.8645,"say":"The third digit of the third number is a seven. The fourth digit of the fourth is a zero. Those four entries lie along the diagonal of the table, and the diagonal is where the whole argument lives.","live":null,"does":[[91.39900000000002,"cells_13 is indicated — a transient flash."],[94.22000000000003,"cells_19 is indicated — a transient flash."],[98.71300000000002,"guide is shown on the screen, drawn."]]},{"start":103.72500000000001,"say":"The rule for the new number is this. Take each diagonal digit and add one to it. If a diagonal digit happens to be a nine, write a one instead, so that we never finish with a tail of nines or a tail of zeros.","live":["claim","sheet","head_list","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide"],"does":[[104.39800000000001,"rule is shown on the screen, written out."],[104.94400000000002,"divider is shown on the screen, written out."],[104.94400000000002,"new_label is shown on the screen, written out."],[104.94400000000002,"new_point is shown on the screen, written out."]]},{"start":118.024,"say":"One becomes two. Three becomes four. Seven becomes eight. And zero becomes one. Call the result d.","live":["claim","rule","sheet","head_list","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide","divider","new_label","new_point"],"does":[[118.97600000000001,"new_cells is shown on the screen, written out."],[120.88000000000001,"new_cells_2 is shown on the screen, written out."],[122.784,"new_cells_3 is shown on the screen, written out."],[124.096,"new_cells_4 is shown on the screen, written out."]]},{"start":128.121,"say":"So d is zero point two four eight one, and it carries on forever, one fresh digit for every row of the list. Now the only question that matters. Is d on the list?","live":["claim","rule","sheet","head_list","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide","divider","new_label","new_point","new_cells","new_cells_2","new_cells_3","new_cells_4"],"does":[[132.48600000000002,"new_tail is shown on the screen, written out."],[140.4735,"rule moves to a new place on the board."],[140.4735,"claim is hidden from the screen — left the board."],[140.4735,"head_list is hidden from the screen — left the board."]]},{"start":141.0735,"say":"It cannot be the first number, because d was built to differ from the first number in the first decimal place. Two, not one.","live":["rule","sheet","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide","divider","new_label","new_point","new_cells","new_cells_2","new_cells_3","new_cells_4","new_tail"],"does":[[141.0735,"head_check is shown on the screen, written out."],[141.666,"m1 is shown on the screen, written out."],[147.69099999999997,"new_cells is indicated — a transient flash."],[148.58499999999998,"cells is indicated — a transient flash."]]},{"start":149.986,"say":"It cannot be the second number either, because they differ in the second place. Four against three. And not the third, and not the fourth, for exactly the same reason.","live":["rule","sheet","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide","divider","new_label","new_point","new_cells","new_cells_2","new_cells_3","new_cells_4","new_tail","m1","head_check"],"does":[[151.182,"m2 is shown on the screen, written out."],[154.17699999999996,"new_cells_2 is indicated — a transient flash."],[155.01299999999998,"cells_7 is indicated — a transient flash."]]},{"start":160.7565,"say":"And for any row number n at all, d differs from row n in the n-th decimal place, because that is precisely what the rule was built to do. So d is a real number between zero and one, missing from a list that was supposed to contain every real number between zero and one.","live":["rule","sheet","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide","divider","new_label","new_point","new_cells","new_cells_2","new_cells_3","new_cells_4","new_tail","m1","m2","head_check"],"does":[[161.75499999999997,"m3 is shown on the screen, written out."],[167.26899999999998,"rule is indicated — a transient flash."]]},{"start":178.48149999999998,"say":"That is a contradiction, so the supposition was wrong. No list of real numbers can be complete. There are strictly more reals than there are rows to put them in.","live":["rule","sheet","row_labels","row_points","cells","cells_2","cells_3","cells_4","cells_5","row_tails","row_labels_2","row_points_2","cells_6","cells_7","cells_8","cells_9","cells_10","row_tails_2","row_labels_3","row_points_3","cells_11","cells_12","cells_13","cells_14","cells_15","row_tails_3","row_labels_4","row_points_4","cells_16","cells_17","cells_18","cells_19","cells_20","row_tails_4","more_rows","guide","divider","new_label","new_point","new_cells","new_cells_2","new_cells_3","new_cells_4","new_tail","m1","m2","m3","head_check"],"does":[[179.35199999999995,"A box is drawn around m3."],[188.62849999999997,"head_check is hidden from the screen — left the board."],[188.62849999999997,"m1 is hidden from the screen — left the board."],[188.62849999999997,"m2 is hidden from the screen — left the board."],[188.62849999999997,"m3 is hidden from the screen — left the board."],[188.62849999999997,"rule is hidden from the screen — left the board."],[188.62849999999997,"sheet is hidden from the screen — left the board."],[188.62849999999997,"row_labels is hidden from the screen — sheet left the board."],[188.62849999999997,"row_points is hidden from the screen — sheet left the board."],[188.62849999999997,"cells is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_2 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_3 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_4 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_5 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_tails is hidden from the screen — sheet left the board."],[188.62849999999997,"row_labels_2 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_points_2 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_6 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_7 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_8 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_9 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_10 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_tails_2 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_labels_3 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_points_3 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_11 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_12 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_13 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_14 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_15 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_tails_3 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_labels_4 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_points_4 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_16 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_17 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_18 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_19 is hidden from the screen — sheet left the board."],[188.62849999999997,"cells_20 is hidden from the screen — sheet left the board."],[188.62849999999997,"row_tails_4 is hidden from the screen — sheet left the board."],[188.62849999999997,"more_rows is hidden from the screen — sheet left the board."],[188.62849999999997,"guide is hidden from the screen — sheet left the board."],[188.62849999999997,"divider is hidden from the screen — sheet left the board."],[188.62849999999997,"new_label is hidden from the screen — sheet left the board."],[188.62849999999997,"new_point is hidden from the screen — sheet left the board."],[188.62849999999997,"new_cells is hidden from the screen — sheet left the board."],[188.62849999999997,"new_cells_2 is hidden from the screen — sheet left the board."],[188.62849999999997,"new_cells_3 is hidden from the screen — sheet left the board."],[188.62849999999997,"new_cells_4 is hidden from the screen — sheet left the board."],[188.62849999999997,"new_tail is hidden from the screen — sheet left the board."]]},{"start":189.8285,"say":"Strip that argument down to its bones, because we are about to run it again on something completely different. Step one, assume a complete table, with one row for every object. Step two, read the entries down the diagonal.","live":[],"does":[[189.8285,"head_shape is shown on the screen, written out."],[191.45399999999998,"steps is shown on the screen, written out."],[196.64299999999997,"steps (the \"Assume\" part) is emphasized."],[201.78599999999997,"steps (the \"Assume\" part) is no longer emphasized."],[201.78599999999997,"steps (the \"Read\" part) is emphasized."]]},{"start":205.1495,"say":"Step three, build a new object that disagrees with row n at position n, for every n at once. Step four, notice that this new object cannot be any row at all, so the table was never complete.","live":["steps","head_shape"],"does":[[205.83399999999997,"steps (the \"Build\" part) is emphasized."],[205.83399999999997,"steps (the \"Read\" part) is no longer emphasized."],[213.19399999999996,"steps (the \"Build\" part) is no longer emphasized."],[213.19399999999996,"steps (the \"The new object\" part) is emphasized."]]},{"start":219.29749999999999,"say":"The diagonal is doing all of the work there. It is the one place where a single new object can be made to disagree with every row of an infinite table, using just one entry from each row.","live":null,"does":[[219.81999999999996,"steps (the \"The new object\" part) is no longer emphasized."],[219.81999999999996,"steps (the \"diagonal\" part) is emphasized."],[229.17799999999994,"steps (the \"diagonal\" part) is no longer emphasized."],[230.2426458333333,"head_shape is hidden from the screen — left the board."],[230.2426458333333,"steps is hidden from the screen — left the board."]]}]},{"title":"The Table of Programs","start":231.28431249999997,"end":627.3433333333335,"objects":{"bit_def":"a Math [text] that says \"$1 = upright(\"halts\"), quad 0 = upright(\"loops\")$\"","c1":"a Math [text] that says \"$c(k, k) = 1 quad arrow.r quad D upright(\" loops\")$\"","c2":"a Math [text] that says \"$c(k, k) = 0 quad arrow.r quad D upright(\" halts\")$\"","cell_def":"a Math [text] that says \"$c(i, j) = P_i upright(\" on \") P_j$\"","clash":"a Math [red] that says \"$?$\" drawn in table","col_dots":"a Math [gray] that says \"$dots$\" drawn in table","col_heads":"a Math [gray] that says \"$P_1$\" drawn in table","col_heads_2":"a Math [gray] that says \"$P_2$\" drawn in table","col_heads_3":"a Math [gray] that says \"$P_3$\" drawn in table","col_heads_4":"a Math [gray] that says \"$P_4$\" drawn in table","col_k":"a Math [red] that says \"$P_k$\" drawn in table","d0":"a Math [text] that says \"$D(P): quad upright(\"ask \") H(P, P)$\"","d1":"a Math [text] that says \"$upright(\"halts\") arrow.r D upright(\" loops\")$\"","d2":"a Math [text] that says \"$upright(\"loops\") arrow.r D upright(\" halts\")$\"","d_cells":"a Math [red] that says \"$0$\" drawn in table","d_cells_2":"a Math [red] that says \"$0$\" drawn in table","d_cells_3":"a Math [red] that says \"$0$\" drawn in table","d_cells_4":"a Math [red] that says \"$1$\" drawn in table","d_dots":"a Math [red] that says \"$dots$\" drawn in table","d_row_math":"a Math [text] that says \"$d_j = 1 - c(j, j)$\"","diag_dots":"a Math [gray] that says \"$dots$\" drawn in table","enum":"a Math [text] that says \"$P_1, P_2, P_3, P_4, dots$\"","final":"a Math [text] that says \"$c(k, k) eq.not c(k, k)$\"","grid_cells":"a Math [text] that says \"$1$\" drawn in table","grid_cells_10":"a Math [text] that says \"$0$\" drawn in table","grid_cells_11":"a Math [text] that says \"$1$\" drawn in table","grid_cells_12":"a Math [text] that says \"$1$\" drawn in table","grid_cells_13":"a Math [text] that says \"$1$\" drawn in table","grid_cells_14":"a Math [text] that says \"$0$\" drawn in table","grid_cells_15":"a Math [text] that says \"$0$\" drawn in table","grid_cells_16":"a Math [text] that says \"$0$\" drawn in table","grid_cells_2":"a Math [text] that says \"$0$\" drawn in table","grid_cells_3":"a Math [text] that says \"$1$\" drawn in table","grid_cells_4":"a Math [text] that says \"$1$\" drawn in table","grid_cells_5":"a Math [text] that says \"$1$\" drawn in table","grid_cells_6":"a Math [text] that says \"$1$\" drawn in table","grid_cells_7":"a Math [text] that says \"$0$\" drawn in table","grid_cells_8":"a Math [text] that says \"$0$\" drawn in table","grid_cells_9":"a Math [text] that says \"$0$\" drawn in table","guide":"a Line [yellow] drawn in table (start=(2.8, 6.18), end=(10.6, 0.72), dashed=True)","h_note":"a Panel that says \"Decidable means one program answers every instance, correctly, in finite time.\"","h_sig":"a Math [text] that says \"$H(P_i, P_j) = c(i, j)$\"","head_clash":"a Heading that says \"The Cell That Cannot Decide\"","head_d":"a Heading that says \"The Contrary Program\"","head_h":"a Heading that says \"Assume the Decider Exists\"","head_table":"a Heading that says \"Every Program Is on a List\"","head_theorem":"a Heading that says \"The Halting Problem\"","input_label":"a Math [gray] that says \"$upright(\"input\")$\" drawn in table","k_line":"a Math [text] that says \"$D = P_k quad upright(\"for some \") k$\"","machine_label":"a Math [gray] that says \"$upright(\"machine\")$\" drawn in table","point":"a Point [yellow] drawn in table (location=(6.2, 3.8))","point_2":"a Point [yellow] drawn in table (location=(4.7, 2.75))","row_d":"a Math [red] that says \"$D$\" drawn in table","row_dots":"a Math [gray] that says \"$dots$\" drawn in table","row_labels":"a Math [gray] that says \"$P_1$\" drawn in table","row_labels_2":"a Math [gray] that says \"$P_2$\" drawn in table","row_labels_3":"a Math [gray] that says \"$P_3$\" drawn in table","row_labels_4":"a Math [gray] that says \"$P_4$\" drawn in table","table":"a Figure (x_range=(0.4, 11.4), y_range=(0.3, 7.7), aspect=(11.0, 7.4))","theorem":"a Math [text] that says \"$H upright(\" does not exist\")$\"","theorem_note":"a Panel that says \"No program takes an arbitrary program and an arbitrary input and always reports correctly whether it halts.\""},"beats":[{"start":231.28431249999997,"say":"Start with programs. A program is a finite string of characters, and that is the only fact about programs we are going to need. So write out every finite string, shortest first, alphabetically within each length, and cross out every string that is not a valid program. What survives is a list.","live":[],"does":[[231.28431249999997,"head_table is shown on the screen, written out."],[231.28431249999997,"table is shown on the screen, written out."],[249.98831249999998,"table moves to a new place on the board."],[249.98831249999998,"enum is shown on the screen, written out."]]},{"start":252.29481249999998,"say":"P one, P two, P three, P four, and on forever. Every program you will ever write sits on it, at a definite finite position, and nothing sits on it twice. Unlike Cantor's list of reals, this list is not a supposition. We can actually construct it.","live":["enum","table","head_table"],"does":[[252.64331249999998,"row_labels is shown on the screen, written out."],[253.50231249999996,"row_labels_2 is shown on the screen, written out."],[254.30331249999998,"row_labels_3 is shown on the screen, written out."],[255.04631249999997,"row_labels_4 is shown on the screen, written out."],[256.5443125,"row_dots is shown on the screen, written out."],[261.7803125,"machine_label is shown on the screen, written out."]]},{"start":271.68031249999996,"say":"Inputs are finite strings too, so there is nothing to stop us handing a program the text of another program. Or the text of itself. So along the top I will put that same list again, this time as inputs.","live":["enum","table","head_table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label"],"does":[[272.08631249999996,"input_label is shown on the screen, written out."],[282.3153125,"col_heads is shown on the screen, written out."],[282.49531249999995,"col_heads_2 is shown on the screen, written out."],[282.67531249999996,"col_heads_3 is shown on the screen, written out."],[282.85531249999997,"col_heads_4 is shown on the screen, written out."],[283.0353125,"col_dots is shown on the screen, written out."]]},{"start":287.11781249999996,"say":"That gives us a table. The entry in row i, column j records what program P i does when you run it on the text of P j. It either stops eventually, and I will write a one, or it runs forever, and I will write a zero.","live":["enum","table","head_table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label"],"does":[[289.38231249999995,"cell_def is shown on the screen, written out."],[296.5223125,"bit_def is shown on the screen, written out."]]},{"start":302.5613125,"say":"Here is a corner of it. Row P one, run on the text of P one, stops, so that entry is a one. Row P one on P two runs forever, so a zero. Fill in the rest of the table the same way.","live":["enum","cell_def","bit_def","table","head_table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label"],"does":[[303.18231249999997,"grid_cells is shown on the screen, written out."],[303.2623125,"grid_cells_2 is shown on the screen, written out."],[303.3423125,"grid_cells_3 is shown on the screen, written out."],[303.4223125,"grid_cells_4 is shown on the screen, written out."],[303.50231249999996,"grid_cells_5 is shown on the screen, written out."],[303.5823125,"grid_cells_6 is shown on the screen, written out."],[303.6623125,"grid_cells_7 is shown on the screen, written out."],[303.74231249999997,"grid_cells_8 is shown on the screen, written out."],[303.82231249999995,"grid_cells_9 is shown on the screen, written out."],[303.9023125,"grid_cells_10 is shown on the screen, written out."],[303.9823125,"grid_cells_11 is shown on the screen, written out."],[304.06231249999996,"grid_cells_12 is shown on the screen, written out."],[304.1423125,"grid_cells_13 is shown on the screen, written out."],[304.2223125,"grid_cells_14 is shown on the screen, written out."],[304.30231249999997,"grid_cells_15 is shown on the screen, written out."],[304.3823125,"grid_cells_16 is shown on the screen, written out."],[304.4623125,"diag_dots is shown on the screen, written out."],[307.2583125,"grid_cells is indicated — a transient flash."],[313.1673125,"grid_cells_2 is indicated — a transient flash."]]},{"start":317.25031249999995,"say":"Every cell has an entry. Not an entry we know: an entry. Run P three on its own text and either it stops or it does not, and that is settled, whether or not anybody ever finds out which. The table is completely determined before we ask how to compute it.","live":["enum","cell_def","bit_def","table","head_table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots"],"does":[[322.8113125,"point is shown on the screen, grown."],[324.8113125,"point is hidden from the screen."],[334.5948125,"bit_def is hidden from the screen — left the board."],[334.5948125,"cell_def is hidden from the screen — left the board."],[334.5948125,"enum is hidden from the screen — left the board."],[334.5948125,"head_table is hidden from the screen — left the board."]]},{"start":335.1948125,"say":"Now assume the decider exists. H takes a program and an input, and returns the correct entry of this table, in finite time. Feed it a row and a column and it hands you back that cell. Always.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots"],"does":[[335.1948125,"head_h is shown on the screen, written out."],[338.6553125,"h_sig is shown on the screen, written out."],[348.2913125,"point_2 is shown on the screen, grown."],[350.2913125,"point_2 is hidden from the screen."]]},{"start":351.2943125,"say":"That is exactly what decidable means. Not that the answer exists, which we have already agreed it does, but that one single program computes it, for every pair, and finishes. If H exists, this whole infinite table is on tap.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","h_sig","head_h"],"does":[[353.1753125,"h_note is shown on the screen, written out."]]},{"start":368.90331249999997,"say":"Now look at the diagonal. Each of these cells asks what one program does when you run it on a copy of its own text. P one on itself, P two on itself, P three on itself, and so on down.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","h_sig","h_note","head_h"],"does":[[370.14531250000005,"guide is shown on the screen, drawn."],[377.33231250000006,"grid_cells is indicated — a transient flash."],[378.94631250000003,"grid_cells_6 is indicated — a transient flash."],[380.52531250000004,"grid_cells_11 is indicated — a transient flash."],[382.03431250000006,"grid_cells_16 is indicated — a transient flash."]]},{"start":383.4933125,"say":"There is nothing paradoxical about that yet. A program is a string, and a string is a perfectly ordinary thing to feed to a program. Compilers do it every day of the week.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","h_sig","h_note","head_h","guide"],"does":[[388.1373125,"guide is indicated — a transient flash."],[395.0918125,"h_note is hidden from the screen — left the board."],[395.0918125,"h_sig is hidden from the screen — left the board."],[395.0918125,"head_h is hidden from the screen — left the board."]]},{"start":396.2918125,"say":"And now we build the contrary program, exactly the way Cantor built his number. Call it D. D takes one input, a program P, and the first thing it does is ask H whether P halts when you run it on its own text.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide"],"does":[[396.2918125,"head_d is shown on the screen, written out."],[407.5303125,"d0 is shown on the screen, written out."]]},{"start":411.8683125,"say":"And then D does the opposite of whatever it hears. If H says P halts on itself, D deliberately drops into an infinite loop. If H says P loops on itself, D stops immediately.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","d0","head_d"],"does":[[420.8543125,"d1 is shown on the screen, written out."],[424.9173125,"d2 is shown on the screen, written out."]]},{"start":427.0963125,"say":"D is not exotic. It is a call and a branch, perhaps five lines long. If the decider exists then this program exists too, and there is no sleight of hand anywhere in the construction.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","d0","d1","d2","head_d"],"does":[[429.9413125,"d0 is indicated — a transient flash."],[430.66031250000003,"d1 is indicated — a transient flash."]]},{"start":441.21581249999997,"say":"So let us fill in D's row. Column one asks what D does on the text of P one. The diagonal entry there is a one, meaning P one halts on itself, so D does the opposite and runs forever. I write a zero.","live":null,"does":[[442.8473125,"row_d is shown on the screen, written out."],[448.1413125,"grid_cells is indicated — a transient flash."],[455.8503125,"d_cells is shown on the screen, written out."]]},{"start":457.3208125,"say":"Column two: the diagonal entry is a one again, so D loops, and I write a zero. Column three: another one, so another zero. Column four: the diagonal entry is a zero, P four never stops on its own text, so D halts.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","d0","d1","d2","head_d","row_d","d_cells"],"does":[[458.0873125,"grid_cells_6 is indicated — a transient flash."],[463.1613125,"d_cells_2 is shown on the screen, written out."],[464.8563125,"grid_cells_11 is indicated — a transient flash."],[466.7253125,"d_cells_3 is shown on the screen, written out."],[468.5943125,"grid_cells_16 is indicated — a transient flash."],[474.2603125,"d_cells_4 is shown on the screen, written out."]]},{"start":475.6613125,"say":"And there is the pattern. D's row is the diagonal with every entry flipped. Where the diagonal says one, D says zero, and where it says zero, D says one. D disagrees with the diagonal everywhere, and it does so deliberately.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","d0","d1","d2","head_d","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4"],"does":[[480.50231249999996,"d_row_math is shown on the screen, written out."],[480.50231249999996,"d_dots is shown on the screen, written out."],[489.2913125,"guide is indicated — a transient flash."],[492.32181249999996,"d0 is hidden from the screen — left the board."],[492.32181249999996,"d1 is hidden from the screen — left the board."],[492.32181249999996,"d2 is hidden from the screen — left the board."],[492.32181249999996,"d_row_math is hidden from the screen — left the board."],[492.32181249999996,"head_d is hidden from the screen — left the board."]]},{"start":493.5218125,"say":"Now the same question Cantor asked. Is D on the list? It has to be. D is a program, and the list contains every program, so D appears on it somewhere. Call its position k. D is P k.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4","d_dots"],"does":[[493.5218125,"head_clash is shown on the screen, written out."],[505.5263125,"k_line is shown on the screen, written out."],[507.3253125,"row_d becomes \"$D = P_k$\"."],[507.3253125,"col_k is shown on the screen, written out."]]},{"start":508.87181250000003,"say":"That means two things at the same time. D has a row of its own, row k, and that row is the one we have just filled in. And D has a column of its own, column k, because the text of D is a legitimate input like any other.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4","d_dots","k_line","head_clash","col_k"],"does":[[512.5583124999999,"row_d is indicated — a transient flash."],[518.8393125,"col_k is indicated — a transient flash."]]},{"start":525.0703125,"say":"So look at where that row meets that column. Cell k, k. It sits on the diagonal, and it sits in D's row, and it has to answer exactly one question. Does D halt when you run it on a copy of its own text?","live":null,"does":[[529.0173125,"clash is shown on the screen, written out."],[535.8903125,"clash is indicated — a transient flash."]]},{"start":541.1343125000001,"say":"Suppose the answer is one. D halts on its own text. But D's row was built to disagree with the diagonal, and this cell is on the diagonal, so D's row says zero there. D halts and D does not halt.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4","d_dots","k_line","head_clash","col_k","clash"],"does":[[541.4823125,"c1 is shown on the screen, written out."]]},{"start":557.3088125,"say":"Suppose instead the answer is zero. Then H reports that D loops on its own text, so D, by its own definition, does the opposite and halts immediately. Which makes the cell a one after all. Again both.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4","d_dots","k_line","c1","head_clash","col_k","clash"],"does":[[557.6393125000001,"c2 is shown on the screen, written out."]]},{"start":573.1878125000001,"say":"And there is no third option. The cell is a one or it is a zero, because the run either stops or it does not, and we have just shown that both are impossible. Cell k, k is not equal to itself.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4","d_dots","k_line","c1","c2","head_clash","col_k","clash"],"does":[[581.5643125000001,"c1 (the \"c(k, k) = 1\" part) is struck through — it is ruled out."],[581.8643125000001,"c2 (the \"c(k, k) = 0\" part) is struck through — it is ruled out."],[585.1513125000001,"final is shown on the screen, written out."]]},{"start":587.4583125000001,"say":"So one of our assumptions is false, and it is worth checking which ones we made. That programs can be listed: true, we constructed the list. That every cell has an entry: true, every run either stops or it does not. That D can be built from H: true, it is a call and a branch.","live":["table","row_labels","row_labels_2","row_labels_3","row_labels_4","row_dots","machine_label","col_heads","col_heads_2","col_heads_3","col_heads_4","col_dots","input_label","grid_cells","grid_cells_2","grid_cells_3","grid_cells_4","grid_cells_5","grid_cells_6","grid_cells_7","grid_cells_8","grid_cells_9","grid_cells_10","grid_cells_11","grid_cells_12","grid_cells_13","grid_cells_14","grid_cells_15","grid_cells_16","diag_dots","guide","row_d","d_cells","d_cells_2","d_cells_3","d_cells_4","d_dots","k_line","c1","c2","final","head_clash","col_k","clash"],"does":[[593.3793125000002,"k_line is indicated — a transient flash."],[607.0323125000002,"final is indicated — a transient flash."],[607.9148125000002,"c1 is hidden from the screen — left the board."],[607.9148125000002,"c2 is hidden from the screen — left the board."],[607.9148125000002,"final is hidden from the screen — left the board."],[607.9148125000002,"head_clash is hidden from the screen — left the board."],[607.9148125000002,"k_line is hidden from the screen — left the board."],[607.9148125000002,"table is hidden from the screen — left the board."],[607.9148125000002,"row_labels is hidden from the screen — table left the board."],[607.9148125000002,"row_labels_2 is hidden from the screen — table left the board."],[607.9148125000002,"row_labels_3 is hidden from the screen — table left the board."],[607.9148125000002,"row_labels_4 is hidden from the screen — table left the board."],[607.9148125000002,"row_dots is hidden from the screen — table left the board."],[607.9148125000002,"machine_label is hidden from the screen — table left the board."],[607.9148125000002,"col_heads is hidden from the screen — table left the board."],[607.9148125000002,"col_heads_2 is hidden from the screen — table left the board."],[607.9148125000002,"col_heads_3 is hidden from the screen — table left the board."],[607.9148125000002,"col_heads_4 is hidden from the screen — table left the board."],[607.9148125000002,"col_dots is hidden from the screen — table left the board."],[607.9148125000002,"input_label is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_2 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_3 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_4 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_5 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_6 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_7 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_8 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_9 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_10 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_11 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_12 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_13 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_14 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_15 is hidden from the screen — table left the board."],[607.9148125000002,"grid_cells_16 is hidden from the screen — table left the board."],[607.9148125000002,"diag_dots is hidden from the screen — table left the board."],[607.9148125000002,"guide is hidden from the screen — table left the board."],[607.9148125000002,"row_d is hidden from the screen — table left the board."],[607.9148125000002,"d_cells is hidden from the screen — table left the board."],[607.9148125000002,"d_cells_2 is hidden from the screen — table left the board."],[607.9148125000002,"d_cells_3 is hidden from the screen — table left the board."],[607.9148125000002,"d_cells_4 is hidden from the screen — table left the board."],[607.9148125000002,"d_dots is hidden from the screen — table left the board."],[607.9148125000002,"col_k is hidden from the screen — table left the board."],[607.9148125000002,"clash is hidden from the screen — table left the board."]]},{"start":609.1148125000001,"say":"The only thing left is H, so H is what has to go. There is no program that takes an arbitrary program and an arbitrary input and always reports, correctly and in finite time, whether it halts. The halting problem is undecidable.","live":[],"does":[[609.1148125000001,"head_theorem is shown on the screen, written out."],[610.0893125000001,"theorem is shown on the screen, written out."],[615.7443125000002,"theorem_note is shown on the screen, written out."],[624.9043125000002,"A box is drawn around theorem."],[626.3016666666667,"head_theorem is hidden from the screen — left the board."],[626.3016666666667,"theorem is hidden from the screen — left the board."],[626.3016666666667,"theorem_note is hidden from the screen — left the board."]]}]},{"title":"Undecidable Is Not the Same as Expensive","start":627.3433333333335,"end":790.7419375000002,"objects":{"a_bounded":"a Text [text] that says \"Decidable. Simulate $N$ steps and look.\"","a_ever":"a Text [text] that says \"Undecidable. There is no $N$ at which silence becomes an answer.\"","head_collatz":"a Heading that says \"A Program Nobody Can Settle\"","head_cost":"a Heading that says \"Two Questions About One Program\"","head_moral":"a Heading that says \"Cost and Existence\"","left_label":"a Tex [text] that says \"A bounded question\"","moral":"a Panel that says \"Complexity asks how long a procedure takes. Computability asks whether one exists. The proof never mentioned time.\"","moral_math":"a Math [text] that says \"$upright(\"undecidable\") eq.not upright(\"slow\")$\"","open_note":"a Panel that says \"Checked for every start below $2^(68)$. Checking is not proving.\"","plot":"an Axes (x_range=(0.0, 115.0), y_range=(0.0, 10000.0), x_ticks_every=25.0)","probe":"a PlotPoint [yellow] drawn in plot (target='trace', x=<VariableNumber walk = 111.0>)","q_bounded":"a Math [text] that says \"$P upright(\" halts within \") N upright(\" steps?\")$\"","q_ever":"a Math [text] that says \"$P upright(\" halts, ever?\")$\"","right_label":"a Tex [text] that says \"The unbounded question\"","rule_text":"a Text [text] that says \"Even: halve it. Odd: triple it and add one. Stop at 1.\"","trace":"a FunctionPlot [blue] drawn in plot (function=<function>, x_range=(0.0, 111.0))","walk":"a VariableNumber"},"beats":[{"start":627.3433333333335,"say":"Before we go any further I want to separate two things that get run together constantly. Undecidable does not mean hard. It does not mean expensive, or exponential, or out of reach of current hardware. Compare two questions.","live":[],"does":[[627.3433333333335,"head_cost is shown on the screen, written out."],[640.2533333333334,"left_label is shown on the screen, written out."],[640.4533333333335,"right_label is shown on the screen, written out."]]},{"start":642.0498333333335,"say":"Here is the first. Does this program halt within a billion steps? That question is decidable, and the algorithm for it is embarrassing. Simulate a billion steps. If it stopped, say yes. If it is still running, say no.","live":["left_label","right_label","head_cost"],"does":[[643.9423333333335,"q_bounded is shown on the screen, written out."],[648.9343333333335,"a_bounded is shown on the screen, written out."]]},{"start":659.3098333333335,"say":"That may take a week. It may take longer than the universe has been going. None of that matters here. The procedure is finite, it always terminates, and it always gives the correct answer. That question is about cost.","live":["left_label","q_bounded","a_bounded","right_label","head_cost"],"does":[[666.2413333333335,"a_bounded is indicated — a transient flash."]]},{"start":673.2613333333335,"say":"Here is the second. Does this program halt, ever? Run the very same procedure. Simulate a billion steps, and it is still running. What do you conclude? Nothing whatsoever. It might stop on the next step.","live":null,"does":[[675.0263333333335,"q_ever is shown on the screen, written out."],[684.1983333333335,"a_ever is shown on the screen, written out."]]},{"start":687.9563333333335,"say":"There is no number of steps at which silence turns into an answer. Simulation buys you exactly one thing. If the program halts, you will eventually find out. If it does not, you wait forever, and waiting forever is not an algorithm.","live":["left_label","q_bounded","a_bounded","right_label","q_ever","a_ever","head_cost"],"does":[[689.8833333333334,"a_ever (the \"silence becomes an answer\" part) is emphasized."],[692.0893333333335,"a_ever (the \"silence becomes an answer\" part) is no longer emphasized."],[702.1903333333335,"q_ever is indicated — a transient flash."],[703.2698333333335,"a_bounded is hidden from the screen — left the board."],[703.2698333333335,"a_ever is hidden from the screen — left the board."],[703.2698333333335,"head_cost is hidden from the screen — left the board."],[703.2698333333335,"left_label is hidden from the screen — left the board."],[703.2698333333335,"q_bounded is hidden from the screen — left the board."],[703.2698333333335,"q_ever is hidden from the screen — left the board."],[703.2698333333335,"right_label is hidden from the screen — left the board."]]},{"start":703.8698333333334,"say":"Here is what that feels like from the inside. This program takes a whole number and repeats one rule. If the number is even, halve it. If it is odd, triple it and add one. Stop when you reach one.","live":[],"does":[[703.8698333333334,"head_collatz is shown on the screen, written out."],[703.8698333333334,"plot is shown on the screen, written out."],[708.7223333333335,"trace is shown on the screen, drawn."],[711.1143333333334,"plot moves to a new place on the board."],[711.1143333333334,"rule_text is shown on the screen, written out."]]},{"start":717.9833333333335,"say":"Start it at twenty seven and follow the value along. It wanders up and down for a hundred and eleven steps, climbing above nine thousand on the way, and then it falls to one and stops.","live":["rule_text","plot","head_collatz","trace"],"does":[[718.2853333333335,"probe is shown on the screen, written out."],[721.7333333333335,"probe is redrawn as the numbers it depends on change."],[721.7333333333335,"walk ticks to 111.0."]]},{"start":729.4618333333335,"say":"Now the question. Is there a starting number for which this program never stops? Nobody knows. It has been checked for every start below two to the sixty eight, and checking is not proving.","live":["rule_text","plot","head_collatz","trace","probe"],"does":[[736.6143333333334,"open_note is shown on the screen, written out."]]},{"start":741.9158333333335,"say":"And notice how little our theorem actually claims. It does not say we cannot analyse programs. Compilers prove termination of particular loops all day long. It says no single procedure works for every program and every input, and one bad case is enough to sink it.","live":["rule_text","open_note","plot","head_collatz","trace","probe"],"does":[[750.7043333333335,"trace is indicated — a transient flash."],[759.7603333333335,"head_collatz is hidden from the screen — left the board."],[759.7603333333335,"open_note is hidden from the screen — left the board."],[759.7603333333335,"plot is hidden from the screen — left the board."],[759.7603333333335,"trace is hidden from the screen — plot left the board."],[759.7603333333335,"probe is hidden from the screen — plot left the board."],[759.7603333333335,"rule_text is hidden from the screen — left the board."]]},{"start":760.9603333333334,"say":"So keep the two ideas apart. Complexity asks how long a procedure takes. Computability asks whether a procedure exists at all. Our proof never mentioned time, or memory, or the speed of the machine.","live":[],"does":[[760.9603333333334,"head_moral is shown on the screen, written out."],[762.5863333333334,"moral_math is shown on the screen, written out."],[763.7583333333334,"moral is shown on the screen, written out."]]},{"start":776.6068333333335,"say":"Give H a faster processor, and D still contradicts itself. Give it a thousand years and unlimited memory, and D still contradicts itself. The obstruction is logical, not economic.","live":["moral_math","moral","head_moral"],"does":[[786.9283333333335,"moral (the \"The proof never mentioned time\" part) is emphasized."],[787.6363333333335,"moral_math is indicated — a transient flash."],[788.5883333333335,"moral (the \"The proof never mentioned time\" part) is no longer emphasized."],[789.7002708333334,"head_moral is hidden from the screen — left the board."],[789.7002708333334,"moral is hidden from the screen — left the board."],[789.7002708333334,"moral_math is hidden from the screen — left the board."]]}]},{"title":"One More, by Reduction","start":790.7419375000002,"end":991.6238125000002,"objects":{"arrow_in":"an Arrow [gray] drawn in pipeline (start=(1.75, 3.2), end=(2.55, 3.2))","arrow_mid":"an Arrow [gray] drawn in pipeline (start=(5.55, 3.2), end=(6.35, 3.2))","arrow_out":"an Arrow [gray] drawn in pipeline (start=(8.75, 3.2), end=(9.55, 3.2))","box_build":"a Polygon [green] drawn in pipeline (vertices=((2.7, 2.3), (5.4, 2.3), (5.4, 4.1), (2.7, 4.1)), fill_opacity=0.18)","box_t":"a Polygon [blue] drawn in pipeline (vertices=((6.5, 2.3), (8.6, 2.3), (8.6, 4.1), (6.5, 4.1)), fill_opacity=0.18)","build_def":"a Math [text] that says \"$M(y): quad upright(\"run \") P upright(\" on \") x$\"","build_label":"a Math [green] that says \"$upright(\"build \") M$\" drawn in pipeline","closing":"a Panel that says \"Diagonalise once. After that, reduce: show that a decider for the new question would build a decider for one we have already killed.\"","conclusion":"a Math [text] that says \"$T upright(\" exists\") arrow.r H upright(\" exists\")$\"","head_end":"a Heading that says \"The Technique\"","head_reduce":"a Heading that says \"Turning $T$ Into $H$\"","head_total":"a Heading that says \"A Second Question\"","in_label":"a Math [text] that says \"$(P, x)$\" drawn in pipeline","out_label":"a Math [text] that says \"$upright(\"yes or no\")$\" drawn in pipeline","pipeline":"a Figure (x_range=(0.0, 12.0), y_range=(0.4, 6.4), aspect=(12.0, 6.0))","r1":"a Math [text] that says \"$P upright(\" halts\") arrow.r M upright(\" is total\")$\"","r2":"a Math [text] that says \"$P upright(\" loops\") arrow.r M upright(\" halts on nothing\")$\"","shell":"a Polygon [red] drawn in pipeline (vertices=((2.3000000000000003, 1.4999999999999998), (9.0, 1.499999999999…, filled=False, dashed=True)","shell_label":"a Math [red] that says \"$H$\" drawn in pipeline","t_label":"a Math [blue] that says \"$T$\" drawn in pipeline","total_math":"a Math [text] that says \"$T(M): quad forall y, quad M upright(\" halts on \") y$\"","total_q":"a Panel that says \"Does machine $M$ halt on every input? This is the totality problem.\"","verdict":"a Math [text] that says \"$upright(\"no \") H arrow.r upright(\"no \") T$\""},"beats":[{"start":790.7419375000002,"say":"One theorem on its own is a curiosity. What makes this a technique is that you only ever have to run the diagonal once. Everything after it arrives by reduction, and I want to do one so that you can see the shape of it.","live":[],"does":[[790.7419375000002,"head_total is shown on the screen, written out."]]},{"start":803.8224375000002,"say":"Here is a second question. Given a machine M, does M halt on every input? Not on one particular input. On all of them. That is called the totality problem, and it is the question a compiler would love to answer about your loops.","live":["head_total"],"does":[[806.4119375000001,"total_math is shown on the screen, written out."],[815.4679375000002,"total_q is shown on the screen, written out."]]},{"start":821.1644375000002,"say":"It looks harder than halting rather than easier, since it asks about infinitely many runs at once. Suppose all the same that it is decidable. So there is a program T which takes a machine and always tells you, correctly and in finite time, whether it halts on everything.","live":["total_math","total_q","head_total"],"does":[[827.4099375000002,"total_math is indicated — a transient flash."],[838.0219375000001,"head_total is hidden from the screen — left the board."],[838.0219375000001,"total_math is hidden from the screen — left the board."],[838.0219375000001,"total_q is hidden from the screen — left the board."]]},{"start":839.2219375000002,"say":"Watch what we can do with T. Take any program P and any input x, the pair we would like to answer the halting question about. Out of those two pieces we build a new machine, and here is the machine.","live":[],"does":[[839.2219375000002,"head_reduce is shown on the screen, written out."],[839.2219375000002,"pipeline is shown on the screen, written out."],[844.7949375000002,"in_label is shown on the screen, written out."],[849.3919375000002,"arrow_in is shown on the screen, written out."],[849.3919375000002,"box_build is shown on the screen, written out."],[849.3919375000002,"build_label is shown on the screen, written out."],[849.9149375000002,"build_def is shown on the screen, written out."]]},{"start":852.5584375000002,"say":"It takes an input y, throws y away without looking at it, and runs P on x. That is the whole of it. Building the thing is pure text manipulation: you are pasting P and x into a template, and that always finishes.","live":["build_def","pipeline","head_reduce","in_label","arrow_in","box_build","build_label"],"does":[[854.4389375000002,"build_def is indicated — a transient flash."],[864.7599375000002,"box_build is indicated — a transient flash."]]},{"start":867.8104375000001,"say":"So what does this machine do? Because it ignores its input, it behaves identically on every input, which leaves only two cases, and they are exactly the two cases we care about.","live":null,"does":[[872.5009375000002,"build_def (the \"upright(\"run \") P upright(\" on \") x\" part) is emphasized."],[878.7579375000001,"build_def (the \"upright(\"run \") P upright(\" on \") x\" part) is no longer emphasized."]]},{"start":880.8674375000002,"say":"If P halts on x, then M halts on y, whatever y happens to be. So M halts on every input, which is to say M is total. If P runs forever on x, then M runs forever on every input, so M halts on nothing at all.","live":null,"does":[[889.9819375000002,"r1 is shown on the screen, written out."],[895.9959375000002,"r2 is shown on the screen, written out."]]},{"start":897.6524375000001,"say":"So hand M to the totality decider. If T says yes, then P halts on x. If T says no, then P does not halt on x. Either way you have a correct answer to the halting question, in finite time.","live":["build_def","r1","r2","pipeline","head_reduce","in_label","arrow_in","box_build","build_label"],"does":[[898.2329375000002,"arrow_mid is shown on the screen, written out."],[898.2329375000002,"box_t is shown on the screen, written out."],[898.2329375000002,"t_label is shown on the screen, written out."],[909.0989375000001,"arrow_out is shown on the screen, written out."],[909.0989375000001,"out_label is shown on the screen, written out."]]},{"start":912.8629375000002,"say":"Now put the two pieces inside one box. That box takes a program and an input, builds M, asks T, and reports whether the program halts. Correctly, always, in finite time. That box is H.","live":["build_def","r1","r2","pipeline","head_reduce","in_label","arrow_in","box_build","build_label","arrow_mid","box_t","t_label","arrow_out","out_label"],"does":[[915.1789375000002,"shell is shown on the screen, written out."],[916.3979375000001,"shell_label is shown on the screen, written out."],[921.1119375000002,"conclusion is shown on the screen, written out."],[928.8094375000002,"conclusion moves to a new place on the board."],[928.8094375000002,"r1 moves to a new place on the board."],[928.8094375000002,"r2 moves to a new place on the board."],[928.8094375000002,"build_def is hidden from the screen — left the board."]]},{"start":929.4094375000002,"say":"And we spent the last ten minutes proving that H cannot exist. So the assumption that manufactured it is the thing that is false. There is no totality decider, and the totality problem is undecidable too.","live":["r1","r2","conclusion","pipeline","head_reduce","in_label","arrow_in","box_build","build_label","arrow_mid","box_t","t_label","arrow_out","out_label","shell","shell_label"],"does":[[932.2649375000002,"conclusion (the \"H upright(\" exists\")\" part) is emphasized."],[934.5289375000002,"shell_label is indicated — a transient flash."],[939.0339375000001,"conclusion (the \"H upright(\" exists\")\" part) is no longer emphasized."],[943.8054375000002,"conclusion is hidden from the screen — left the board."],[943.8054375000002,"head_reduce is hidden from the screen — left the board."],[943.8054375000002,"pipeline is hidden from the screen — left the board."],[943.8054375000002,"in_label is hidden from the screen — pipeline left the board."],[943.8054375000002,"arrow_in is hidden from the screen — pipeline left the board."],[943.8054375000002,"box_build is hidden from the screen — pipeline left the board."],[943.8054375000002,"build_label is hidden from the screen — pipeline left the board."],[943.8054375000002,"arrow_mid is hidden from the screen — pipeline left the board."],[943.8054375000002,"box_t is hidden from the screen — pipeline left the board."],[943.8054375000002,"t_label is hidden from the screen — pipeline left the board."],[943.8054375000002,"arrow_out is hidden from the screen — pipeline left the board."],[943.8054375000002,"out_label is hidden from the screen — pipeline left the board."],[943.8054375000002,"shell is hidden from the screen — pipeline left the board."],[943.8054375000002,"shell_label is hidden from the screen — pipeline left the board."],[943.8054375000002,"r1 is hidden from the screen — left the board."],[943.8054375000002,"r2 is hidden from the screen — left the board."]]},{"start":945.0054375000002,"say":"Notice what we did not have to do there. We did not diagonalise again. We took the one impossible object we already had, and showed that a totality decider would manufacture it, so the totality decider goes the same way the first one went.","live":[],"does":[[945.0054375000002,"head_end is shown on the screen, written out."],[951.4949375000001,"verdict is shown on the screen, written out."]]},{"start":960.6174375000002,"say":"That is a reduction, and it is the standard move. Does this machine ever print the word hello? Do these two programs compute the same function? Is there any input at all that this machine accepts? Same argument, every time.","live":["verdict","head_end"],"does":[[961.4069375000001,"closing is shown on the screen, written out."]]},{"start":976.2409375000002,"say":"Almost every interesting question about what a program does, as opposed to what its text looks like, turns out to be undecidable. And all of it traces back to one table, one flipped row, and one cell that cannot decide what it is.","live":["verdict","closing","head_end"],"does":[[982.5219375000001,"A box is drawn around verdict."],[984.8559375000002,"closing (the \"Diagonalise once\" part) is emphasized."],[989.0819375000001,"closing (the \"Diagonalise once\" part) is no longer emphasized."],[990.5821458333335,"closing is hidden from the screen — left the board."],[990.5821458333335,"head_end is hidden from the screen — left the board."],[990.5821458333335,"verdict is hidden from the screen — left the board."]]}]}]},"durationSeconds":992,"chapters":[{"title":"A List That Cannot Be Complete","startSeconds":0,"narration":"Here is a claim that ought to sound impossible. There is a question about computer programs, a completely precise question with a yes or no answer, that no computer program can answer. Not a slow one. Not one with more memory than any machine ever built. None. The question is this one. You are handed the text of a program P, and an input x. Does P eventually stop when you run it on x, or does it run forever? Call a program that answers that H. H always returns. It never runs forever itself, and it never says maybe. For every program and every input it hands back halts or loops, and it is right. The theorem we are heading for is that H does not exist. I want that to feel forced rather than clever, so we are going to practise the move first on something else. Something with no programs in it at all. The real numbers. Here is a list of real numbers between zero and one, written out as decimals. I have drawn four rows; you should imagine infinitely many. And here is the supposition we are going to break. This list is complete. Now I am going to build a number that is not on this list, and I am going to build it out of the list itself. Take the first digit of the first number. It is a one. Take the second digit of the second number, and that is a three. The third digit of the third number is a seven. The fourth digit of the fourth is a zero. Those four entries lie along the diagonal of the table, and the diagonal is where the whole argument lives. The rule for the new number is this. Take each diagonal digit and add one to it. If a diagonal digit happens to be a nine, write a one instead, so that we never finish with a tail of nines or a tail of zeros. One becomes two. Three becomes four. Seven becomes eight. And zero becomes one. Call the result d. So d is zero point two four eight one, and it carries on forever, one fresh digit for every row of the list. Now the only question that matters. Is d on the list? It cannot be the first number, because d was built to differ from the first number in the first decimal place. Two, not one. It cannot be the second number either, because they differ in the second place. Four against three. And not the third, and not the fourth, for exactly the same reason. And for any row number n at all, d differs from row n in the n-th decimal place, because that is precisely what the rule was built to do. So d is a real number between zero and one, missing from a list that was supposed to contain every real number between zero and one. That is a contradiction, so the supposition was wrong. No list of real numbers can be complete. There are strictly more reals than there are rows to put them in. Strip that argument down to its bones, because we are about to run it again on something completely different. Step one, assume a complete table, with one row for every object. Step two, read the entries down the diagonal. Step three, build a new object that disagrees with row n at position n, for every n at once. Step four, notice that this new object cannot be any row at all, so the table was never complete. The diagonal is doing all of the work there. It is the one place where a single new object can be made to disagree with every row of an infinite table, using just one entry from each row."},{"title":"The Table of Programs","startSeconds":231.28431249999997,"narration":"Start with programs. A program is a finite string of characters, and that is the only fact about programs we are going to need. So write out every finite string, shortest first, alphabetically within each length, and cross out every string that is not a valid program. What survives is a list. P one, P two, P three, P four, and on forever. Every program you will ever write sits on it, at a definite finite position, and nothing sits on it twice. Unlike Cantor's list of reals, this list is not a supposition. We can actually construct it. Inputs are finite strings too, so there is nothing to stop us handing a program the text of another program. Or the text of itself. So along the top I will put that same list again, this time as inputs. That gives us a table. The entry in row i, column j records what program P i does when you run it on the text of P j. It either stops eventually, and I will write a one, or it runs forever, and I will write a zero. Here is a corner of it. Row P one, run on the text of P one, stops, so that entry is a one. Row P one on P two runs forever, so a zero. Fill in the rest of the table the same way. Every cell has an entry. Not an entry we know: an entry. Run P three on its own text and either it stops or it does not, and that is settled, whether or not anybody ever finds out which. The table is completely determined before we ask how to compute it. Now assume the decider exists. H takes a program and an input, and returns the correct entry of this table, in finite time. Feed it a row and a column and it hands you back that cell. Always. That is exactly what decidable means. Not that the answer exists, which we have already agreed it does, but that one single program computes it, for every pair, and finishes. If H exists, this whole infinite table is on tap. Now look at the diagonal. Each of these cells asks what one program does when you run it on a copy of its own text. P one on itself, P two on itself, P three on itself, and so on down. There is nothing paradoxical about that yet. A program is a string, and a string is a perfectly ordinary thing to feed to a program. Compilers do it every day of the week. And now we build the contrary program, exactly the way Cantor built his number. Call it D. D takes one input, a program P, and the first thing it does is ask H whether P halts when you run it on its own text. And then D does the opposite of whatever it hears. If H says P halts on itself, D deliberately drops into an infinite loop. If H says P loops on itself, D stops immediately. D is not exotic. It is a call and a branch, perhaps five lines long. If the decider exists then this program exists too, and there is no sleight of hand anywhere in the construction. So let us fill in D's row. Column one asks what D does on the text of P one. The diagonal entry there is a one, meaning P one halts on itself, so D does the opposite and runs forever. I write a zero. Column two: the diagonal entry is a one again, so D loops, and I write a zero. Column three: another one, so another zero. Column four: the diagonal entry is a zero, P four never stops on its own text, so D halts. And there is the pattern. D's row is the diagonal with every entry flipped. Where the diagonal says one, D says zero, and where it says zero, D says one. D disagrees with the diagonal everywhere, and it does so deliberately. Now the same question Cantor asked. Is D on the list? It has to be. D is a program, and the list contains every program, so D appears on it somewhere. Call its position k. D is P k. That means two things at the same time. D has a row of its own, row k, and that row is the one we have just filled in. And D has a column of its own, column k, because the text of D is a legitimate input like any other. So look at where that row meets that column. Cell k, k. It sits on the diagonal, and it sits in D's row, and it has to answer exactly one question. Does D halt when you run it on a copy of its own text? Suppose the answer is one. D halts on its own text. But D's row was built to disagree with the diagonal, and this cell is on the diagonal, so D's row says zero there. D halts and D does not halt. Suppose instead the answer is zero. Then H reports that D loops on its own text, so D, by its own definition, does the opposite and halts immediately. Which makes the cell a one after all. Again both. And there is no third option. The cell is a one or it is a zero, because the run either stops or it does not, and we have just shown that both are impossible. Cell k, k is not equal to itself. So one of our assumptions is false, and it is worth checking which ones we made. That programs can be listed: true, we constructed the list. That every cell has an entry: true, every run either stops or it does not. That D can be built from H: true, it is a call and a branch. The only thing left is H, so H is what has to go. There is no program that takes an arbitrary program and an arbitrary input and always reports, correctly and in finite time, whether it halts. The halting problem is undecidable."},{"title":"Undecidable Is Not the Same as Expensive","startSeconds":627.3433333333335,"narration":"Before we go any further I want to separate two things that get run together constantly. Undecidable does not mean hard. It does not mean expensive, or exponential, or out of reach of current hardware. Compare two questions. Here is the first. Does this program halt within a billion steps? That question is decidable, and the algorithm for it is embarrassing. Simulate a billion steps. If it stopped, say yes. If it is still running, say no. That may take a week. It may take longer than the universe has been going. None of that matters here. The procedure is finite, it always terminates, and it always gives the correct answer. That question is about cost. Here is the second. Does this program halt, ever? Run the very same procedure. Simulate a billion steps, and it is still running. What do you conclude? Nothing whatsoever. It might stop on the next step. There is no number of steps at which silence turns into an answer. Simulation buys you exactly one thing. If the program halts, you will eventually find out. If it does not, you wait forever, and waiting forever is not an algorithm. Here is what that feels like from the inside. This program takes a whole number and repeats one rule. If the number is even, halve it. If it is odd, triple it and add one. Stop when you reach one. Start it at twenty seven and follow the value along. It wanders up and down for a hundred and eleven steps, climbing above nine thousand on the way, and then it falls to one and stops. Now the question. Is there a starting number for which this program never stops? Nobody knows. It has been checked for every start below two to the sixty eight, and checking is not proving. And notice how little our theorem actually claims. It does not say we cannot analyse programs. Compilers prove termination of particular loops all day long. It says no single procedure works for every program and every input, and one bad case is enough to sink it. So keep the two ideas apart. Complexity asks how long a procedure takes. Computability asks whether a procedure exists at all. Our proof never mentioned time, or memory, or the speed of the machine. Give H a faster processor, and D still contradicts itself. Give it a thousand years and unlimited memory, and D still contradicts itself. The obstruction is logical, not economic."},{"title":"One More, by Reduction","startSeconds":790.7419375000002,"narration":"One theorem on its own is a curiosity. What makes this a technique is that you only ever have to run the diagonal once. Everything after it arrives by reduction, and I want to do one so that you can see the shape of it. Here is a second question. Given a machine M, does M halt on every input? Not on one particular input. On all of them. That is called the totality problem, and it is the question a compiler would love to answer about your loops. It looks harder than halting rather than easier, since it asks about infinitely many runs at once. Suppose all the same that it is decidable. So there is a program T which takes a machine and always tells you, correctly and in finite time, whether it halts on everything. Watch what we can do with T. Take any program P and any input x, the pair we would like to answer the halting question about. Out of those two pieces we build a new machine, and here is the machine. It takes an input y, throws y away without looking at it, and runs P on x. That is the whole of it. Building the thing is pure text manipulation: you are pasting P and x into a template, and that always finishes. So what does this machine do? Because it ignores its input, it behaves identically on every input, which leaves only two cases, and they are exactly the two cases we care about. If P halts on x, then M halts on y, whatever y happens to be. So M halts on every input, which is to say M is total. If P runs forever on x, then M runs forever on every input, so M halts on nothing at all. So hand M to the totality decider. If T says yes, then P halts on x. If T says no, then P does not halt on x. Either way you have a correct answer to the halting question, in finite time. Now put the two pieces inside one box. That box takes a program and an input, builds M, asks T, and reports whether the program halts. Correctly, always, in finite time. That box is H. And we spent the last ten minutes proving that H cannot exist. So the assumption that manufactured it is the thing that is false. There is no totality decider, and the totality problem is undecidable too. Notice what we did not have to do there. We did not diagonalise again. We took the one impossible object we already had, and showed that a totality decider would manufacture it, so the totality decider goes the same way the first one went. That is a reduction, and it is the standard move. Does this machine ever print the word hello? Do these two programs compute the same function? Is there any input at all that this machine accepts? Same argument, every time. Almost every interesting question about what a program does, as opposed to what its text looks like, turns out to be undecidable. And all of it traces back to one table, one flipped row, and one cell that cannot decide what it is."}]}}
