Theory of Computation Formulas – Complete Quick Reference Sheet

Home
CS & IT
Theory of Computation
Formulas & Quick Reference
What You Will Find Here: Every key fact, formula, conversion rule, closure property, decidability result, and complexity class relationship in Theory of Computation — organised for quick lookup. Includes the Chomsky Hierarchy, DFA/NFA properties, pumping lengths, NP-Complete reduction chain, and the decidability table.

1. Chomsky Hierarchy

TypeLanguageGrammar Rule FormMachineExample
Type 3RegularA → aB or A → aDFA / NFAa*b, identifiers
Type 2Context-FreeA → α (any string)PDA{anbn}, program syntax
Type 1Context-Sensitive|lhs| ≤ |rhs|Linear-Bounded Automaton{anbncn}
Type 0Recursively EnumerableUnrestrictedTuring MachineATM

Containment: Regular ⊂ CFL ⊂ CSL ⊂ RE. Each containment is strict.

2. DFA & NFA Key Facts

PropertyDFANFA
Transitions per state per symbolExactly 10, 1, or many
Epsilon transitionsNot allowedAllowed
Power (languages recognised)RegularRegular (same as DFA)
States after NFA → DFAUp to 2n (n = NFA states)n
AcceptanceIn accept state after all inputAny path reaches accept state

Minimisation

Minimal DFA states = number of Myhill-Nerode equivalence classes of L

Key Conversions

FromToMethod
NFADFASubset (powerset) construction — track sets of NFA states
RegexNFAThompson’s construction (build inductively)
DFARegexState elimination (remove states, annotate transitions)
DFAMinimal DFATable-filling (Myhill-Nerode) — merge equivalent states

3. Regular Expression Laws

LawExpression
Identity for unionR + ∅ = R
Identity for concatenationRε = εR = R
Annihilator for concatenationR∅ = ∅R = ∅
Idempotence of unionR + R = R
Commutativity of unionR + S = S + R
Associativity of union(R+S)+T = R+(S+T)
Associativity of concatenation(RS)T = R(ST)
DistributivityR(S+T) = RS+RT
Star of star(R*)* = R*
Star decompositionR* = ε + R + RR + RRR + …
Arden’s LemmaIf X = RX + S then X = R*S (unique solution if ε ∉ L(R))

4. Pumping Lemmas

For Regular Languages

w = xyz,   |xy| ≤ p,   |y| ≥ 1,   xyiz ∈ L for all i ≥ 0

The pumping constant p is at most the number of states in the minimal DFA for L.

For Context-Free Languages

w = uvxyz,   |vxy| ≤ p,   |vy| ≥ 1,   uvixyiz ∈ L for all i ≥ 0

Both v and y are “pumped” together. Since |vxy| ≤ p, they span at most two symbol types in structured languages.

Using the Pumping Lemma (Proof Checklist)

  1. Assume L is regular/CFL (for contradiction)
  2. Let p be the pumping length
  3. You choose a specific w ∈ L with |w| ≥ p — choose cleverly so all splits cause problems
  4. For all valid splits, show pumping escapes L (at i=0 or i=2 usually works)
  5. Contradiction — L is not regular/CFL

5. Closure Properties

OperationRegularCFLDecidableRE (semi-decidable)
UnionYesYesYesYes
IntersectionYesNoYesYes
ComplementYesNoYesNo
ConcatenationYesYesYesYes
Kleene StarYesYesYesYes
Difference (L1−L2)YesNoYesNo
ReversalYesYesYesYes
HomomorphismYesYesYesYes
Inverse HomomorphismYesYesYesYes
Intersection with RegularYesYesYesYes

Key trick: CFL ∩ Regular = CFL (intersecting a CFL with a regular language gives a CFL — useful in compiler design to add keyword restrictions).

6. CFG & PDA Key Facts

PropertyDetail
Equivalent modelsCFG = PDA = Context-Free Languages
CNF rule formsA → BC (two non-terminals) or A → a (one terminal)
CYK complexityO(n3 |G|) — requires CNF
DPDA vs PDADeterministic PDA recognises strict subset of CFLs
Inherently ambiguousSome CFLs have no unambiguous grammar
ECFG (is CFL empty?)Decidable
ACFG (does CFG generate w?)Decidable (CYK)
EQCFG (do two CFGs generate same language?)Undecidable
Ambiguity of a CFGUndecidable

CNF Conversion Steps (in order)

  1. New start symbol S0 → S
  2. Eliminate ε-rules (handle nullable variables)
  3. Eliminate unit rules (A → B)
  4. Break long rules (A → B1B2…Bk, k ≥ 3)
  5. Move terminals out of binary rules (A → aB becomes A → NaB, Na → a)

7. Decidability Quick Reference

ProblemDescriptionDecidable?RE?
ADFADoes DFA M accept w?YesYes
EDFAIs L(DFA M) empty?YesYes
EQDFADo two DFAs accept same language?YesYes
ACFGDoes CFG G generate w?YesYes
ECFGIs L(CFG G) empty?YesYes
EQCFGDo two CFGs generate same language?NoNo
ATMDoes TM M accept w?NoYes
HALTTMDoes TM M halt on w?NoYes
ETMIs L(TM M) empty?NoNo
EQTMDo two TMs accept same language?NoNo
REGULARTMIs L(M) a regular language?NoNo
PCPPost Correspondence ProblemNoYes

Key Decidability Facts

  • L is decidable ⇔ both L and complement(L) are RE
  • ATM is RE but not decidable (complement of ATM is not RE)
  • ETM is not RE (neither is its complement)
  • Every non-trivial semantic property of TMs is undecidable (Rice’s Theorem)

8. Complexity Class Summary

ClassDefinitionKnown Relationship
PDecidable in O(nk) time (deterministic)P ⊆ NP
NPSolutions verifiable in O(nk) timeNP ⊆ PSPACE
co-NPComplements of NP problemsP ⊆ NP ∩ co-NP
NP-CompleteNP ∩ NP-HardIn NP, every NP problem reduces to it
NP-HardEvery NP problem reduces to itMay or may not be in NP
PSPACEDecidable in polynomial spaceP ⊆ NP ⊆ PSPACE ⊆ EXPTIME
EXPTIMEDecidable in 2poly(n) timeP ≠ EXPTIME (proved)

9. NP-Complete — Reduction Chain

CIRCUIT-SAT
↓ (Cook-Levin, 1971)
SAT (Boolean Satisfiability)

3-SAT (3-literal clauses)
↓  ↓  ↓
Clique    Independent Set    Vertex Cover

Hamiltonian Cycle  →  TSP (decision)

3-Coloring    Subset Sum    Bin Packing

Important NP-Complete Problems — One-Line Summary

ProblemInputQuestion
SATBoolean formulaSatisfying assignment?
3-SATCNF with ≤3 literals/clauseSatisfying assignment?
CliqueGraph G, integer kComplete subgraph of size k?
Vertex CoverGraph G, integer kk vertices covering all edges?
Independent SetGraph G, integer kk mutually non-adjacent vertices?
Hamiltonian CycleGraph GCycle visiting all vertices once?
TSP (decision)Weighted graph, integer kTour of all cities with cost ≤ k?
3-ColoringGraph GColour with 3 colours, no same-colour adjacent?
Subset SumSet S, target TSubset of S summing to exactly T?
PartitionSet S of integersPartition S into two equal-sum halves?

10. Frequently Asked Questions

What is the pumping length p in the Pumping Lemma for regular languages?

The pumping length p is at least the number of states in the minimal DFA for the language. The formal guarantee is that any string of length ≥ p must contain a repeatable section. When using the lemma to prove non-regularity, you treat p as an unknown constant — you choose a string in terms of p, then show pumping breaks the language regardless of what p’s actual value is.

Why is EQ_CFG undecidable but EQ_DFA decidable?

For DFAs, you can construct the DFA for the symmetric difference L1 Δ L2 and check if it is empty — all these operations (complement, intersection, emptiness testing) are decidable for regular languages. For CFGs, complement and intersection are not closed operations on CFLs, so you cannot construct a CFG for the symmetric difference. The undecidability of EQCFG follows by reduction from the halting problem.

How do I remember which closure properties CFLs do NOT have?

Remember the counterexample: L1 = {anbncm} and L2 = {ambncn} are both CFLs. Their intersection L1 ∩ L2 = {anbncn} is not CFL. Since complement(L) = Σ* minus L, if CFLs were closed under complement, they would be closed under intersection (via De Morgan) — but they aren’t. So CFLs are not closed under complement either. CFLs ARE closed under intersection with a regular language — only CFL ∩ CFL can fail.

What are the key differences between the Pumping Lemma for regular languages and for CFLs?

Regular: w = xyz, pump y (one segment in the first p characters). CFL: w = uvxyz, pump v and y together (two segments, total length of vxy ≤ p). The CFL version is harder to apply because the adversary can place the vxy window anywhere in the string — you must show pumping escapes the language for every possible placement, not just the obvious one. For the CFL version, common choices are strings with three equal blocks (like apbpcp) where any two-point pump disrupts the balance.

Leave a Comment