Assignment 6

  1. Describe a PDA and a CFG for the language \(A=\left\{b^ia^jb^ka^jb^l \mid j > 0,\, i,k,l\geq 0 \right\}\)

  2. Consider the language \(A\) of all words in \(\Sigma=\{a,b\}\) such that every prefix of \(w\) has at least as many \(a\)’s as \(b\)’s. Construct a PDA for this language. As extra credit, also construct a CFG for it.

  3. This problem concerns the language \(C = A/B =\{w\mid wx\in A\textrm{ for some }x\in B\}\). In other words a string is in \(C=A/B\) if it can be extended to a string in \(A\), where the extension belongs to \(B\). This part has an easy question for you, the next part will be more challenging. There is an obvious relation between the languages \(CB\) (concatenation of \(C\) and \(B\)) and \(A\) (one is a subset of the other). Which relation is that?

  4. In this problem we will sketch the proof of the following fact: If \(A\) is a context-free language, and \(B\) is regular, then \(A/B\) is context-free. You may want to think about it on your own first, get a bit of a feel for the question before reading on.

    We will outline the proof. It is your assignment to provide the details. Assume \(P\) is a PDA for \(A\), and \(D\) is a DFA for \(B\). We will construct a PDA \(O\) for \(A/B\).

  5. If \(A\) and \(B\) are languages, we define a new language \(C=A\diamond B =\{xy\mid x\in A,\, y\in B\, |x|=|y|\}\), i.e. the new language is formed out of the contatenation of a string from \(A\) with a string from \(B\), whenever those strings have the same length. Show that if \(A\) and \(B\) are regular languages, then \(A\diamond B\) has to be context-free. (Hint: Construct the PDA for \(A\diamond B\). Start with DFAs for \(A\) and for \(B\), use the union of their states, with some epsilon transitions thrown in, and maybe extra start/end states for stack cleanup. Use the stack to keep track of how many elements you’ve seen in \(x\), then count them backwards in \(y\).).

Extra credit problem: If \(C=A/B\) as above, part 3 already asked you to show that one of \(CB\) and \(A\) is a subset of the other. As an extra credit problem, determine the status of the other direction: Are \(A\) and \(CB\) always equal? Either prove that they are always equal or provide a counterexample of languages \(A\) and \(B\) where if we define \(C=A/B\) then \(A\) and \(CB\) are not equal.

Extra credit problem 2: What about \(A\diamond B\) when \(A\) is a CFL and \(B\) is regular?