Turing Machine Primer - Computerphile

The Touring Machine: A Universal Computing Model

The touring machine is a universal computing model that was discovered very early on in the development of modern computers. It is based on a simple yet powerful concept: a tape divided into notional cells, each containing a pattern of bits that represent either program instructions or data. The machine has a read/write head that visits a location on the tape and can either read from it or write to it, depending on the instruction being executed.

The Tape: A Memory Location

The tape is the primary memory location for the touring machine. It is divided into cells, each of which contains a pattern of bits that represent either program instructions or data. These cells are notional, meaning that they can be used in any way that is desired by the programmer. The tape is essentially an infinite array of these cells, and it is possible to erase and rewrite any cell as needed.

The Read/Write Head

The read/write head is a critical component of the touring machine. It visits a location on the tape and can either read from it or write to it, depending on the instruction being executed. The head must always move, whether it is moving left or right, and it is not possible for the machine to stop at any point during execution.

The Program: A Sequence of Instructions

In most touring machine primers, the program code is stored at one end of the tape, while data is stored at the other end. The read/write head reads an instruction from the tape and executes it, which may involve shifting the head into the data section or reading a value from memory. This process repeats until the program halts.

Simplification: From Tape to Cards

One way to simplify the touring machine model is to remove the program code from the tape and replace it with instructions stored on cards. Each card represents an instruction, and the read/write head reads one card at a time and executes its instructions. This approach makes it easier to understand how the machine works, but it does require that the programmer remember the specific instructions being used.

The TBO Card: A Typical Touring Machine Instruction

A typical touring machine instruction is represented by a TBO (Touring Binary Operation) card. The TBO card contains a sequence of bits that represent an instruction, along with a flag indicating whether the instruction should halt the machine if it reads zero. The instruction may involve shifting the read/write head left or right, reading from memory, or writing to memory.

The Halting Problem: A Paradox

One of the most famous results in the history of computer science is the halting problem, which states that there cannot exist an algorithm that can determine whether a given program will halt for all possible inputs. The touring machine model illustrates this paradox, as the machine may either halt or go into an infinite loop, depending on its instructions.

The Busy Beaver Movie: An Introduction to Undecidability

The Busy Beaver movie is a classic example of the halting problem in action. It is a sequence of 1s and 0s that represents a program for a touring machine, and it explores the idea of undecidability through this single sequence of bits. The movie shows how the machine can produce an infinite number of different outputs based on its instructions, highlighting the paradoxical nature of the halting problem.

In conclusion, the touring machine is a fundamental concept in computer science that illustrates the power and limitations of universal computing models. By understanding how the machine works and exploring its properties, we can gain insights into the nature of computation and the limits of algorithmic solutions to complex problems.

"WEBVTTKind: captionsLanguage: enI've just done a a film about a special class of touring machine called byy Beaver that enables you to play the byy Beaver game so there's lots of wonderful video footage that you can see on that however for those of you new to this game who aren't familiar at all with how touring machines work what we've now done is sectioned off a little piece of footage that you could watch first of all to get some idea of Ros tibo who invented the byy Beaver game how he designed his particular touring machine to enable this game to be played first of all what does a touring machine actually look like what does it do so here we are then this is a touring machine tape it's divided up into lots and lots of notional cells these are memory locations into these memory locations you can put patterns of bits that represent your program patterns of bits that represent the data your working on in the data part of memory and you can have an infinite amount of it in principle the only other thing you need to give this Universal Computing model is a read WR head it visits a location on the tape and you can either reute to it a read command or a write command now suppose these cells have been pre-initialized with zeros if in the current head position you say read and tell me what it is it says it's a zero you can then if you want to so I'm going to overwrite that with a one so in every cell of this memory there is the ability to erase and optionally to override with something else now you can if you're completely masochistic and some churing machine programs work out like this you could always overwrite a zero with a zero there's nothing to stop you doing that so it can shift left or right or not at all and this is a binary touring machine there are other formulations which try to make life simpler and keep the tape shorter by saying oh I'll let you work in decimal arithmetic what was discovered very early on was it really didn't matter how uh fancy your alphabet was for the tape all cheering machines were the same they all had the same computing power it's just that sometimes you can keep the tape length shorter okay so where does the program come from that causes this head to read and to write and to shift in many touring machine primers you say let's park the program code there's tons of ones and zeros at this end of the tape and data in memory at the top end of the tape and you will read an instruction it will tell you something to do with the read WR head and you'll shift the head up into the data section you'll do it and you're oscillating back between reading program writing data the simplification I'm going to do which is what Tiber does on his Busy B vuring machine and it makes life so much simpler but I'm going to take the program code off from tape sounds like good old fashioned Computing onto cards not Punch Cards of the sort we've covered but a TBO card here's a typical TBO type touring machine card and the idea is that every card represents an instruction and touring machine so let us look at this card in the context of this touring machine tape here tore says for the sake of argument let's assume that all these data memory cells are initialized to zeros since you don't know whether the head is going to shift to the right a lot or shift to the left a lot ahead of time let's put it in the middle of this tape here the zero here means if you've got a zero under the head at the moment in other words you read and you see a zero it then says here the one is character to be written so we have read a zero it now says write a one second binary digit here says now move the head and again what R did is not absolutely essential in chury machine law he said if I make the CH machine work like this it's a lot easier to show you what's going on so please forgive me in the r machine the head must always move you can't say no I'm stopping still here you either move left or you move right 0 equals left 1 equals right and then finally what's this two here that's your next instruction two we're on card one your next instruction will be on another card card two so you've got all of these actions that must happen if you read a zero in this current state of the machine C1 is the start card c0 is the halt card okay so if something in one of these instructions says your next card is zero you're going to Halt the zero card is the halt card so that's the general layout of these cards well now having seen this introduction I'd encourage you to go on and watch the main Busy Beaver movie and I think at the end of that you'll get some real feeling for just what the word undecidability actually means if it doesn't halt we get a no answer but then it halts so if it does halt then it doesn't halt but if it doesn't halt then it does halt either way we get a contradiction it's a paradoxI've just done a a film about a special class of touring machine called byy Beaver that enables you to play the byy Beaver game so there's lots of wonderful video footage that you can see on that however for those of you new to this game who aren't familiar at all with how touring machines work what we've now done is sectioned off a little piece of footage that you could watch first of all to get some idea of Ros tibo who invented the byy Beaver game how he designed his particular touring machine to enable this game to be played first of all what does a touring machine actually look like what does it do so here we are then this is a touring machine tape it's divided up into lots and lots of notional cells these are memory locations into these memory locations you can put patterns of bits that represent your program patterns of bits that represent the data your working on in the data part of memory and you can have an infinite amount of it in principle the only other thing you need to give this Universal Computing model is a read WR head it visits a location on the tape and you can either reute to it a read command or a write command now suppose these cells have been pre-initialized with zeros if in the current head position you say read and tell me what it is it says it's a zero you can then if you want to so I'm going to overwrite that with a one so in every cell of this memory there is the ability to erase and optionally to override with something else now you can if you're completely masochistic and some churing machine programs work out like this you could always overwrite a zero with a zero there's nothing to stop you doing that so it can shift left or right or not at all and this is a binary touring machine there are other formulations which try to make life simpler and keep the tape shorter by saying oh I'll let you work in decimal arithmetic what was discovered very early on was it really didn't matter how uh fancy your alphabet was for the tape all cheering machines were the same they all had the same computing power it's just that sometimes you can keep the tape length shorter okay so where does the program come from that causes this head to read and to write and to shift in many touring machine primers you say let's park the program code there's tons of ones and zeros at this end of the tape and data in memory at the top end of the tape and you will read an instruction it will tell you something to do with the read WR head and you'll shift the head up into the data section you'll do it and you're oscillating back between reading program writing data the simplification I'm going to do which is what Tiber does on his Busy B vuring machine and it makes life so much simpler but I'm going to take the program code off from tape sounds like good old fashioned Computing onto cards not Punch Cards of the sort we've covered but a TBO card here's a typical TBO type touring machine card and the idea is that every card represents an instruction and touring machine so let us look at this card in the context of this touring machine tape here tore says for the sake of argument let's assume that all these data memory cells are initialized to zeros since you don't know whether the head is going to shift to the right a lot or shift to the left a lot ahead of time let's put it in the middle of this tape here the zero here means if you've got a zero under the head at the moment in other words you read and you see a zero it then says here the one is character to be written so we have read a zero it now says write a one second binary digit here says now move the head and again what R did is not absolutely essential in chury machine law he said if I make the CH machine work like this it's a lot easier to show you what's going on so please forgive me in the r machine the head must always move you can't say no I'm stopping still here you either move left or you move right 0 equals left 1 equals right and then finally what's this two here that's your next instruction two we're on card one your next instruction will be on another card card two so you've got all of these actions that must happen if you read a zero in this current state of the machine C1 is the start card c0 is the halt card okay so if something in one of these instructions says your next card is zero you're going to Halt the zero card is the halt card so that's the general layout of these cards well now having seen this introduction I'd encourage you to go on and watch the main Busy Beaver movie and I think at the end of that you'll get some real feeling for just what the word undecidability actually means if it doesn't halt we get a no answer but then it halts so if it does halt then it doesn't halt but if it doesn't halt then it does halt either way we get a contradiction it's a paradox\n"