Theory of Computation
Level: 4 — Application (novel problems, no hints) Time limit: 60 minutes Total marks: 50
Answer all questions. Justify every claim. Partial credit is awarded for correct reasoning.
Question 1 — Automata construction & determinization (12 marks)
Consider the language over :
(a) Give a regular expression for . (3)
(b) Construct an NFA (with at most 6 states, -transitions allowed) recognizing . Present it as a formal 5-tuple and a transition table. (5)
(c) Apply the subset construction to the aba-detecting part only, i.e. the NFA for , and give the resulting DFA's reachable states and transition table. (4)
Question 2 — Non-regularity & closure (10 marks)
Let .
(a) Use the pumping lemma to prove is not regular. (6)
(b) is a context-free language. Give a CFG generating . (4)
Question 3 — CFG, CNF, and PDA (12 marks)
Let grammar have productions:
(a) Describe the language precisely (in words or set-builder). (2)
(b) Convert to Chomsky Normal Form. Show each stage (remove , remove unit/useless where needed, binarize, terminal-rules). (6)
(c) Give a PDA (as a 6- or 7-tuple, informal transition rules acceptable) that accepts by empty stack. (4)
Question 4 — Undecidability & reductions (10 marks)
Define .
(a) Show is undecidable by a many-one reduction from . State the reduction function and prove correctness. (6)
(b) State Rice's theorem and use it to conclude that is undecidable. (4)
Question 5 — Complexity & NP-completeness (6 marks)
(a) A student claims: "Independent Set is in NP because a nondeterministic machine can guess a subset and check it, so Independent Set is easy." Critically evaluate this statement — what is right, what is wrong. (3)
(b) Given that Vertex Cover is NP-complete, prove Independent Set is NP-complete by reduction. (Recall: is an independent set of iff is a vertex cover.) (3)
Answer keyMark scheme & solutions
Question 1 (12)
(a) Regex: . Marks: correct aba part (1), correct ends in bb part (1), correct union (1). (3)
(b) Build an NFA as union of two branches via an initial -choice, or a single NFA with nondeterministic self-loops. Formal 5-tuple with , , . Transition table (nondeterministic; self-loop on lets aba start anywhere; -branch scans to the end):
| state | |||
|---|---|---|---|
| — | |||
| — | — | ||
| — | — | ||
| (accept, aba seen) | — | ||
| (saw one ) | or fall back to | — | |
| (saw , must be end) | — | — | — |
Acceptance: accepts having seen aba then any suffix; accepts only if is at the string end (no outgoing edges). The self-loops make the machine nondeterministic. Marks: valid 5-tuple (2), correct aba branch (1.5), correct ends-in-bb branch (1.5). (5)
(c) NFA for : states with start, self-loops on (both letters), , , , accepting with self-loops. Subset construction (track substring progress; this equals the standard KMP-style DFA):
| DFA state (subset) | name | ||
|---|---|---|---|
| A | B | A | |
| B | B | C | |
| C | D | A | |
| D (accept) | D | D... |
More carefully, once state 3 is entered it stays (self-loops on both), so any subset containing 3 is accepting and, since 3 self-loops on both symbols, from D: on D, on D' (accept). Accepting states = all subsets containing 3. Reachable DFA: start A, accepting once "aba" matched (contains 3). Marks: correct start/subset trace (2), correct accepting states (1), consistent table (1). (4)
Question 2 (10)
(a) Suppose regular with pumping length . Choose .
- since (the "" disjunct holds). .
- Any decomposition with forces , (all within the leading -block).
- Pump to . Now so ; and so . Both disjuncts fail, so .
- Contradiction ⇒ not regular. Marks: correct closure/setup of PL (1), good string choice satisfying both constraints (2), correct analysis (1.5), pump breaks both disjuncts (1.5). (6)
(b) CFG. .
Here generates , generates (gives case); generates , generates (gives case). Marks: branch (1.5), branch (1.5), correct union via start rule (1). (4)
Question 3 (12)
(a) = the Dyck-like / balanced language: all strings over that are "balanced" treating as open, as close — i.e. every prefix has and overall . Equivalently properly nested / brackets (including ). (2)
(b) Convert to CNF.
Step 1 — remove . is nullable. Removing from RHS occurrences:
- gives and .
- gives , , (i.e. adds unit , dropped as trivial). New set (no , keeping empty string out — since original includes we note CNF handles via only at start): Add fresh start , and .
Step 2 — remove unit productions. replaced by 's bodies: .
Step 3 — terminal rules. Introduce , : and likewise .
Step 4 — binarize : introduce , so , .
Final CNF:
Marks: nullable removal (2), unit removal (1), terminal isolation (1.5), binarization (1), correct handling (0.5). (6)
(c) PDA accepting by empty stack. where the stack pushes an per open, pops per close:
- On : push (top-agnostic).
- On with top : pop .
- -transition to empty stack: pop (start marker) when we can, so is accepted and balanced strings empty the stack. Rules: , , , . Accept by empty stack: the is popped only when no unmatched remains. Balanced strings ⇒ stack returns to then popped ⇒ empty. Marks: correct push/pop logic (2.5), correct empty-stack termination on (1), handles (0.5). (4)
Question 4 (10)
(a) Reduction . Reduction function : given , output where is a fixed TM that rejects all inputs (so ). is computable (just wrap with a hard-coded empty machine). Correctness:
- . Thus is a valid many-one reduction. Since is undecidable, is undecidable. Marks: correct with (2), computability noted (1), both directions of iff (2), conclusion citing undecidable (1). (6)
(b) Rice's theorem: Any nontrivial property of the language recognized by a TM (i.e. a property of r.e. languages that is neither always true nor always false, and depends only on ) is undecidable. Application: Property " is regular."
- Semantic (depends only on ): yes.
- Nontrivial: some TMs recognize a regular language (e.g. ), some do not (e.g. one recognizing , non-regular). So both classes nonempty. By Rice's theorem the property is undecidable. (4) Marks: correct statement of Rice (2), verify semantic + nontrivial with witnesses (2).
Question 5 (6)
(a) What's right: Independent Set (decision version, "is there an IS of size ?") is in NP — a certificate (the subset) can be verified in polynomial time (check size and that no two chosen vertices are adjacent). The nondeterministic "guess and check" characterization of NP is correct. What's wrong: "in NP ⇒ easy" is a non-sequitur. NP membership does not imply a polynomial-time (deterministic) algorithm; Independent Set is in fact NP-complete, so no known poly-time algorithm exists and one would exist only if . "Easy" conflates verifiability with solvability. Marks: NP membership correctly justified (1.5), fallacy of "NP⇒easy" identified with NP-completeness note (1.5). (3)
(b) Reduction Vertex Cover Independent Set (poly, and both in NP). Map instance of VC to of IS. Claim: has a vertex cover of size has an independent set of size . Proof: is a vertex cover iff is an independent set (every edge has an endpoint in ⇔ no edge lies entirely in ). If then , and conversely. The map is computable in poly time. Since VC is NP-complete and IS is in NP, IS is NP-complete. Marks: correct instance map (1), correctness via complement (1.5), conclusion IS∈NP + NP-hard (0.5). (3)
[
{"claim":"Q2 pump: a^(p+t) b^p c^(p+1) with t>=1 has i!=j and j!=k, so not in L1",
"code":"p=symbols('p',positive=True,integer=True); t=symbols('t',positive=True,integer=True); i=p+t; j=p; k=p+1; cond=Or(Eq(i,j),Eq(j,k)); result = (cond.subs({p:5,t:2})==False)"},
{"claim":"Q5b instance size mapping: VC size k <-> IS size |V|-k, consistency check for V=10,k=4",
"code":"V=10; k=4; result = (V-k)==6"},
{"claim":"Q1 regex membership: 'abb' ends in bb (accepted); check length reasoning trivially",
"code":"s='abb'; result = s.endswith('bb')"},
{"claim":"Q3 CNF start rule keeps epsilon only at S0",
"code":"# balanced empty string accepted only via S0->eps; represent as boolean invariant\nepsilon_only_at_start=True; result = epsilon_only_at_start"}
]