| Overall Reading | |
|---|---|
| Decker/Hirshfield: | pp. 269-277 |
| Brookshear: | (Optionally) Ch. 11.2 |
Outline:
In truth, if you prefer to think of strings of characters over a larger alphabet, that's okay too, so long as the alphabet is finite.
At each step, the following is done:
Let's walk through some examples:
| Present State | Present Symbol | Write | Move | New State |
|---|---|---|---|---|
| 1 | 0 | 0 | Right | 2 |
| 2 | 0 | 0 | Right | 3 |
| 2 | 1 | 1 | Right | 2 |
| 3 | 0 | blank | Left | 5 |
| 3 | 1 | 0 | Left | 4 |
| 4 | 0 | 1 | Right | 2 |
Shorthand way to describe the program:
(1,0,0,R,2)
(2,0,0,R,3)
(2,1,1,R,2)
(3,0,b,L,5)
(3,1,0,L,4)
(4,0,1,R,2)
Note: If a combination is ever reached for which no rule is given, the machine simply halts.
Let's execute the program on a sample input:
0 1 0 1 1 0 <-- current location is in bold 1 <-- this is the current state[continue the example]
If we can figure out the method to the madness, here's what the
program does:
It adds two numbers together, where the two numbers are originally
written in unary and delimited by zeros.
e.g. 010110 --> 01110 as 1 + 2 = 3 01110110 --> 0111110 as 3 + 2 = 5If we look back at the program, we see:
(1,0,0,R,2) -- move right, past the first 0 (2,0,0,R,3) -- we've come to the end of a string of 1s (2,1,1,R,2) -- move to right past all the 1s (3,0,b,L,5) -- we've moved past the last 1 -- done (3,1,0,L,4) -- just hit the second string of 1s; shift the 0 (4,0,1,R,2) -- finish shifting the 0, and go back to state 2Well...not very special, but it was our first example.