You are on page 1of 2

Question 4: Add comments to the Turing machine below.

What is the domain of the


partial function?

COMMENTS

q0 0 B R q1

q0 1 B R q2

First of all we note that the Turing machine will not loop on an empty loop. This is due to the first
state q0 which is only defined for an input starting with either a 0 or a 1. The first step executed
will be reading the first digit of the input, overwriting it with a blank space (deleting it), moving to
the right and, depending on whether it was a one or a zero, state 2 or state 1 will be adopted.

q1 0 B R q1

q1 1 B R q2

q1 B B L q3

We are at state 1, which means that the first digit of the input was a "0". The machine proceeds to
read the next "cell" and three different things can happen.

• q1 B B L q3: If the cell is blank, it means that the input consisted of only one integer,
namely zero. If this is the case, it will leave the cell blank (overwrite it with a blank) and
move left, where the machine will adopt state 3. However, there is no quintuple defined
which starts on q3! This means that the Turing machine will hault. In conclusion: the input
will have been "0", the machine deleted it and after checking there were no more integers,
it halted.

• q1 0 B R q1: If the machine reads a zero, it overwrites it with a blank (deleting the zero)
and moves to the right, adopting state zero again. The machine will repeat this process
until it finds a 1 or a blank space.

• q1 1 B R q2: If the machine reads a one, it overwrites it with a blank (deleting the one) and
moves to the right, adopting state two. The machine will repeat this until it finds a 1 or a
blank space.

q2 B B L q3

q2 0 B R q4

q2 1 B R q4

We are at state 2, which means that either the first digit of the input was a "1" or the input
consists of a string of "n" zeros followed by a 1. Whichever was the case, it is certain that the last
integer read was a 1. The machine proceeds to read the next "cell" and again, three different
things can happen.

• q2 B B L q3: If the cell is blank, it means that the input finishes here. If this is the case, it will
leave the cell blank (overwrite it with a blank) and move left, where the machine will adopt state
3. As we said before, there is no quintuple defined which starts on state q3! This means that the
turing machine will hault. In conclusion: the input will have been either {1} or {(0)*,1}, the
machine deleted it and after checking there were no more integers, it halted.
• q2 0 B R q4: If the machine reads a zero, it overwrites it with a blank (deleting the zero) and
moves to the right, adopting state four, which we will analyze later. Namely, the machine deleted
the next integer.

• q2 1 B R q4: If the machine reads a one, it overwrites it with a blank (deleting the one) and
moves to the right, adopting state four. Namely, the machine deleted the next integer.

q4 0 B R q4

q4 1 B R q4

q4 B B L q4

Once the machine reaches state four it is safe to say that there is "no way out", that is to say it
loops no matter what. If the machine reads a 0 or 1 it will overwrite the number with a blank
(deleting it), move right and adopt state q4, this will continue until the machine finds a blank space
which will eventually happen. When it reads a blank space it "turns around", it keeps overwriting
the blank with a blank space (without changing anything) and moves on and on to the left. It
keeps doing this without an end.

Domain

We finally study the domain of our partial function. The domain includes the values (or inputs) for
which the machine halts after executing one or more steps. As we have seen above, the machine
only halts when it reaches state 3 (as there is not a quintuple which begins with state q3 defined).
The question is, when does it reach state q3 and which input is valid?

Well, we explained before that this will only happen when the input is either a single "0", a single
"1" or a string of "n" zeros followed by a "1". Hence the domain is [{0}, {1}, {(0)*,1}].

You might also like