CMPSCI 401: Theory of Computation

David Mix Barrington

Spring, 2013

Questions and Answers on Homework #2

Page started 17 February 2013, HW#2 due in lecture 19 February 2013.

Question text is in black, answers in blue.

Question 2.1, posted 17 February: I'm confused by the definition of sets B and C in Problem 1.49.

Yeah, the definition could be clearer, and I've written a clearer one on the assignment page. In particular, a string w might be in B or C if any k and y exist meeting the conditions. There might be multiple possible choices of k and y, and you might be able to show that if any k and y exist, a k and y exist meeting certain properties.

Question 2.2, posted 17 February: In 1.49, I've found an infinite sequence of regular languages that union together to give the language I want. Is that enough to show it regular?

No, any language at all is the union of infinitely many one-string languages, and every one-string language is regular. But we know that there are non-regular languages, so the regular languages cannot be closed under infinite union. They are closed under finite union.

Question 2.3, posted 17 February: For Exercise 2.4 (b), does the empty string "start and end with the same symbol"?

I would say not -- to "start and end with the same symbol" I think you would have to start with a symbol, and the empty string doesn't.

Question 2.4, posted 17 February: In 1.49 (a), can I make a family of DFA's, one for each value of k?

You could do that, but you'd only be doing the same thing as the "infinite union" person in Question 1.2, and you wouldn't be showing B to be regular. To show B regular with a DFA, you need a single DFA that works for the language B as defined. Or maybe you can show that this infinite union can be replaced by a finite union...

Question 2.5, posted 17 February: I'm still confused about how to use Myhill-Nerode to show a language to be non-regular.

To show that L is non-regular, you need to show that there exists an infinite set of strings S, such that any two different strings in S are L-dinstinguishable. And to show that two strings x and y are L-distinguishable, you need a string z such that exactly one of xz and yz are in L. You only need one z for each pair, and the definition of z can depend on that of x and y.

Question 2.6, posted 17 February: How do I make a grammar to generate the empty language? I can generate {ε} with the rule S --> ε, but I don't think I'm allowed to have a rule with nothing on the right-hand side. What about the rule S --> S?

That would do it -- if S --> S is your only rule, then you can never generate a string of terminals, and so the set of strings you can generate is the empty language. Even easier is to have no rules at all, so you clearly can't generate anything.

Question 2.7, posted 17 February:I'm still confused about the pumping lemma in 1.54(b). What if some choices of pumping string work and others don't?

When you use the RLPL to prove a language isn't regular, you're showing it doesn't pump, that for any number p there exists a string w that meets the conditions, and any strings x, y, and z don't work. But here you are showing that this language F does satisfy the RLPL. So you need to find a p such that any string w that satisfies |w| ≥ p and w ∈ F can be divided into an x, y, and z satisfying the conditions. In this case a string w might be in F for different reasons, so your argument might need a separate case for each reason.

Question 2.8, posted 18 February: Problem 1.61 refers Problem 1.60 which talks about a string having an a "exactly k places from the right-hand end". Is the last letter of the string "exactly 0 places from the end" or "exactly one place from the end"?

The last position is "one place from the end". The problem makes this clear by saying that the language C1 is Σ*a, C2 is &Sigma'*aΣ, and so forth.

<Question 2.9, posted 18 February: I think I have a grammar for 2.21 that generates all the strings with twice as many a's as b's. How do I make sure it is right, and what kind of proof do you need that it is correct?

To be correct, your grammar has to generate all the strings with twice as many a's as b's, and it has to generate only strings of that form. To prove the first half would be easiest with an induction -- let P(n) be the statement "any string with 2n a's and n b's is generated by my grammar". The second half is probably easier -- you just need to show an invariant of every string derived in your grammar, that forces every string of terminals to have the desired property. I'm fairly flexible about how you justify a correct answer, but an incorrect answer needs some reasoning to get any credit.

Question 2.10, posted 18 February: In Problem 2.44, I have an idea how to get a grammar but it's getting complicated. I think it might be easier to show that there is a PDA. If I do that, can I just say that it can be converted into a grammar by the construction in the book?

Yes, I think that the PDA is definitely the way to go, and you may quote and use the theorem that a language has a PDA if and only if it is context-free.

Last modified 18 February 2013