Definition and Components

COS3701 - Theoretical Computer Science III · Turing Machines

Definition and Components of Turing Machines

A Turing machine is a theoretical model of computation that defines an abstract machine. It manipulates symbols on a strip of tape according to a set of rules. Turing machines are fundamental in the field of theoretical computer science, as they help us understand the limits of what can be computed.

Components of a Turing Machine

A Turing machine consists of several key components:

  • Tape: An infinite length of tape divided into cells. Each cell can hold a symbol from a finite alphabet. The tape serves as both input and storage for the machine.
  • Head: A read/write head that can move left or right along the tape. It reads the symbol in the current cell and can write a new symbol in that cell.
  • State Register: This holds the current state of the Turing machine. The machine can be in one of a finite number of states, including a start state and one or more accept or reject states.
  • Transition Function: A set of rules that dictates how the machine behaves. It takes the current state and the symbol being read, and it specifies the next state, the symbol to write, and the direction to move the head.

Remember: The Turing machine operates based on its transition function, which is crucial for its computation process.

Formal Definition

A Turing machine can be formally defined as a 7-tuple (Q, Σ, Γ, δ, q0, q_accept, q_reject), where:

  • Q: A finite set of states.
  • Σ: A finite set of input symbols (input alphabet).
  • Γ: A finite set of tape symbols (tape alphabet), where Σ ⊆ Γ and includes a blank symbol.
  • δ: The transition function, δ: Q × Γ → Q × Γ × {L, R}, where L means move left and R means move right.
  • q0: The initial state from Q.
  • q_accept: The accept state, indicating successful computation.
  • q_reject: The reject state, indicating unsuccessful computation.

Example of a Turing Machine

Consider a simple Turing machine that accepts the language L = {a^n b^n | n ≥ 0}. This language consists of strings with equal numbers of 'a's followed by 'b's. The Turing machine will have the following components:

  • States: Q = {q0, q1, q2, q_accept, q_reject}
  • Input Alphabet: Σ = {a, b}
  • Tape Alphabet: Γ = {a, b, X, Y, blank}

In this case, 'X' and 'Y' are used to mark the symbols that have been processed. The transition function could be defined as follows:

δ(q0, a) = (q0, X, R)  // Replace 'a' with 'X' and move right
δ(q0, b) = (q1, Y, L) // Replace 'b' with 'Y' and move left
δ(q0, blank) = (q_accept, blank, R) // If blank, accept
δ(q1, X) = (q0, X, R) // Move back to the right on 'X'
δ(q1, Y) = (q1, Y, L) // Move left on 'Y'
δ(q1, blank) = (q_reject, blank, R) // If blank, reject

In this example, the Turing machine starts in state q0. It scans the tape for 'a's and replaces them with 'X'. After replacing an 'a', it moves right until it finds the first 'b'. It then replaces the 'b' with 'Y' and moves left back to the first 'X'. This process continues until the machine reaches the blank symbol, at which point it either accepts or rejects the input.

Watch out: Ensure that the transition function is complete. If there are states or symbols that are not accounted for, the Turing machine may not operate correctly.

Operation of a Turing Machine

The operation of a Turing machine is based on its transition function. The machine starts in the initial state (q0) with the tape containing the input string. The head is positioned at the beginning of the input. The machine performs the following steps:

  1. Read the symbol under the head.
  2. Use the transition function to determine the next state, the symbol to write, and the direction to move the head.
  3. Write the new symbol in the current cell.
  4. Move the head left or right based on the instruction from the transition function.
  5. Repeat the process until the machine enters either the accept state (q_accept) or the reject state (q_reject).

Types of Turing Machines

While this topic focuses on the basic definition and components of Turing machines, it is important to note that there are various types of Turing machines. These include:

  • Deterministic Turing Machines (DTMs): These machines have a single transition for each state and symbol combination.
  • Non-deterministic Turing Machines (NTMs): These machines can have multiple transitions for the same state and symbol combination, allowing them to explore several computation paths simultaneously.
  • Multi-tape Turing Machines: These machines have multiple tapes and heads, enabling them to perform more complex computations.

Tip: Familiarise yourself with the various types of Turing machines, as they will be important when studying more advanced topics such as the Chomsky hierarchy and the Church-Turing thesis.

Conclusion

The Turing machine is a powerful theoretical model that helps us understand the limits of computation. Its components—tape, head, state register, and transition function—work together to perform calculations. By understanding these components and how they operate, you will be better prepared to explore more complex topics in theoretical computer science.

Check your understanding

  • What are the components of a Turing machine?
  • Define the transition function in the context of a Turing machine.
  • Explain the difference between a deterministic Turing machine and a non-deterministic Turing machine.
  • What is the significance of the accept and reject states in a Turing machine?