Fall 98, CSE 468: Solution of Assignment 6

Exercise 1

  1. The set S1 of all the finite strings on {a1, a2, ... , ak} is countable. In fact, we can define a injective function f : S1 -> N in the following way:
    f(b1b2...bn) = v(b1)*kn-1 + v(b2)*kn-2 + ... + v(bn)*k0
    where v(ai) = i. It is easy to see that f is injective (it is similar to the function used to represent numbers in base k; the only difference is that we assign to ai the value i instead of i-1 in order to count also the prewsence of the initial a1's in a string.

    Another injective function g : S1 -> N which we could have used is

    g(b1b2...bn) = p1v(b1)*p2v(b2)*... *pnv(bn)
    where v(ai) is defined as before and pi = i-th prime number.

  2. The set S2 of all the infinite strings on {a1, a2, ... , ak} (for k > 1) is uncountable. The proof is by diagonalization, and it is similar to Cantor's proof that the interval of real numbers between 0 and 1 is not countable (in Cantor's proof the real numbers are represented as infinite strings of digits - the representation of their decimal part).

    Assume (by contradiction) that S2 is countable. Then consider some indexing of the elemenst of S2 = {s1, s2, ... , sn, ...}. Define a string s as follows:

    the i-th symbol of s is h(i-th symbol of si)
    where h(a1) = a2, h(a2) = a3, ... h(ak) = a1. Since s belongs to S2, it must have an index (as we are assuming that S2 is countable). Let j be the index of s, i.e. s = sj. Let b be the j-th symbol of sj. Then we have that b = h(b), which is impossible.

  3. The set S3 of all the finite strings on the infinite alphabet {a1, a2, ... , ak, ...} is countable. In fact, S3 can be obtained as the union of all the sets Tn = set of finite strings on the finite alphabet {a1, a2, ... , an}. Each Tn is countable (by the part 1 of this exercise), and the set of indexes is N (i.e. n ranges over n). Since N is countable, we have that S3 is the countable union of countable sets and therefore is countable.

Exercise 2

  1. L1L2 is RE. The (nondeterministic) TM M which accepts L1L2 can be defined in terms of the TMs M1 and M2 (accepting L1 and L2 respectively) as follows. Let x be the input string. divide nondeterministically x into two substrings x1 and x2 and check (in "parallel") whether x1 is accepted by M1 and x2 is accepted by M2.

  2. L* is RE. The proof is similar to part 1. The only difference is that the input string has to be divided (nondeterministically) into some substrings x1, x2, ..., xn, where n (also choosen nondeterministically) is not greater than the length of x.

Exercise 3

  1. L1L2 is Rec. The difference with Exercise 2(1) is that we need to construct a deterministic machine M (because we need to compute a function -- the characteristic function of L1L2). This can be done by simulating (via backtracking) the computations of M1 and M2 (computing the characteristic functions of L1 and L2 respectively) on all the possible divisions of the input string x into substrings x1 and x2. If we find at least one division on which both M1 and M2 answer "yes", then M answers "yes". Otherwise M answers "no".

  2. L* is Rec. The proof is like Exercise 3(1). The only difference is that the input string has to be divided into some substrings x1, x2, ..., xn, where n is not greater than the length of x. If, for at least one of these divisions, we get that each xi is in L (i.e. the machine which decides L gives answer "yes" on each xi) then then answer is "yes". Otherwise the answer is "no".

Exercise 4

To solve this exercise we use the theorems of Rice and of Rice-Shapiro. They could also be solved by reduction. In particular, parts 2 and 3 are solved by reduction at the end of Chapter 12.3 of Martin's book.
  1. L1 is not RE. In fact, the property
    p(L) =def= L is empty
    is not upward closed. Hence if L1 were RE it would contadict Point 1 of the Lemma of Effective Discontinuity.

  2. L2 is RE, but not recursive. To prove that L2 is RE, just consider a machine which, given a machine M as input, it generates all possible strings, and tests, for each of them (in "parallel") whether M accetps that string.

    Alternatively, one could use the theorem of Rice-Shapiro. In fact, the set of non-empty languages can be written as the union of all the upward closure of the sets {x}, for any string x. These sets are finite, and they are indexed on the strings on {0,1}, which constitite a RE (even Rec) set.

    To prove that L2 is not Rec, consider the property

    p(L) =def= L is not empty.
    This property is not-trivial, hence, by the theorem of Rice, L1 cannot be upward closed.

    Another proof that L2 is not Rec is the following. Note that L1 is the complement of L2 union the set NE = {x in {0,1}* | x is not the encoding of any TM}. Since NE is Rec, if L2 were Rec then L1 would be Rec as well. But we have proved that L1 is not even RE.

  3. L3 is not RE. In fact, the property
    p(L) =def= L = {0,1}*
    is not finitely reachable. Hence if L3 were RE it would contradict Point 2 of te Lemma of Effective Discontinuity.