Chapter 8 Introduction To Turing Machines
Chapter 8 Introduction To Turing Machines
Chapter 8 Introduction To Turing Machines
Rothenberg, Germany
1
Outline
Problems that Computers Cannot Solve The Turing Machine (TM) Programming Techniques for TMs Extensions to the Basic TM Restricted TMs TMs and Computers
8.0 Introduction
Concepts to be taught ---
Studying questions about what languages can be defined be any computational device?? There are specific problems that cannot be solved by computers! --- undecidable! Studying the Turing machine which seems simple, but can be recognized as an accurate model for what any physical computing device is capable of doing.
3
to provide an informal proof , C-programmingbased introduction to proof of a specific problem that computers cannot solve.
The problem:
whether the first thing a C program prints is hello, world. We will give the intuition behind the formal proof.
4
}
Define hello, world problem to be: determine whether a given C program, with a given input, prints hello, world as the first 12 characters that it prints.
Is there a program H that could examine any program P and input I for P, and tell whether P, run with I as its input, would print hello, world? (A program H means an
algorithm in concept here.)
The answer is: undecidable! That is, there exists no such program H. We will prove this by contradiction.
Hello-world yes if P, with input I, prints hello world 2nd step: transform H to another form H2 in simple ways which can be done by C tester programs no if not. H P rd Figure 8.3 3 step: prove H2 not existing. So H also not existing.
8.1 Problems That Computers Cannot Solve 8.1.2 Hypothetical Hello, World Tester
2nd step:
(1) transform H to H1 in the following way -
H1
Hello-world P tester H2
yes
Figure 8.5 hello, world
8
8.1 Problems That Computers Cannot Solve 8.1.2 Hypothetical Hello, World Tester
2nd step (contd): Hello-world
The function of H2 is: P
yes
tester
Figure 8.5
given any programHP as input, hello, world 2 if P prints hello world as first output, then H2 makes output yes; if P does not prints hello world as first output, then H2 prints hello world.
10
Now, yes Hello-world (1) if the box H2, given itself as input, makes output yes, then it means that
Figure 8.6 tester the input H2, given itself as input, prints hello world as first output. world But this is contradictory because we H just suppose that H2, given hello, itself as input, makes output yes. H2
2
11
The above contradiction means the other alternative must be true (since itFigure must be 8.6 one or the other), H that is --2 tester (2) the box H2, given itself as input, prints hello, world. This then world means that Hello, H2 such H2, when taken as input H2 to the box H2(itself), will make the box H2 to make output yes. Contradiction again because we just say that the box H2, given itself as input, prints hello, world.
Hello-world
yes
12
Since both cases lead to contradiction, we conclude that the assumption that H2 exists is wrong by
Hello-world
yes
Figure 8.6
Hello, world
13
The above self-contradiction technique, similar to the diagonalization technique (to be introduced later), was used by Alan Turing for proving undecidable problems.
14
If P2 is decidable, then P1 is decidable. But P1 is known undecidable. So, contradiction! Consequently, P2 is undecidable.
15
Construct
Decide
yes
16
17
If Q has a function called foo, rename it and all calls to that function a new program Q1 doing the same
Q3
Modify Q3 so that whenever it executes any output statement, it checks A to see if it has written 12 characters or more, and if so, whether hello, world are the first characters. In that case, call the new function foo
R with input z = y.
18
19
P1 instance
yes
if and only if
Old problem New problem no
20
21
22
whether
it was possible to find an algorithm for determining the truth or falsehood of any mathematical proposition. (in particular, he asked if there was a way to decide whether any formula in the 1st-order predicate calculus, applied to integer, was true)
23
A certain formula in the predicate calculus applied to integers could not be neither proved nor disproved within the predicate calculus.
The proof technique is diagonalization, resembling the self-contradiction technique used previously.
24
Natures of computational model -- Predicate calculus --- declarative Partial-recursive functions --- computational (a programming-language-like notion) Turing machine --- computational (computer-like) (invented by Alan Turing several years before true computers were invented)
25
26
27
Finite control
B B X1 X2
Xi
Xn B B
28
change state; write a tape symbol in the cell scanned; move the tape head left or right.
Formal definition:
A Turing machine (TM) is a 7-tuple M = (Q, S, G, d, q0, B, F) where Q: a finite set of states of the finite control; S: a finite set of input symbols; G: a set of tape symbols, with S being a subset of it;
29
31
32
If d(q, Xi) = (p, Y, L) (a leftward move), then _we write _ | |M the following to describe the left move:
X1X2Xi1qXiXi+1Xn X1X2Xi2pXi1YXi+1Xn Right moves are defined similarly.
|_ M
33
Change 1 to Y.
Move left over Ys and 0s until an X. Look for a 0 immediately to the right. If a 0 is found, change it to X and repeat the above process.
34
35
36
Y
(q3, Y, R)8 (q1, Y, R)3 (q2, Y, L)6 (q3, Y, R)9
(q2, Y, L)4
(q0, X, R)7
q4
(q4, B, R)10
37
_ | (use instead of )
q00011 Xq1011 X0q111 Xq20Y1 q2X0Y1 Xq00Y1 XXq1Y1 XXYq11 XXq2YY Xq2XYY XXq0YY XXYq3Y XXYYq3B XXYYBq4B
38
39
The set of languages accepted by aM TM is often called the recursively enumerable language or RE language.
L(M) = {w | wS* and q0w apb with pF} (w _ final state accept!!!)
|*
The term RE came from computational formalism that predates the TM.
40
42
So TMs that always halt can be used for studies of decidability (see Chapter 9).
43
44
=0
if m < n.
_
45
46
47
state
q0
0 (q1, B, R)
1 (q5, B, R)
B -
q1
q2 q3 q4 q5 q6
(q1, 0, R)
(q3, 1, L) (q3, 0, L) (q4, 0, L) (q5, B, R) -
(q2, 1, R)
(q2, 1, R) (q3, 1, L) (q4, B, L) (q5, B, R) -
49
50
The above extensions make no increase of the original TMs power, but make TMs easier to use:
Multitape TM --- useful for simulating real computers Nondeterministic TM --- making TM programming easier.
51
Finite control
Tape 1 Tape 2 Tape 3
53
54
55
56
57
The above restrictions make no decrease of the original TMs power, but are useful for theorem proving. Undecidability of the TM also applies to these restricted TMs.
58
M1s head never moves left of its initial position (so the tape is semi-infinite essential); M1 never writes a blank. (i.e., M1 and M2 are equivalent) Proof. See the textbook.
59
60
A counter holds any nonnegative integer. The machine can only distinguish zero and nonzero counters. A move conducts the following operations: changing the state; add or subtract 1 from a counter which cannot becomes negative.
61
For an example of a counter machine of the 2nd type, do the exercise (part a) of this chapter.
62
63
64
That means:
the real computer we use every day is nearly an implementation of the maximal computational model under the assumptions that the memory space (including registers, RAM, hard disks, ) is infinite in size. the address space is infinite (not only that defined by 32 bits used in most computers today).