BCS 402 · Dr. Arash Kermani · CUD

Prerequisites — what to know before Day 1

Our course starts at Sipser Chapter 4 / MIT 18.404J Lecture 7. Everything below is the foundation we will assume.
≈ 8 hours of self-study covers it. All MIT videos are free on OCW.
← back to course site 💬 Ask Khayyam ↗

What's in this page

🎧 Overview

Eleven topics, each with a written explanation, a hand-drawn diagram, and a pointer to the place in Sipser's textbook and the matching MIT lecture video. Read it top-to-bottom in one sitting and you have the vocabulary for our entire semester.

🎧 Narration

§ 0 · Sets, functions, strings, languages

A finite alphabet Σ is just a finite collection of symbols (the simplest is Σ = {0, 1}). A string is a finite sequence of symbols from Σ. The empty string is ε. The set of all finite strings over Σ is written Σ*. A language is any subset L ⊆ Σ*.

From symbols to languages alphabet Σ { 0, 1 } finite set of symbols strings of length ≤ k Σ* ε, 0, 1, 00, 01, 10, 11, … all finite strings pick any subset language L { ε, 0, 00, 000, … } subset of Σ* Vocabulary: |w|= length of string w ε= empty string · |ε| = 0 w · v= concatenation wᴿ= reversal of w
An alphabet is a finite set. Σ* is the (infinite) set of all finite strings you can form. A language is any subset of Σ*. Every algorithmic question in this course is "is this string in this language?".

Set operations you'll see constantly

Set operations on languages A and B A B A ∪ B union A B A ∩ B intersection A A̅ = Σ* − A complement A B A △ B symmetric difference
Four set operations. Symmetric difference (A △ B) — the striped region — is the key to the EQDFA algorithm in Module 1.

Function classification

Injective · Surjective · Bijective Injective (one-to-one) A B distinct inputs → distinct outputs Surjective (onto) A B every B value is hit Bijective A B perfect pairing · |A| = |B|
Injective = no collisions; surjective = nothing left over; bijective = both. Bijections are how we'll prove two infinite sets are "the same size" (used in Cantor's diagonal argument).
📖 Read: Sipser §0.2 Sipser §0.4 (proof techniques) · ⏱ Effort: 1 hour.
🎧 Narration

§ 1 · Deterministic finite automata (DFA)

A DFA is the simplest computing model: finitely many states, a read-only input head that moves left-to-right, and a deterministic transition function. Given a string, the DFA either accepts or rejects after reading the last symbol.

DFA for "strings with an even number of 0s" start q₀ accept · even count q₁ reject · odd count 0 0 1 1 DFA = (Q, Σ, δ, q₀, F) Q = {q₀, q₁} Σ = {0, 1} δ(q₀,0) = q₁, δ(q₀,1) = q₀ δ(q₁,0) = q₀, δ(q₁,1) = q₁ start = q₀ F = {q₀}
A DFA is a 5-tuple. Double circle = accept state. The string "0101" traces q₀ → q₁ → q₁ → q₀ → q₀ — ends in accept state, so accepted.
📖 Read: Sipser §1.1 🎬 Watch: MIT 18.404J L1 ⏱ Effort: 1 hour.
🎧 Narration

§ 2 · Nondeterministic finite automata (NFA)

An NFA can be in multiple states at once, has ε-transitions (free moves), and several edges can leave a state with the same label. Despite seeming more powerful, every NFA can be converted to a DFA via the subset construction — at the cost of exponentially many states.

NFA → DFA subset construction (sketch) NFA · "strings ending in 01" A B C 0, 1 0 1 3 NFA states · A nondeterministically "guesses" when string is about to end Equivalent DFA · 2³ = 8 possible state-subsets, only 3 reachable {A} {A,B} {A,C} 0 1 Each DFA state = the set of NFA states the input could currently be in. 2ⁿ possible subsets.
Subset construction: every DFA state is a subset of NFA states. For an NFA with n states, the equivalent DFA can have up to 2ⁿ states — exponential blow-up, but always finite.
📖 Read: Sipser §1.2 🎬 Watch: MIT 18.404J L1–L2 ⏱ Effort: 1.5 hours.
🎧 Narration

§ 3 · Regular expressions

Regular expressions describe regular languages with a compact algebra: ∅, ε, single characters, union (∪), concatenation (·), Kleene star (*). Kleene's theorem says regex, NFA, and DFA all recognize exactly the same class of languages — the regular languages.

Three equivalent representations · the regular languages Regex (0 ∪ 1)*01 "any prefix, then 01" NFA A B C guess when "01" starts DFA s 0 01 3 deterministic states build recover subset trivial Kleene's theorem: all three describe exactly the regular languages.
The three faces of regular languages are interchangeable. Regex is the algebraic, NFA the nondeterministic-machine, and DFA the deterministic-machine view.
📖 Read: Sipser §1.3 🎬 Watch: MIT 18.404J L2 ⏱ Effort: 45 min.
🎧 Narration

§ 4 · The pumping lemma

The pumping lemma is how we prove a language is not regular. Every long enough string in a regular language must have a "pump" — a substring that can be repeated any number of times and still stay in the language.

Pumping lemma · w = xyz where |xy| ≤ p and y ≠ ε string w (length ≥ pumping length p) x y · the pump z |xy| ≤ p For every i ≥ 0: x · yⁱ · z ∈ L i = 0: xz ∈ L i = 2: xyyz ∈ L i = 3: xyyyz ∈ L
If the language is regular and w is long enough, w decomposes as xyz with a pumpable middle. To prove a language is NOT regular: assume it is, pick a long string, then exhibit some i for which xyⁱz is not in the language.

Classic example. The language {0ⁿ1ⁿ : n ≥ 0} is not regular. Proof sketch: take w = 0ᵖ1ᵖ. Whatever x, y, z gives |xy| ≤ p, the pump y lies entirely in the 0s. Pumping makes the 0-count differ from the 1-count, so the result is not in L.

📖 Read: Sipser §1.4 🎬 Watch: MIT 18.404J L3 ⏱ Effort: 1 hour.
🎧 Narration

§ 5 · Context-free grammars (CFG)

A CFG is a set of production rules that rewrite variables into strings of variables and terminals. The language of the grammar is all strings of terminals derivable from the start variable. CFGs describe nested / matched structure (parentheses, palindromes, programming-language syntax).

CFG for balanced parentheses · derivation tree for "(())" Rules S → ( S ) S → S S S → ε start variable: S Parse tree for "(())" S ( S ) ( S ) ε S ⇒ (S) ⇒ ((S)) ⇒ (())
A CFG generates strings by recursively applying rules. The parse tree captures the derivation: leaves spell out the terminal string left-to-right. CFGs are strictly more powerful than regex — they can express nested structure regex cannot.

Chomsky Normal Form (CNF)

Every CFG can be converted to CNF, where every rule has either two variables on the right (A → BC) or a single terminal (A → a). CNF is what the CYK parsing algorithm needs (used in Module 1's ACFG widget).

📖 Read: Sipser §2.1 🎬 Watch: MIT 18.404J L3–L4 ⏱ Effort: 1.5 hours.
🎧 Narration

§ 6 · Pushdown automata (PDA)

A PDA = finite-state automaton + an unbounded LIFO stack. The stack lets it remember unbounded context, which is exactly the power needed for context-free languages. CFG ⇔ PDA equivalence is the bridge between grammars and machines.

Pushdown automaton · finite state + stack Input tape (read-only) (()) head Finite control q Stack (LIFO) $ ( ( top ↓ read symbol push / pop
A PDA reads input left-to-right, can push or pop the stack on each step, and accepts when its state is an accept state at the end of the input (or, in some variants, when the stack is empty). PDAs recognize exactly the context-free languages.
📖 Read: Sipser §2.2 🎬 Watch: MIT 18.404J L4 ⏱ Effort: 1 hour.
🎧 Narration

§ 7 · Turing machines (TM)

A Turing machine is the full computational model: a two-way read/write tape (unbounded in both directions, conceptually), a head that can move left or right one cell per step, and a finite control with accept and reject states. Everything in our course from Lecture 2 onward is about Turing machines.

Turing machine · two-way tape + finite control __1010______ Tape … extends infinitely both ways … head Finite control δ : Q × Γ → Q × Γ × {L, R} M = (Q, Σ, Γ, δ, q₀, qₐ, qᵣ)
A TM is a 7-tuple. The transition function δ reads (state, current cell), and prescribes (new state, write symbol, move L or R). When δ enters qaccept or qreject, the machine halts. Otherwise it might run forever.
📖 Read: Sipser §3.1 🎬 Watch: MIT 18.404J L5–L6 ⏱ Effort: 1.5 hours.
🎧 Narration

§ 8 · TM variants — all the same power

A surprisingly robust feature of Turing machines: many variations look more powerful, but in fact recognize exactly the same class of languages. The cost is sometimes polynomial time or constant tape blow-up, but the class is unchanged.

Variants of the Turing machine Single-tape basic model Multi-tape k tapes, k heads Nondeterministic branching computation Enumerator w₁ w₂ w₃ prints all of L All four variants recognize exactly the same class of languages — the Turing-recognizable (a.k.a. recursively enumerable) languages
Multi-tape and nondeterministic TMs can be simulated by single-tape deterministic ones, but at a polynomial / exponential time cost. They are equally powerful, but not equally efficient — this is what motivates complexity classes.
📖 Read: Sipser §3.2 🎬 Watch: MIT 18.404J L6 ⏱ Effort: 1 hour.
🎧 Narration

§ 9 · Church-Turing thesis

The Church-Turing thesis is an informal claim, not a theorem: everything that can be computed by an algorithm can be computed by a Turing machine. It lets us interchange "algorithm", "program", "procedure", and "Turing machine" in proofs.

Church-Turing thesis · the bridge between informal and formal Informal world • Pseudocode • Python · Java · C • Lambda calculus • Recursive functions Church-Turing thesis Formal world • Turing machines • Configurations • δ : Q × Γ → Q × Γ × {L,R} • Provable properties "There is an algorithm" ⇔ "There is a Turing machine" — used freely from Lecture 2 onward.
The Church-Turing thesis isn't a theorem we prove; it's a working assumption that has never been refuted in 90 years. It lets us describe TMs informally in English and trust the formal construction exists.
📖 Read: Sipser §3.3 🎬 Watch: MIT 18.404J L6 ⏱ Effort: 30 min.
🎧 Narration

§ 10 · Encodings: ⟨M⟩ and ⟨M, w⟩

A Turing machine is just a finite table of transitions. So you can encode it as a binary string ⟨M⟩. Once a TM is data, you can feed it as input to another TM — this is the foundation of the universal TM (Lecture 2) and every undecidability proof we will see.

A TM is just data · ⟨M⟩ is a string TM M (the picture) q₀ q₁ 0/1,R _/_,R encode ⟨M⟩ (the string) 10110100110010110010110... a binary representation of all of M Pair encoding ⟨M, w⟩ ⟨M⟩ # ⟨w⟩ a single string built from both
Once M is a string, we can write down questions like "does M accept w?" as language membership questions about pairs ⟨M, w⟩. This is what makes ATM = {⟨M, w⟩ : M accepts w} a well-defined language.
🎧 Narration

§ 11 · Decidable vs Turing-recognizable

This is the single most important distinction in the entire course. A TM that decides a language always halts with the correct yes/no answer. A TM that only recognizes a language accepts every yes-instance but may loop forever on no-instances.

Behavior of a recognizer vs a decider on input w DECIDER always halts w? accept reject no third option RECOGNIZER may loop forever w? accept reject loop forever loop = "no answer ever"
A decider gives a verdict for every input. A recognizer may loop forever on no-instances. The famous ATM language is recognizable (use a universal TM) but not decidable (Cantor diagonal kills the decider) — this is the gap that drives the entire undecidability story.

Day-one checklist · prove you're ready

Before the first lecture, every student should be able to:

If you can do all eight, you're ready. If two or more feel impossible, spend a day with Sipser chapters 0–3 before our first session.

Self-study schedule · 5 days, ≈ 8 hours total

DayTopicsSipserMIT videoHours
Day 1 Sets, functions, languages, proofs §0.2§0.4 1 h
Day 2 DFA · NFA · regular expressions §1.1§1.2§1.3 L1L2 2 h
Day 3 Pumping lemma · CFGs §1.4§2.1 L3 1.5 h
Day 4 PDAs · non-CFLs §2.2§2.3 L4L5 1.5 h
Day 5 Turing machines · variants · Church-Turing §3.1§3.2§3.3 L5L6 2 h

Free MIT videos and lecture notes: ocw.mit.edu/courses/18-404j-theory-of-computation-fall-2020

Notation cheat sheet

SymbolMeaning
Σfinite alphabet (often {0,1})
Σ*set of all finite strings over Σ
εempty string (length 0)
|w|length of string w
La language (subset of Σ*)
L(M)the language a machine M recognizes
⟨M⟩encoding of TM M as a binary string
⟨M, w⟩encoded pair of machine and input
δtransition function
AX"does X accept w?" language
EX"is L(X) empty?" language
EQX"do X₁ and X₂ accept the same?" language
⊆ · ⊊subset · proper subset
A △ Bsymmetric difference
p · ≤m · ≤Tpolynomial · mapping · Turing reduction