0% found this document useful (0 votes)
109 views14 pages

Chapter 9: Turing Machines

The document summarizes key concepts about Turing machines through examples and definitions: 1) Turing machines are formal models of computation that have an unbounded tape for storage and a finite set of internal states. They are defined by their state set, tape alphabet, transition function, initial state, and accepting states. 2) A computation of a Turing machine is a sequence of configurations representing its internal state, tape contents, and head position over time. It halts if it reaches a configuration with no defined transition. 3) A language is accepted by a Turing machine if the machine has an accepting computation on inputs in the language. Non-accepting computations are ones that halt in a non

Uploaded by

SISAY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views14 pages

Chapter 9: Turing Machines

The document summarizes key concepts about Turing machines through examples and definitions: 1) Turing machines are formal models of computation that have an unbounded tape for storage and a finite set of internal states. They are defined by their state set, tape alphabet, transition function, initial state, and accepting states. 2) A computation of a Turing machine is a sequence of configurations representing its internal state, tape contents, and head position over time. It halts if it reaches a configuration with no defined transition. 3) A language is accepted by a Turing machine if the machine has an accepting computation on inputs in the language. Non-accepting computations are ones that halt in a non

Uploaded by

SISAY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 9: Turing Machines∗

Peter Cappello
Department of Computer Science
University of California, Santa Barbara
Santa Barbara, CA 93106
[email protected]

• Please read the corresponding chapter before attending this lecture.

• These notes are supplemented with figures, and material that arises during the lecture in
response to questions.

• Please report any errors in these notes to [email protected]. I’ll fix them immediately.

Based on An Introduction to Formal Languages and Automata, 3rd Ed., Peter Linz, Jones and Bartlett
Publishers, Inc.

1
Turing machines are the outcome of a quest to understand the limits
of computation.

9.1 The Standard Turing Machine

• The principal difference between a Turing machine (TM) and less


capable machine models, such as pushdown automata, is the TM’s
storage.
• A TM has a tape for storage.
• Like the stack of a PDA, the tape is not bounded.

2
Definition of a Turing Machine

Def. 9.1: A Turing machine M is defined by


M = (Q, Σ, Γ, δ, q0, 2, F ), where
Q is the set of internal states,
Γ is a finite tape alphabet,
2 ∈ Γ is a special symbol, called blank,
Σ ⊆ Γ − {2} is the input alphabet,
δ : Q × Γ 7→ Q × Γ × {L, R} is the transition function,
q0 ∈ Q is the initial state,
F ⊆ Q is the set of final states.

• δ is a partial function.

3
• When the machine enters a state with no defined transition, it halts.
• We assume that there is no transition from any final state.
Example: Consider the TM defined by
Q = {q0 , q1},
Σ = {a, b}
Γ = {a, b, 2}
F = {q1 }
and
δ(q0, a) = (q0 , b, R),
δ(q0, b) = (q0 , b, R),
δ(q0, 2) = (q1 , 2, L).
What does it do on input babba?

4
Example 9.3: Consider a TM, whose:
• Q, Σ, and Γ are as defined in the previous example
•F =Ø
• δ is given by

δ(q0, a) = (q1 , a, R),


δ(q0, b) = (q1 , b, R),
δ(q0, 2) = (q1 , 2, R)
δ(q1, a) = (q0 , a, L),
δ(q1, b) = (q0 , b, L),
δ(q1, 2) = (q0 , 2, L)

What does it do on input babba?

5
Def.: A standard Turing Machine has the following features:
• Its tape is unbounded in both directions.
• It is deterministic: δ defines at most 1 transition for each state.
• There is no input file: its input is on its tape when it starts.
A computation’s state is given by an instantaneous description (ID):
• Tape contents between the leftmost & rightmost non-blank symbols.
• Its internal state.
• The position of the read/write head.
This is displayed as
a1a2 · · · ak−1 q ak ak+1 · · · an, where
q is to the left of the read/write head:
The TM is in internal state q, reading ak .

6
• A sequence of IDs, I1, I2, . . . , In is depicted
I1 ` I2 ` . . . ` In or
I 1 `∗ I 2 I n .
• Illustrate this, using the infinite loop example.
• This notation is summarized by the following definition.
Def. 9.2
• Let M = (Q, Σ, Γ, δ, q0, 2, F ) be a TM.
• Let a1 · · · ak−1 q ak ak+1 · · · an, with ai ∈ Γ, q ∈ Q be an ID of M .

a1 · · · ak−1 q ak ak+1 · · · an ` a1 · · · ak−1 b p ak+1 · · · an


is possible if and only if δ(q, ak ) = (p, b, R).
a1 · · · ak−1 q ak ak+1 · · · an ` a1 · · · p ak−1 bak+1 · · · an
is possible if and only if δ(q, ak ) = (p, b, L).

7
• M halts, when starting from initial configuration x1 q x2,
x1 q x2 `∗ y1 p ay2,
where δ(p, a) is undefined.
• The sequence of configurations from the initial configuration to the
halting configuration is called a computation.
• Example shows that a TM may never halt.
• This is depicted by
x1 q x2 `∗ ∞, where
x1 q x2 is the initial state.

8
Turing Machines as Language Acceptors

Def. 9.3: Let M = (Q, Σ, Γ, δ, q0, 2, F ) be a TM. The language ac-


cepted by M is
L(M ) = {w ∈ Σ+ : q0w `∗ x1 qf x2, for qf ∈ F, and x1, x2 ∈ Γ∗}.
• To ensure that M can detect the end-of-input, w cannot contain the
2 symbol.
•w∈
/ L(M ) when M either:
– halts in a non-final state, or
– never halts.

9
Example: For Σ = {0, 1}, construct a TM that accepts L((0 + 1)∗0).
• When reading an a, provisionally accept and move right;
• When reading a b, provisional reject and move right;
• When reading a 2, accept, if in the provisionally accept state, else
reject.
(diagram)
• M = ({a, r, A, R}, {0, 1}, {0, 1, 2}, δ, r, 2, {A}), where δ is given by
δ(r, 0) = (a, 0, R),
δ(r, 1) = (r, 1, R),
δ(a, 0) = (a, 0, R),
δ(a, 1) = (r, 1, R),
δ(a, 2) = (A, 2, R),
δ(r, 2) = (R, 2, R).

10
Example 9.7: For Σ = {a, b}, make a TM accepting L(anbn : n > 0).
• Starting at leftmost a, replace it with x;
• Go right over a and y symbols until, reading a b;
• replace b with y;
• Go left until x is encountered;
• Go right; // we are now in initial state
• if encounter a y, scan right while encountering y symbols
• if encounter a 2, accept.
• M = ({q0 , q1, q2, q3, q4 }, {a, b}, {a, b, 2}, δ, q0 , 2, {q4 }), where δ is

11
// replace the leftmost a with x and go right until a b is read
δ(q0, a) = (q1, x, R),
δ(q1, a) = (q1, a, R),
δ(q1, y) = (q1, y, R),
δ(q1, b) = (q2, y, L).
// go left until an x is read; go right 1 space
δ(q2, y) = (q2 , y, L),
δ(q2, a) = (q2 , a, L),
δ(q2, x) = (q0 , x, R).
// termination sequence
δ(q0, y) = (q3, y, R),
δ(q3, y) = (q3, y, R),
δ(q3, 2) = (q4, 2, R).

12
• After 1 pass, the TM has accomplished
q0 aa · · · abb · · · b `∗ x q0 a · · · ayb · · · b.
After 2 passes, the TM has accomplished
q0 aa · · · abb · · · b `∗ xx q0 a · · · ayyb · · · b.

• For aabb, the TM goes through the following configuration sequence:


q0 aabb ` x q1 abb ` xa q1 bb ` x q2ayb
` q2xayb ` x q0 ayb ` xx q1 yb
` xxy q1 b ` xx q2 yy ` x q2 xyy
` xx q0 yy ` xxy q3 y ` xxyy q32
` xxyy2 q42.

• Try some examples of strings not in the language.

13
Example 9.8: For Σ = {a, b}, make a TM accepting L(anbncn : n > 0).
One can extend the strategy used in the previous example to ensure
that both b and c symbols match in number to a symbols.

14

You might also like