Turing Complete - Computerphile
Understanding the concept of Turing completeness is fundamental to computer science, defining the absolute boundaries of what programming languages and computational systems can achieve. This chapter explores the theoretical mechanics of Turing machines, the historical contributions of Alan Turing and Charles Babbage, and the practical realities of memory limitations in modern hardware.
1. Introduction: What is Turing Completeness?
When evaluating programming languages (such as Fortran, Basic, Pascal, Cobol, C, C++, and Java), computer scientists frequently ask whether a language is Turing complete.
- Definition of Turing Completeness: A system or programming language is Turing complete if it possesses the computational power required to simulate a Universal Turing Machine.
- The Usual Suspects: Virtually all general-purpose programming languages used in industry today fall into this category.
- Core Implication: If a language is Turing complete, it can theoretically compute any problem that is computable by any other algorithmic system, given enough time and memory.
2. The Core Mental Model: The Turing Machine
To understand what makes a language Turing complete, we must look at the foundational model established by Alan Turing in the late 1930s.
Real-Life Analogy: The Infinite Paper Tape and Reader
Imagine a mechanical worker sitting at a desk with an infinitely long roll of paper tape divided into discrete squares.
- Each square can either be blank or contain a simple symbol (conventionally restricted to zeros and ones).
- A read/write head sits over the tape, able to inspect the current symbol, erase it, write a new symbol, and shift the tape one step to the left or right.
... [0] [1] [1] [0] [1] [0] [0] ...
^
|
Read/Write Head reads/writes 0 or 1, then shifts left or right
Despite its extreme simplicity—manipulating mere zeros and ones on a strip of tape—this abstract model is powerful enough to compute anything that can mathematically be computed. While a raw Turing machine program might require 10 trillion steps to execute what a modern high-level language does in a few lines, in principle, its computational capability is absolute.
3. Charles Babbage and "Babbage Complete"
While Alan Turing formalized the mathematics in the 1930s, computer science historians often argue that the concept should rightfully be called Babbage Complete, referencing 19th-century English mathematician and inventor Charles Babbage.
- From Difference Engines to Analytical Engines: Babbage initially built massive calculating machines (Difference Engines) weighing tons and constructed entirely of brass cogwheels.
- Simulating Human Thought: Babbage realized that to move beyond a simple pocket calculator, a machine needed to mimic human-like decision-making.
- The Breakthrough Insight: Babbage determined that computational power requires conditional branching (if-then-else logic). The machine must inspect data and alter its behavior dynamically:
Structure & Concept Flow
4. The Two Bedrock Pillars of Turing Completeness
To achieve Turing completeness, a system must satisfy two indispensable requirements at its bedrock level:
- Conditional Branching (Decision Making): The ability to evaluate data and make a two-way choice (
if-then-else). This implies that execution flow does not simply cascade downward line-by-line; it can jump to entirely different memory locations based on runtime evaluations.- Low-level Reality: Under the hood, assembly languages utilize explicit
jmp(jump) orgotoinstructions to shift execution pointers across memory addresses.
- Low-level Reality: Under the hood, assembly languages utilize explicit
- Arbitrary / Unlimited Amount of Memory: The system must be capable of expanding its working memory to whatever size the computation demands. In Turing's model, this is represented by the infinite tape. In modern systems, this translates to having access to as much RAM as the problem requires.
5. Theoretical Reality: Are Modern Computers Truly Turing Complete?
A fascinating paradox arises when comparing theoretical Turing machines to physical hardware:
Note: Strictly speaking, no modern computer is a true Turing machine.
Every physical computer possesses finite memory (e.g., 8GB, 16GB, or 128GB of RAM). Once physical memory is exhausted, the computer cannot allocate further space, violating the theoretical requirement of an infinite tape.
The Chomsky Hierarchy Distinction
- Chomsky Type 0 (Unrestricted Grammars / Turing Machines): Characterized by arbitrary amounts of memory and operations that may run infinitely without guaranteeing termination (the Halting Problem).
- Chomsky Type 1 (Context-Sensitive Grammars): Because physical computers are constrained by finite memory and must terminate within bounded resources, they technically fall into lower tiers of the Chomsky hierarchy in strict formal automata theory.
6. Summary of Computational Models
7. Summary and Key Takeaways
- Universal Benchmark: Turing completeness defines whether a programming language or system can simulate a Universal Turing Machine and compute any computable function.
- The Usual Suspects: Major general-purpose languages (C, C++, Java, Python, Pascal, etc.) are all Turing complete.
- The Turing Machine Model: Based on an infinite strip of tape with a read/write head processing binary patterns (zeros and ones).
- Historical Roots: While formalized by Alan Turing, the core requirement of conditional branching was pioneered by Charles Babbage with his mechanical Analytical Engine.
- Bedrock Requirements: A system requires conditional branching (dynamic execution paths via
if-else/goto) and arbitrary memory allocation. - The Hardware Paradox: Real-world computers are technically not true Turing machines because their physical memory (RAM) is strictly finite.
- Chomsky Hierarchy Impact: Finite memory boundaries and termination guarantees drop physical computers out of Chomsky Type 0 into restricted memory tiers.