General Computer Science 320201 GenCS I & II Lecture ... - Kwarc
General Computer Science 320201 GenCS I & II Lecture ... - Kwarc
General Computer Science 320201 GenCS I & II Lecture ... - Kwarc
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
State Machine:<br />
1<br />
1,R 1 1,R 1 1,L 1 1,L<br />
1 0 0 0<br />
1 0,R 2 0,R 3 1,L 4 0,L<br />
5<br />
0<br />
1,R<br />
c○: Michael Kohlhase 329<br />
The computation of the turing machine is driven by the transition funciton: It starts in the initial<br />
state, reads the character on the tape, and determines the next action, the character to write, and<br />
the next state via the transition function.<br />
Example Computation<br />
T starts out in s1, replaces the first<br />
1 with a 0, then<br />
uses s2 to move to the right, skipping<br />
over 1’s and the first 0 encountered.<br />
s3 then skips over the next sequence<br />
of 1’s (initially there are none) and<br />
replaces the first 0 it finds with a 1.<br />
s4 moves back left, skipping over 1’s<br />
until it finds a 0 and switches to s5.<br />
Step State Tape Step State Tape<br />
1 s1 1 1 9 s2 10 0 1<br />
2 s2 0 1 10 s3 100 1<br />
3 s2 01 0 11 s3 1001 0<br />
4 s3 010 0 12 s4 100 1 1<br />
5 s4 01 0 1 13 s4 10 0 11<br />
6 s5 0 1 01 14 s5 1 0 011<br />
7 s5 0 101 15 s1 11 0 11<br />
8 s1 1 1 01 — halt —<br />
s5 then moves to the left, skipping over 1’s until it finds the 0 that was originally written by<br />
s1.<br />
It replaces that 0 with a 1, moves one position to the right and enters s1 again for another<br />
round of the loop.<br />
This continues until s1 finds a 0 (this is the 0 right in the middle between the two strings of<br />
1’s) at which time the machine halts<br />
c○: Michael Kohlhase 330<br />
We have seen that a Turing machine can perform computational tasks that we could do in other<br />
programming languages as well. The computation in the example above could equally be expressed<br />
in a while loop (while the input string is non-empty) in SW, and with some imagination we could<br />
even conceive of a way of automatically building action tables for arbitrary while loops using the<br />
ideas above.<br />
What can Turing Machines compute?<br />
Empirically: anything any other program can also compute<br />
Memory is not a problem (tape is infinite)<br />
Efficiency is not a problem (purely theoretical question)<br />
Data representation is not a problem (we can use binary, or whatever symbols we like)<br />
All attempts to characterize computation have turned out to be equivalent<br />
primitive recursive functions ([Gödel, Kleene])<br />
lambda calculus ([Church])<br />
186