Theory of Computation Cheat Sheet

Automata Theory

AutomatonMemoryLanguage ClassAcceptsExample
Finite Automaton (FA)No memoryRegular LanguagesRegular expressions, simple patternsStrings ending with '01'
Pushdown Automaton (PDA)Stack memoryContext-Free LanguagesBalanced parentheses, palindromesStrings with equal 0s and 1s
Linear Bounded Automaton (LBA)Limited tapeContext-Sensitive LanguagesContext-sensitive grammarsanbncn
Turing Machine (TM)Infinite tapeRecursively Enumerable LanguagesAll computable functionsAny algorithmic problem

Chomsky Hierarchy

TypeGrammarAutomatonProduction RulesExample Language
Type-0UnrestrictedTuring Machineα → β (α contains at least one non-terminal)All recursively enumerable languages
Type-1Context-SensitiveLinear Bounded AutomatonαAβ → αγβ (|γ| ≥ |A|){anbncn | n ≥ 1}
Type-2Context-FreePushdown AutomatonA → α (A is non-terminal)Palindromes, arithmetic expressions
Type-3RegularFinite AutomatonA → aB or A → a (right-linear)Strings ending with '01', even numbers

Regular Languages

ConceptDescriptionPropertiesOperations
Regular ExpressionPattern for describing regular languagesClosed under union, concatenation, Kleene starUnion (∪), concatenation (.), Kleene star (*)
Finite AutomatonMachine with finite statesDeterministic and non-deterministic equivalentUnion, intersection, complement
Myhill-Nerode TheoremCriterion for regularityFinite number of equivalence classesMinimization of DFA
Pumping LemmaTool to prove non-regularityFor regular L, ∃ p such that ∀ s ∈ L with |s| ≥ p, s = xyz, |xy| ≤ p, |y| ≥ 1, xyiz ∈ L ∀ i ≥ 0Proving languages non-regular

Context-Free Languages

ConceptDescriptionPropertiesApplications
Context-Free Grammar (CFG)Rules of form A → α where A is non-terminalChomsky Normal Form, Greibach Normal FormProgramming language syntax, parsing
Pushdown Automaton (PDA)FA with stack memoryDeterministic and non-deterministic not equivalentCompiler design, syntax analysis
CYK AlgorithmDynamic programming for CFG parsingO(n³) time complexityRecognition of CFL
Pumping LemmaTool to prove non-CFLFor CFL L, ∃ p such that ∀ s ∈ L with |s| ≥ p, s = uvxyz, |vxy| ≤ p, |vy| ≥ 1, uvixyiz ∈ L ∀ i ≥ 0Proving languages non-CFL

Turing Machines

VariantDescriptionPowerEquivalence
Standard TMOne-way infinite tape, read/write headMost powerful computational modelEquivalent to other variants
Multi-tape TMMultiple tapes with independent headsSame power as standard TMCan simulate standard TM
Non-deterministic TMMultiple possible transitionsSame power as deterministic TMCan be simulated by deterministic TM
Multi-dimensional TMTape arranged in multiple dimensionsSame power as standard TMCan simulate standard TM
Universal TMTM that simulates any other TMCan compute any computable functionFoundation of modern computers

Decidability

ClassDescriptionExamplesProperties
Decidable (Recursive)Turing machine halts and accepts/rejects all inputsRegular languages, Context-free languagesClosed under complement, union, intersection
Undecidable (Recursively Enumerable)Turing machine accepts all strings in the language but may not halt on non-membersHalting problem, Post correspondence problemNot closed under complement
Not Recursively EnumerableNo Turing machine can recognize the languageComplement of halting problemNo algorithm exists

Undecidable Problems

ProblemDescriptionWhy UndecidableSignificance
Halting ProblemDetermine if TM halts on given inputDiagonalization argument, self-referenceFundamental result in computability
Post Correspondence ProblemFind sequence of dominoes with matching top/bottom stringsCan encode computation of TMsUseful for proving other problems undecidable
Emptiness ProblemDetermine if language accepted by TM is emptyReduction from halting problemImportant for program analysis
Equivalence ProblemDetermine if two TMs accept same languageReduction from emptiness problemImportant for program verification
Membership ProblemDetermine if string is in language of given TMReduction from halting problemGeneralization of halting problem

Complexity Classes

ClassDefinitionCharacteristicsExamples
PProblems solvable in polynomial time by deterministic TMEfficiently solvableShortest path, sorting, primality testing
NPProblems solvable in polynomial time by non-deterministic TMSolutions verifiable in polynomial timeTSP, graph coloring, SAT
NP-CompleteNP problems to which all other NP problems reduce in polynomial timeHardest problems in NPSAT, 3-SAT, vertex cover, TSP
NP-HardProblems to which all NP problems reduce in polynomial timeAt least as hard as NP-completeTSP optimization, halting problem
PSPACEProblems solvable in polynomial spaceContains P and NPQuantified Boolean formulas
EXPProblems solvable in exponential timeContains P and NPGeneralized chess

Reductions

TypeDescriptionPurposeMethod
Polynomial ReductionTransform instance of problem A to instance of problem B in polynomial timeProve problem B is at least as hard as AConstruct function f such that x ∈ A iff f(x) ∈ B
Many-one ReductionEach instance of A maps to single instance of BCompare complexity of decision problemsFunction f is computable and x ∈ A iff f(x) ∈ B
Turing ReductionProblem A solved using algorithm for B as subroutineMore general than many-one reductionAlgorithm for A uses B as oracle

Key Theorems and Results

TheoremStatementSignificanceApplications
Kleene's TheoremRegular expressions, finite automata, and regular grammars are equivalentFoundation of formal language theoryCompiler design, pattern matching
Pumping Lemma for Regular LanguagesRegular languages satisfy the pumping propertyTool to prove languages non-regularProving undecidability of certain problems
Cook's TheoremSAT is NP-completeFirst NP-complete problemFoundation of NP-completeness theory
Rice's TheoremAll non-trivial properties of recursively enumerable languages are undecidableGeneral result about undecidabilityProving many problems undecidable
Church-Turing ThesisIntuitive notion of computation equals Turing machine computationFoundation of computability theoryDefines limits of computation