Vous êtes sur la page 1sur 3

CMPT 710 — Complexity

Outline Solutions to Exercises on Turing Machines


1. Give a complete formal definition of a single-tape deterministic
Turing Machine with alphabet Σ = {0, 1} that accepts all strings
containing an even number of 1s and rejects all other strings.
T = (Q, Σ, δ, q0 , F ) where
– Q = {q0 , qeven , qodd , qA , qR }
– Σ = {0, 1}
– The transition function δ is given by:

q s q′ s′ m
q0 △ qA △ S
q0 1 qodd 1 R
q0 0 qeven 0 R
qeven 1 qodd 1 R
qeven 0 qeven 0 R
qeven △ qA △ S
qodd 1 qeven 1 R
qodd 0 qodd 0 R
qodd △ qR △ S

– F = {qA , qR }
2. Give an informal description of a 2-tape deterministic Turing
machine that accepts {wcwR | w ∈ {0, 1}∗} where wR means w
reversed, and rejects all other inputs.
“Copy input to a second tape. If more than one group of cs are scanned,
reject. Move the head on the input tape to the leftmost non-blank symbol.
Move right on input tape and left on second tape comparing symbols.
Accept if everything matches, reject otherwise. Time is 3n steps on a
string of length n.”
3. Which of the following are reasonable encoding schemes for nat-
ural numbers? Why or why not?
1. Decimal representation?
Fine.
2. Base 128 representation?
Fine - (easily obtained from binary representation, length is of same
order)

1
3. A string of n 1s to represent the number n?
Not concise - (longer by an exponential factor than the first two
possibilities)
4. A list of prime factors in binary notation, separated by com-
mas
Not easily obtained - (it is not known whether prime factors can be
found in polynomial time)
5. A Caesar cipher encoding of the decimal digits where A rep-
resents 1, B represents 2, etc (so 412 is encoded as “DAB”)
Fine - (choice of symbols is irrelevant)
6. Representing n by the nth string (in lexicographic ordering)
over the alphabet {0, 1}?
Fine - (easily obtained from, say, binary representation, with no sig-
nificant increase in length).
4. Suggest a suitable encoding scheme for (finite) TM computa-
tions.
Computation = sequence of configurations, so can use, say, comma sepa-
rated list of encodings for configurations.
Each configuration can be encoded by a list of symbols specifying:
– The state
– For each tape:
∗ The contents of the tape to the left of the head position (finite,
may be empty)
∗ The contents of the tape to the right of (and at) the head position
up to last non-blank symbol (finite, may be empty)
5. Explain how to design a deterministic Turing Machine that ac-
cepts the same language as a given non-deterministic Turing
Machine.
Explore the computation tree using breadth-first search, recording the con-
figuration at each node of the tree, and following each possible transition
from each node. Accept if an accept state is found, otherwise reject.
See Sipser Theorem 7.10
(Note that this may require O(k t ) steps to simulate t steps of the non-
deterministic machine, where k is the branching factor - maximum number
of choices)
6. Let U be a Universal Turing Machine which operates as de-
scribed in the lectures. Prove that if a Turing Machine T halts
after n steps on input x, then U will halt after at most kn2 steps
on input x, where k is a constant that depends on M , but not
on x.

2
All stages can be simulated in a constant number of steps, except that the
contents of T s tapes have to be all stored on a single tape. This means
the time to update the tape increases with the length of the tape, given a
quadratic bound overall.
(See Sipser Theorem 7.8 for single-tape simulation argument - note that
strictly speaking we must have n > |x|)

Vous aimerez peut-être aussi