# CMPSCI 601: Theory of Computation

### Exam was given in class Monday 31 March 2003

Solutions are in blue

• Question 1 (10): If A is an r.e. language, the decision problem for A can be solved by a Bloop program.

FALSE. Bloop programs can decide only primitive recursive languages, and all primitive recursuve languages are recursive. There exist r.e. languages, such as K, that are not recursive.

Note: I got many answers that said "the machine for A does not halt". This approaches the right idea but is wrong for two reasons. We can't talk about "the machine for A" because there are many such machines. Also, A might or might not be recursive -- you have to say that you're considering an A that isn't.

• Question 2 (20): If a sentence φ is provable from the axiom statement NT, then φ is true in the structure N. (In symbols, if NT "proves" φ, then N "models" φ.)

TRUE. The statement NT is true in N. Since our proof system is sound, any statement provable from NT is thus also true in N.

Note: I got many answers that talked about NT being sound or being provable. The key point is that the proof of φ from NT preserves truth. NT itself is not FO-valid, for example, because there exist models of first-order logic in which it is false.

• Question 3 (10): The language {D: L(D) = Σ*} is in the class P. (Recall that the variable D denotes a DFA.)

TRUE. D is in this language iff there is not a path from the start state to a non-final state in its graph. (Technically, in the graph we get be erasing all the letters on the edges.) We can test any REACHABILITY question in P, using depth-first search or a variety of other methods. Thus we can ask the REACHABILITY question about each non-final state (there are at most n of them) and accept D iff all the answers are "no".

Note: I got some wrong answers proposing to exhaustively search all the paths, which takes far too long.

• Question 4 (10): If A and B are both r.e.-complete languages, then A ≤ B (A is reducible to B).

TRUE. Since A is r.e.-complete, we know that A is an r.e. language. Since B is r.e.-complete, any r.e. language is reducible to B. So A is reducible to B.

• Question 5 (15): The language Z = {M: L(M) is regular} is r.e.-complete.

FALSE. Z does have the property that all r.e. languages are reducible to it -- if you proved this you got a lot of partial credit. But in fact Z is not r.e. and is thus not r.e.-complete. To see this latter fact we reduce K-bar to Z.

Given a machine Mn, we define a machine Mf(n) as follows. Mf(n) first runs Mn on input n, then (if that computation accepts) accepts iff its original input is of the form 0k1k for some number k. If n is not in K, Mf(n) never accepts and its language is the empty set, which is regular so f(n) is in Z. But if n is in K, L(Mf(n)) is equal to the non-regular language {0k1k: k ≥ 0}, and thus f(n) is not in Z. The function f reduces K-bar to Z, so Z is not an r.e. language.

Note: There was considerable confusion on this one. Many people thought that "not recursive" and "r.e.-complete" meant the same thing. Some quoted the Rice-Myhill-Shapiro Theorem, which can be used to prove that Z is not recursive but (in the version we did) says nothing about r.e.-completeness. Many people designed a reduction that always made L(Mf(n)) a regular language. And many people started talking about whether a machine MZ, apparently meant to decide Z, had a regular language or not -- this betrays a serious confusion about types.

• Question 6 (15): The language {(G_1,G_2): L(G_1) = L(G_2)} is recursive.

FALSE. We proved in Lecture 9 that the language Σ*-CFL is not recursive. We can reduce that language to this one by letting f(G) be that pair (G,Gall) where Gall is a fixed grammar that generates all strings in Σ*.

Note: Many people tried to apply Rice-Myhill-Shapiro, which is no good because it talks about Turing machines, not grammars. It is true that you can reduce this language to the non-recursive language EQUIV-TM, but that doesn't say anything directly about the easier language EQUIV-CFL. Note, for example, that EQUIV-DFA is recursive.

Some people tried to argue that you could test each rule of one grammar to see whether it was simulatable in the other -- in fact this is not possible.

• Question 7 (20): The formula

[∀ x: ∃ y: Cube(x) implies (Larger(x,y) OR LeftOf(x,y))]

iff

[∃y:&forall x;: Cube(x) implies (Larger(x,y) OR LeftOf(x,y))]

is valid for Tarski's World.

FALSE. The simplest counterexample has a small cube c to the left of a large cube d. Then the first statement is true because c has d which is larger than it is, and d has c which is left of it. But the second statement is not true because no cube is either smaller or to the right of all other cubes -- in particular it is not smaller or to the right of itself.

Note: Many people tried to prove this, not seeing that it is false. In fact is it true that the second statement implies the first, and a correct proof of this got you a lot of points. But many of the proofs I saw totally misused the intro and elim rules for ∀ and &exists;. Each of these rules places conditions on the variable introduced or eliminated, which cannot be ignored. If you messed this up you should construct a correct proof in Fitch that the second statement implies the first, and check it, and note how your alleged proof that the first implies the second does not work.

By the way, if I had used a transitive relation instead of the non-transitive "Larger(x,y) OR LeftOf(x,y)", the equivalence would have been true.

Last modified 25 April 2003