Lecture 2 - Turing Machines
Still in preparation. Please check the references at the end of the document.
Turing Machines
A Turing machine is a mathematical model of computation that is used to model a general-purpose computer.
The Turing machine model uses an infinite tape as its memory. This tape is divided into cells, each of which can contain a symbol from a finite set of symbols called the tape alphabet. The tape is infinite in both directions, but only finitely many cells contain non-blank symbols.
The machine has a tape head, which is always positioned over one of the cells, and the machine can read and write symbols on the cell where the head is, and can move the head left or right of its current position along the tape.
We are now ready to define a Turing machine more formally.
Definition 1: A deterministic, one-tape Turing machine is described by a $3$-tuple $(S, \Gamma, \tau)$ where
-
$S := \{s_0, s_1, \dots, s_m, s_{accept}, s_{reject}\}$ is a finite set of internal states, where $s_0$ is the start state, $s_{accept}$ is the accept state, and $s_{reject}$ is the reject state.
-
$\Gamma := \{\sqcup, 0, 1, \dots, k\}$ is a finite set of tape symbols, also known as the tape alphabet, where $\sqcup$ is the blank symbol.
-
$\tau: S \setminus \{s_{accept}, s_{reject}\} \times \Gamma \rightarrow S \times \Gamma \times \{L, R\}$ is the transition function.
Note that in the above definition the states $s_{accept}$ and $s_{reject}$ are halting states, meaning that the machine halts when it reaches either of these states. This is due to the fact that the transition function $\tau$ is not defined for these states.
Also note that in the above definition, the machine is deterministic, meaning that for each internal state and tape symbol, there is exactly one transition that the machine can make.
Definition 2: the configuration of a Turing machine $M(S, \Gamma, \tau)$ is a string of the form $u \boldsymbol{s} v$ where
- $uv \in \Gamma^*$ is the content of the tape.
- $\boldsymbol{s} \in S$ is the current internal state of the machine.
- The tape head is positioned on the leftmost symbol of $v$.
The start configuration of $M$ on input $w$ is $s_0 w$.
A configuration $u \boldsymbol{s} v$ is a halting configuration if $\boldsymbol{s} \in \{s_{accept}, s_{reject}\}$. This is because we have defined that the machine halts when it reaches either the accept or reject state.
Now that we have defined configurations, we can talk about how a Turing maching will change from one configuration to another.
Definition 3: For any strings $u, v \in \Gamma^*$, states $q, r \in S$, and symbols $a, b, c \in \Gamma$, we say that the Turing machine $M(S, \Gamma, \tau)$ moves from configuration $uaqvb$ to configuration $ucrb$
We say that a Turing machine $M$ accepts an input $w$ if there is a sequence of configurations $C_1, C_2, \dots, C_k$ such that
- $C_1$ is the start configuration of $M$ on input $w$.
- $C_k$ is a halting configuration with $\boldsymbol{s} = s_{accept}$.
- For each $i$, $C_{i+1}$ is obtained from $C_i$ by applying the transition function $\tau$.
Similarly, we say that $M$ rejects an input $w$ if in the above we have that $C_k$ is a halting configuration with $\boldsymbol{s} = s_{reject}$.
The collection of strings that $M$ accepts is the language of $M$, or the language recognized by $M$, denoted $L_M$. This notion leads to the definition of a Turing-recognizable language.
Definition 4: A language $L$ is Turing-recognizable (also known as recursively enumerable language) if there is a Turing machine $M$ such that $L = L_M$. That is, $L$ is the language recognized by some Turing machine.
Now, it is possible that a Turing machine does not halt on some inputs. This behaviour is denoted by looping. A machine may not halt (i.e. may loop) because of simple or complex behavior, which never reaches a halting state. (For example, a machine which enters an “infinite loop,” in the sense that you are used to.)
Acknowledgements & References
This lecture was based on these resources:
- Lecture notes by Prof. Eric Blais.
- [S13, Chapter 3]