Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages...
-
Upload
polly-watkins -
Category
Documents
-
view
216 -
download
2
Transcript of Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages...
Prof. Busch - LSU 1
Turing Machines
Prof. Busch - LSU 2
The Language Hierarchy
*aRegular Languages
Context-Free Languagesnnba Rww
nnn cba ww?
**ba
?
Prof. Busch - LSU 3
*aRegular Languages
Context-Free Languagesnnba Rww
nnn cba ww
**ba
Languages accepted byTuring Machines
Prof. Busch - LSU 4
A Turing Machine
............Tape
Read-Write head
Control Unit
Prof. Busch - LSU 5
The Tape
............
Read-Write head
No boundaries -- infinite length
The head moves Left or Right
Prof. Busch - LSU 6
............
Read-Write head
The head at each transition (time step):
1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right
Prof. Busch - LSU 7
............
Example:Time 0
............Time 1
1. Reads
2. Writes
a a cb
a b k c
a
k3. Moves Left
Prof. Busch - LSU 8
............Time 1
a b k c
............Time 2
a k cf
1. Reads
2. Writes
bf
3. Moves Right
Prof. Busch - LSU 9
The Input String
............
Blank symbol
head
a b ca
Head starts at the leftmost positionof the input string
Input string
Prof. Busch - LSU 10
States & Transitions
1q 2qLba ,
Read Write Move Left
1q 2qRba ,
Move Right
Prof. Busch - LSU 11
Example:
1q 2qRba ,
............ a b ca
Time 1
1qcurrent state
Prof. Busch - LSU 12
............ a b caTime 1
1q 2qRba ,
............ a b cbTime 2
1q
2q
Prof. Busch - LSU 13
............ a b caTime 1
1q 2qLba ,
............ a b cbTime 2
1q
2q
Example:
Prof. Busch - LSU 14
............ a b caTime 1
1q 2qRg,
............ ga b cbTime 2
1q
2q
Example:
Prof. Busch - LSU 15
Determinism
1q
2qRba ,
Allowed Not Allowed
3qLdb ,
1q
2qRba ,
3qLda ,
No lambda transitions allowed
Turing Machines are deterministic
Prof. Busch - LSU 16
Partial Transition Function
1q
2qRba ,
3qLdb ,
............ a b ca
1q
Example:
No transitionfor input symbol c
Allowed:
Prof. Busch - LSU 17
Halting
The machine halts in a state if there isno transition to follow
Prof. Busch - LSU 18
Halting Example 1:
............ a b ca
1q
1q No transition from
HALT!!!
1q
Prof. Busch - LSU 19
Halting Example 2:
............ a b ca
1q
1q
2qRba ,
3qLdb ,
No possible transitionfrom and symbol
HALT!!!
1q c
Prof. Busch - LSU 20
Accepting States
1q 2q Allowed
1q 2q Not Allowed
•Accepting states have no outgoing transitions•The machine halts and accepts
Prof. Busch - LSU 21
Acceptance
Accept Input If machine halts in an accept state
Reject Input
If machine halts in a non-accept state or If machine enters an infinite loop
string
string
Prof. Busch - LSU 22
Observation:
In order to accept an input string,it is not necessary to scan all thesymbols in the string
Prof. Busch - LSU 23
Turing Machine Example
Accepts the language: *a
0q
Raa ,
L,1q
Input alphabet },{ ba
Prof. Busch - LSU 24
aaTime 0
0q
a
0q
Raa ,
L,1q
Prof. Busch - LSU 25
aaTime 1
0q
a
0q
Raa ,
L,1q
Prof. Busch - LSU 26
aaTime 2
0q
a
0q
Raa ,
L,1q
Prof. Busch - LSU 27
aaTime 3
0q
a
0q
Raa ,
L,1q
Prof. Busch - LSU 28
aaTime 4
1q
a
0q
Raa ,
L,1q
Halt & Accept
Prof. Busch - LSU 29
Rejection Example
0q
Raa ,
L,1q
baTime 0
0q
a
Prof. Busch - LSU 30
0q
Raa ,
L,1q
baTime 1
0q
a
No possible Transition
Halt & Reject
Prof. Busch - LSU 31
Accepts the language: *a
0q
but for input alphabet }{aA simpler machine for same language
Prof. Busch - LSU 32
aaTime 0
0q
a
0q
Halt & Accept
Not necessary to scan input
Prof. Busch - LSU 33
Infinite Loop Example
0q
Raa ,
L,1q
Lbb ,
A Turing machine for language *)(* baba
Prof. Busch - LSU 34
baTime 0
0q
a
0q
Raa ,
L,1q
Lbb ,
Prof. Busch - LSU 35
baTime 1
0q
a
0q
Raa ,
L,1q
Lbb ,
Prof. Busch - LSU 36
baTime 2
0q
a
0q
Raa ,
L,1q
Lbb ,
Prof. Busch - LSU 37
baTime 2
0q
a
baTime 3
0q
a
baTime 4
0q
a
baTime 5
0q
a
Infinite
loop
Prof. Busch - LSU 38
Because of the infinite loop:
•The accepting state cannot be reached
•The machine never halts
•The input string is rejected
Prof. Busch - LSU 39
Another Turing Machine Example
Turing machine for the language }{ nnba
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
1n
Prof. Busch - LSU 40
Match a’s with b’s:Repeat: replace leftmost a with x find leftmost b and replace it with yUntil there are no more a’s or b’s
If there is a remaining a or b reject
Basic Idea:
Prof. Busch - LSU 41
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
ba
0q
a bTime 0
Prof. Busch - LSU 42
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
bx
1q
a b Time 1
Prof. Busch - LSU 43
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
bx
1q
a b Time 2
Prof. Busch - LSU 44
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
2q
a b Time 3
Prof. Busch - LSU 45
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
2q
a b Time 4
Prof. Busch - LSU 46
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
0q
a b Time 5
Prof. Busch - LSU 47
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
1q
x b Time 6
Prof. Busch - LSU 48
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
1q
x b Time 7
Prof. Busch - LSU 49
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx x y
2q
Time 8
Prof. Busch - LSU 50
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx x y
2q
Time 9
Prof. Busch - LSU 51
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
0q
x y Time 10
Prof. Busch - LSU 52
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
3q
x y Time 11
Prof. Busch - LSU 53
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
3q
x y Time 12
Prof. Busch - LSU 54
0q 1q 2q3qRxa ,
Raa ,Ryy ,
Lyb ,
Laa ,Lyy ,
Rxx ,
Ryy ,
Ryy ,4q
L,
yx
4q
x y
Halt & Accept
Time 13
Prof. Busch - LSU 55
If we modify the machine for the language }{ nnba
we can easily construct a machine for the language }{ nnn cba
Observation:
Prof. Busch - LSU 56
Formal Definitionsfor
Turing Machines
Prof. Busch - LSU 57
Transition Function
1q 2qRba ,
),,(),( 21 Rbqaq
Prof. Busch - LSU 58
1q 2qLdc ,
),,(),( 21 Ldqcq
Transition Function
Prof. Busch - LSU 59
Turing Machine:
),,,,,,( 0 FqQM
States
Inputalphabet
Tapealphabet
Transitionfunction
Initialstate
blank
Acceptstates
Prof. Busch - LSU 60
Configuration
ba
1q
a
Instantaneous description:
c
baqca 1
Prof. Busch - LSU 61
yx
2q
a b
Time 4
yx
0q
a b
Time 5
A Move: aybqxxaybq 02
(yields in one mode)
Prof. Busch - LSU 62
yx
2q
a b
Time 4
yx
0q
a b
Time 5
bqxxyybqxxaybqxxaybq 1102
yx
1q
x b
Time 6
yx
1q
x b
Time 7
A computation
Prof. Busch - LSU 63
bqxxyybqxxaybqxxaybq 1102
bqxxyxaybq 12
Equivalent notation:
Prof. Busch - LSU 64
Initial configuration: wq0
ba
0q
a b
w
Input string
Prof. Busch - LSU 65
The Accepted Language
For any Turing Machine M
}:{)( 210 xqxwqwML f
Initial state Accept state
Prof. Busch - LSU 66
If a language is accepted by a Turing machinethen we say that is:
•Turing Acceptable•Recursively Enumerable
ML
L
•Turing Recognizable
Other names used: