Get this book > Problems on Array: For Interviews and Competitive Programming
A turing machine is a mathematical model of a computation that defines an abstract machine. In this article, we learn about Turing machines, how they are defined formally and informally, and the ChurchTuring thesis.
Table of contents.
 Introduction.
 Formal and informal definitions.
 Multitape turing machines.
 Formal definition of multitape turing machines.
 The ChurchTuring thesis.
 Summary.
 References.
Prerequisites.
Introduction.
In the prerequisite articles, we learned about regular and contextfree languages. We learned of computational devices that accept or generate these languages and their limitations when it comes to languages such as; A = {${\mathrm{a}}^{\mathrm{m}}$${\mathrm{b}}^{\mathrm{n}}$${\mathrm{c}}^{\mathrm{mn}}$ : m â‰¥ 0, n â‰¥ 0}.
A turing machine models a real computer. These machines accept all contextfree grammar as well as languages such as A.
In this article, we will try to prove that "every problem solvable by a real computer is solvable by a turing machine"  this is the church turing thesis.
Formal and informal definitions.
A turing machine will consist of the following;
 First we have k tapes, each tape divided into cells. This tape is infinite on both sides left and right. Each cell in the tape stores a symbol that belongs to a finite set T referred to as the tape alphabet. This alphabet has a blank symbol â‹„ If a cell has this symbol, it is considered empty.
Let's look at an example of a turing machine where k is 2;

Each tape has a tape that can be moved along the other tape. It only moves a single cell per move. It reads the cell it is currently positioned at and replaces the symbol in the cell with another symbol.

There is also a state control that can be any of a finite number of states. A finite set of states is denoted by Q, this set has three special states namely, start, accept, and reject.
During a single step of computation the turing machine does the following;
 At the beginning it is in a state r of Q and each k tape head is on a specific cell.
 Depending on the current state r and k symbols;
 The machine switches to state r' of Q
 Each tape head writes a symbol T in the cell it is currently scanning.
 Each tape head can move one cell to the left, right, or stay where it currently is.
A formal definition.
A deterministic turing machine is 7tuple consisting of M = (Î£, Î“, Q, Î´, q, ${\mathrm{q}}_{\mathrm{accept}}$, ${\mathrm{q}}_{\mathrm{reject}}$).
Where;
 Î£ is a finite set referred to as an input alphabet.
 Î“ is a finite set referred to as a tape alphabet, it has the blank symbol â‹„ and Î£ âŠ† Î“.
 Q is a finite set whose elements are referred to as states.
 q is an element of Q referred to as the start state.
 ${\mathrm{q}}_{\mathrm{accept}}$ is an element of Q, it is referred to as the accept state.
 ${\mathrm{q}}_{\mathrm{reject}}$ is also an element of Q, it is referred to as the reject state.
 Î´ is referred to as a transition function.
Î´:Q Ã— ${\mathrm{\xce\u201c}}^{\mathrm{k}}$â†’ Q Ã— ${\mathrm{\xce\u201c}}^{\mathrm{k}}$ Ã— ${\mathrm{\{L,\; R,\; N\}}}^{\mathrm{k}}$.
This function is a program of the turing machine, it tells the machine what it can do in one computation step.
Multitape turing machines.
These machines have multiple tapes each accessed with a separate head that moves independently despite the other heads.
In the beginning, the input is at tape 1 while others remain blank. In the next step, the machine reads consecutive symbols under its head and prints a symbol on each tape then moves its head.
Although it is easier to obtain a twotape machine compared to a singletape turing machine, this doesn't mean that a twotape machine is more powerful.
A formal definition of multitape turing machines.
This machine is 6tuple (Q, X, B, Î´, q0, F) where;
 Q is a finite set of states.
 X is the tape alphabet.
 B is the blank symbol.
 Î´ is a relation between states and symbols where;
Î´: Q Ã— Xk â†’ Q Ã— (X Ã— {Leftshift, Rightshift, Noshift })k where there is k number of tapes.  q0 is the initial state.
 F is the set of final states.
Note that for every multitape turing machine, there is an equivalent singletape turing machine.
The ChurchTuring thesis.
An algorithm is a list of steps describing how to solve a problem with a computer and therefore any computational process that can be specified by a program is considered an algorithm.
Similarly, a turing machine specifies a computational process and therefore we consider it as an algorithm.
Now, we ask. Is it possible to give a mathematical definition of an algorithm?
Having stated that every program be it a java program or C program represents an algorithm and that every turing machine represents an algorithm. We ask ourselves, are these two statements regarding an algorithm equivalent?
The answer is yes, it also implies that many different notions of computational processes are equivalent.
For example, the following are computational models.
 Onetape turing machines.
 Nondeterministic turing machines.
 ktape turing machines where k >= 1.
 Java, C++ programs.
Any of the models can be converted to any other model.
The ChurchTuring thesis: It states that every computational process that is intuitively considered an algorithm can be converted to a turing machine.
In other terms, we define an algorithm to be a turing machine.
Summary.
A turing machine is a mathematical model of a computation that defines an abstract machine. Despite its simplicity, given any algorithm, this machine is capable of implementing the algorithm's logic.
The ChurchTuring thesis states that every computational process that is said to be an algorithm can be implemented by a turing machine.