UNIT 4: THEORY OF COMPUTATION - EXAM-FOCUSED SHORT NOTES
Based on exhaustive analysis of RGPV past papers (Dec 2025, Dec 2024, May 2023, Nov 2023, Nov 2022, Jun 2025, May 2024).
I. FINITE AUTOMATA & FINITE STATE MACHINES
A. Fundamental Concepts
-
Finite Automaton (FA): A simple computational model that accepts/rejects strings based on state transitions. It has finite memory (states only).
-
Deterministic Finite Automaton (DFA):
-
Formal Definition: $$\displaystyle M = (Q, \Sigma, \delta, q_0, F) $$
-
$Q$: Finite set of states.
-
$\Sigma$: Input alphabet.
-
$\delta$: Transition function $$\displaystyle Q \times \Sigma \rightarrow Q $$.
-
$$\displaystyle q_0 $$: Start state.
-
$F$: Set of final/accepting states.
-
-
Key Feature: For each state and input symbol, exactly one next state.
-
-
Non-deterministic Finite Automaton (NFA/ε-NFA):
-
Formal Definition: $$\displaystyle M = (Q, \Sigma, \delta, q_0, F) $$
- $\delta$: Transition function $$\displaystyle Q \times (\Sigma \cup \{\epsilon\}) \rightarrow \mathcal{P}(Q) $$ (power set of Q).
-
Key Features: Can have multiple next states for a symbol; can move on ε (empty string) without consuming input.
-
ε-closure(q): Set of states reachable from state
qvia ε-transitions alone (includingqitself).
-
-
Language Acceptance: A string
wis accepted if, starting fromq_0and processingw, the automaton ends in a final state.
[!TIP] EXAM TIP: NFA/ε-NFA are equivalent to DFA in expressive power (both recognize Regular Languages). The conversion NFA→DFA is a very high frequency exam question.
B. Conversions & Constructions (High Frequency)
1. Subset Construction (NFA/ε-NFA → DFA)
-
Idea: Each DFA state represents a set of NFA states.
-
Steps:
-
Start state of DFA = ε-closure(q₀).
-
For each DFA state
S(a set of NFA states) and each symbola ∈ Σ:-
Compute
T = ∪ δ(s, a)for alls ∈ S. -
New DFA state = ε-closure(T).
-
-
A DFA state is final if it contains any NFA final state.
-
-
Result: DFA may have up to $$\displaystyle 2^{|Q|} $$ states.
2. Thompson's Construction (RE → ε-NFA)
-
Builds an ε-NFA for a given Regular Expression (RE) recursively.
-
Base Cases:
-
For
∅: No states. -
For
ε: Single transitionq₀ → ε → q₁. -
For symbol
a: Single transitionq₀ → a → q₁.
-
-
Inductive Steps:
-
Union (R₁ + R₂): New start/final states with ε-transitions to/from R₁ and R₂ NFAs.
-
Concatenation (R₁R₂): Final state of R₁ connected via ε to start state of R₂.
-
Kleene Star (R)*: New start/final states. ε from new start to R's start and to new final. ε from R's final back to R's start and to new final.
-
-
Result: ε-NFA with exactly one start and one final state.
3. State Elimination Method (DFA/NFA → RE)
-
Procedure:
-
Ensure a single start (add new start with ε-transition if needed) and single final state (add new final with ε-transitions from all finals).
-
Repeatedly eliminate a non-start, non-final state
q:-
For every pair of states
p, rthat have paths throughq, add a new direct path:label(p→q) · (label(q→q))* · label(q→r). -
Remove
qand all its incident transitions.
-
-
The remaining direct transition from start to final gives the RE.
-
4. Composite Machine Construction
-
Union (L₁ ∪ L₂): Build NFA with new start state having ε-transitions to starts of L₁ and L₂ automata. Final states remain as is.
-
Intersection (L₁ ∩ L₂): Use De Morgan's Law: $$\displaystyle L₁ ∩ L₂ = \overline{\overline{L₁} ∪ \overline{L₂}} $$. Complement requires DFA (swap final/non-final).
-
Concatenation (L₁L₂): Connect final states of L₁ to start state of L₂ via ε-transitions. Start state = start of L₁. Final states = final states of L₂.
C. Finite Automata with Outputs
| Feature | Mealy Machine | Moore Machine |
|---|---|---|
| Output Depends On | Current state AND current input | Only current state |
| Output Function | $$\displaystyle \lambda: Q \times \Sigma \rightarrow \Delta $$ | $$\displaystyle \lambda: Q \rightarrow \Delta $$ |
| Response Time | Output produced with input (faster) | Output produced after state change (one cycle delay) |
| State Count | Can have fewer states for same behavior | May require more states |
| Conversion | Mealy → Moore: Split states with different outputs on same input. | Moore → Mealy: Assign output of Moore state to all outgoing transitions. |
[!TIP] EXAM TIP: Converting Mealy to Moore often increases states; converting Moore to Mealy keeps state count same.
D. Analysis & Minimization
-
Minimization of DFA (Table-Filling / Partitioning Method):
-
Initial Partition: Split states into FINAL and NON-FINAL groups.
-
Refinement: For each group
Gand symbola, check if states inGtransition to states in different groups. If yes, splitG. -
Repeat until no more splits.
-
Each group becomes a single minimized state.
-
-
Dead State: A non-final state with self-loops on all symbols (sink state). Often omitted in diagrams but crucial for minimization.
-
Generating Strings of Length ≤ k: Perform BFS/DFS from start state, tracking path labels, up to depth
k. Collect strings ending in final states.
E. Specialized/Advanced FA (Lower Frequency)
-
Two-way Finite Automaton (2-DFA): Head can move left or right. Power equivalent to standard DFA (can be simulated by a DFA), but may require more states.
-
Residue/Modulo DFA (e.g., mod 3):
-
States represent remainders (0, 1, 2 for mod 3).
-
Transition: $$\displaystyle \delta(r, a) = (2r + a) \mod 3 $$ for binary input.
-
Final state = remainder 0.
-
II. REGULAR LANGUAGES & EXPRESSIONS
A. Regular Expressions (RE)
-
Definition: Algebraic description of a regular language using operators:
-
Union (
+):r₁ + r₂ -
Concatenation:
r₁r₂ -
Kleene Star (
*):r*(zero or more repetitions) -
Precedence:
*> concatenation >+.
-
-
Common Constructions:
-
Strings ending with
"ab":(a+b)*ab -
Exactly two
a's:b*ab*ab*b* -
Length divisible by 3 or 5:
( (000+111)* + (00000+11111)* )(over {0,1})
-
B. Arden's Theorem (Very High Frequency)
-
Statement: If
RandSare REs andε ∉ R, then the equationX = R X + Shas a unique solution:X = R* S. -
Application to FA → RE:
-
For each state
qᵢ, write an equation:qᵢ = Σ (δ(qᵢ, a) qⱼ) + εifqᵢis start. -
Solve the system of equations using Arden's Theorem (substitute, eliminate).
-
The RE for the language is the solution for the start state.
-
-
Steps:
-
Eliminate non-reachable states first.
-
Arrange equations so that LHS is the state to eliminate.
-
Substitute RHS expressions, applying
X = R X + S → X = R* S. -
The final expression for start state is the answer.
-
[!TIP] EXAM TIP: Arden's is guaranteed to work for right-linear grammars/DFAs. Always check for
εinR; if present, useR+or restructure.
C. Closure Properties of Regular Languages (Very High Frequency)
| Operation | Closure? | Reason/Method |
|---|---|---|
| Union | ✅ | NFA with new start & ε-transitions to both starts. |
| Intersection | ✅ | Use De Morgan: $$\displaystyle L₁ ∩ L₂ = \overline{\overline{L₁} ∪ \overline{L₂}} $$. Complement via DFA (swap finals). |
| Concatenation | ✅ | NFA: ε from finals of L₁ to start of L₂. |
| Kleene Star | ✅ | NFA: New start/final with ε-loops. |
| Complement | ✅ | DFA only: Swap final/non-final states. |
| Reversal | ✅ | Reverse all transitions, swap start/final. |
| Homomorphism | ✅ | Replace each symbol a with string h(a). |
| Inverse Homomorphism | ✅ | Pre-image under a homomorphism is regular. |
[!TIP] EXAM TIP: To prove a language is not regular, use Pumping Lemma. Closure properties are used to reduce a known non-regular language to the target via operations that preserve regularity.
D. Pumping Lemma for Regular Languages
-
Statement: If
Lis regular, then ∃ a pumping lengthp ≥ 1such that any strings ∈ Lwith|s| ≥ pcan be split ass = xyzsatisfying:-
|y| > 0 -
|xy| ≤ p -
∀ i ≥ 0: xyⁱz ∈ L
-
-
Proof Strategy (to show
Lis not regular):-
Assume
Lis regular → ∃ pumping lengthp. -
Choose a specific string
s ∈ Lwith|s| ≥ p(oftens = a^p b^por similar). -
Consider all possible splits
s = xyzwith|xy| ≤ p, |y|>0. -
Show for at least one split,
xyⁱz ∉ Lfor somei(usuallyi=0ori=2). -
Contradiction →
Lnot regular.
-
[!TIP] EXAM TIP: For
L = {aⁿ bⁿ}, chooses = a^p b^p. Since|xy|≤p,yconsists only ofa's. Pumpingi=0gives fewera's thanb's → not inL.
III. CONTEXT-FREE GRAMMARS (CFG) & LANGUAGES (CFL)
A. CFG Fundamentals
-
Formal Definition: $$\displaystyle G = (V, T, P, S) $$
-
V: Finite set of non-terminals (variables). -
T: Finite set of terminals (alphabet). -
P: Finite set of productions of formA → α,A ∈ V,α ∈ (V ∪ T)*. -
S: Start symbol (S ∈ V).
-
-
Derivation: Applying productions to replace a non-terminal. Leftmost (replace leftmost NT first), Rightmost (replace rightmost NT first).
-
Parse Tree: Tree representation of derivation. Root =
S. Interior nodes = NTs, leaves = terminals. Yield = string read left-to-right from leaves. -
Language Generated: $$\displaystyle L(G) = \{ w \in T^* \mid S \Rightarrow^* w \} $$.
B. Ambiguity in Grammar (High Frequency)
-
Definition: A CFG
Gis ambiguous if ∃ a stringw ∈ L(G)that has more than one parse tree (or equivalently, more than one leftmost/rightmost derivation). -
Identification: For a given string, explicitly construct two different leftmost derivations.
-
Methods to Remove Ambiguity:
-
Left-factoring: Factor common prefixes.
A → aB | aCbecomesA → aA',A' → B | C.
-
Introduce new non-terminals to enforce precedence/association.
- For arithmetic:
E → E + T | T,T → T * F | F(resolvesa+b*c).
- For arithmetic:
-
Rewrite grammar to be unambiguous (may change language slightly if not careful).
-
C. Normal Forms for CFG (Very High Frequency)
Chomsky Normal Form (CNF)
-
Definition: Every production is of form:
-
A → BC(two non-terminals) -
A → a(one terminal) -
S → ε(only if empty string is in language;Scannot appear on RHS).
-
-
Conversion Steps:
-
Eliminate ε-productions (
A → ε):-
Find nullable NTs (can derive ε).
-
For each production
A → α, add new productions with all combinations of nullable NTs inαremoved (except keepεifαall nullable). -
Remove
ε-productions (except possiblyS → ε).
-
-
Eliminate unit productions (
A → B):-
For each
A → B, addA → γfor allB → γ(whereγis not a single NT). -
Remove all unit productions.
-
-
Eliminate useless symbols (non-generating or non-reachable).
-
Convert long productions (
A → αwhere|α| ≥ 3):- Replace
A → B₁B₂...Bₖ(k≥3) withA → B₁C₁,C₁ → B₂C₂, ...,Cₖ₋₂ → Bₖ₋₁Bₖ, introducing new NTsCᵢ.
- Replace
-
Convert mixed productions (
A → aBorA → Ba):-
Replace terminal
awith a new NTAₐand addAₐ → a. -
Apply step 4.
-
-
Greibach Normal Form (GNF)
-
Definition: Every production is of form
A → aα, wherea ∈ T,α ∈ V*(string of zero or more NTs). -
Conversion Steps (Outline):
-
Ensure start symbol doesn't appear on RHS (add new start
S₀ → Sif needed). -
Order NTs:
A₁, A₂, ..., Aₙ. -
For
i = 1 to n:-
Eliminate left-recursion for
Aᵢ. -
Replace
Aⱼ(j < i) on RHS ofAᵢ's productions using existingAⱼ → aαforms.
-
-
Convert remaining productions to
A → aα.
-
[!TIP] EXAM TIP: CNF is more common in exams. In CNF, parse tree height is
log₂|w|for stringw. GNF is used for PDA construction (leftmost derivation simulation).
D. Properties & Constructions
-
Simplifying CFG:
-
Remove useless symbols: NT
Ais useless if:-
Adoes not derive any terminal string (non-generating). -
Ais not reachable from start symbol.
-
-
-
Constructing CFG from RE:
-
For
∅,ε,a: trivial. -
For
R₁ + R₂:S → S₁ | S₂. -
For
R₁R₂:S → S₁S₂. -
For
R*:S → SS₁ | ε.
-
-
Constructing CFG for Complex Languages:
-
{aᵐ bⁿ c²ᵐ dⁿ}:S → aScD | T,T → bTd | ε. -
{w c wᴿ}:S → c | aSa | bSb.
-
-
Proving a Language is NOT Context-Free:
-
Pumping Lemma for CFL: If
Lis CFL, ∃psuch that anys ∈ Lwith|s|≥pcan be splits=uvwxywith:-
|vwx| ≤ p -
|vx| > 0 -
∀ i ≥ 0: u vⁱ w xⁱ y ∈ L
-
-
Closure Properties: CFLs are not closed under intersection/complement. Use: if
Lwere CFL, thenL ∩ R(with regularR) would be CFL. ChooseRso thatL ∩ Ris known non-CFL (e.g.,{aⁿ bⁿ cⁿ}).
-
-
Closure Properties of CFLs:
-
✅ Union, Concatenation, Kleene Star.
-
❌ Intersection, Complement, Difference.
-
✅ Intersection with Regular (PDA with two stacks? No:
L ∩ Ris CFL ifLis CFL andRis regular).
-
IV. PUSHDOWN AUTOMATA (PDA)
A. PDA Model
-
Formal Definition: $$\displaystyle M = (Q, \Sigma, \Gamma, \delta, q_0, Z_0, F) $$
-
Q: Finite states. -
Σ: Input alphabet. -
Γ: Stack alphabet. -
δ: Transition function: $$\displaystyle Q \times (\Sigma \cup \{\epsilon\}) \times \Gamma \rightarrow \mathcal{P}(Q \times \Gamma^*) $$.-
Input:
(current state, current input symbol or ε, stack top) -
Output: Set of
(next state, string to replace stack top).
-
-
q₀: Start state. -
Z₀: Initial stack symbol. -
F: Set of final states (for final state acceptance).
-
-
Instantaneous Description (ID):
(q, w, γ)where:-
q: current state. -
w: unread input. -
γ: current stack contents (top on left).
-
-
Modes of Acceptance:
-
Final State: Accept if, after reading entire input, PDA is in a state in
F(stack can be non-empty). -
Empty Stack: Accept if, after reading entire input, stack is empty (state can be any).
-
B. Deterministic vs. Non-deterministic PDA
-
DPDA: For any ID
(q, a, A):-
At most one transition.
-
If
δ(q, a, A)is non-empty, thenδ(q, ε, A)must be empty.
-
-
NPDA: No such restriction.
-
Power: NPDA > DPDA. All DPDA languages are CFL, but some CFLs (e.g., even-length palindromes
{wwᴿ}) are not deterministic CFL (require NPDA). -
Example:
L = {aⁿ bⁿ cⁿ | n≥1}is not CFL, butL = {aⁿ bⁿ}is DCFL (accepted by DPDA by final state).
C. PDA Design (Very High Frequency)
Design by Final State
-
Idea: Use stack to match symbols, then move to final state.
-
Example:
L = {aⁿ bⁿ | n≥1}-
Push
a's onto stack. -
For each
b, pop onea. -
Accept if input ends and stack has only
Z₀(or popZ₀on lastband go to final state).
-
-
Example:
L = {x | nₐ(x) = n_b(x)}(order doesn't matter)-
Push
afora, popaforb. -
If stack empty when reading
b, pushb(or use two stack symbols). -
Accept if stack empty at end.
-
Design by Empty Stack
-
Idea: Ensure stack is exactly empty after processing.
-
Example:
L = {aⁿ bⁿ | n≥0}-
Push
a's. -
For each
b, pop onea. -
At end, pop
Z₀via ε-move to empty stack.
-
-
Example:
L = {aⁿ b³ⁿ | n≥0}-
For each
a, push three markers (e.g.,XXX). -
For each
b, pop one marker. -
Accept when stack empty.
-
-
Example: Even-length palindromes
{wwᴿ}-
Non-deterministically guess midpoint.
-
Push first half symbols.
-
For second half, pop and match.
-
Empty stack at end.
-
-
Example: Odd-length palindromes
{w a wᴿ}- Similar, but middle symbol
ais skipped (ε-transition after readinga).
- Similar, but middle symbol
[!TIP] EXAM TIP: For
{w c wᴿ}, push symbols beforec, then afterc, pop and match. Usecas midpoint marker.
D. Conversion between CFG and PDA
CFG → PDA (by empty stack) - Standard Construction
-
Idea: Simulate leftmost derivation.
-
Construction:
-
PDA has one state
q. -
Initial stack symbol = start symbol
Sof CFG. -
Transitions:
-
For each terminal
a:δ(q, ε, A)contains(q, a)ifA → ais a production. -
For each production
A → α:δ(q, ε, A)contains(q, α)(pushαin reverse order).
-
-
On input
w, PDA will non-deterministically choose productions to derivewon stack, then match terminals with input. Accept by empty stack.
-
-
To convert to final state acceptance: Add new start state
q₀and new final stateq_f. Fromq₀, ε-move toqwithSon stack. Fromq, when stack empty (onlyZ₀), ε-move toq_f.
PDA → CFG
-
Idea: For every pair of states
(p, q)and stack symbolA, create a variable[p A q]generating strings that take PDA from stateptoqwithAon top initially and popping it. -
Procedure (Outline):
-
For each transition
δ(r, a, B) = (s, γ)whereγ = C₁C₂...Cₖ:- Add productions:
[r B s] → a [s C₁ t₁] [t₁ C₂ t₂] ... [tₖ₋₁ Cₖ s]for all intermediate statestᵢ.
- Add productions:
-
For ε-transitions
δ(r, ε, B) = (s, ε):- Add
[r B s] → ε.
- Add
-
Start variable =
[q₀ Z₀ q_f]for some final stateq_f(or use empty stack method).
-
V. TURING MACHINES (TM)
A. TM Model & Definition
-
Formal Definition: $$\displaystyle M = (Q, \Sigma, \Gamma, \delta, q_0, B, F) $$
-
Q: Finite states. -
Σ: Input alphabet (B ∉ Σ). -
Γ: Tape alphabet (Σ ⊆ Γ,B ∈ Γ). -
δ: Transition function: $$\displaystyle Q \times \Gamma \rightarrow Q \times \Gamma \times \{L, R\} $$. -
q₀: Start state. -
B: Blank symbol. -
F: Set of final states.
-
-
Instantaneous Description (ID):
u q vwhere tape content isu v(head at first symbol ofv). -
Transition:
δ(q, a) = (p, b, D)means: in stateqreadinga, writeb, move headD(LorR), go to statep.
B. Techniques for TM Construction (Very High Frequency)
-
Marking Symbols: Change symbol to a marked version (e.g.,
a → a') to remember processed symbols. -
Shuttling: Move head back and forth between ends of input (e.g., to match
awithb). -
Multi-tape TM: Easier to design (e.g., copy input to second tape). Equivalent to single-tape TM (can simulate with one tape using delimiters).
-
Subroutines: Modular design (e.g., subroutine to increment binary number, to copy string).
-
Storage in Finite Control: If the amount of information to store is bounded (e.g., parity, small count), can store in state itself.
C. TM Design Problems (Very High Frequency)
1. L = {aⁿ bⁿ | n ≥ 1}
-
Technique: Marking & shuttling.
-
Scan right to find first unmarked
a, mark it (a → X). -
Scan right to find first unmarked
b, mark it (b → Y). -
Repeat until no unmarked
aorb. Accept if allb's marked and no extraa's.
-
-
Transition sketch:
-
q₀: Move right, ifa→X, go toq₁(search forb); ifb→ reject; ifY→ check allYthen accept. -
q₁: Move right, skipX/Y, ifb→Y, go toq₂(return to left). -
q₂: Move left, skipX/Y, ifX→ go toq₀.
-
2. L = {aⁿ bⁿ cⁿ | n ≥ 1}
-
Technique: Mark in pairs.
-
Mark first
a(a → X). -
Find first unmarked
b, mark (b → Y). -
Find first unmarked
c, mark (c → Z). -
Repeat. Accept if all
a,b,cmarked simultaneously.
-
3. L = {w c wᴿ | w ∈ {0,1}*}
-
Technique: Match symbols symmetrically around
c.-
Scan right to find
c, mark it (c → C). -
Move left to first unmarked symbol (start of
w), mark it (0→X,1→Y). -
Move right to
C, then right to first unmarked afterC(start ofwᴿ), check if matches mark (X→0,Y→1), mark asZ. -
Repeat inward. Accept if all symbols matched and
Cis only between.
-
4. Even number of 1's over {0,1}
-
Technique: Store parity in state.
-
States:
q_even(even 1's seen),q_odd(odd 1's seen). -
On
0: stay in same state. -
On
1: toggle betweenq_evenandq_odd. -
Accept in
q_evenat end of input.
-
5. Binary numbers divisible by 3
-
Technique: Remainder in state.
-
States:
q₀(remainder 0),q₁(remainder 1),q₂(remainder 2). -
Transition:
δ(qᵣ, a) = q_{(2r + a) mod 3}. -
Accept in
q₀.
-
6. Multiplication of two unary numbers (aⁿ and aᵐ)
-
Technique: Copy and add.
-
Separate two numbers by
#(e.g.,aⁿ # aᵐ). -
For each
ain second number, copy the first number to the end (using marking). -
At end, count total
a's (or erase separators and leave product).
-
D. Advanced TM Concepts
-
Universal Turing Machine (UTM): A TM
Uthat takes as input encoding of any TMMand stringw, and simulatesMonw.- Significance: Shows existence of a general-purpose computer. Proves that the set of TMs is enumerable.
-
TM as Enumerator: TM that prints strings of a language (may not halt). Enumerates RE languages.
-
Semi-infinite tape: Tape infinite only to the right. Equivalent to infinite tape (can simulate with two stacks).
VI. DECIDABILITY, UNDECIDABILITY & COMPLEXITY
A. Language Classes
| Class | Definition | Machine | Halting? |
|---|---|---|---|
| Recursive (Decidable) | TM halts on all inputs and accepts exactly L. |
TM that halts everywhere. | Yes, always. |
| Recursively Enumerable (RE) | TM accepts strings in L (may loop on w ∉ L). |
General TM. | Not necessarily. |
| Co-RE | Complement is RE. | TM that rejects w ∉ L (may loop on w ∈ L). |
Not necessarily. |
| Relationship | Recursive ⊂ RE, Recursive ⊂ Co-RE. | L is recursive iff L is RE and Co-RE. |
[!TIP] EXAM TIP:
A_TM = {<M,w> | M accepts w}is RE but not recursive.HALT_TMis also RE but not recursive.E_TM = {<M> | L(M)=∅}is not RE.
B. Undecidable Problems (Very High Frequency)
1. The Halting Problem (HP)
-
Statement:
HALT_TM = {<M, w> | TM M halts on input w}. -
Undecidability Proof (by reduction from
A_TM):-
Assume
HALT_TMis decidable by TMH. -
Construct TM
Dthat on input<M, w>:-
Run
Hon<M, w>. -
If
Hrejects (does not halt), accept. -
If
Haccepts (halts), loop forever.
-
-
Consider
Don its own encoding<D>. Contradiction arises.
-
-
Alternative Proof: Diagonalization (construct TM that halts iff given TM does not halt on its own encoding).
2. Acceptance Problem A_TM
-
A_TM = {<M, w> | M accepts w}. -
Undecidable (diagonalization proof).
-
RE: Simulate
Monw; accept ifMaccepts.
3. Post Correspondence Problem (PCP)
-
Instance: Finite set of pairs
{(x₁, y₁), (x₂, y₂), ..., (xₖ, yₖ)}wherexᵢ, yᵢ ∈ Σ*. -
Question: Is there a sequence of indices
i₁, i₂, ..., iₙsuch thatx_{i₁} x_{i₂} ... x_{iₙ} = y_{i₁} y_{i₂} ... y_{iₙ}? -
Undecidable (reduction from
A_TM). -
Solving Small Instances (Exam):
-
Try all sequences up to a reasonable length.
-
Look for top/bottom strings that can match.
-
Example:
{(ba, bab), (100, 001), (110, 10)}→ try(2,3,1):100110bavs0011010bab→ no match. Usually no solution.
-
4. Other Undecidable Problems
-
E_TM(Emptiness):{<M> | L(M)=∅}— not RE. -
REGULAR_TM:{<M> | L(M) is regular}— undecidable. -
EQ_TM:{<M₁, M₂> | L(M₁)=L(M₂)}— undecidable.
C. Complexity Classes (High Frequency)
| Class | Definition | Key Points |
|---|---|---|
| P | Problems solvable by a deterministic TM in polynomial time (O(nᵏ)). | "Efficiently solvable". Examples: Sorting, Shortest Path. |
| NP | Problems solvable by a non-deterministic TM in polynomial time. <br> Equivalently: Solutions verifiable in polynomial time. | Contains P. Examples: SAT, Clique, Hamiltonian Cycle. |
| NP-Complete | 1. In NP.<br>2. Every problem in NP is polynomial-time reducible to it. | "Hardest problems in NP". If any NPC is in P → P=NP. |
| NP-Hard | At least as hard as all NP problems (every NP problem reduces to it). May not be in NP. | Examples: Halting Problem (not in NP), TSP (NPC). |
-
Reductions:
L₁ ≤ₚ L₂meansL₁is polynomial-time reducible toL₂. IfL₂ ∈ PthenL₁ ∈ P. -
Cook-Levin Theorem: SAT is NP-Complete (first NPC problem).
-
Common NPC Problems: SAT, 3-SAT, Clique, Vertex Cover, Hamiltonian Path, Subset Sum.
[!TIP] EXAM TIP: Halting Problem is NP-Hard (since all NP problems reduce to it? Actually, HP is not NP-Hard unless NP ⊆ RE? Wait: HP is undecidable, so it's not in NP. But is it NP-Hard? NP-Hard means all NP problems reduce to it. Since NP problems are decidable, and undecidable problems are "harder", yes, any decidable problem reduces to an undecidable one? Not necessarily in polynomial time. Actually, standard: Halting Problem is not NP-Hard because NP-Hard problems must be at least as hard as NP, but HP is undecidable, and reductions from decidable to undecidable may not exist in polynomial time. Correct: HP is not known to be NP-Hard; it's undecidable and not in NP. Better: NP-Complete problems are decidable. HP is undecidable, so it's not in NP, hence not NP-Complete. But can it be NP-Hard? For a problem to be NP-Hard, every problem in NP must reduce to it in polynomial time. Since NP problems are decidable, if an undecidable problem were NP-Hard, then all NP problems would be reducible to an undecidable problem, which would imply NP problems are undecidable — contradiction. So undecidable problems cannot be NP-Hard (unless NP contains undecidable problems, which it doesn't). So: HP is undecidable, not in NP, not NP-Hard. Common mistake! Clarify: NP-Hard problems are decidable (at least as hard as NP, which are decidable). So HP is neither NP nor NP-Hard.
VII. ADVANCED & SUPPLEMENTARY TOPICS
A. Chomsky Hierarchy of Grammars
| Type | Grammar Restrictions | Language Class | Recognizing Automaton |
|---|---|---|---|
| Type 0 (Unrestricted) | No restrictions. | Recursively Enumerable | Turing Machine |
| Type 1 (Context-sensitive) | α → β with ` |
α | ≤ |
| Type 2 (Context-free) | A → α (A single NT). |
Context-Free (CFL) | Pushdown Automaton (PDA) |
| Type 3 (Regular) | A → aB or A → a (right-linear) or left-linear. |
Regular | Finite Automaton (FA) |
-
Inclusions: Regular ⊂ CFL ⊂ CSL ⊂ RE.
-
Proper Containment: Each inclusion is proper (e.g.,
{aⁿ bⁿ cⁿ}is CSL but not CFL;{aⁿ}is CFL but not regular).
B. Additional Models & Problems
-
Linear Bounded Automaton (LBA): TM with tape limited to length of input (plus constant). Recognizes CSL.
LBAacceptance problem is undecidable. -
Petri Net Model:
-
Components: Places (circles), Transitions (rectangles), Tokens (dots).
-
Arcs connect places to transitions and vice versa.
-
Firing: Transition fires if each input place has ≥1 token; consumes one token from each input place, produces one token to each output place.
-
Application: Modeling concurrent systems, resource allocation, deadlocks.
-
-
Two-way Finite Automata (2-DFA): Head can move left/right. Power equivalent to DFA (can be converted, but may cause exponential state blowup).
-
Mathematical Induction: Used in proofs (e.g., closure properties, theorem proofs). Structure:
-
Base case (
n=0orn=1). -
Inductive hypothesis (assume true for
k). -
Inductive step (prove for
k+1).
-
SUMMARY OF HIGH-FREQUENCY EXAM TOPICS
| Topic | What to Master | Exam Question Type |
|---|---|---|
| NFA → DFA | Subset construction, ε-closure. | Given NFA, convert to DFA (7-14m). |
| RE ↔ FA | Thompson's construction, State elimination, Arden's theorem. | Construct RE from FA using Arden's (7m). |
| CFG → CNF | Step-by-step: ε-productions, unit productions, long productions. | Convert given CFG to CNF (7m). |
| Ambiguity | Show two leftmost derivations. | Check given grammar/string for ambiguity (7m). |
| PDA Design | Final state vs empty stack; for aⁿbⁿ, palindromes. |
Design PDA for {aⁿbⁿ}, {wwᴿ} (7m). |
| CFG ↔ PDA | CFG→PDA (empty stack), PDA→CFG (variables [pAq]). |
Convert given CFG to PDA (7m). |
| TM Design | Marking, shuttling, multi-tape simulation. | Design TM for aⁿbⁿcⁿ, w c wᴿ, even 1's (7m). |
| Halting Problem | Statement, reduction proof from A_TM. |
"Why is Halting Problem undecidable?" (7m). |
| P vs NP | Definitions, examples (SAT, Clique), NPC concept. | Explain P, NP, NP-Complete (7m). |
| PCP | Definition, solve small instances by trial. | Given 3-4 pairs, find match (7m). |
Final Advice: Practice conversions (NFA→DFA, RE↔FA, CFG↔CNF↔GNF, CFG↔PDA, Mealy↔Moore). For design problems (PDA, TM), start with intuitive marking/sharding strategy, then formalize transitions. For undecidability, know the standard proofs (diagonalization for
A_TM, reduction forHALT_TM). For complexity, distinguish P (solvable), NP (verifiable), NPC (hardest in NP).