# CMPSCI 601: Theory of Computation

### Posted 28 July 2003

Questions are in black, solutions in blue.

• Question 1 (15): The language {(M,w,x): M on input w halts with an output other than x} is r.e.-complete.

TRUE. Call this language A. To see that A is r.e., we must design a machine MA that takes input (M,w,x) and halts with output 1 iff (M,w,x) is in A. This machine simulates M on w, and if it halts, prints a 1 if the output is not x and loops forever if the output is equal to x. If M does not halt on w, MA does not accept, so it accepts iff its input is in A.

The more interesting direction is to reduce K to A and thus show that every r.e. language reduces to A. We need a reduction f such that for any number n, f(n) is in A iff n is in K. Note the type of f(n) carefully, as it should be a triple (M,w,x) where M is a machine and w and x are strings.

If n is any number, we need to design an M, w, and x such that Mn halts on input n iff M halts on w with an output other than x. Naturally M should begin by simulating Mn on input n, after erasing its input. We can have it print a 1 if Mn halts on n, and of course it will print nothing otherwise. So all we have to do is to specify x, which can be anything other than 1.

Thus we define f(n) to be the triple (M,0,0) where M is the machine described above. If n is in K, this M will halt on input 0 with an output other than 0. If n is not in K, it will not halt at all. So n is in K iff (M,0,0) is in A and we have the reduction we need from K to A.

Since A is r.e. and K ≤ A we have shown that A is r.e.-complete.

• Question 2 (10): The language {(G,w): w is in L(G)} is r.e.-complete.

FALSE. This language is recursive (in fact it is even in P) and recursive languages cannot be r.e.-complete.

To see that it is recursive we need to show an algorithm that inputs G and w and determines whether w is in L(G). Sipser does this in a simple but hideously inefficient way, by testing out all possible derivations in G that lead to strings of length at most that of w. More practically, as shown in lecture, we can use the poly-time CKY algorithm that tests for each A, i, and j whether the non-terminal A can derive the substring wi...wj of w, using dynamic programming to avoid answering the same subproblem more than once.

• Question 3 (15): The language {n: L(Mn) is recursively enumerable} is regular.

TRUE. This was a trick question intended to see whether you could interpret a simple language expressed in a complicated way. For any Turing machine M, L(M) is a recursively enumerable language. Hence for any number n, L(Mn) is a recursively enumerable language, so any number n is in the given language. And any string of ones and zeros represents a number, unless we disallow leading zeros. So the language in question is the set of all binary strings, if we allow leading zeros, or the language 0 + 1(0+1)*, if we don't, and both these languages are regular.

• Question 4 (20): Every primitive recursive function is computable in polynomial time.

FALSE. We proved in homework that a language is Bloop-computable (primitive recursive) iff it is computable by a Turing machine within some Bloop-computable time bound. Everyone misinterpreted Bloop to conclude that the bounded loops in Bloop could only run for polynomial time. But the index of a Bloop loop need not be the input size. For example,

``````
x = 1;
loop n times
x = x * 2;
return x;
``````

computes the function 2n, and a future statement `loop x times` could then run 2n times.

Every exponential-time computable function is primitive recursive, and by the Time Hierachy Theorem there are exponential-time functions that are not computable in polynomial time. So the statement is provably false.

• Question 5 (10): If A is any non-empty set of Turing machines, there exists M in A such that L(M) is not the empty set.

FALSE. This is another trick question, which I'm glad to see most of you saw through. All we know about A is that it is non-empty, which means that it contains at least one Turing machine M. But there is no reason that M couldn't have an empty language, and if M is the only machine in A (or if all the other machines in A also have empty languages) then we have a counterexample to the given statement.

• Question 6 (10): If A ≤ FO-THEOREM, then A is recursively enumerable.

TRUE. We know from lecture that FO-THEOREM is r.e.-complete and therefore is r.e. -- even if we didn't remember this it is clear that since a statement φ is in FO-THEOREM iff there exists a first-order proof of φ, we could have a Turing machine search through all possible sequences of statements and accept iff one of them is a proof of φ. This machine's language would be FO-THEOREM, proving that FO-THEOREM is recursively enumerable.

We know that any language reducible to an r.e. language is itself r.e., so the statement is true.

• Question 7 (20): The formula

[∃ x: ∀ y: Sphere(y) implies (Larger(x,y)]

implies

[∀z: not Sphere(z) or (exist; w: not Larger(z,w))]

is valid for Tarski's World.

TRUE. I will present two proofs, one straightforward and one using a sort of "back door".

Back Door proof:

1. assume [∃ x: ∀ y: Sphere(y) implies (Larger(x,y)]
2. let z be arbitrary
3. not Larger(z,z) -- axiom of Tarski's World
4. ∃ w: not Larger(z,w) -- exist-intro from 3
5. not Sphere(z) or (∃ w: not Larger(z,w)) -- or-intro from 4
6. ∀z: not Sphere(z) or (exist; w: not Larger(z,w)) -- forall-intro from 2-5
7. conclusion holds by implies-intro from 1-6

I call this a "back door" proof because the assumption in 1 is never used to prove the conclusion in 6, since the conclusion turns out to be valid in Tarski's World itself.

Straightforward proof:

1. assume [∃ x: ∀ y: Sphere(y) implies (Larger(x,y)]
2. ∀ y: Sphere(y) implies Larger(a,y) -- exists-elim from 1
3. let z be arbitrary
4. Sphere(z) or not Sphere(z) -- excluded middle from Taut Con
5. assume not Sphere(z)
6. not Sphere(z) or (∃ w: not Larger(z,w)) -- or-intro from 5
7. assume Sphere(z)
8. Sphere(z) implies Larger(a,z) -- forall-elim from 2
9. Larger(a,z) -- implies-elim from 7, 8
10. not(Larger(a,z) and Larger(z,a)) -- axiom of Tarski's World
11. not Larger(z,a) -- Taut Con from 9, 10
12. ∃ w: not Larger(z,w) -- exists-intro from 11
13. not Sphere(z) or (∃ w: not Larger(z,w)) -- or-intro from 12
14. not Sphere(z) or (∃ w: not Larger(z,w)) -- or-elim from 4, 5-6, and 7-13
15. conclusion by implies-intro from 1-14