CMPSCI 601: Theory of Computation

David Mix Barrington

Fall, 2003

Here are questions and answers on HW#1, due 24 September 2003. Questions are in black, answers in blue.

Question 8, 23 September 2003

For questions 3 and 4, if I can show a procedure to convert the 17-letter PDA and 17-letter Turing Machine into DFAs, would this prove that L(PDA-17) and L(TM-17) are regular? Or would there be additional things that need to be proved?

If you can design a DFA that successfully, for all strings, predicts what the PDA-17 or the TM-17 will do, then you may conclude that the languages are regular, yes.

In question 5, we must prove that A is r.e. iff there exists a machine M such that A=H(M), where H(M) is defined as the set of strings such that M hangs on w. From this, is it true that H(M) is equal to complement of L(M), where L(M) is the set of strings w that M accepts and halts on?

No. A particular machine on a particular string might accept, reject, hang, or loop. Looping is running forever without doing any of the other things. So H(M) is a subset of the complement of L(M), but not necessarily equal to the complement of L(M).

One half of this proof will be to take the machine N, such that A=L(N) (known to exist because A is r.e.) and design a _new_ machine M so that A = H(M). The other will be to assume that M exists with A = H(M) and then design a suitable N such that A = L(N).

Question 7, 23 September 2003

This is a general question not directly related to Homework 1.

Can you please suggest which relevant sections of Papadimitriou, Sipser, or some other book, we should be reading before/after each lecture to gain additional understanding of the material to be able to better complete homework assignments?

What are the corresponding chapter / page numbers that we are expected to read for a given lecture number, if any?

The Spring 2003 syllabus includes section numbers of [P] and/or [BE] for every lecture.

Maybe some suggested reading assignments, or a reading schedule. There is a lot of material in the books, and sometimes it is not clear to me what material in the books is most relevant for a particular lecture or homework assignment.

Have you seen the Spring 2003 syllabus? It's at www.cs.umass.edu/~barring/cs601/syllabus.html.

Question 6, 23 September 2003

I have some questions on Homework 1.

1. In question 5, I don't believe that it is *always* necessary for the machine M such that A=H(M) to exist. A counter-example to this would simply be to have a Turing machine M that accepted all strings. In other words, every state is an accepting state, and the Turing machine doesn't hang on or reject any string. This Turing machine that accepts all strings could probably just accept without bothering to look at its input. In this case, machine M such that A=H(M) does not exist unless we just want to have it accept the empty string. Is this counter-example valid?

If M accepts all strings, then H(M) is the empty language. Since the empty language is r.e., you have to include this possibility but it doesn't pose any problem. The empty language is r.e. because it is L(N) where N is a machine that never accepts any string.

2. This is related to question 6. When a Turing machine reads the empty string, does the tape head move just as if it read a regular letter, or does it just stay put? Is the empty string represented by a letter on the tape? I flipped through the book (Sipser, Papadimitriou, etc.) and could find examples of a Turing machine reading a "blank", but not reading an "empty string". Is a "blank" the same thing as an "empty string"?

A blank is a kind of letter that is in the tape alphabet of the TM but not in the input alphabet. When we "start the TM M on input w", this means that the head of M starts on the leftmost square of the tape, which contains a blank. To the right of this square are the letters of w in order, then another blank. In the case that w is the empty string, there _are_ no letters in w and the entire tape is blank.

Sipser carefully defines what it means for a TM to accept a string -- look at what his definition becomes if the input string is empty.

Would using nondeterministic or multitape Turing machines in question 6a be helpful?

Possibly, though the point of the question is the definition of "recursive" and "r.e." in terms of deterministic machines and I would answer the problem only referring to deterministic machines.

3. Questions 3 and 4 seem to be similar to Homework Assignment 1, questions 2 and 3 from the Summer 2003 semester. Is this a valid observation?

They are similar in that you're proving languages to be regular, but the proofs this time are rather different, and in fact are somewhat easier.

4. In question 1, is proving that A is regular enough to prove that it is DFA-recognizable? Do I also have to prove the reverse direction of the if-and-only-if statement, or is it enough to prove that A is regular?

Yes, you may quote Kleene's Theorem for this direction of the proof. The hard direction is to show that if the language is DFA-recognizable, it has a regular expression of the specified form.

Question 5, 22 September 2003

Question 6 of HW#1 states thats "if u and v are any two strings of the same length that differ in exactly one position, then exactly one of u and v is in A."

It's obvious from the condition that the two strings of the same length will differ by a single symbol, a : a is in {0,1}. Therefore can we arbitarily set a condition and decide as to whether u or v is in A ?

It depends what you're trying to prove, because that will determine what, if anything, you know about u and v. If you are trying to prove part (a) and you have an idea about how to design M, then you may break into cases to show that your M works if w is in A and also works if w is not in A. But of course M doesn't know which case it's in unless it can find out itself.

Remember that because A is r.e., you are given that there exists a machine N such that L(N) = A. N will probably be useful in constructing M.

Question 4, 21 September 2003

For question 3 and 4 of HW#1, to prove that L(M), where M is a PDA in Question 3 and M is a Turing Machine in Question 4, is regular:

  1. Can we assume a language first and then prove OR

  2. Do we have to recognize the language that is genrated by the imposed condition i.e. max of 17 letters in input and then carry on from there ?

You must show that for any M meeting the conditions of the problem, L(M) is a regular language. So assuming a particular L(M) will not do. But you may be able to find a specific condition such that (1) if M has the given property, then L(M) has the condition, and (2) every language with the condition is regular.

Question 3, 19 September 2003

For Q(2) in HW#1, can we assume the following:

Since A is subset of {a}*, then L(a*) = {a^i : i in N} Therefore proof that A = {a^i : i belongs to N} is a CFL ?

It is true that the language a* is context-free, as it has the grammar "S goes to aS; S goes to emptystring". If A is a subset of a*, then the set X = {i: ai is in A} might be any subset of N. Your job here is to explain for what possible X the language A is or isn't context-free.

Also is it possible that a non-regular language be a CFL ?

Yes, the language {a^nb^n: n in N} is context-free, because it has the grammar "S goes to aSb; S goes to emptystring". But this language is not regular. Any unary context-free language is regular, but that is what you are trying to prove here.

Question 2, 19 September 2003

If A is a CFL, then according to the CFL Pumping Lemma, when we say z=uvwxy, then is it always true that |z| = |uvwxy| ?

Yes, because if z and uvwxy are the same string then they have to have the same length.

If not then if |z| < 5 assuming each of u,v,w,x,y are of atleast length 1, then how can we break it up in u,v,w,x and y ? Do we use the empty string ? If so how ?

Only v and x are guaranteed to be no-empty -- u, w, and y might be the empty string. But remember that the conclusion of the CFL Pumping Lemma only holds for sufficiently long strings z. Remember the proof -- we need z to be long enough so that its parse tree must contain a path with a repeated nonterminal.

Question 1, 15 September 2003

I attended your CMPSCI 601 (Fall 2003) Lecture 1(in video) and have a question on DFA and Regular Expression which I think is also part related to the first question in the HW#1.

Welcome to the class!

Question:

If A is a language over only a single-letter alphabet sigma = {a}, then is it not always true that there will always exists a DFA D, that will accept a non-empty strings of any format ?

Since a belongs to sigma, then a belongs to Regular Expression(sigma). Also since a* is a regular expression , so is a^n. Then from this is it not possible to have a DFA which will accept a string of any format created out of any combination of the symbol a ?

You are confusing strings with languages, I think. It is true that for any string w, there exists a DFA that will accept w. But it is not true that any _language_, even on a one-letter alphabet, is the language of some DFA. For example, consider the language {a^n: n is a perfect square}. This language does not obey the regular-language Pumping Lemma, so it cannot be regular. Also, it has an infinite number of Myhill-Nerode classes so it is not regular.

Let me prove the latter fact as I'm going to post this. It's a good example of how to use the M-N Theorem.