CSE2315 Automata, Languages and Computability. 10 open questions, 45 points total. Closed-book — one double-sided A4 handwritten cheatsheet allowed. No calculator. Assume P ≠ NP and NP ≠ EXP. Karp reductions denoted ≤P. Irrelevant information costs points.
Comparable to the actual Endterm 24-25. Requires solid understanding; some questions have non-obvious angles.
Consider the following two DFAs over Σ = {a, b}.
DFA D1: States {q0, q1}, start state q0, accept states F1 (to be determined).
L(D1) = {w ∈ {a, b}* | w contains an even number of a’s}.
DFA D2: States {p0, p1}, start state p0, accept states F2 = {p1}.
L(D2) = {w ∈ {a, b}* | w contains an odd number of b’s}.
(a) (1 pt) Give the set F1 for D1.
(b) (4 pts) Construct a DFA D such that L(D) = L(D1) ⊕ L(D2) (symmetric difference). Leave out unreachable states.
Part (a)
q0 tracks "even number of a’s seen." The start state q0 has seen zero a’s (even), so:
Part (b) — Product construction
Symmetric difference: accept when exactly one of D1, D2 accepts (XOR).
Product states: (qi, pj). Start: (q0, p0).
Accept states F = {(qi, pj) | exactly one of qi ∈ F1, pj ∈ F2}.
Transition table:
| State | a | b |
|---|---|---|
| (q0, p0) ☆ | (q1, p0) | (q0, p1) |
| (q1, p0) | (q0, p0) | (q1, p1) |
| (q0, p1) | (q1, p1) | (q0, p0) |
| (q1, p1) ☆ | (q0, p1) | (q1, p0) |
All 4 states are reachable from the start state. L(D) = "even #a’s XOR odd #b’s."
Consider the NFA N over Σ = {0, 1} with states {q0, q1, q2}, start state q0, accept state q2.
Convert N to a GNFA G with L(G) = L(N) using Sipser’s procedure, then remove state q1. Show the resulting GNFA (all transitions with their regex labels).
Step 1 — Build GNFA
Add new start state qs with ε-transition to q0, and new accept state qa with ε-transition from q2.
GNFA transitions (before elimination):
Step 2 — Eliminate q1
For each pair (qi, qj) where qi has an edge to q1 and q1 has an edge to qj:
Formula: R(qi, qj) = Rold(qi, qj) ∪ R(qi, q1) · R(q1, q1)* · R(q1, qj)
Only affected pair: (q0, q2)
Old q0 → q2: ∅ (no direct edge)
New q0 → q2: ∅ ∪ 1 · 1* · 0 = 1·1*·0 = 1+0
Resulting GNFA
States: {qs, q0, q2, qa}. Transitions:
| From | To | Label |
|---|---|---|
| qs | q0 | ε |
| q0 | q0 | 0 |
| q0 | q2 | 1+0 |
| q2 | q2 | 0 |
| q2 | q0 | 1 |
| q2 | qa | ε |
The path through q1 means: read one or more 1’s, then a 0 to reach q2.
Give a regular expression R over Σ = {0, 1} such that:
$$L(R) = \{w \in \{0,1\}^* \mid w \text{ does not contain } 110 \text{ as a substring}\}$$
Key insight
The substring "110" is forbidden. After seeing "11", the next character cannot be 0 — it must be another 1 (or the string ends). So once a run of two or more 1’s starts, only more 1’s can follow until the string ends.
Building the regex
The string consists of two phases:
Verification
| String | Contains "110"? | Matches R? | ✓? |
|---|---|---|---|
| ε | No | Yes — empty (0|10)*, empty 1* | ✓ |
| 110 | Yes | No — cannot produce "110" | ✓ |
| 111 | No | Yes — empty first part, 1*=111 | ✓ |
| 0101 | No | Yes — (0)(10)(1)*=0·10·1 | ✓ |
| 1100 | Yes | No — "10" block can’t be followed by "0" then back to phase 1 with "11" | ✓ |
| 10100 | No | Yes — (10)(10)(0) | ✓ |
The (0|10)* part ensures every 1 in phase 1 is immediately followed by 0 — so no two consecutive 1’s can occur before the final trailing block.
Let \(L = \{w \in \{a,b\}^* \mid w = w^R\}\) (the language of palindromes).
Use the pumping lemma to prove that L is not regular. Use the word \(w = a^p b a^p\).
Setup
Assume for contradiction that L is regular with pumping length p.
Choose \(w = a^p b a^p\). Then \(w \in L\) since \(w^R = a^p b a^p = w\), and \(|w| = 2p + 1 \ge p\).
Pumping
By the pumping lemma, \(w = xyz\) where:
Since \(|xy| \le p\), both x and y lie entirely within the first block of a’s. So \(y = a^k\) for some \(k \ge 1\).
Pump down: i = 0
$$xy^0z = xz = a^{p-k} b a^p$$
Left side has \(p - k\) a’s before b. Right side has \(p\) a’s after b.
Since \(k \ge 1\), we have \(p - k < p\), so the string is not a palindrome.
Consider the CFG G = ({S}, {a, b, c}, R, S) with rules:
$$S \to aSa \mid bSb \mid c$$
(a) (2 pts) Is G ambiguous? Prove your answer.
(b) (3 pts) Give a PDA P with at most 6 states that recognizes L = \(\{wcw^R \mid w \in \{a, b\}^*\}\).
Part (a) — Ambiguity
G is not ambiguous.
Every word in L(G) has the form \(wcw^R\) where \(w \in \{a,b\}^*\). The derivation is uniquely forced:
Part (b) — PDA
Strategy: push symbols until c is read, then pop matching symbols.
States: qstart, qpush, qpop, qacc.
| State | Input | Stack top | → | Push | Next state |
|---|---|---|---|---|---|
| qstart | ε | ε | $ | qpush | |
| qpush | a | ε | a | qpush | |
| qpush | b | ε | b | qpush | |
| qpush | c | ε | ε | qpop | |
| qpop | a | a | ε | qpop | |
| qpop | b | b | ε | qpop | |
| qpop | ε | $ | ε | qacc |
Consider TM M with input alphabet Σ = {a}, tape alphabet Γ = {a, ␣, X}, and transition function:
| State | Read | Write | Move | Next |
|---|---|---|---|---|
| q0 | a | X | R | q1 |
| q0 | ␣ | ␣ | R | qacc |
| q1 | a | a | R | q1 |
| q1 | ␣ | ␣ | L | q2 |
| q2 | a | ␣ | L | q3 |
| q2 | X | X | R | qrej |
| q3 | a | a | L | q3 |
| q3 | X | X | R | q0 |
(a) (2 pts) Find a word w with |w| = 4 on which M accepts. Show the full sequence of TM configurations.
(b) (2 pts) Is L(M) decidable? What language does M recognize?
Understanding M
M operates in rounds. Each round:
Each round removes a pair: one from the left (marked X) and one from the right (erased). Accepts when all a’s are consumed. Rejects if in q2 no a is left (only X), meaning odd number of a’s.
Part (a) — w = aaaa
| # | Configuration | State |
|---|---|---|
| 1 | aaaa | q0 |
| 2 | Xaaa | q1 |
| 3 | Xaaa | q1 |
| 4 | Xaaa | q1 |
| 5 | Xaaa␣ | q1 |
| 6 | Xaaa␣ | q2 |
| 7 | Xaa␣␣ | q3 |
| 8 | Xaa␣␣ | q3 (a→L) |
| 9 | Xaa␣␣ | q3 |
| 10 | Xaa␣␣ | q0 |
| 11 | XXa␣␣ | q1 |
| 12 | XXa␣␣ | q1 |
| 13 | XXa␣␣ | q2 |
| 14 | XX␣␣␣ | q3 |
| 15 | XX␣␣␣ | q0 |
| 16 | accept | qacc |
Part (b)
Let \(L = \{\langle M \rangle \mid M \text{ is a TM and } L(M) \text{ is infinite}\}\).
(a) (2 pts) Prove that L is Turing-recognizable.
(b) (4 pts) Prove that L is undecidable.
(c) (1 pt) Prove that L is not co-Turing-recognizable.
Part (a) — L is Turing-recognizable (2 pts)
Build a TM T that recognizes L using dovetailing:
T = “On input ⟨M⟩:
More precisely: for each threshold k = 1, 2, …, dovetail until k distinct strings are found to be accepted. If L(M) is infinite, every threshold k is eventually met, so T accepts. If L(M) is finite, T never reaches a high enough threshold and loops (never accepts).
Part (b) — L is undecidable (4 pts)
Reduce from ATM = {⟨M, w⟩ | M accepts w}.
Assume for contradiction that decider R decides L. Build decider S for ATM:
S = “On input ⟨M, w⟩:
Correctness:
So S decides ATM. Contradiction since ATM is undecidable.
Part (c) — L is not co-TR (1 pt)
From (a), L is Turing-recognizable. If L were also co-Turing-recognizable, then L would be both TR and co-TR, which means L would be decidable (by running both recognizers in parallel). But (b) shows L is undecidable. Contradiction.
Consider the language:
$$L = \{\langle M \rangle \mid M \text{ accepts all strings of length } \le 5\}$$
We want a mapping reduction from ATM to L. The computable function F is:
F = “On input ⟨M, w⟩:
(a) (1 pt) What should M′ do on input x? Complete the description.
(b) (2 pts) What does this reduction prove about L? What complexity class does L belong to (TR, co-TR, neither)?
Part (a)
Correctness of the reduction
Part (b)
ATM ≤m L, so L is undecidable.
For the recognizability class: L is co-Turing-recognizable.
To see this, we build a recognizer for the complement \(\overline{L}\) = {⟨M⟩ | ∃ string x with |x| ≤ 5 that M does not accept}:
“On input ⟨M⟩: Run M on all strings of length 0, 1, …, 5 in parallel (dovetail). There are finitely many such strings. If any run halts and rejects, accept.”
This recognizes \(\overline{L}\), so L is co-TR.
COLORFUL MATCHING
Instance: A bipartite graph G = (A ∪ B, E), a coloring c: E → {1, …, k}, and an integer m.
Question: Is there a matching M ⊆ E with |M| ≥ m such that no two edges in M have the same color?
(a) (2 pts) Prove that COLORFUL MATCHING ∈ NP.
(b) (1 pt) Give a yes-instance of Vertex Cover with |V| = 4, |E| = 4, K = 2.
(c) (2 pts) A student proposes the following reduction from Vertex Cover to COLORFUL MATCHING:
Given VC instance (G = (V, E), K): set A = V, B = E. Add edge (v, e) iff v is an endpoint of e. Color all edges color 1. Set m = K.
Apply this reduction to your VC instance from (b).
(d) (1 pt) Is the resulting COLORFUL MATCHING instance a yes-instance?
(e) (1 pt) Explain what is wrong with the reduction and suggest a fix.
Part (a) — COLORFUL MATCHING ∈ NP
Certificate: a set of edges M.
Verifier checks in polynomial time:
Part (b) — VC yes-instance
V = {v1, v2, v3, v4}, E = {(v1,v2), (v2,v3), (v3,v4), (v1,v3)}, K = 2.
Part (c) — Apply the reduction
Bipartite graph: Left side A = {v1, v2, v3, v4}, right side B = {e1, e2, e3, e4}.
Edges in the bipartite graph (vertex v connected to edge e iff v is an endpoint):
All bipartite edges are colored 1. m = K = 2.
Part (d)
Part (e) — The flaw and fix
Flaw: All edges are assigned the same color (color 1). This means the "colorful" constraint forbids any matching of size ≥ 2, regardless of the VC instance. The reduction always produces a no-instance (for K ≥ 2), so it cannot be correct.
Alternatively: drop the color constraint entirely, reducing to standard bipartite matching. But this changes the target problem, so it’s a weaker fix.
For each statement, determine whether it is true or false and provide a brief justification.
(a) (2 pts) If L1 and L2 are both Turing-recognizable, then L1 ∩ L2 is Turing-recognizable.
(b) (1 pt) Every regular language is in P.
(c) (2 pts) If A ≤P B and B ∈ NP, then A ∈ NP.
(d) (1 pt) ATM ≤m HALTTM.
(a) True
Given recognizers T1 for L1 and T2 for L2, build recognizer T for L1 ∩ L2:
T = “On input w: Run T1 and T2 on w in parallel (dovetail). If both accept, accept.”
If w ∈ L1 ∩ L2: both eventually accept → T accepts. If w ∉ L1 ∩ L2: at least one never accepts → T never accepts.
(b) True
A DFA processes input in a single left-to-right pass, reading each symbol once. Running time is O(n) where n = |w|. Since O(n) ⊂ O(nk) for k = 1, this is polynomial.
(c) True
A ≤P B means there exists a poly-time computable function f such that x ∈ A iff f(x) ∈ B.
Since B ∈ NP, there is a poly-time verifier VB for B.
Build verifier VA for A: “On input (x, c): compute f(x) in poly time. Run VB(f(x), c). Accept iff VB accepts.”
Total time: poly(|x|) for f + poly(|f(x)|) for VB = polynomial.
(d) True
Construct mapping f: on input ⟨M, w⟩, output ⟨M′, w⟩ where:
M′ = “On input x: simulate M on x. If M accepts, accept. If M rejects, loop forever.”
| Question | Topic | Points | Correct? |
|---|---|---|---|
| Q1a | DFA Product — accept states | 1 | |
| Q1b | DFA Product — symmetric difference | 4 | |
| Q2 | GNFA State Elimination | 3 | |
| Q3 | Regular Expression | 2 | |
| Q4 | Pumping Lemma | 3 | |
| Q5a | CFG Ambiguity | 2 | |
| Q5b | PDA Construction | 3 | |
| Q6a | TM Trace | 2 | |
| Q6b | TM Language | 2 | |
| Q7a | TR proof | 2 | |
| Q7b | Undecidability reduction | 4 | |
| Q7c | Not co-TR | 1 | |
| Q8a | Fill-in — M′ description | 1 | |
| Q8b | Fill-in — conclusion | 2 | |
| Q9a | NP membership | 2 | |
| Q9b | VC instance | 1 | |
| Q9c | Apply reduction | 2 | |
| Q9d | Yes/No instance | 1 | |
| Q9e | Fix the flaw | 1 | |
| Q10a | TR ∩ closure | 2 | |
| Q10b | REG ⊂ P | 1 | |
| Q10c | NP closed under ≤P | 2 | |
| Q10d | ATM ≤m HALTTM | 1 | |
| Total | /45 | ||