THEORY OF COMPUTATION / OVERVIEW
Theory of Computation — The Full Map
What can computers solve? What can they never solve? The mathematical foundation of CS
EXPLANATION
Theory of Computation answers three fundamental questions: ① What problems can be solved by a computer at all? (Computability) ② What problems can be solved efficiently? (Complexity) ③ What is the minimum machine needed to solve a given problem? (Automata) This is the most mathematically pure branch of CS — it uses formal proofs, not code. But it has enormous practical impact: every regex engine, every parser, every programming language, every proof that certain bugs cannot be detected automatically — all rooted here. The three pillars: AUTOMATA THEORY — models of computation: - Finite Automata (FA): the simplest machine. Has states, reads input, accepts or rejects. Models regex. - Pushdown Automata (PDA): FA + a stack. Models programming language syntax (parsers). - Turing Machine (TM): the most powerful theoretical model. Has infinite tape. Models everything a real computer can do. FORMAL LANGUAGES — what each machine can recognize: - Regular Languages: recognized by FA. Described by regular expressions. - Context-Free Languages: recognized by PDA. Described by context-free grammars. Most programming language syntax is CFL. - Recursively Enumerable Languages: recognized by Turing Machines. - Some languages cannot be recognized by ANY machine (undecidable problems). COMPLEXITY THEORY — efficiency of computation: - P: problems solvable in polynomial time (efficient) - NP: problems verifiable in polynomial time (maybe hard to solve) - NP-Complete: the hardest problems in NP. If any one is in P, then P=NP. - P vs NP: the most famous unsolved problem in mathematics. Million dollar prize. The Chomsky Hierarchy — a beautiful classification: Regular ⊂ Context-Free ⊂ Context-Sensitive ⊂ Recursively Enumerable Each level requires a more powerful machine. Each level is strictly larger than the previous.
DIAGRAM
THE CHOMSKY HIERARCHY: ┌─────────────────────────────────────────────┐ │ Recursively Enumerable (Turing Machine) │ │ ┌───────────────────────────────────────┐ │ │ │ Context-Sensitive (Linear Bounded) │ │ │ │ ┌─────────────────────────────────┐ │ │ │ │ │ Context-Free (Pushdown Auto.) │ │ │ │ │ │ ┌───────────────────────────┐ │ │ │ │ │ │ │ Regular (Finite Auto.) │ │ │ │ │ │ │ │ a*b*, (a|b)*, [0-9]+ │ │ │ │ │ │ │ └───────────────────────────┘ │ │ │ │ │ │ aⁿbⁿ, balanced parens │ │ │ │ │ └─────────────────────────────────┘ │ │ │ │ aⁿbⁿcⁿ │ │ │ └───────────────────────────────────────┘ │ │ Halting problem (undecidable) │ └─────────────────────────────────────────────┘ MODELS OF COMPUTATION: Finite Automaton → states + input tape (read only, left to right) Pushdown Automaton → FA + stack (push/pop) Turing Machine → infinite tape (read/write, move both directions)
CODE