Métodos computacionales

Turing Machines

General Overview

A Turing machine (TM) is a hypothetical machine (computing device) first conceived by the English mathematician Alan Turing in 1936 to help solve a specific question in mathematical logic. Despite its simplicity, the machine can simulate any computer algorithm, no matter how complicated it may be.

We may visualize a TM as follows [1]:

The machine consists of a finite control (equivalent to a CPU in modern day computers), which can be in any of a finite set of states. There is a tape divided into squares or cells ; each cell can hold any one of a finite number of symbols.

Initially the input, which is a finite-length string of symbols chosen from the input alphabet, is placed on the tape. All other tape cells, extending infinitely to the left and right, hold a special symbol called the blank. The blank is a tape symbol but not an input symbol.

There is a tape head that is always positioned at one of the tape cells. The TM is said to be scanning that cell. Initially, by convention, the tape head is at the leftmost cell that holds the input.

A move of the TM is a function of the state of the finite control and the tape symbol scanned. In one move the TM will:

  1. Change state. The next state optionally may be the same as the current state.

  2. Write a tape symbol in the cell scanned. This tape symbol replaces whatever symbol was in that cell. Optionally, the symbol written may be the same as the symbol currently there.

  3. Move the tape head left or right.

Formally, a TM is defined by the 7-tuple \(M = (Q, \Sigma, \Gamma, \delta, q_0, B, F) \), where:

Let \(M\) be a TM and \(w\) a string.

TM Example

Let’s define a TM that accepts the language \(\{ a^n \; | \; n \ge 0, n \bmod 2 = 0\}\). In other words, the TM should accept strings that contain a sequence with an even number of \(a\)’s.

The formal specification of this Turing machine \(M\) is:

$$ M = (\{q_0, q_1, q_2 \}, \{ a \}, \{ B, a \}, \delta, q_0, B, \{ q_2\} ) $$

where \(\delta\) is given by the following table:

State Symbol
\(a\) \(B\)
\(q_0\) \((a, R, q_1)\) \((B, L, q_2)\)
\(q_1\) \((a, R, q_0)\)
\(q_2\)

We can alternatively represent \(\delta\) using a state diagram as shown below [1]:

The diagram consists a set of nodes corresponding to the states of the TM. An arc from state \(q\) to state \(p\) is labeled by one or more items of the form \(X/Y;D\), where \(X\) and \(Y\) are tape symbols, and \(D\) is a direction, either \(L\) or \(R\). That is, whenever  \(\delta(q,X) = (Y, D, p)\), we find the label \(X/Y;D\) on the arc from \(q\) to \(p\). Also, in the above diagram the blank symbol \(B\) is represented with an underscore (_).

References