College · 30 classes

Computer Science - Theory of Computation

Each class is a short animated explainer with narration and illustrations, plus quick checks and a mastery quiz. Your progress saves automatically as you complete classes.

▶ Watch class 1 free — no sign-up
Progress map · 30 classes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Not startedStartedCompletedMastered
01
Beyond the Keyboard: What is Computation?
Not started
Start →
02
The Grammar of Machines: Speaking in Formal Languages
Not started
Start →
03
The Art of the Airtight Argument: Mastering Mathematical Proof
Not started
Start →
04
Meet the Simplest Machine: The Deterministic Finite Automaton
Not started
Start →
05
The Power of Guessing: Nondeterministic Finite Automata
Not started
Start →
06
From Automata to Regex: Unifying our Models with Kleene's Theorem
Not started
Start →
07
How to Prove a Negative: The Pumping Lemma for Regular Languages
Not started
Start →
08
The Regular Language Toolkit: Closure, Decisions, and Minimization
Not started
Start →
09
Beyond Regularity: Describing Structure with Context-Free Grammars
Not started
Start →
10
Giving Automata a Memory: The Pushdown Automaton
Not started
Start →
11
Two Sides of the Same Coin: The Equivalence of PDAs and CFGs
Not started
Start →
12
The Pumping Lemma Strikes Back: The Context-Free Version
Not started
Start →
13
The Ultimate Machine: An Introduction to the Turing Machine
Not started
Start →
14
Coding on an Infinite Tape: Programming the Turing Machine
Not started
Start →
15
Do More Tapes Help? Exploring Variants of the Turing Machine
Not started
Start →
16
The Edge of Computability: The Church-Turing Thesis
Not started
Start →
17
The Machine That Simulates All Others: The Universal Turing Machine
Not started
Start →
18
Problems We Can Solve: Decidability in Regular and Context-Free Languages
Not started
Start →
19
The Unanswerable Question: Alan Turing and the Halting Problem
Not started
Start →
20
Dominoes and Grammars: Post's Correspondence Problem and Rice's Theorem
Not started
Start →
21
The Art of Reduction: Proving New Problems are Unsolvable
Not started
Start →
22
A Place for Everything: The Chomsky Hierarchy of Languages
Not started
Start →
23
Beyond 'Solvable': Measuring the *Cost* of Computation
Not started
Start →
24
What is an 'Efficient' Algorithm? Exploring the Class P
Not started
Start →
25
The Power of a Lucky Guess: Understanding the Class NP
Not started
Start →
26
The Million Dollar Question: Does P Equal NP?
Not started
Start →
27
The Hardest Problems in NP: NP-Completeness and the Cook-Levin Theorem
Not started
Start →
28
Into the Polynomial Hierarchy: PSPACE, EXPTIME, and Beyond
Not started
Start →
29
Breaking the Mold: Quantum and Probabilistic Computing
Not started
Start →
30
From Theory to Reality: Cryptography, AI, and the Future of Computation
Not started
Start →
See inside a class

Here’s all of Class 1, in full.

Every class is 13 cards · narrated film + illustration · 2 quick checks · an interactive · a 4-question mastery quiz. Nothing hidden — this is the complete text of Beyond the Keyboard: What is Computation?.

▸ Read the full class — Beyond the Keyboard: What is Computation?

Consider the statement: 'This statement is false.' If it’s true, then it must be false. If it’s false, then it must be true. This is the liar paradox, a puzzle known since antiquity. It reveals a crack in the foundation of logic and language, a place where self-reference creates undecidability. This isn't just a philosophical curiosity. In 1931, Kurt Gödel showed that any sufficiently powerful mathematical system contains statements that are true, but cannot be proven true within that system. He effectively showed that this paradox lives at the heart of mathematics itself. This course begins here, at this limit. Because before we can understand what computers can do, we must first grapple with the profound discovery that there are things that are fundamentally, and provably, beyond the reach of any computation whatsoever.

1. Defining the Undefinable

To understand the limits of machines, we must first define what a machine is.

So, what is the core problem? It's the problem of definition. Without a rigorous, mathematical definition of 'computation,' we can't prove anything about its limits. We can build faster chips, write cleverer software, but we remain in the dark about what is fundamentally possible. Imagine I ask you to write a program that can analyze any other program and tell me if it will ever finish running or if it will loop forever. This is the famous Halting Problem. Your intuition might be to just run the program and see. But if it hasn't stopped after a day, or a year, or a billion years, do you conclude it's in an infinite loop, or just that it's very slow? You can't know. This ambiguity is the problem. To prove that no such universal bug-checker can exist, we first need a formal model of what a 'program' is. This course is built around two central questions that stem from this need. First, what problems are solvable by a computational process at all? This is the domain of Computability Theory. Second, for the problems that are solvable, what resources—like time and memory—do they require? This is the domain of Complexity Theory. To begin, we must define our object of study: the algorithm itself.

  • Computation lacks rigorous mathematical definition
  • Limits cannot be proven without formalism
  • Halting Problem motivates the urgency
  • Course splits questions into computability and complexity
  • Begin by defining the algorithm itself

2. The Church-Turing Thesis

An intuitive idea of an 'algorithm' is formalized into a powerful hypothesis.

So how do we define computation? Intuitively, a computation is an 'effective method'—a finite sequence of simple, unambiguous, mechanical steps that a human could, in principle, follow with pencil and paper to arrive at an answer. This is fine as an intuition, but it's not a mathematical definition. The breakthrough of the 1930s was to formalize this. Several different formalisms were proposed, but they all turned out to be equivalent in power. This led to what we now call the Church-Turing Thesis. It states: any function that is calculable by an 'effective method' is calculable by a Turing Machine. This isn't a theorem we can prove, because 'effective method' is an informal concept. It's a thesis—a hypothesis about the nature of computation that we accept as a definition. It forges a link between the intuitive world of algorithms and the formal world of mathematics. Every time someone invents a new model of computation, from quantum computers to DNA computing, one of the first questions we ask is whether it can solve problems that a Turing Machine cannot. So far, for problems with a single, definite answer, the answer has been no. The thesis has held for nearly a century.

  • Effective method is a finite mechanical procedure
  • Church-Turing Thesis equates it to TM computability
  • Multiple formalisms proven equivalent
  • Thesis defines computation rather than proves
  • Held nearly a century without challenge

3. Hilbert's Tenth Problem

The quest to automate mathematics led to the discovery of its limits.

This formalization didn't arise in a vacuum. It was the direct result of a crisis in mathematics. The story begins with Gottfried Leibniz in the 17th century, who dreamed of a 'calculus ratiocinator,' a universal logical calculus that could solve all human disputes. This dream was carried forward to the early 20th century by the great mathematician David Hilbert. Hilbert proposed a grand program to place all of mathematics on a firm, formal foundation. In a famous 1928 address, he posed a challenge called the *Entscheidungsproblem*, or the 'decision problem.' He asked for an algorithm that could take any statement of first-order logic and decide, in a finite number of steps, whether that statement was universally valid. Essentially, Hilbert was asking for a machine that could automate all of mathematics. This single question motivated a generation. In 1936, two mathematicians, working independently, answered Hilbert's question in the negative. In the United States, Alonzo Church used his lambda calculus. And in England, a young Alan Turing conceived of an abstract machine—the Turing Machine—to prove that no such general algorithm could exist. Their work showed that there are fundamental limits to what can be decided algorithmically, shattering Hilbert's dream but laying the foundation for computer science.

  • Leibniz dreamed of calculus ratiocinator
  • Hilbert posed Entscheidungsproblem in 1928
  • Church used lambda calculus to answer negatively
  • Turing used abstract machine in 1936
  • Their work founded computer science

4. The Machine on the Tape

How the simplest possible computer model works, step by mechanical step.

Let's visualize Turing's machine. It's an abstraction, designed for proof, not for construction. First, imagine an infinitely long tape. This tape is divided into discrete cells. Think of it as a computer's memory, but one that is unbounded—it never runs out. Each cell on this tape can hold exactly one symbol from a finite alphabet, for example, a '0', a '1', or a special 'blank' symbol. Poised over this tape is a read/write head. The head can see only one cell at a time. It can read the symbol in that cell, and it can write a new symbol, erasing what was there. After it writes, it can move one cell to the left or one cell to the right. What controls the head? A finite state control. This is the 'processor' of the machine. It is always in one of a finite number of states. The machine's entire operation is governed by a set of rules—its program. A rule looks like this: 'If you are in state Q1 and you see the symbol '0' on the tape, then write a '1', move one step to the right, and transition into state Q2.' That's it. A set of states, a tape, and a list of rules. This simple, mechanical process is, according to the Church-Turing thesis, capable of performing any calculation that any physical computer, now or in the future, can perform.

  • Infinite tape divided into discrete cells
  • Read-write head sees one cell at a time
  • Finite state control executes transition rules
  • Each rule prescribes write, move, new state
  • Performs any computation given enough resources

5. The Formal 7-Tuple

Translating the mechanical intuition into the precise language of mathematics.

To prove things about this machine, we must define it with mathematical precision. A Turing Machine is formally defined as a 7-tuple. Let's walk through its components. First, we have Q, a finite, non-empty set of states. This is the machine's internal memory. Second, Sigma, the input alphabet. These are the symbols that can be on the tape at the start of the computation. It cannot contain the blank symbol. Third, Gamma, the tape alphabet. This is the complete set of symbols the machine can write to the tape, and it must contain Sigma as a subset, plus the blank symbol. Fourth, and this is the most critical part, is delta, the transition function. This function is the machine's program. It takes two inputs: the current state from Q, and the current tape symbol from Gamma. It produces three outputs: the next state, the symbol to write on the tape, and the direction, Left or Right, to move the head. Fifth, q_zero, the start state, which is an element of Q. Sixth, B, the blank symbol, which is in Gamma but not Sigma. Finally, F, a subset of Q, is the set of final or accepting states. If the machine's control enters any state in F, the computation halts and succeeds.

  • Standard TM is seven-tuple
  • Q is finite set of states
  • Sigma is input alphabet
  • Gamma is tape alphabet containing blank
  • Delta maps state-symbol to state-symbol-direction

6. Simplicity, Universality, and Robustness

The key properties that make the Turing Machine the foundation of computer science.

This formal model, despite its apparent limitations, has several profound and powerful features. The first is its radical simplicity. Because the machine has so few components, it is an ideal object for mathematical proof. We can reason about the behavior of any algorithm by analyzing the behavior of a corresponding, simple Turing machine. The second feature is universality. Turing's most significant insight was arguably the concept of a Universal Turing Machine, or UTM. This is a specific Turing machine whose program is designed to simulate any other Turing machine. You provide the UTM with a description of another machine M on its tape, followed by the input for M, and the UTM will simulate M step-for-step. This is the theoretical foundation of the general-purpose, programmable computer. Your laptop is a physical approximation of a UTM. Third is its robustness, captured by the Church-Turing thesis. All other reasonable models of computation proposed have been proven to be equivalent to or weaker than the Turing machine. Finally, it provides a definitive boundary. With this formalism, we can cleanly separate the set of all problems into two categories: the computable and the uncomputable. This is the line that defines our field.

  • Simplicity: The minimal model is ideal for formal proofs about computation.
  • Universality: A Universal Turing Machine can simulate any other Turing Machine, forming the basis for general-purpose computers.
  • Robustness: The model is equivalent in power to all other known formalisms for classical computation (Church-Turing Thesis).
  • Definitive Boundary: It provides a clear, formal line between computable and uncomputable problems.

7. An Even Number of Ones

A concrete example of a Turing Machine that solves a simple decision problem.

Let's make this concrete by designing a Turing Machine that decides a simple language: the set of all strings composed of an even number of 1s. The input on the tape will be a string of one or more 1s, surrounded by blanks. We need a way to count, or rather, to keep track of parity. We can do this with two states: q_even and q_odd. We'll designate q_even as our start state. The head starts on the leftmost '1'. In state q_even, if we see a '1', it means we've seen our first, third, fifth, etc., '1'. So, we should transition to the q_odd state. We'll also mark the '1' as seen by replacing it with a blank, then move right. Now, in state q_odd, if we see another '1', we've found a pair. We transition back to q_even, replace the '1' with a blank, and move right. We shuttle back and forth between these two states, consuming one '1' at a time. Eventually, we will move right and find a blank symbol, meaning we've reached the end of the input. If we are in state q_even when we see that blank, it means every '1' had a pair. We've counted an even number. So, we transition to a final 'accept' state and halt. If we're in q_odd, we've seen an odd number, and we can halt in a non-accepting state.

  • Decide even number of ones
  • Use states q-even and q-odd to track parity
  • Flip state on every 1 encountered
  • Erase processed ones with blanks
  • Accept if halting in q-even

8. Computable vs. Practical

The Turing Machine is a perfect model of possibility, but a poor model of performance.

The Turing Machine is a model of what is *possible* to compute, not what is *practical*. Its primary limitation is that it has no built-in notion of efficiency. The machine we just designed for checking parity is grotesquely slow. A real computer would use a single flip-flop circuit to solve this instantly. The Turing model, in its raw form, is a terrible guide for writing good software because it treats a one-step operation and a trillion-step operation as equally 'computable'. We can, and will, augment the model by counting the number of steps (time complexity) or the number of tape cells used (space complexity). This is how we build complexity theory on top of computability theory. But the base model is blind to resources. Furthermore, it is a poor model for many modern computational paradigms. It is inherently sequential. It struggles to represent concurrent or distributed systems. It has no concept of interaction or real-time input. While we can create variants like probabilistic or non-deterministic Turing machines to explore these ideas, the classical, deterministic machine defines a very specific, and limited, mode of computation. Its power is in what it enables us to prove about limits, not in how it guides us to build systems.

  • Model captures possibility not practicality
  • Treats all steps as equally computable
  • Bad guide for efficient software design
  • Inherently sequential, ignores concurrency
  • Real time and interaction not modeled

9. The Chomsky Hierarchy

Placing the Turing Machine in a family of simpler computational models.

The Turing Machine is not the only model of computation. It is the most powerful in a nested sequence of models known as the Chomsky Hierarchy. You may have encountered some of these in other courses. At the bottom of the hierarchy are the weakest machines: Finite Automata. A finite automaton is essentially a Turing Machine with no tape at all; it only has a set of states and transitions. Its memory is limited to the single state it is currently in. These machines are used for simple pattern matching, like regular expressions, and can only recognize the class of regular languages. If we give a finite automaton a single stack for memory—a last-in, first-out data structure—we get a Pushdown Automaton. This machine is more powerful; it can recognize context-free languages, which are sufficient to describe the syntax of most programming languages. The Turing Machine sits at the top of this hierarchy. Its infinite, randomly-accessible tape is a more powerful form of memory than a simple stack. This allows it to recognize the recursively enumerable languages. Each step up this hierarchy—from no memory, to a stack, to a full tape—unlocks the ability to solve a broader and more complex class of problems.

  • Finite automata recognize regular languages
  • Pushdown automata recognize context-free languages
  • Linear-bounded automata recognize context-sensitive
  • Turing machines recognize recursively enumerable
  • Each step up unlocks broader problem class

10. Common Misconceptions

Four common mistakes to avoid when thinking about computation.

When first studying computability, several conceptual traps are common. The most significant is conflating what is computable with what is feasible. A problem being 'decidable' or 'computable' only means a Turing machine exists that will eventually halt with the correct answer. It makes no claim about whether that will happen before the heat death of the universe. This is the computability vs. complexity distinction. A second pitfall is to take the 'infinite tape' too literally. The model does not require an actually infinite physical object. It requires an *unbounded* tape. The machine can always ask for one more cell if it needs it. It's a model of unbounded memory, not infinite memory usage on every problem. Third, many students mistakenly believe the Church-Turing Thesis has been 'proven.' It is a definition, not a theorem. It connects a formal model to an intuitive notion. It can be challenged and potentially falsified if a convincing, physically realizable counterexample were found, but it cannot be proven in a mathematical sense. Finally, avoid mistaking the model for an engineering blueprint. We don't build physical Turing machines. We use the mathematical abstraction to prove universal truths about the limits of any computer we could possibly build.

  • Confusing Computability with Complexity: 'Computable' does not imply 'efficiently computable'.
  • Misinterpreting the Infinite Tape: The model assumes unbounded memory, not that infinite memory is used.
  • Believing the Church-Turing Thesis is a Theorem: It is a foundational, but unprovable, definition linking formalism to intuition.
  • The Model vs. The Implementation: The Turing Machine is a tool for mathematical proof, not a design for a physical computer.

11. Texts, Simulators, and Sources

Resources for deepening your understanding of these foundational concepts.

To master this material, you'll need to go beyond the lecture. The canonical textbook for this field, and the one we will follow, is Michael Sipser's "Introduction to the Theory of Computation." It is a model of clarity and precision. For a deeper dive into the historical context and Turing's original genius, I highly recommend Charles Petzold's "The Annotated Turing." It provides a brilliant, accessible walkthrough of Turing's 1936 paper. To build an intuition for how these machines work, you should experiment. JFLAP, the Java Formal Languages and Automata Package, is an excellent piece of academic software that allows you to design and run your own automata, from finite state machines up to Turing machines. Finally, I encourage you to read the primary sources. Turing's paper, "On Computable Numbers, with an Application to the Entscheidungsproblem," is one of the most important intellectual achievements of the 20th century. Reading it directly is a challenging but incredibly rewarding experience.

  • Textbook: Michael Sipser, "Introduction to the Theory of Computation"
  • Historical Context: Charles Petzold, "The Annotated Turing"
  • Software Simulator: JFLAP (Java Formal Languages and Automata Package)
  • Primary Source: A. M. Turing, "On Computable Numbers..." (1936)

12. Design a Palindrome Checker

This week's problem: translate an intuitive algorithm into a formal Turing Machine.

Your task for this week is to apply these concepts by designing a Turing Machine on paper. The problem is to decide whether an input string of 0s and 1s is a palindrome—that is, it reads the same forwards and backwards. For example, '101101' is a palindrome; '1010' is not. Before you think about states and transitions, think about the mechanical process. How would you check this with a pencil and a very long piece of paper? You would likely look at the first character, remember it, go to the last character, and see if they match. If they do, you'd erase both and repeat the process on the smaller string. If they don't, you stop and reject. Now, translate that intuition into a formal machine. What states do you need? You'll need states for 'moving right to find the end,' 'remembering a 0,' 'remembering a 1,' 'moving left to find the start,' and so on. Your goal is to produce the full 7-tuple for your machine. Define your sets Q, Sigma, and Gamma, and then write down the list of transitions for your delta function. This exercise will force you to bridge the gap between an informal algorithm and its formal, computational representation.

  • Design TM recognizing binary palindromes
  • Read first symbol and remember in state
  • Travel to last symbol and compare
  • Erase matched pair and recurse inward
  • Specify the seven-tuple explicitly

13. Computation Defined

Today, we established the central question of what can be computed and introduced the formal definition that makes this question answerable. The Turing Machine provides a simple, robust, and universal model that separates the computable from the uncomputable.

  • Computation is a process that can be described by a formal model, such as a Turing Machine.
  • The Church-Turing Thesis posits that this formal model captures the full power of any intuitive 'effective method' of calculation.
  • This formalism allows us to prove the existence of fundamental limits, including uncomputable problems.
  • The Turing Machine is a model of what is possible (computability), not what is practical (complexity).
  • Our language for analyzing computation will be that of these formal systems: sets, functions, and automata.

Mastery quiz

  1. What does the Church-Turing Thesis state?
    • Every Turing Machine halts on every input
    • Any function calculable by an effective method is calculable by a Turing Machine
    • Quantum computers can solve problems Turing Machines cannot
    • The Halting Problem is decidable
  2. Which historical challenge, posed by David Hilbert in 1928, asked for an algorithm to decide the validity of any first-order logic statement?
    • The liar paradox
    • Hilbert's calculus ratiocinator
    • The Entscheidungsproblem (the decision problem)
    • Gödel's incompleteness theorem
  3. In the Chomsky Hierarchy, which machine results from giving a finite automaton a single stack for memory?
    • A Universal Turing Machine
    • A Pushdown Automaton
    • A deterministic Turing Machine
    • A finite automaton with no tape
  4. According to the class, what does it mean for the Turing Machine's tape to be 'infinite'?
    • The machine uses infinite memory on every problem
    • The tape is unbounded — the machine can always ask for one more cell if needed
    • The tape physically exists as an infinite object
    • The tape can hold infinitely many symbols in one cell
HomePracticeFeedBlogMe