Eli5: How does a Turing machine work?

777 views

A Turing machine has an infinite tape with 1s and 0s that acts as a memory. Where does it get the instruction to perform a task? Are the instruction written on the tape? Because from what I understand, the machine reads what’s written on the tape and then perform some instruction on that same tape. So it replaces the input data with output date?

In: 4

21 Answers

Anonymous 0 Comments

A CPU is a modern example, but not definition of a Turing machine. Inside is a register (place to store information, like a variable in Algebra) called the program counter which points to a cell in memory. For most programs, memory is essentially an endless tape where each cell can store a binary number from 0 to 2^(n)-1 for however many bits the CPU is designed for. In reality, there is a limit to how many cells there are, but you shouldn’t typically have to worry about it.

The instructions come from the RAM and a decoder. Basically, the CPU is filled with machines to do jobs. The ALU is the most important one as it can add, subtract, AND, OR, NOT, and any other number of functions. There’s a flags register which is our main way of checking the result of an operation, which allows us to branch given certain scenarios (typically a zero, negative, and overflow/carry flag are used). The instructions can read from the flags and run certain operations given the results. The operations are typically run through a decoder. For instance ADD in assembly will have several steps, to pull the instruction from memory to the instruction register, increment the program counter, move to the correct address in RAM, put that value in the ALU, add to the appropriate register and update flags. The decoder will act like the gears and knobs of a machine to make all the little pieces work. The program in RAM will act like the operator of the machine.

But remember, that’s just one example of a Turing Machine, not the definition. But that’s one way in which we can make it work. Basically, the RAM values, program counter, and flags and data registers act as our states. The program counter has a jump/increment feature which acts as our way to move backwards and forwards on the tape. RAM is the tape, and the decoder (along with the instructions written into RAM) acts like our decision tree

You are viewing 1 out of 21 answers, click here to view all answers.