Title: Turing Machines
1Turing Machines
2The Language Hierarchy
?
?
Context-Free Languages
Regular Languages
3Languages accepted by Turing Machines
Context-Free Languages
Regular Languages
4A Turing Machine
Tape
......
......
Read-Write head
Control Unit
5The Tape
No boundaries -- infinite length
......
......
Read-Write head
The head moves Left or Right
6......
......
Read-Write head
The head at each time step 1.
Reads a symbol 2. Writes a
symbol 3. Moves Left or Right
7Example
Time 0
......
......
Time 1
......
......
1. Reads
2. Writes
3. Moves Left
8Time 1
......
......
Time 2
......
......
1. Reads
2. Writes
3. Moves Right
9The Input String
Input string
Blank symbol
......
......
head
Head starts at the leftmost position of the input
string
10States Transitions
Write
Read
Move Left
Move Right
11Example
Time 1
......
......
current state
12Time 1
......
......
Time 2
......
......
13Example
Time 1
......
......
Time 2
......
......
14Example
Time 1
......
......
Time 2
......
......
15Determinism
Turing Machines are deterministic
Not Allowed
Allowed
No epsilon transitions allowed
16Partial Transition Function
Example
......
......
Allowed
No transition for input symbol
17Halting
The machine halts if there are no possible
transitions to follow
18Example
......
......
No possible transition
HALT!!!
19Final States
Allowed
Not Allowed
- Final states have no outgoing transitions
- In a final state the machine halts
20Acceptance
If machine halts in a final state
Accept Input
If machine halts in a non-final state
or If machine enters an infinite loop
Reject Input
21Turing Machine Example
A Turing machine that accepts language a
22Time 0
23Time 1
24Time 2
25Time 3
26Time 4
Halt Accept
27Rejection Example
Time 0
28Time 1
No possible Transition
Halt Reject
29Infinite Loop Example
Another Turing machine for language aand is
this one correct???
30Time 0
31Time 1
32Time 2
33Time 2
Time 3
Time 4
Time 5
... Infinite Loop
34- Because of the infinite loop
- The final state cannot be reached
- The machine never halts
- The input is not accepted
35Another Turing Machine Example
Turing machine for the language
36Time 0
37Time 1
38Time 2
39Time 3
40Time 4
41Time 5
42Time 6
43Time 7
44Time 8
45Time 9
46Time 10
47Time 11
48Time 12
49Time 13
Halt Accept
50Observation
If we modify the machine for the language
we can easily construct a machine for the
language
51Formal Definitionsfor Turing Machines
52Transition Function
53Transition Function
54Turing Machine
Input alphabet
Tape alphabet
States
Transition function
Final states
Initial state
blank
55Configuration
Instantaneous description
56Time 4
Time 5
ayb
q
x
xayb
q
A Move
?
0
2
57Time 4
Time 5
Time 6
Time 7
b
q
xxy
yb
q
xx
ayb
q
x
xayb
q
?
?
?
1
1
0
2
58b
q
xxy
yb
q
xx
ayb
q
x
xayb
q
?
?
?
1
1
0
2
b
q
xxy
xayb
q
Equivalent notation
?
1
2
59Initial configuration
Input string
60The Accepted Language
For any Turing Machine
)
(
x
q
x
w
q
w
M
L
?
2
1
0
f
Initial state
Final state
61Standard Turing Machine
The machine we described is the standard
- Deterministic
- Infinite tape in both directions
- Tape is the input/output file
62Implementation-level descriptions
ww contains an equal number of 0s and 1s
63Implementation-level descriptions
ww contains an equal number of 0s and 1s
On input string w
64Implementation-level descriptions
ww contains an equal number of 0s and 1s
- On input string w
- Scan the tape mark the 1st 0 which is unmarked.
If none is found, go to 4. Otherwise, move the
head back to the front of the tape.
65Implementation-level descriptions
ww contains an equal number of 0s and 1s
- On input string w
- Scan the tape mark the 1st 0 which is unmarked.
If none is found, go to 4. Otherwise, move the
head back to the front of the tape. - Scan the tape mark the 1st 1 which is unmarked.
If none is found, reject.
66Implementation-level descriptions
ww contains an equal number of 0s and 1s
- On input string w
- Scan the tape mark the 1st 0 which is unmarked.
If none is found, go to 4. Otherwise, move the
head back to the front of the tape. - Scan the tape mark the 1st 1 which is unmarked.
If none is found, reject. - Move the head back to the front of the tape go
to 1.
67Implementation-level descriptions
ww contains an equal number of 0s and 1s
- On input string w
- Scan the tape mark the 1st 0 which is unmarked.
If none is found, go to 4. Otherwise, move the
head back to the front of the tape. - Scan the tape mark the 1st 1 which is unmarked.
If none is found, reject. - Move the head back to the front of the tape go
to 1. - Move the head back to the front of the tape.
Scan the tape to see if any unmarked 1s remain.
If none are found, accept otherwise, reject.
68Try this one
ww contains twice as many 0s as 1s
- On input string w
- Scan the tape ...
- (Hint, you can mark and double mark.)
69Try this one
ww anbn, n ? 0
- On input string w
- Scan the tape ...