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 transition (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 lambda transitions allowed
16Partial Transition Function
Example
......
......
Allowed
No transition for input symbol
17Halting
The machine halts in a state if there is no
transition to follow
18Halting Example 1
......
......
No transition from
HALT!!!
19Halting Example 2
......
......
No possible transition from and symbol
HALT!!!
20Accepting States
Allowed
Not Allowed
- Accepting states have no outgoing transitions
- The machine halts and accepts
21Acceptance
If machine halts in an accept state
Accept Input
string
If machine halts in a non-accept state
or If machine enters an infinite loop
Reject Input
string
22Observation
In order to accept an input string, it is not
necessary to scan all the symbols in the string
23Turing Machine Example
Input alphabet
Accepts the language
24Time 0
25Time 1
26Time 2
27Time 3
28Time 4
Halt Accept
29Rejection Example
Time 0
30Time 1
No possible Transition
Halt Reject
31A simpler machine for same language
but for input alphabet
Accepts the language
32Time 0
Halt Accept
Not necessary to scan input
33Infinite Loop Example
A Turing machine for language
34Time 0
35Time 1
36Time 2
37Time 2
Time 3
Infinite loop
Time 4
Time 5
38- Because of the infinite loop
- The accepting state cannot be reached
- The machine never halts
- The input string is rejected
39Another Turing Machine Example
Turing machine for the language
40Basic Idea
Match as with bs Repeat replace
leftmost a with x find leftmost b and
replace it with y Until there are no more as or
bs If there is a remaining a or b reject
41Time 0
42Time 1
43Time 2
44Time 3
45Time 4
46Time 5
47Time 6
48Time 7
49Time 8
50Time 9
51Time 10
52Time 11
53Time 12
54Time 13
Halt Accept
55Observation
If we modify the machine for the language
we can easily construct a machine for the
language
56Formal Definitionsfor Turing Machines
57Transition Function
58Transition Function
59Turing Machine
Input alphabet
Tape alphabet
States
Transition function
Accept states
Initial state
blank
60Configuration
Instantaneous description
61Time 4
Time 5
A Move
(yields in one mode)
62Time 4
Time 5
Time 6
Time 7
A computation
63Equivalent notation
64Initial configuration
Input string
65The Accepted Language
For any Turing Machine
Initial state
Accept state
66If a language is accepted by a Turing
machine then we say that is
Other names used
- Turing Acceptable
- Recursively Enumerable
67Computing FunctionswithTuring Machines
68A function
has
Result Region
Domain
69A function may have many parameters
Example
Addition function
70Integer Domain
Decimal
5
Binary
101
Unary
11111
71Definition
A function is computable if there is
a Turing Machine such that
Initial configuration
Final configuration
accept state
initial state
For all
Domain
72In other words
A function is computable if there is
a Turing Machine such that
Initial Configuration
Final Configuration
For all
Domain
73Example
is computable
The function
are integers
Turing Machine
Input string
unary
Output string
unary
74Start
initial state
The 0 is the delimiter that separates the two
numbers
75Start
initial state
Finish
final state
76The 0 here helps when we use the result for other
operations
Finish
final state
77Turing machine for function
78Execution Example
Time 0
(2)
(2)
Final Result
79Time 0
80Time 1
81Time 2
82Time 3
83Time 4
84Time 5
85Time 6
86Time 7
87Time 8
88Time 9
89Time 10
90Time 11
91Time 12
HALT accept
92Another Example
is computable
The function
is integer
Turing Machine
Input string
unary
Output string
unary
93Start
initial state
Finish
accept state
94Turing Machine Pseudocode for
- Find rightmost , replace it with 1
- Go to right end, insert 1
Until no more remain
95Turing Machine for
96Example
Start
Finish
97Another Example
if
The function
if
is computable
Input
or
Output
98Turing 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
99Combining Turing Machines
100Block Diagram
Turing Machine
input
output
101Example
if
if
Adder
Comparator
Eraser