Problem Set
7.1 Regular Languages
Problem 1. Construct a DFA over that accepts exactly those strings whose Length is a multiple of 3. Prove your DFA is correct.
Problem 2. Let . Give a DFA with the minimum number of states for .
Problem 3. Use the Myhill-Nerode theorem to prove that is not regular.
Problem 4. Prove or disprove: if is regular, then both and are regular.
7.2 Context-Free Languages
Problem 5. Give a CFG for . Prove your grammar generates Exactly this language.
Problem 6. Convert the following grammar to CNF: . Show all steps of the conversion.
Problem 7. Use the CFL pumping lemma to prove that is not context-free.
Problem 8. Construct a PDA for . Give the formal definition Of the PDA and explain why it is correct.
7.3 Turing Machines and Decidability
Problem 9. Design a TM that decides the language . Describe the algorithm and prove it always halts.
Problem 10. Prove that the language is undecidable.
Problem 11. Use Rice”s theorem to prove that is undecidable. Explain why Rice’s theorem applies.
Problem 12. Show that the PCP instance with and Has a solution by finding one, or prove it has no solution.
7.4 Complexity Theory
Problem 13. Show that if Then .
Problem 14. A 3-colouring of a graph is a function Such that for every edge . Show that 3-SAT 3-Colouring By describing the reduction construction.
Problem 15. Prove that is self-reducible: given an oracle for Describe a polynomial-time algorithm to find an actual clique of size (if one exists).
Problem 16. Using Savitch’s theorem, prove that . What is the time complexity of your algorithm?
Problem 17. Define the language . Show that is NP-complete.
Problem 18. A language is in DP (difference of two NP sets) if there exist such that . Show that is in DP. Is DP contained in ? Justify.
7.5 Comprehensive
Problem 19. Consider the language . (a) Prove is not regular using the pumping lemma. (b) Give a CFG for and prove it is correct. (c) Is decidable? Justify.
Problem 20. For each of the following languages, state the smallest complexity class (from , \mathrm{CFL, , \mathrm{NP \mathrm{PSPACE, Or “undecidable”) that is known to contain it. Justify each answer briefly.
(a) (b) (c) (d) (e)
7.6 Selected Solutions and Hints
Problem 1. States with transitions for All . Accept state: . Proof by induction on the number of symbols read.
Problem 3. The strings are pairwise distinguishable: for The suffix distinguishes from since but (because ).
Problem 4. Dis…/1-number-and-algebra/3_proof-and-logic: let (not regular) and (regular). Then is regular, but is not.
Problem 7. Let with pumping length . Since The Substring cannot span all four blocks. Case analysis shows that pumping any valid Decomposition produces a string not in .
Problem 10. Reduce from . Given Construct two TMs (accepts only) and (accepts what accepts). Then iff accepts iff (after adjusting for the specific reduction).
Problem 13. If Then for any We have . Since is closed under complement, . So for every , meaning . By symmetry, .
Problem 19. (a) Let . Since , is in the first block. Pumping down gives . (b) (generate matched pairs on both sides of ). (c) Yes — a TM can check the symbol and verify both halves are reverses of each other.
Problem 20. (a) Decidable but not CFL (pumping lemma for CFLs). (b) NP-complete (Hamiltonian cycle is NP-complete). (c) NP-complete (vertex cover is NP-complete). (d) Decidable (in fact, in P — simulate for 100 steps). (e) PSPACE-complete (TQBF is PSPACE-complete).
Common Pitfalls
- Confusing regular and context-free languages. Regular: recognised by finite automata (no memory). Context-free: recognised by pushdown automata (stack memory). Fix: is context-free but not regular. is neither.
- Wrong halting problem understanding. The halting problem is undecidable — no algorithm can determine for all programs whether they halt. Fix: This is a fundamental limitation; specific cases may be decidable, but the general problem is not.
- Confusing P and NP. P: problems solvable in polynomial time (deterministic). NP: solutions verifiable in polynomial time. P NP; P NP is unknown. Fix: NP-complete: hardest problems in NP; if any NP-complete problem is in P, then P NP.
Worked Examples
Example 1: DFA construction
Problem. Construct a DFA that accepts binary strings ending in “01”.
Solution. States: (start), (last symbol was 0), (accept, ends in 01), (dead state). Transitions: —0—>, —1—>; —0—>, —1—>; —0—>, —1—>; —0/1—>.
Example 2: Pumping lemma
Problem. Prove that is not regular.
Solution. Suppose is regular with pumping length . Choose . By the pumping lemma, with , , for all . Since , for some . Then (since ). Contradiction.
Summary
- Chomsky hierarchy: regular context-free context-sensitive recursively enumerable.
- Regular languages: DFAs, NFAs, regular expressions; closed under union, concatenation, Kleene star.
- Context-free languages: CFGs, pushdown automata; pumping lemma for non-regular languages.
- Computability: halting problem is undecidable; P vs NP is open; NP-completeness.
Cross-References
| Topic | Site | Link |
|---|---|---|
| [Theory of Computation] | A-Level | View |
| [Theory of Computation] | University | View |