The Theory of Computation

This section explains the theory of computation. The Theory of Computation is a fundamental area in computer science that explores the nature of computation, what can and cannot be computed, and how different models of computation work. Key concepts include Turing machines, formal languages, and the limits of computation.

Turing Machines

A Turing machine (TM) is an abstract mathematical model of computation introduced by Alan Turing in 1936. It is used to define what is computable.

    Structure of a Turing Machine:

  • Tape: An infinite, one-dimensional tape divided into cells, each of which can hold a symbol from a finite alphabet.
  • Head: A read/write head that can move left or right across the tape and modify the symbols.
  • State Register: A set of states that the machine can be in, including the starting state and the halting state(s).
  • Transition Function: A function that dictates the machine’s next action based on its current state and the symbol under the head.
  • Alphabet: The set of symbols the machine can read or write on the tape (often includes a blank symbol).
  • Initial State: The state the machine starts in.
  • Accepting/Rejecting States: The final states that determine if the machine halts and accepts or rejects the input.

    Operation:

  • The machine starts in the initial state with an input written on the tape.
  • The machine reads the current symbol on the tape, applies the transition function, and then changes state, writes a new symbol, and moves the tape head.
  • The process continues until the machine enters a halting state (either accepting or rejecting the input).

Turing Completeness: A computational model is Turing-complete if it can simulate any Turing machine. This includes languages such as C, Python, or JavaScript, and also the Universal Turing Machine, which can simulate any other Turing machine.

Formal Languages

A formal language is a set of strings (sequences of symbols) constructed from a finite alphabet. Formal languages are used to define programming languages and describe syntactical structures.

  • Alphabet: A finite set of symbols. For example, in the binary alphabet, the symbols are {0, 1}.
  • String: A finite sequence of symbols from the alphabet. For example, "011" is a string over the alphabet {0, 1}.
  • Language: A set of strings. A formal language is a set of strings that are all valid according to some specific rules or grammar.

Types of Formal Languages

    Regular Languages:

  • Can be described by regular expressions or recognised by finite automata.
  • Simple to parse and analyse.
  • Limited in power, as they cannot handle nested structures (e.g., parentheses).

    Context-Free Languages (CFLs):

  • Can be described by context-free grammars (CFGs) or recognised by pushdown automata (PDA).
  • More powerful than regular languages, and can handle nested structures (e.g., balanced parentheses).
  • Used in programming language syntax (e.g., the structure of if-else statements).

    Context-Sensitive Languages:

  • Can be described by context-sensitive grammars (CSG).
  • More powerful than context-free languages and can express more complex structures.

    Recursively Enumerable Languages:

  • The most general class of languages.
  • Can be recognised by a Turing machine, but may not halt for all inputs (non-decidable).

Chomsky Hierarchy

The Chomsky hierarchy classifies languages into four levels based on their generative power:

  • Type 0 (Recursively Enumerable Languages): Described by Turing machines.
  • Type 1 (Context-Sensitive Languages): Described by context-sensitive grammars.
  • Type 2 (Context-Free Languages): Described by context-free grammars.
  • Type 3 (Regular Languages): Described by regular expressions and recognised by finite automata.

Finite Automata (FA)

Finite automata are abstract machines used to recognise regular languages. They come in two types:

    Deterministic Finite Automata (DFA):

  • For every state and input symbol, there is exactly one transition.
  • Simple to implement and efficient in recognising regular languages.

    Non-Deterministic Finite Automata (NFA):

  • Can transition to multiple states for the same input symbol or even without reading an input symbol (epsilon transition).
  • Although NFAs are more flexible, any NFA can be converted into an equivalent DFA.

Pushdown Automata (PDA)

A pushdown automaton is a computational model that uses a stack as additional memory. It can recognise context-free languages, such as those involving nested structures (e.g., balanced parentheses).

    A PDA consists of:

  • A finite set of states.
  • A stack alphabet.
  • A transition function that includes the current state, the input symbol, and the symbol on top of the stack.

Limits of Computation

The limits of computation refer to the problems that are inherently uncomputable, meaning no algorithm can solve them in a finite amount of time for all possible inputs.

    Decidability:

  • A decision problem is decidable if there exists an algorithm (a Turing machine) that can always provide a correct yes/no answer.
  • A problem is undecidable if there is no such algorithm that can solve all instances of the problem.

    Halting Problem:

  • One of the most famous undecidable problems is the halting problem, which asks whether a given Turing machine will halt on a given input.
  • Alan Turing proved that no algorithm can solve this problem for all possible Turing machines and inputs.

    Complexity Classes:

  • P (Polynomial Time): Problems that can be solved by a deterministic Turing machine in polynomial time. These are considered efficiently solvable.
  • NP (Nondeterministic Polynomial Time): Problems for which a solution can be verified in polynomial time, but it may not be possible to find the solution in polynomial time.
  • NP-complete: The hardest problems in NP, for which no polynomial-time solution is known, and solving one NP-complete problem in polynomial time would imply a solution for all NP problems.
  • NP-hard: Problems that are at least as hard as NP-complete problems but may not belong to NP.

Church-Turing Thesis

The Church-Turing Thesis posits that any function that can be computed by any mechanical process can also be computed by a Turing machine. This forms the foundation of modern computational theory, asserting that Turing machines are a model of "effective computation".

Key Takeaways:

  • Turing Machines are the core model of computation, providing a formal definition of what is computable.
  • Formal Languages categorise languages based on their structure and the computational models used to recognise them.
  • Finite Automata and Pushdown Automata recognise different classes of languages (regular and context-free languages, respectively).
  • The Limits of Computation show that not all problems are solvable by an algorithm, exemplified by the undecidability of the Halting Problem and the classification of problems into different complexity classes.

By understanding the theory of computation, we gain insight into both the power and limitations of computers, and how computational models form the foundation for programming, algorithms, and artificial intelligence (AI).

sign up to revision world banner
Southampton University
Slot