Assigment 7 Solutions

3.1 (a)  Here (and in the other parts of this problem and the next) is the list of successive configurations.  I use the symbol ^ for a blank.

q_1 0
^ q_2 ^
^ ^ q_accept


(c)

q_1 000
^ q_2 00
^ x q_3 0
^x 0 q_4 ^
^ x 0 ^ q_reject



(d)

q_1 000000
^ q_2 00000
^ x q_3 0000
^ x 0 q_4 000
^ x 0 x q_3 00
^ x 0 x 0 q_4 0
^ x 0 x 0 x q_3 ^
^ x 0 x 0 q_5 x
^ x 0 x  q_5  0 x
^ x 0 q_5   x  0 x
^ x  q_5   0 x  0 x
^  q_5   x  0 x  0 x
q_5   ^ x  0 x  0 x
^  q_2   x  0 x  0 x
^   x  q_2   0 x  0 x
^ x x q_3 x  0 x
^ x x x q _3 0 x
^ x x x 0 q_4 x
^x x x 0 x  q_4 ^
^ x x x 0 x ^ q_reject


3.2 (b)

q_1 1 # 1
x q_3 # 1
x # q_5 1
x q_6 # x
q_7 x # x
x q_1 # x
x # q_8 x
x # x q_8 ^
x # x ^ q_accept

3.2 (c)

q_1 1 # # 1
x q_3 #  # 1
x # q_5  # 1
x # # q_reject 1
(this is one of those implicit transitions to the reject state that is not indicated in the diagram)

3.2 (d)

q_1 1 0 # 1 1
x q_3  0 # 1 1
x 0 q_3  # 1 1
x 0 # q_5 1 1
x 0 q_6 # x 1
x q_7 0 # x 1
q_7 x 0 # x 1
x q_1 0 # x 1
x x q_2 # x 1
x x # q_4 x 1
x x # x q_4 1
x x # x 1 # q_reject

3.8 (b)

On input string w,

      
       1. Scan input from left to right until a 1 is found and replace it by x. If a blank is reached without finding
          either 1 or 0, accept.  If a blank is reached and 0 has been seen but no 1, reject.
       2. Scan left to beginning of tape, then scan right to first 0 and replace it by x. (If none found, reject.)
       3. Scan right to next 0 and replace it by x. (If none found reject.)
       4. Go back to step 1.

The idea, of course, is to cross off two 0's for every 1. Note that the language in (c) is the complement of the language in (b), so the same description works for part (c) provided you interchange the instructions to accept and reject.

3.7.  There are two problems here.  The first is that it is not specified how we carry out step 1, since we cannot make a complete list of the infinitely many integer settings of the variables before we move to step 2. The second is, we would not possibly know when to reject.  A better-specified result is to enumerate (using our methods for showing various sets are countable) all the k-tuples of integers.  We can do this by considering those for which the sum of the absolute values is 0, 2, 2, etc.  For example with k=3, we would have (0,0,0),(1,0,0),(-1,0,0),(0,1,0),(0,-1,0),(0,0,1),(0,0,-1),(2,0,0),(-2,0,0),(1,1,0), etc.  We then have:

On input p,
    for each k-tuple in an enumeration (x11,...,x1k),(x21,...,x2k), of all the k-tuples of integers,
       if p(xi1,...,xik)=0, accept.

The problem is, we still have no way to know when to say "reject".  The idea appears to be to determine whether a given polynomial p with integer coefficients has a solution, and in fact this problem is undecidable.  (It is called Hilbert's Tenth Problem.)

3.15 (c) Suppose L is decidable.  Here is an algorithm to decide whether a given string w belongs to L*.  We look at all the ways to factor w into a sequence of substrings.  There are only finitely many of these, and we can list them all.  For example, if w has length 4, w=abcd, and the list of factorizations is:

abcd
abc | d
ab  | cd
ab | c | d
a | bcd
a  | bc |  d
a | b | cd
a |  b  | c  | d

For each factorization, we use our algorithm for membership in L and apply it to each of the factors.  If all the factors in one of the factorizations belong to L, then we accept.  If none of the factorizations leads to acceptance, we reject.

3.15(d).  We just take our algorithm for L, and interchange "accept" and "reject" (exactly what we did for changing a DFA for L into one for the complement of L).  This works because for each input, our algorithm for testing membership in L terminates with the answer "accept" or "reject", so switching these two gives an algorithm for the complement.

3.16 (c)

Observe that the above algorithm for L* doesn't really work, because we have only a partial algorithm for L, one that terminates with acceptance when the input is in L, but may run forever when the input is not in L.  We thus assemble all the substrings of w as above.  There are only finitely many of them---in the case w=abcd we have the 10 substrings a,b,c,d,ab,bc,cd,abc,bcd,abcd.  We run the L algorithm for one step on each of these: first a, then b, ...,then abcd.  We then run the algorithm for one more step on a, b, ...,abcd, and continue in this fashion--in essence running ten copies of the program in parallel.  Whenever we get an accept, we check that substring off in all of the factorizations of w in which it occurs.  (For instance, ab occurs in two of the factorizations, d in four of them.)  Whenever we find that all the factors in one factorization are checked off, we terminate and accept.

This algorithm is again a partial one:  It accepts all strings in L* and only those strings, but we do not know when to reject.

Additional Problem.  A polynomial can be thought of as a finite sequence of integers.  For example, 3x4-7x3+2x+5 can be identified with the sequence (5,2,0,-7,3).  (Note the 0 component, which is the coefficient of the missing degree 2 term.)  The set of such sequences is countable.  The idea is that for each k there are only finitely many sequences whose length is less than or equal to k, and such that the sum of the absolute values of its components is less than or equal to k.  We can thus list all such sequences for k=1 (they are (0), (1) and (-1)) then adjoin to these all such with k=2 ((2),(-2),(1,1), (1,-1), etc.) , and so on.  Thus the set of all one-variable polynomials with integer coefficients is countable.

Since each of these polynomials has only finitely many roots, we can also enumerate all the roots of all such polynomials.  Thus the set of algebraic numbers is countable.

Since the set of real numbers is uncountable, there must be real numbers that are not algebraic.  Thus transcendental numbers exist.

In fact, the set of transcendental numbers in uncountable. The reason is as follows:  If we had an enumeration

t_1,t_2,t_3,...

of all the transcendental numbers, we can use the fact that there is such an enumeration

a_1, a_2, a_3,......

of all the algebraic numbers, and obtain an enumeration

a_1, t_1, a_2, t_2, a_3, t_3

of all the real numbers.  But we know that the set of real numbers is uncountable, so there could not be any such enumeration of the transcendental numbers.