Problem Set 03
1. The Subtractor Function
Consider the following function:
f(n) = n - 1, for all natural numbers n > 1.
Show that f is Turing Machine Computable by constructing a Turing Machine that computes it--i.e., give a flow graph of the instruction set to solve the function for any such n. (10)
2. The Adder/Subtractor Function
Show that the following function is Turing Machine Computable by constructing a Turing Machine that computes it--i.e., give a flow graph of the instruction set to solve the function for non-zero natural numbers n, m, and p such that (n + m) > p. (30)
f(n,m,p) = (n + m) - p
[Hint: Recall the flow graph we gave to show binary subtraction (f(n,m) = n-m, n > m > 0) in class on Thursday, 2/25, Turing Machine computable and the flow graph we gave Tuesday, 2/25, to show binary addition (f(n,m) = n+m, n > 0 and m > 0.) Turing Machine computable.]
3. The Subtractor/Adder Function
Would the TM you gave in (2) above to compute f(n,m,p) = (n + m) - p for non-zero natural numbers n, m, and p such that (n + m) > p also compute the function f(n,m,p) = n + (m - p)--aka the Subtractor/Adder--under the same assumptions? Why or why not? (10)
Extra Credit: The Ugly Doubler
Turing's Theorem--that there exists a Turing Machine that can compute any function computable by any Turing Machine--demonstrates that for any given Turing Machine computable function there are at least two Turing Machine's that compute it. Indeed, we can prove that there are countably infinitely many Turing Machines that compute any Turing Machine computable function.
Of any two Turing Machines TM-1 and TM-2 that compute the same function, let us say that TM-1 is more elegant than TM-2 iff TM-1 requires fewer states in its flow-graph than TM-2. We might add that TM-2 is uglier than TM-1 if it requires more states to do the same thing.
The Ugly Doubler (pdf) is ugly indeed. It requires a total of 17 states to compute the function f(n)=2n, x>0. Write the flow graph of a less ugly Turing Machine that computes the same function. Note that some of the states are obviously eliminable, while more dramatic cuts might be made by reconsidering the basic strategy. The most elegant solution (a mere 6 states!) of the problem I've yet seen is the Ariel McCree Solution:
Whatever your solution, be sure to run your Turing Machine on limiting input (n=1) as well as other test cases (n=3, say) to check whether it works in general! (20)