Chapter Questions
Describe what factors might be included in a model for the spread of an epidemic.
Say an automobile manufacturer designs a new car using a sophisticated and detailed computer simulation, but no prototype vehicles, and the automobile is later found to have a defect. Do you think the manufacturer is accountable? Is the manufacturer accountable if it builds prototypes that do not reveal the defect, but it does not do a simulation?
Give an example of a potential use of computerized models ina. The pharmaceutical industryb. The food processing industryc. The insurance industry
Which of the following can be considered computing agents and why?a. A clock radiob. A vacuum cleanerc. A video camerad. A programmable calculator
A Turing machine contains only the following instructions:$$\begin{aligned}& (1,1,1,1, R) \\& (1,0,1,2, R)\end{aligned}$$Can this machine ever reach the following configuration? Explain your answer.$$.0016 \ldots$$
Is the following a legitimate Turing machine? Why or why not?$$\begin{aligned}& (1,1,0,2, R) \\& (1,0,0,3, R) \\& (2,1,1,2, R) \\& (3,0,0,3, R) \\& (2,0,0,4, L) \\& (3,0,1,4, L) \\& (4,1,1,5, R) \\& (4,0,0,5, R)\end{aligned}$$
Find the output for the Turing machine$$\begin{aligned}& (1,1,1,2, R) \\& (1,0,0,2, R) \\& (1, b, 1,2, R) \\& (2,0,0,2, R) \\& (2,1,0,1, R)\end{aligned}$$when run on the tape$$\ldots b 1001 b \ldots$$
Find the output for the Turing machine$$\begin{aligned}& (1,1,1,2, L) \\& (2, b, 0,3, L) \\& (3, b, 1,4, R) \\& (4,0,1,4, R)\end{aligned}$$when run on the tape$$\ldots b 1 b \ldots$$
Describe the behavior of the Turing machine$$\begin{aligned}& (1,1,1,2, R) \\& (2,0,0,1, L)\end{aligned}$$when run on the tape$$\ldots .01016 \ldots$$
Describe the behavior of the Turing machine$$\begin{aligned}& (1,1,1,1, R) \\& (1,0,0,2, L) \\& (2,1,0,2, L) \\& (2, b, 1,3, L) \\& (3, b, b, 1, R)\end{aligned}$$when run on the tape$$\ldots 01016 \ldots$$
Describe the behavior of the following Turing machine on any input tape containing a binary string:$$\begin{aligned}& (1,1,1,1, R) \\& (1,0,0,1, R) \\& (1,0,1,1, R)\end{aligned}$$
Write a Turing machine that, when run on the tape ...b11111b... produces an output tape of b01111b...You can accomplish this using only one instruction.
Say a Turing machine is supposed to change any string of $1 \mathrm{~s}$ to a string of 0 s. For example,...b111b...should become... b000b...Will the following Turing machine do the job? Why or why not?$$\begin{aligned}& (1,1,0,2, R) \\& (2,1,0,3, R) \\& (3,1,0,4, R)\end{aligned}$$
a. Write a Turing machine that, when run on the tapeb11111b...produces an output tape of b11110b...b. Write a Turing machine that, when run on any tape containing a unary string, changes the rightmost 1 to 0 and then halts. (If your solution to Exercise 15 a was sufficiently general, you will not have to change it here.)
Write a Turing machine to perform a unary decrement(the opposite of an increment). Assume that $n>0$.
Write a Turing machine to perform a unary decrement. Assume that $n$ may be 0 , in which case a single 0 should be output on the tape to signify that the operation results in a negative number.
Write a Turing machine that operates on any binary string and changes it to a string of the same length with all 1s. It should, for example, change the tape tob011010b...tob111111 b...However, you must write instructions that allow your Turing machine to work on any binary string, not just the one shown here.
Write a Turing machine that operates on any strin of $1 \mathrm{~s}$ and changes it to a string of alternating $1 \mathrm{~s}$ and $0 \mathrm{~s}$.
The parity-bit Turing machine of Section 12.5 .2 uses an odd parity bit scheme. Write a Turing machine that uses an even parity bit scheme.
Write a Turing machine that efficiently adds 3 to any unary number.
Write a Turing machine that begins on a tape containing a single 1 and never halts but successively displays the strings$$\begin{array}{r}. .616 \ldots \\\text {... b010b... } \\\text { bo0100b... }\end{array}$$and so on.
Write a Turing machine that operates on the unary representation of any number and decides whether the number is 0 ; your machine should produce an output tape containing the unary representation of 1 if the number was 0 and the unary representation of 2 if the number was not 0 .
Write a Turing machine that takes any unary string of an even number of $1 \mathrm{~s}$ and halts with the first half of the string changed to 0 s. (Hint: You may need to use a "marker" symbol such as $X$ or $Y$ to replace temporarily any input symbols you have already processed and do not want to process again; at the end, your program must "clean up" any marker symbols.)
Write a Turing machine that takes as input the unary representation of any two different numbers, separated by a blank, and halts with the representation of the larger of the two numbers on the tape. (Hint: You may need to use a "marker" symbol such as $X$ or $Y$ to replace temporarily any input symbols you have already processed and do not want to process again; at the end, your program must "clean up" any marker symbols.)
The Turing machine described in Section 12.5 .4 to add two unary numbers was designed to erase the two leftmost is on the tape, move to the right to the blank separating the two numbers, and replace the blank with a 1 . If the first of the two numbers being added is 0 , then there are not two 1s before the separating blank. Does the algorithm still work in this case?
Draw a state diagram for a Turing machine that takes any string of 1 s and changes every third 1 to a 0. Thus, for example,...b111111b...becomesb110110b...
Draw a state diagram for a Turing machine that increments a binary number. Thus, if the binary representation of 4 is initially on the tape, b100... then the output is the binary representation of 5 , $.6101 .$.or if the initial tape contains the binary representation of 7 ,b1116...then the output is the binary representation of 8 , $.61000 b \ldots$
Analyze the time and space efficiency of the following Turing machine operating on a unary string of length $n$.$$\begin{aligned}& (1,1,1,1, R) \\& (1, b, b, 2, L) \\& (2,1,0,2, L) \\& (2, b, b, 3, R) \\& (3,0,1,3, R)\end{aligned}$$
Suppose we already have Turing machine instructions to copy a unary string; we al so know how to add two unary numbers. Describe (in words only) the design of a Turing machine to multiply two unary numbers.
Two other Turing machine unary addition algorithms follow.1. Fill in the separating blank with a 1, go to the far right end, and erase two $1 \mathrm{~s}$.2. Erase a 1 on the leftend, fill in the separating blank with a 1 , and erase a 1 on the right end.a. Do both of these algorithms work correctly?b. Write the Turing machine for each of these algorithms.c. Informally, which of the three addition algorithms (the one given in the chapter and these two) seems most time efficient?d. Suppose that the numbers to be added are $n$ and $m$. The original tape contains the unary representation of $n$, followed by a blank, followed by the unary representation of $m$.
A palindrome is a string of characters that reads the same forward and backward, such as radar or IUPUI. Write a Turing machine to decide whether any binary string is a palindrome by halting with a blank tape if the string is a palindrome and halting with a nonblank tape if the string is not a palindrome.Note: The world's longest single-word palindrome is the Finnish word for "lye dealer":SaippuakivikauppiasOther palindromes include:Slap a ham on Omaha palsDo geese see godA man a plan a canal Panama
The following BNF grammar defines a set of binary strings.$\langle$ string $\rangle::=\langle$ one $\rangle \mid\langle$ <one $\rangle\langle$ string $\rangle$<ones $::=1$a. Describe the language defined by this grammar.b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.
The following BNF grammar defines a set of binary strings.$\langle$ string $\rangle:=\langle$ zero $\rangle\langle$ zero $\rangle\langle$ string $\rangle \mid<$ one $\rangle$$\langle$ zero $>::=0$<ones $::=1$a. Describe the language defined by this grammar.b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.
The following BNF grammar defines a set of binary strings.$$\begin{aligned}& \langle\text { string }\rangle:=\langle\text { zero }\rangle\langle A\rangle\langle\text { zero }\rangle \\& \langle A\rangle:=\langle\text { zero }\rangle\langle B\rangle\langle\text { zero }\rangle \\& \langle B\rangle:=\langle 0 n e\rangle\langle B\rangle \mid\langle\text { one }\rangle \\& \langle\text { zero }\rangle::=0 \\& \langle 0 \text { en }\rangle:=1\end{aligned}$$a. Describe the language defined by this grammar.b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.
The following BNF grammar defines a set of binary strings.$$\begin{aligned}& \langle\text { string }\rangle::=\langle\text { zero }\rangle\langle\text { one }\rangle \mid\langle\text { zero }\rangle\langle\text { string }\rangle\langle\text { <one }\rangle \\& \langle\text { zero }\rangle:=0 \\& \langle\text { one }\rangle:=1\end{aligned}$$a. Describe the language defined by this grammar.b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.
Your boss gives you a computer program and a set of input data and asks you to determine whether the program will get into an infinite loop running on these data. You report that you cannot do this job, citing the Church-Turing thesis. Should your boss
What is the significance of the unsolvability of the halting problem?
The uniform halting problem is to decide, given any collection of Turing machine instructions, whether that Turing machine will halt for every input tape. This is an unsolvable problem. Which of the three oractical consequences of unsolvability problems described in Section 12.7 follows from the uniform nalting problem?
The 10-step halting problem is to decide, given any collection of Turing machine instructions, together with any initial tape contents, whether that Turing machine will halt within 10 steps when started on that tape. Explain why the 10-step halting problem is computable.