Answers to the other homework #5 problems.

3.6 Because M might loop on one of the strings s_i. For example, suppose the language consists of just the string s_2, but M happens to loop on string s_1. The procedure would never get to s_2. It would not print out anything because it would be stuck looping on s_1.

3.14 a. Say M_i decides language L_i, i=1,2. To decide the union of the languages, run an input string s on M_1. Since M_1 is a decider, you know you this computation will halt. If M_1 accepts, accept. If not, run s on M_2 and accept if M_2 does.

d. To decide the complement of L, where L is decided by M, run string s on M and accept iff M doesn't. This works because M will halt. If M did not halt on a string s, this procedure would not halt. The string s would not be accepted by M (not in L) but our procedure would not accept s either -- it would loop -- and we would think s was not in the complement of L.

e. This is like a but you accept only if both M_1 and M_2 accept.

3.15 d Say M_i recognizes L_i. Given string s, run s on M_1. If M_1 rejects, reject. If M_1 loops, we will loop so we won't accept. If M_1 accepts, run M_2 on s, and accept iff M_2 does.

a. This is trickier. We can't do the procedure we used in part d. Why not? What if s is in L_2, but not in L_1. Then we want to accept s since it is in the union. However, M_1 might loop on s. If we follow the procedure from part d, we will loop, and not accept s. Instead, for i = 1, 2, 3, ...:

Begin

Run s for i steps on M_1. If M_1 accepts, accept.

Run s for i steps on M_2. If M_2 accepts, accept.

End (for i)

Why there is no 3.15e.

The class of Turing-recognizable languages is not closed under complementation. The halting problem language A_TM is an example. The answer above, to part d of 3.14 explains why the proof for complements of decidable languages doesn't work for recognizable languages.