TOC Summary
Compact reference of the definitions, theorems, and proof recipes of Theory of Computation: regular languages and the pumping lemma, Turing machines, decidability and recognizability, reductions, and the P, NP, and NP-completeness landscape.
Regular Languages
DFA. with total . Accepts iff . Accepts iff .
NFA. Same tuple with : any number of next states, including none, plus -moves. Accepts iff at least one path reading ends in .
Equivalence of models.
- Every DFA is an NFA (the case with exactly one next state and no -moves).
- Every NFA has an equivalent DFA, by the subset construction: a DFA state is a set of NFA states. The DFA can be exponentially larger.
- So DFAs and NFAs recognize exactly the same class, the regular languages.
Regular language. A language recognized by some DFA, equivalently some NFA.
- Closed under: , , , (concatenation), (Kleene star, , which includes ).
- : keep the DFA, swap accepting and non-accepting states. and : product DFA on , accepting when one side (union) or both sides (intersection) accept. : link two NFAs with -moves, then determinize. : add a new accepting start state with an -move to the old start, and -moves from each accepting state back to it.
Regular languages to know.
- and : regular (a DFA with no accepting state; a DFA with all states accepting).
- and every finite language: regular.
- Fixed substring, prefix, suffix, or position, e.g. strings ending in : regular.
- Parity and divisibility, e.g. number of s divisible by : regular (counting modulo a fixed number).
- Pattern shapes and : regular.
- Equal number of substrings and : regular. The answer depends only on whether the first and last symbols are equal, which is two bits, not on the counts.
Non-regular languages to know. Each needs unbounded exact memory, which counting modulo a fixed number cannot provide.
- : must match two unbounded counts exactly.
- : must store the entire first half.
- .
- Equal number of s and s.
Pumping lemma. If is regular, there is a length such that every with splits as with:
- ,
- ,
- for every .
This is a necessary condition only. It proves non-regularity by contradiction, never regularity.
Proving non-regularity (pumping).
- Assume is regular with pumping length .
- Pick one with , written in terms of .
- Check every split with and . A good forces into a single block.
- Pick one (usually or ) for which .
Proving non-regularity (closure). Assume is regular, then combine it with regular languages under closure (intersect with a regular filter, complement, union) to reach a known non-regular language. Example: , so equal s and s is non-regular.
Turing Machines and Computability
Turing machine (TM). : a finite control on a one-way-infinite tape, with , blank , and (read, write one cell, move one cell). On each input it accepts, rejects, or runs forever.
Recognizable. Some TM accepts every , and on it rejects or runs forever. Not closed under complement: is recognizable, but is not.
Decidable. Some TM halts on every input and accepts exactly . Closed under complement: run the decider and swap accept and reject.
Decidable languages. Every regular language; ; equal s and s; (unary powers of two).
Recognizable languages. is decidable iff both and are recognizable (run both recognizers in alternation; one must accept).
Decidable problems about automata.
- : decidable. iff no accepting state is reachable from , which is reachability on the state graph.
- : decidable. Build the DFA for the symmetric difference and test it for emptiness; the two are equal iff it is empty.
Church-Turing thesis. Anything computable by an algorithm is computable by a Turing machine. The same class of computable functions arises from multi-tape TMs, -calculus, and ordinary programming languages.
Encoding . A finite string describing an object: a DFA, a graph, a TM, or a pair . A decision problem is the set of encodings whose answer is yes.
Countability.
- Countable: , all finite encodings, all DFAs, all Turing machines.
- Uncountable: the set of all languages (diagonal argument on characteristic sequences).
- Consequence: there are more languages than Turing machines, so some languages are not recognizable.
Diagonalization. is undecidable. A decider for it would have to disagree with its own behavior on its own encoding.
Core undecidable problems.
- : recognizable, undecidable.
- : recognizable, undecidable.
- Difference on the no-instances: says no only when loops; says no when rejects or loops.
Mapping reduction . A total computable with . It makes at least as hard as .
- decidable decidable. undecidable undecidable.
- recognizable recognizable. unrecognizable unrecognizable.
Proving undecidability by reduction.
- Take a known hard language: for undecidability, for unrecognizability.
- Map each instance to a target instance by writing the new machine's code, without running it.
- Show is total computable and that .
More undecidable and unrecognizable problems.
- : undecidable, by .
- and : not recognizable.
- : not recognizable, by , hence also undecidable.
Hierarchy. , every containment strict:
- : decidable, not regular.
- : recognizable, not decidable.
- : not recognizable.
Time Complexity: P and NP
Worst-case time. For a decider , is the maximum number of steps over all inputs of length . Defined for deciders only, since recognizers may loop.
Asymptotics.
- : for some constant and all large .
- : .
P. Languages decidable in polynomial time by a deterministic TM: .
- Every regular language is in (one constant-time step per input symbol).
- Known in : sortedness of an array; - connectivity by BFS; graph connectivity.
Certificate and verifier. A verifier for reads a pair , where is a proposed proof that . It is polynomial-time if valid certificates have length and the check runs in time polynomial in .
NP. Languages with a polynomial-time verifier.
- iff some certificate is accepted; iff every certificate is rejected.
- Equivalent definition: languages decided by a polynomial-time nondeterministic TM, . The certificate is the choices of one accepting branch.
P vs NP. (a decider is a verifier that ignores the certificate). Whether is open.
Polynomial-time reduction . A total polynomial-time computable with .
- If and , then .
- Transitive: and give .
NP-hard and NP-complete.
- NP-hard: every reduces to it, .
- NP-complete: NP-hard and in NP.
- If any NP-complete language is in , then .
Cook-Levin. SAT is NP-complete. So , and the same holds for every NP-complete language.
Proving NP-complete.
- Show with a polynomial-time verifier.
- Reduce a known NP-complete language to (direction: known problem , never known problem).
- By transitivity, every NP language then reduces to .
NP-complete problems.
- SAT: a CNF formula, an AND of clauses where each clause is an OR of literals, that has a satisfying assignment.
- 3SAT: SAT restricted to formulas with at most literals per clause.
- INDSET: where has vertices with no edge between any two.
- CLIQUE: where has vertices that are pairwise adjacent.
- VERTEX COVER: where has vertices that together touch every edge.
- SET COVER: where of the sets in have union .
- SUBSET-SUM: where some sub-multiset of the positive integers sums to .
Graph isomorphism (GI). In NP, but not known to be NP-complete and not known to be in .
Pseudo-polynomial time. SUBSET-SUM has an dynamic program with . This is polynomial in the integer values but exponential in the binary input length, so it does not place SUBSET-SUM in . NP-completeness assumes binary encoding.