CMSC 28000 — Problem Set -2

About the Final Exam

There will be eight problems on the final. Here are (a not necessarily exhaustive list of, but will be very similar to) the kinds of problems that you've seen so far and can expect may show up on the final.

  1. Anything that you did on the midterm.
  2. Given a language, describe its Myhill-Nerode equivalence classes.
  3. Given a language, construct a CFG/PDA that recognizes/matches it.
  4. Given a language operation, show that the context-free languages are closed under the operation.
  5. Given a language, show that it is not a context-free language.
  6. Given a language, is it a context-free language?
  7. Given a language, construct a Turing machine that recognizes/decides it.
  8. Given a modified Turing machine, show that an ordinary Turing machine can simulate it.
  9. Given a language operation, show that the recognizable/decidable languages are closed under the operation.
  10. Given a language, show that it is undecidable.

Exercises

  1. Give the Myhill-Nerode equivalence classes for the following languages.
    1. $\{w \mid \text{$w$ does not contain $aab$ as a subword} \}$
    2. $\{w \mid \text{$w$ contains $abab$ as a subword} \}$
    3. $\{w \mid \text{$w$ is not $aa$ or $bbb$} \}$
    4. $\{w \in \{a,b\}^* \mid |w|_a = |w|_b\}$
    5. $\{w \in \{(,)\}^* \mid \text{$w$ is balanced} \}$
  2. Construct a CFG/PDA for the following languages.
    1. $\{a^i b^j c^k \mid i \neq j \vee j \neq k \}$
    2. $\{a^i b^j \mid i = j \vee i = 2j \}$
    3. $\{w \in \{a,b\}^* \mid \forall x \in \{a,b\}^*, w \neq x^2 \}$
    4. $\{w \in \{(,),[,]\}^* \mid \text{$w$ is balanced} \}$
    5. $\{w \mid |w| = 4\}$
  3. Given a context-free language $L$, show that the following languages are context-free.
    1. $\{xay \mid xy \in L, a \in \Sigma \}$ (the language of words in $L$ with exactly one extra symbol inserted)
    2. $pref(L) = \{u \in \Sigma^* \mid ux \in L\}$
    3. $\{x_1 y x_2 \mid x_1 x_2 \in L, y \in L' \}$ (the language of words in $L$ with a word of $L'$ inserted, where $L'$ is context-free)
    4. $\{uv^R \mid u, v \in L \}$
    5. $cyc(L) = \{xy \mid \exists x,y \in \Sigma^*, yx \in L\}$
  4. Show that the following languages are not context-free.
    1. $\{a^{n^2} \mid n \in \mathbb N\}$
    2. $\{a^i b^j c^k \mid 0 \leq i \cdot j = k \}$
    3. $\{a^i b^j c^k \mid k = \max(i,j)\}$
    4. $\{w \in \{a,b,c\}^* \mid |w|_a = \min(|w|_b,|w|_c)\}$
    5. $\{uxv \mid ux \in L_1, xy \in L_2\}$ where $L_1, L_2$ are context-free languages
  5. Are the following languages context-free? Why or why not?
    1. $\{w \in \{a,b\}^* \mid |w|_a = |w|_b \}$
    2. $\{w^R \mid w \in L \}$, for a CFL $L$
    3. $\{ww^R w \mid w \in \Sigma^*\}$
    4. $\{a^i b^j \mid i = \lceil \log_2 j \rceil \}$
    5. $\{n_2(i) \# n_2(i+1) \mid \text{$n_2(k)$ is the binary representation of $k$} \}$
  6. Describe the operation of a Turing machine for each of the following languages.
    1. $\{0^n 1^n 0^n \mid n \geq 1\}$
    2. $\{w \in \{a,b\}^* \mid |w|_a \neq 2 |w|_b\}$
    3. $\{a^i b^j c^k \in \{a,b,c\}^* \mid i \cdot j \leq k \}$
    4. $\{a^i \mid \text{$i$ is prime} \}$
    5. $\{w \in \{0,1\}^* \mid \text{$w$ is a Fibonacci word} \}$ (def.)
  7. Show that each of the following languages is decidable.
    1. $\{w \in \Sigma^* \mid \forall u \in \Sigma^*, k \geq 2, w \neq u^k\}$
    2. $\overline L$, where $L$ is a decidable language
    3. $\{\langle G \rangle \mid \text{$G$ is a CFG and $G$ does not contain any useless symbols} \}$ (a symbol is useless if it is never used in any derivation or a string)
    4. $\{\langle M \rangle \mid \text{$M$ is a TM and $M$ does not move more than 500 tape cells from the beginning of the tape when run on $\varepsilon$}\}$ (think about the number of configurations)
    5. Anything from Question 6.
  8. Show that each of the following languages is recognizable.
    1. $\{\langle M,w \rangle \mid \text{$M$ is a TM and $M$ halts when run on $w$}\}$
    2. $\{\langle M \rangle \mid \text{$M$ is a TM and $M$ accepts a palindrome}\}$
    3. $\{\langle n \rangle \mid \text{$n \geq 2$ and $\exists p,q$ prime such that $n = p+q$} \}$
    4. $L_1 \cup L_2$, where $L_1$ and $L_2$ are recognizable.
    5. $L_1 \cap L_2$, where $L_1$ and $L_2$ are recognizable.
  9. Show that each of the following languages is undecidable. You can use Rice's theorem on some of these, but (1) "which ones are they?" is also a good exercise and (2) proving they're undecidable without it is also good practice.
    1. $\{\langle M \rangle \mid \text{$M$ is a TM and $M$ accepts a palindrome}\}$
    2. $\{\langle M \rangle \mid \text{$M$ is a TM and $L(M)$ is finite}\}$
    3. $\{\langle M \rangle \mid \text{$M$ is a TM and $M$ halts on all inputs}\}$
    4. $\{\langle M \rangle \mid \text{$M$ is a TM and $\varepsilon \in L(M)$}\}$
    5. $\{\langle G \rangle \mid \text{$G$ is a CFG and $L(G)$ is regular }\}$