Theory of Computation
Complete exam notes Β· Beginner to Advanced Β· With tricks, analogies & examples
0. What is Theory of Computation? EASY
TOC studies three big questions:
- What problems CAN be solved by a computer? (Decidability)
- How efficiently can they be solved? (Complexity)
- What mathematical models describe computation? (Automata)
Key Terms β Plain English
| Term | Plain English | Example |
|---|---|---|
| Alphabet (Ξ£) | Set of allowed symbols | Ξ£ = {0,1} or {a,b,c} |
| String | Sequence of symbols from alphabet | "0101", "abc" |
| Language (L) | Set of strings (that follow some rule) | All strings starting with 'a' |
| Ξ΅ (epsilon) | Empty string β has zero characters | Like an empty box |
| Ξ£* (sigma star) | ALL possible strings over Ξ£ including Ξ΅ | All binary strings ever |
| Automaton | An abstract machine that reads input and decides | A traffic light controller |
1. Chomsky Hierarchy β EXAM FAV
| Type | Grammar | Machine | Example Language |
|---|---|---|---|
| Type 3 | Regular | FA (DFA/NFA) | aβΏ, (a+b)*ab |
| Type 2 | Context-Free | PDA | aβΏbβΏ |
| Type 1 | Context-Sensitive | LBA | aβΏbβΏcβΏ |
| Type 0 | Unrestricted | TM | Halting Problem |
R = Regular (Type 3) β C = Context-Free (Type 2) β P = Context-Sensitive (Type 1) β T = Turing (Type 0)
OR: Every Type 3 is Type 2, but NOT vice versa (like every square is a rectangle but not every rectangle is a square)
2. Deterministic Finite Automaton (DFA) β VERY IMP
Input coin β goes UNLOCKED. Push β goes LOCKED. That's it. Simple, deterministic, one step at a time.
Formal Definition
A DFA is a 5-tuple: M = (Q, Ξ£, Ξ΄, qβ, F)
| Symbol | Meaning | Example |
|---|---|---|
Q | Finite set of states | {q0, q1, q2} |
Ξ£ | Input alphabet | {0, 1} |
Ξ΄ | Transition function Ξ΄: Q Γ Ξ£ β Q | Ξ΄(q0, 0) = q1 |
qβ | Start state (initial) | q0 |
F | Set of final/accepting states | {q2} |
Key Rules of DFA
- From every state, for every input symbol, there is exactly ONE transition (no choice, no missing)
- A string is accepted if after reading all characters, we end in a state in F
- A string is rejected if we end in a non-final state
Example β DFA accepting strings ending in '1'
Language: L = {w β {0,1}* | w ends with 1}
Transition Table (same example)
| State | Input: 0 | Input: 1 |
|---|---|---|
| βq0 (start) | q0 | q1 |
| β q1 (final) | q0 | q1 |
Step 2: For "strings ending in X" β 2 states: "last was X" and "last was not X".
Step 3: For "exactly k occurrences" β need k+1 states (count 0 to k).
Step 4: Always add a dead/trap state if some transition is missing.
3. Non-Deterministic Finite Automaton (NFA) β VERY IMP
DFA vs NFA β Differences
| Feature | DFA | NFA |
|---|---|---|
| Transitions per state | Exactly 1 per symbol | 0, 1, or MORE per symbol |
| Ξ΅-transitions | Not allowed | Allowed (optional) |
| Transition function | Ξ΄: Q Γ Ξ£ β Q | Ξ΄: Q Γ Ξ£ β 2^Q (power set) |
| Acceptance | One path must end in F | ANY path ending in F |
| Power | Same as NFA! | Same as DFA! |
Every NFA can be converted to an equivalent DFA. They both accept exactly Regular Languages. NFA just makes it easier to design β DFA is easier to implement.
Example β NFA for strings ending in 'ab'
4. Ξ΅-NFA (Epsilon-NFA) MEDIUM
Ξ΅-Closure
Ξ΅-closure(q) = the set of ALL states reachable from q using ONLY Ξ΅-transitions (including q itself).
Ξ΅-closure(q0) = {q0, q1, q2, q3}Ξ΅-closure(q1) = {q1, q2, q3}Ξ΅-closure(q2) = {q2}
How to process input in Ξ΅-NFA
- Start with Ξ΅-closure(qβ)
- For each input symbol
a:- Find all states reachable via
afrom current set - Take Ξ΅-closure of that result
- Find all states reachable via
- Accept if final set contains any state in F
5. NFA β DFA Conversion (Subset Construction) β MOST IMP
Algorithm (Subset Construction)
- Start state of DFA = Ξ΅-closure(qβ) of NFA
- For each new DFA state (set of NFA states) and each input symbol:
- Find all NFA states reachable via that symbol from any state in the set
- Take Ξ΅-closure of the result β this is the new DFA state
- A DFA state is final if it contains ANY NFA final state
- Repeat until no new states
Full Worked Example
NFA over {a,b}: accepts strings ending in 'a'
NFA States: q0 (start), q1 (final)
Ξ΄_NFA: q0 --a--> {q0, q1}
q0 --b--> {q0}
q1 --a--> {}
q1 --b--> {}
Step 1: DFA start = {q0}
| DFA State | On 'a' | On 'b' | Final? |
|---|---|---|---|
| β{q0} | {q0,q1} | {q0} | No (q1 not in {q0}) |
| β {q0,q1} | {q0,q1} | {q0} | YES (q1 β {q0,q1}) |
Only 2 DFA states needed! (often NFAβDFA can blow up to 2βΏ states though)
6. Minimization of DFA MEDIUM
Table Filling Algorithm (Myhill-Nerode)
- Create a table with all pairs of states (qi, qj)
- Mark all pairs where one is final and other is not β DISTINGUISHABLE
- For each unmarked pair (qi, qj) and each symbol a:
- If Ξ΄(qi,a) and Ξ΄(qj,a) are already marked β mark (qi,qj)
- Repeat until no new pairs can be marked
- All UNMARKED pairs β merge those states
7. Regular Expressions β VERY IMP
Basic Operators
| Operator | Symbol | Meaning | Example |
|---|---|---|---|
| Union | a + b or a|b | a OR b | (0+1) = {0,1} |
| Concatenation | ab | a followed by b | ab = {ab} |
| Kleene Star | a* | Zero or more a's | a* = {Ξ΅, a, aa, aaa,...} |
| Kleene Plus | a+ | One or more a's | a+ = {a, aa, aaa,...} |
| Optional | a? | Zero or one a | a? = {Ξ΅, a} |
Important Identities (Memorize!)
// These are guaranteed exam questions Ξ΅* = Ξ΅ β * = Ξ΅ a** = a* (star is idempotent) a+ = aa* = a*a a? = (Ξ΅ + a) β Β· a = β (nothing Β· anything = nothing) Ξ΅ Β· a = a (empty concat = identity) β + a = a (union with empty language = a) (a+b)* = (a*b*)* (very common identity)
Common Language β Regex Patterns
| Language Description | Regular Expression |
|---|---|
| Strings starting with a | a(a+b)* |
| Strings ending with b | (a+b)*b |
| Strings containing 'ab' | (a+b)*ab(a+b)* |
| Strings of even length | ((a+b)(a+b))* |
| Strings with even no. of a's | (b*ab*a)*b* |
| All strings over {a,b} | (a+b)* |
| At least one 'a' | (a+b)*a(a+b)* |
| Exactly two a's | b*ab*ab* |
Arden's Theorem (for FA β Regex)
If R = Q + RP where P does not contain Ξ΅, then R = QP*
8. Regular Grammar MEDIUM
Types
| Type | Rule Form | Example |
|---|---|---|
| Right Linear (RRG) | A β aB or A β a or A β Ξ΅ | S β aS | bS | Ξ΅ |
| Left Linear (LRG) | A β Ba or A β a or A β Ξ΅ | S β Sa | Sb | Ξ΅ |
9. Pumping Lemma for Regular Languages β EXAM FAVOURITE
The Lemma (Statement)
for every string w β L with |w| β₯ p,
w can be split as w = xyz where:
1.
|xy| β€ p (xy is in first p characters)2.
|y| β₯ 1 (y is non-empty β this is what gets pumped)3.
β i β₯ 0, xy^i z β L (pumping any # of times keeps it in L)
How to PROVE a language is NOT regular (exam procedure)
Choose w = [pick a clever string in L, length β₯ p]. Usually: aα΅bα΅, 0α΅1α΅ etc.
Split w = xyz with |xy| β€ p, |y| β₯ 1.
β Since |xy| β€ p, both x and y consist only of the first symbol!
β y = aα΅ for some k β₯ 1
Pump: Let i = 0 or i = 2: xyβ°z or xyΒ²z
Show contradiction: the pumped string is NOT in L.
Conclude: Contradiction! L is NOT regular. β
Classic Example β aβΏbβΏ is NOT regular
Choose w = aα΅bα΅ β L, |w| = 2p β₯ p β
Split: w = xyz, |xy| β€ p, |y| β₯ 1
β Since |xy| β€ p, x and y are entirely in the 'a' part
β x = aΛ’, y = aα΅ (k β₯ 1), z = aα΅β»Λ’β»α΅bα΅
Pump i=0: xyβ°z = xz = aα΅β»α΅bα΅
This has fewer a's than b's β NOT in L β
Contradiction! L is NOT regular. β
For "equal symbols" β choose boundary where counts are equal
For primes β choose w = aα΅ where p is prime
Always pick w so that pumping y (which is in the first part) breaks the balance!
10. Closure Properties of Regular Languages MEDIUM
| Operation | Closed? | Method |
|---|---|---|
| Union (Lβ βͺ Lβ) | β YES | NFA construction or product automaton |
| Intersection (Lβ β© Lβ) | β YES | Product automaton (both must accept) |
| Concatenation (LβΒ·Lβ) | β YES | Connect final states of Lβ to start of Lβ |
| Kleene Star (L*) | β YES | Add Ξ΅ from final states back to start |
| Complement (LΜ) | β YES | Swap final and non-final states in DFA |
| Difference (Lβ - Lβ) | β YES | Lβ β© LβΜ |
| Reversal (Lα΄Ώ) | β YES | Reverse all transitions |
| Homomorphism | β YES | Replace each symbol per function |
11. Context-Free Grammar (CFG) β VERY IMP
Formal Definition
CFG = (V, T, P, S) where:
| Symbol | Meaning | Example |
|---|---|---|
| V | Variables (non-terminals), uppercase | {S, A, B} |
| T | Terminals (actual symbols), lowercase | {a, b} |
| P | Production rules A β Ξ± | S β aSb | Ξ΅ |
| S | Start symbol | S |
Classic CFG Examples
Language: aβΏbβΏ (equal a's and b's)
S β aSb | Ξ΅ Derivation of "aabb": S β aSb β aaSbb β aaΞ΅bb β aabb β
Language: Balanced Parentheses
S β SS | (S) | Ξ΅ "(())" : S β (S) β (SS) β ((S)S) β ((S)) β (()) β (())
Language: Palindromes over {a,b}
S β aSa | bSb | a | b | Ξ΅
Language: aβΏbα΅ where n β m
S β AB | BA A β aA | a (generates aβΏ, n β₯ 1) B β bB | b (generates bα΅, m β₯ 1) ... (more complex, needs careful construction)
Parse Trees and Derivations
Rightmost Derivation (RMD): Always expand the rightmost variable first.
A grammar is Ambiguous if a string has TWO different parse trees (or two different LMDs).
Ambiguous Grammar Example
G: E β E+E | E*E | id String: id + id * id has TWO parse trees: Tree 1: (id + id) * id β + is root Tree 2: id + (id * id) β * is root β AMBIGUOUS!
12. Simplification of CFG MEDIUM
To simplify CFG, remove 4 types of useless things:
1. Useless Symbols
A symbol is useful if it: (a) can derive a terminal string, AND (b) is reachable from S.
2. Ξ΅-Productions (Remove Nullable Variables)
- Find all nullable variables (A β Ξ΅ directly, or A β B where B is nullable)
- For every production with nullable var, add new production with that var removed
- Remove all A β Ξ΅ rules (except S β Ξ΅ if Ξ΅ β L)
3. Unit Productions (A β B)
- Find all unit pairs: (A,B) where A βΉ* B by unit steps
- For each (A,B), add A β Ξ± for every B β Ξ± (non-unit)
- Remove all unit rules
4. Order to Apply
Step 2: Remove unit productions
Step 3: Remove useless symbols
If done in wrong order, results may differ!
13. Normal Forms: CNF and GNF β EXAM IMP
Chomsky Normal Form (CNF)
β’
A β BC (two variables only)β’
A β a (single terminal only)β’
S β Ξ΅ (only if Ξ΅ β L)
Converting to CNF β Algorithm
- Remove Ξ΅-productions
- Remove unit productions
- Remove useless symbols
- For any terminal 'a' in long rules: replace 'a' with new variable Tβ, add Tβ β a
- Break rules with 3+ variables: A β BCD becomes A β BX, X β CD
Original: S β aBC Step 4: Replace 'a' β Tβ: S β Tβ BC, Tβ β a Step 5: 3 vars β Break: S β Tβ X, X β BC, Tβ β a β CNF! β
Greibach Normal Form (GNF)
A β a Ξ±where 'a' is a terminal and Ξ± is a (possibly empty) string of variables.
Every RHS starts with a terminal!
GNF: "Terminal FIRST, then variables" β G for "Go terminal first"
GNF is useful because: each step in derivation consumes exactly ONE terminal β useful for parsing proofs.
14. Pushdown Automaton (PDA) β VERY IMP
Formal Definition
PDA = (Q, Ξ£, Ξ, Ξ΄, qβ, Zβ, F) where:
| Symbol | Meaning |
|---|---|
| Q | Finite states |
| Ξ£ | Input alphabet |
| Ξ | Stack alphabet |
| Ξ΄ | Transition: Q Γ (Ξ£βͺ{Ξ΅}) Γ Ξ β 2^(QΓΞ*) |
| qβ | Start state |
| Zβ | Initial stack symbol (bottom marker) |
| F | Final states |
Transition Notation
Ξ΄(q, a, X) = {(r, Ξ³)} means: "In state q, reading input 'a', with 'X' on top of stack β go to state r, replace X with Ξ³ on stack"
Stack Operations
| You write | Meaning |
|---|---|
| Ξ³ = Ξ΅ | POP X from stack (replace with nothing) |
| Ξ³ = X | No change to stack (keep X) |
| Ξ³ = YX | PUSH Y (Y goes on top of X) |
| Ξ³ = Y | REPLACE X with Y |
Two Acceptance Modes
| Mode | Accept when... |
|---|---|
| By Final State | Input exhausted AND in final state (stack can have anything) |
| By Empty Stack | Input exhausted AND stack is empty (state doesn't matter) |
Both modes are equivalent β you can convert between them!
PDA for aβΏbβΏ
States: q0 (start), q1, q2 (final)
Stack alphabet: {A, Zβ}
Phase 1 (reading a's): push A for each 'a'
Ξ΄(q0, a, Zβ) = {(q0, AZβ)} β first 'a': push A on Zβ
Ξ΄(q0, a, A) = {(q0, AA)} β each 'a': push A on A
Phase 2 (reading b's): pop A for each 'b'
Ξ΄(q0, b, A) = {(q1, Ξ΅)} β first 'b': pop A, go to q1
Ξ΄(q1, b, A) = {(q1, Ξ΅)} β each b: pop A
Ξ΄(q1, Ξ΅, Zβ) = {(q2, Zβ)} β stack has only Zβ β accept
Input "aabb":
(q0, aabb, Zβ) β (q0, abb, AZβ) β (q0, bb, AAZβ)
β (q1, b, AZβ) β (q1, Ξ΅, Zβ) β (q2, Ξ΅, Zβ) β ACCEPTED
For palindromes: PUSH first half, POP second half
For ww^R (reverse): same as palindrome
Non-determinism helps! You can guess the middle point.
15. Pumping Lemma for Context-Free Languages β IMP
1.
|vy| β₯ 1 (v or y is non-empty)2.
|vxy| β€ p (middle part β€ p)3.
β i β₯ 0: uvβ±xyβ±z β L (pump both v and y together)
CFL: w = uvxyz, pump v and y SIMULTANEOUSLY (two parts)
Think: CFL has a stack, so two things are being tracked!
Classic Example β aβΏbβΏcβΏ is NOT CFL
Choose w = aα΅bα΅cα΅ β L
Split w = uvxyz, |vxy| β€ p, |vy| β₯ 1
β Since |vxy| β€ p, vxy cannot span all three sections (a,b,c)
β Case 1: v,y only in a's and b's. Pump i=2: more a's+b's but same c's β NOT in L β
β Case 2: v,y only in b's and c's. Pump i=2: same a's but more b's+c's β NOT in L β
β Case 3: v or y spans two symbol types (e.g., aα΅bΚ²). Pump i=2: order violated β NOT in L β
All cases β contradiction! aβΏbβΏcβΏ is NOT CFL. β
16. Turing Machine (TM) β MOST IMP
Formal Definition
TM = (Q, Ξ£, Ξ, Ξ΄, qβ, B, F) where:
| Symbol | Meaning |
|---|---|
| Q | Finite states |
| Ξ£ | Input alphabet (Ξ£ β Ξ) |
| Ξ | Tape alphabet (includes blank B) |
| Ξ΄ | Ξ΄: Q Γ Ξ β Q Γ Ξ Γ {L, R} |
| qβ | Start state |
| B | Blank symbol (represents empty tape) |
| F | Final/accepting states |
Transition Meaning
Ξ΄(q, a) = (r, b, L) means: In state q, reading 'a' β go to state r, write 'b', move Left
Configuration (Instantaneous Description)
Written as: Ξ± q Ξ² where q = current state, Ξ± = tape left of head, Ξ² = tape at+right of head
TM for aβΏbβΏ β Step by Step
Idea: Repeatedly cross off one 'a' and one 'b' until all done.
Input: "aabb"
Tape: [a][a][b][b][B]
Strategy:
β Replace leftmost 'a' with X
β Scan right to find leftmost 'b', replace with Y
β Go back left, find next 'a'...
β When no more 'a': verify no more 'b' remain
States: q0(start), q1(scan right for b), q2(scan left for a),
q3(check all done), q_accept, q_reject
Ξ΄(q0, a) = (q1, X, R) β cross off 'a', go right to find 'b'
Ξ΄(q1, a) = (q1, a, R) β skip over a's
Ξ΄(q1, Y) = (q1, Y, R) β skip over already-marked Y's
Ξ΄(q1, b) = (q2, Y, L) β cross off 'b', go left
Ξ΄(q2, a) = (q2, a, L) β scan left
Ξ΄(q2, Y) = (q2, Y, L) β scan left past Y's
Ξ΄(q2, X) = (q0, X, R) β found X, go right for next pair
Ξ΄(q0, Y) = (q3, Y, R) β no more a's, check no b's
Ξ΄(q3, Y) = (q3, Y, R) β skip Y's
Ξ΄(q3, B) = (q_accept, B, R) β all matched! ACCEPT
TM Acceptance Modes
| Mode | Meaning |
|---|---|
| Accept | TM enters q_accept state |
| Reject | TM enters q_reject state (explicit rejection) |
| Loop | TM runs forever (never halts) β the problem! |
17. Variants of Turing Machines MEDIUM
| Variant | Description | Power |
|---|---|---|
| Standard TM | 1 tape, infinite right | Base |
| Multi-tape TM | k tapes, k heads | = Standard TM |
| Non-deterministic TM | Multiple choices at each step | = Standard TM |
| 2-way infinite tape | Tape extends left AND right | = Standard TM |
| Universal TM (UTM) | Simulates ANY TM given its description | = Standard TM |
| Linear Bounded Automaton (LBA) | TM restricted to input-length tape | CSL (Type 1) |
Universal Turing Machine (UTM)
A UTM takes as input: β¨M, wβ© (encoding of TM M and input w) β simulates M on w. This is the theoretical basis of modern programmable computers!
18. Decidability & Undecidability β VERY IMP
Undecidable = "Will this program run forever?" β no computer can EVER answer this reliably, even in principle.
Language Classification
| Class | Also Called | TM Behavior | Example |
|---|---|---|---|
| Decidable (Recursive) | Recursive | Always halts with accept/reject | aβΏbβΏ, all CFLs |
| Semi-Decidable (RE) | Recursively Enumerable | Halts on accept; may loop on reject | A_TM |
| Not RE | β | No TM can recognize it | Complement of Halting Problem |
The Halting Problem (HP)
A_TM = {β¨M, wβ© | TM M accepts input w} β also undecidable!
These are the most famous undecidable problems β guaranteed in exams.
Proof that A_TM is Undecidable (Diagonalization)
Construct D(β¨Mβ©): runs H(β¨M, β¨Mβ©β©) then does the OPPOSITE:
β’ If H says "M accepts β¨Mβ©" β D REJECTS
β’ If H says "M rejects β¨Mβ©" β D ACCEPTS
Run D on itself: D(β¨Dβ©):
β’ If D accepts β¨Dβ© β by definition, D rejects β contradiction!
β’ If D rejects β¨Dβ© β by definition, D accepts β contradiction!
Both cases are impossible β H cannot exist β A_TM is undecidable. β
Reduction
To prove language L is undecidable: reduce a known undecidable problem to L.
If A is undecidable and A β€β B (A reduces to B), then B is also undecidable.
β’ A_TM (acceptance problem)
β’ E_TM (does TM accept empty language?) β undecidable
β’ EQ_TM (are two TMs equivalent?) β undecidable
β’ Rice's Theorem: ANY non-trivial property of TM-recognized languages is undecidable!
Rice's Theorem (Big Shortcut!)
Non-trivial = property that is TRUE for some TMs and FALSE for others.
Semantic = about the language it recognizes (not about implementation).
Examples of undecidable (by Rice's): "Does TM accept empty string?", "Does TM accept at least 3 strings?", "Is L(M) regular?"
19. Complexity Theory: P, NP, NP-Complete ADVANCED
NP: Problems where if someone gives you an answer, you can CHECK it quickly β but finding the answer yourself might be slow.
Like a jigsaw puzzle: checking if it's solved is easy, solving from scratch is hard!
Definitions
| Class | Definition | Examples |
|---|---|---|
| P | Solvable in polynomial time O(nα΅) | Sorting, shortest path, primality testing |
| NP | Solution verifiable in polynomial time | SAT, TSP, Graph Coloring, Subset Sum |
| NP-Hard | Every NP problem reduces to it; at least as hard as NP | Halting problem, TSP optimization |
| NP-Complete | In NP AND NP-Hard (hardest problems in NP) | SAT, 3-SAT, Vertex Cover, Clique |
If P = NP: every problem whose solution can be checked fast can also be solved fast.
Most experts believe P β NP but it has never been proven.
Polynomial-Time Reductions
To show B is NP-Complete:
- Show B β NP (give a polynomial verifier)
- Show some NP-Complete problem A β€β B (A reduces to B in poly time)
Important NP-Complete Problems to Know
| Problem | Description |
|---|---|
| SAT | Boolean formula satisfiability (first proven NP-C by Cook) |
| 3-SAT | SAT with clauses of exactly 3 literals |
| Vertex Cover | Find k vertices that touch all edges |
| Clique | Find k mutually connected vertices |
| Hamiltonian Path | Path visiting every node exactly once |
| TSP (decision) | Is there a tour of cost β€ k? |
| Subset Sum | Does a subset sum to target T? |
NP-Complete = NP β© NP-Hard
If any NP-Complete problem is in P β P = NP (and world breaks!)
Venn diagram: P is a circle inside NP; NP-Complete sits on the boundary of NP; NP-Hard extends beyond NP.
20. Quick Revision Cheat Sheet π
Hierarchy Summary
| Language Class | Machine | Grammar | Closed Under |
|---|---|---|---|
| Regular | DFA/NFA | Regular | Everything |
| CFL | PDA | CFG | Union, Concat, Star (NOT β©, complement) |
| CSL | LBA | CSG | All boolean ops |
| RE (r.e.) | TM (halts on accept) | Unrestricted | Union, Concat, Star, β© |
| Recursive | TM (always halts) | β | All boolean ops |
CFL Closure Properties
| Operation | CFL closed? |
|---|---|
| Union | β YES |
| Concatenation | β YES |
| Kleene Star | β YES |
| Intersection | β NO (counterexample: {aβΏbβΏcβΏ}) |
| Complement | β NO |
| Intersection with Regular | β YES |
Must-Know Non-Regular Languages
- aβΏbβΏ (equal a's and b's)
- ww (string repeated) β use pumping lemma
- aβΏΒ² (square number of a's)
- Set of all palindromes
- Set of prime-length strings
Must-Know Non-CFL Languages
- aβΏbβΏcβΏ (equal three symbols)
- {ww | w β {a,b}*} (string is its own copy)
- {a^(nΒ²)} β but this IS NOT CFL (also not regular)
- {aβΏbβΏcβΏdβΏ}
Key Formulae Flashcards
| Fact | Value |
|---|---|
| Max DFA states for n-state NFA | 2βΏ |
| Min states DFA for strings divisible by k | k states |
| |Ξ£*| (all strings over Ξ£) | Infinite (countably) |
| |Power set of Q| (|2^Q|) | 2^|Q| |
| Pumping length for Myhill-Nerode | # of equivalence classes |
| TM tape alphabet vs input | Ξ β Ξ£, B β Ξ, B β Ξ£ |
Last-Minute Exam Tips
1. DFA must have transition for EVERY state-symbol pair β don't forget dead states!
2. NFAβDFA: the empty set β can be a DFA state too (dead/trap state)
3. Pumping Lemma: |y| β₯ 1 (NOT |y| β₯ 0) β y must be non-empty!
4. CFL Pumping Lemma: pump v AND y together (both by i), not separately
5. Undecidable β Non-RE β Halting Problem IS RE (semi-decidable), just not decidable!
CFL β CFG/PDA β equivalent β prove NOT CFL with CFL Pumping Lemma
Decidable β TM always halts β closed under complement
RE β TM halts on yes β NOT closed under complement
NP-Complete β hardest in NP β show by reduction from known NP-C problem