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
10Input string
Blank symbol
......
......
head
Remark the input string is never empty
11States Transitions
Write
Read
Move Left
Move Right
12Example
Time 1
......
......
current state
13Time 1
......
......
Time 2
......
......
14Example
Time 1
......
......
Time 2
......
......
15Example
Time 1
......
......
Time 2
......
......
16Determinism
Turing Machines are deterministic
Not Allowed
Allowed
No lambda transitions allowed
17Partial Transition Function
Example
......
......
Allowed
No transition for input symbol
18Halting
The machine halts if there are no possible
transitions to follow
19Example
......
......
No possible transition
HALT!!!
20Final States
Allowed
Not Allowed
- Final states have no outgoing transitions
- In a final state the machine halts
21Acceptance
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
22Turing Machine Example
A Turing machine that accepts the language
23Time 0
24Time 1
25Time 2
26Time 3
27Time 4
Halt Accept
28Rejection Example
Time 0
29Time 1
No possible Transition
Halt Reject
30Infinite Loop Example
A Turing machine for language
31Time 0
32Time 1
33Time 2
34Time 2
Time 3
Infinite loop
Time 4
Time 5
35- Because of the infinite loop
- The final state cannot be reached
- The machine never halts
- The input is not accepted
36Another Turing Machine Example
Turing machine for the language
37Time 0
38Time 1
39Time 2
40Time 3
41Time 4
42Time 5
43Time 6
44Time 7
45Time 8
46Time 9
47Time 10
48Time 11
49Time 12
50Time 13
Halt Accept
51Observation
If we modify the machine for the language
we can easily construct a machine for the
language
52Formal Definitionsfor Turing Machines
53Transition Function
54Transition Function
55Turing Machine
Input alphabet
Tape alphabet
States
Transition function
Final states
Initial state
blank
56Configuration
Instantaneous description
57Time 4
Time 5
A Move
58Time 4
Time 5
Time 6
Time 7
59Equivalent notation
60Initial configuration
Input string
61The Accepted Language
For any Turing Machine
Initial state
Final state
62Standard Turing Machine
The machine we described is the standard
- Deterministic
- Infinite tape in both directions
- Tape is the input/output file
63Computing FunctionswithTuring Machines
64A function
has
Result Region
Domain
65A function may have many parameters
Example
Addition function
66Integer Domain
Decimal
5
Binary
101
Unary
11111
67Definition
A function is computable if there is
a Turing Machine such that
Initial configuration
Final configuration
final state
initial state
For all
Domain
68In other words
A function is computable if there is
a Turing Machine such that
Initial Configuration
Final Configuration
For all
Domain
69Example
is computable
The function
are integers
Turing Machine
Input string
unary
Output string
unary
70Start
initial state
The 0 is the delimiter that separates the two
numbers
71Start
initial state
Finish
final state
72The 0 helps when we use the result for other
operations
Finish
final state
73Turing machine for function
74Execution Example
Time 0
(2)
(2)
Final Result
75Time 0
76Time 1
77Time 2
78Time 3
79Time 4
80Time 5
81Time 6
82Time 7
83Time 8
84Time 9
85Time 10
86Time 11
87Time 12
HALT accept
88Another Example
is computable
The function
is integer
Turing Machine
Input string
unary
Output string
unary
89Start
initial state
Finish
final state
90Turing Machine Pseudocode for
- Find rightmost , replace it with 1
- Go to right end, insert 1
Until no more remain
91Turing Machine for
92Example
Start
Finish
93Another Example
if
The function
if
is computable
94Turing Machine for
if
if
Input
or
Output
95Turing Machine Pseudocode
Match a 1 from with a 1 from
Until all of or is matched
- If a 1 from is not matched
- erase tape, write 1
- else
- erase tape, write 0
96Combining Turing Machines
97Block Diagram
Turing Machine
input
output
98Example
if
if
Adder
Comparer
Eraser