Formal definition
A Turing Machine is a quintuple (K, ∑, δ, s, H),
where:
K - a finite set of states
∑ - an alphabet. ∑ contains the blank
symbol □ and the left end symbol ∆, but does
not contain ← and →.
s є K
- the initial state
H Í K - the set
of halting states
δ - the
transition function.
This is a function from (K - H) x ∑ to K x
(∑ È
{←,→}) such that
- for all q є
K - H, if δ(q , ∆) = (p, b)
then b = →
If the head is at the left
end of the tape,
the only possible action is
to move one position to the right.
- for all q є
K - H, and a є
∑, if δ(q , a) = (p, b)
then b ≠ ∆.
It is not allowed to write on the tape the
left end symbol.
Its position is fixed to be the leftmost
position of the tape.
The meaning of
δ(q , a) = (p, b):
If M (the machine) is in some state q, and the head
reads an a from the input tape,
then M enters state p and performs one of the following:
- if a is the left end symbol ∆,
then M moves its head one position to the right
(i.e. b = →)
- if b є ∑
then M writes b on the tape, however it is not
allowed to write ∆
- if b = → then M moves its head to the right,
preparing to read the next symbol from the tape
- if b = ← then M moves its
head one position to the left,
preparing to read
the next symbol from the tape
δ
is
not defined for the halting states. If M enters a halting state,
then the operation stops.
Example
The erasing machine:
Reads a symbol a from the tape, replaces the symbol with a
blank, and moves to the next symbol.
This is repeated until the next symbol to be read is a blank.
Then M stops.
The alphabet would be: ∑ = {a, □, ∆}
How many states?
- q0
- initial state, where M reads an a.
- q1 -
where M erases the a.
- h -
a halting state
Transition function:
|
state
q |
symbol
σ |
Transition δ(q , σ ) |
|
q0 |
a |
(q1, □) |
|
q0 |
□ |
(h, □) |
|
q0 |
∆ |
(q0, →) |
|
q1 |
a |
(q0, a) |
|
q1 |
□ |
(q0, →) |
|
q1 |
∆ |
(q1, →) |
Tracing the operation when M is in q0, and the input tape
is: ∆ a a □
(The underline shows the position of the head)
- The first thing to be done is to move the head one position
to the right.
Rule:
Result: ∆ a a □
- When in q0 and a on the tape, M enters q1 and
replaces a with a blank
Rule:
Result: ∆ □ a □
- When in q1 and blank on the tape, M enters q0 and
moves the head one position to the right
Rule:
Result: ∆ □ a □
- When in q0 and a on the tape, M enters q1 and
replaces a with a blank
Rule:
Result: ∆ □ □ □
- When in q1 and blank on the tape, M enters q0 and
moves the head one position to the right
Rule:
Result: ∆ □ □ □
- When in q0 and blank on the tape, M enters h
(the halting state)
-
Rule:
The operation stops.
Note that some of the transitions are never to be performed,
but they are specified because
the transition relation has to be a function,
otherwise the
transition will not be a function.
Configurations and computations
Formally, the operation of M is described in terms of its
configurations.
Configuration: determined by the current state,
the state of the tape, and the position of the head.
E.G. (q1, ∆ □ a ) is a configuration. (written informally)
Formal definition of a configuration:
Let M = (K, ∑, δ, s, H)
be a Turing machine.
A configuration of M is a member of
K x ∆∑* x (∑* (∑ - {□})
È {e})
When M is in a given configuration C1 and we
apply the transition function,
another configuration
C2 is obtained.
We say that C1 immediately yields
C2: C1 |- C2
Initial configuration: initial state, contents of the tape,
the head may be in any position
Halting configuration: halting state, any contents
of the tape, any position of the head
Computation: defined as a sequence of configurations,
each one immediately yielding the next,
except for the last
configuration
Problem
Consider a machine that scans to the left until it finds a blank,
and then stops
∑ = {a, □, ∆}
K = {q0, h}
H = {h}
s = q0
Transition function:
|
state
q |
symbol
σ |
Transition δ(q , σ ) |
|
q0 |
a |
(q0, ←) |
|
q0 |
□ |
(h, □) |
|
q0 |
∆ |
(q0, →) |
Trace the operation if M is in q0, and the
tape is ∆ a a □
Will the machine stop? (the answer is: no)