Date post: | 11-Apr-2017 |
Category: |
Engineering |
Upload: | shiraz316 |
View: | 66 times |
Download: | 0 times |
Costas Busch - LSU 1
Deterministic Finite Automata
And Regular Languages
Costas Busch - LSU 2
Deterministic Finite Automaton (DFA)
Input Tape
“Accept” or“Reject”
String
FiniteAutomaton
Output
Costas Busch - LSU 3
Transition Graph
initialstate
accepting state
statetransition
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
Costas Busch - LSU 4
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
},{ ba
For every state, there is a transitionfor every symbol in the alphabet
Alphabet
Costas Busch - LSU 5
Initial Configuration
1q 2q 3q 4qa b b a
5q
a a bb
ba,Input Stringa b b a
ba,0q
Initial state
Input Tapehead
Costas Busch - LSU 6
Scanning the Input
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
Costas Busch - LSU 7
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
Costas Busch - LSU 8
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
Costas Busch - LSU 9
0q 1q 2q 3q 4qa b b a accept
5q
a a bb
ba,
a b b a
ba,
Input finished
Last state determines the outcome
Costas Busch - LSU 10
1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,0q
A Rejection Case
Input String
Costas Busch - LSU 11
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,
Costas Busch - LSU 12
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,
Costas Busch - LSU 13
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
reject
a b a
ba,
Input finished
Last state determines the outcome
Costas Busch - LSU 14
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,0q
)(
Another Rejection CaseTape is empty
reject
Input Finished (no symbol read)
Costas Busch - LSU 15
Language Accepted: abbaL
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
This automaton accepts only one string
Costas Busch - LSU 16
To accept a string:all the input string is scanned and the last state is accepting
To reject a string:all the input string is scanned and the last state is non-accepting
Costas Busch - LSU 17
Another Example
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
abbaabL ,,
Acceptstate
Acceptstate
Acceptstate
Costas Busch - LSU 18
)(Empty Tape
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
accept
Input Finished
Costas Busch - LSU 19
Another Example
a
b ba,
ba,
0q 1q 2q
Accept state
trap state
Costas Busch - LSU 20
a
b ba,
ba,
0q 1q 2q
a ba
Input String
Costas Busch - LSU 21
a
b ba,
ba,
0q 1q 2q
a ba
Costas Busch - LSU 22
a
b ba,
ba,
0q 1q 2q
a ba
Costas Busch - LSU 23
a
b ba,
ba,
0q 1q 2q
a ba
accept
Input finished
Costas Busch - LSU 24
a
b ba,
ba,
0q 1q 2q
ab b
A rejection case
Input String
Costas Busch - LSU 25
a
b ba,
ba,
0q 1q 2q
ab b
Costas Busch - LSU 26
a
b ba,
ba,
0q 1q 2q
ab b
Costas Busch - LSU 27
a
b ba,
ba,
0q 1q 2q
ab b
reject
Input finished
Costas Busch - LSU 28
Language Accepted: }0:{ nbaL n
a
b ba,
ba,
0q 1q 2q
Costas Busch - LSU 29
Another Example
0q 1q
1
1
}1{Alphabet:
Language Accepted:even} is and :{ * xxxEVEN
},111111,1111,11,{
Costas Busch - LSU 30
Formal Definition Deterministic Finite Automaton (DFA)
FqQM ,,,, 0
Q
0q
F
: set of states: input alphabet: transition function: initial state: set of accepting states
Costas Busch - LSU 31
Set of States
Q
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba, 543210 ,,,,, qqqqqqQ
ba,
Example
Costas Busch - LSU 32
Input Alphabet
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba, ba,
ba,
:the input alphabet never contains
Example
Costas Busch - LSU 33
Initial State
0q
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,0q
Example
Costas Busch - LSU 34
Set of Accepting States
QF
0q 1q 2q 3qa b b a
5q
a a bb
ba, 4qF
ba,
4q
Example
Costas Busch - LSU 35
Transition Function
QQ :
q qx
qxq ),(
Describes the result of a transitionfrom state with symbolq x
Costas Busch - LSU 36
2q 3q 4qa b b a
5q
a a bb
ba,
ba,0q 1q
10 , qaq Example:
Costas Busch - LSU 37
50 , qbq
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,0q
Costas Busch - LSU 38
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
32 , qbq
Costas Busch - LSU 39
a b
0q
1q
2q
3q
4q
5q
1q 5q
5q 2q5q 3q
4q 5q
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,5q5q5q5q
Transition Table for st
ates
symbols
Costas Busch - LSU 40
Extended Transition Function QQ ** :
qwq ),(*
Describes the resulting state after scanning string from statew q
Costas Busch - LSU 41
20
* , qabq
3q 4qa b b a
5q
a a bb
ba,
ba,0q 1q 2q
Example:
Costas Busch - LSU 42
50* , qabbbaaq
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,0q
Costas Busch - LSU 43
41* , qbbaq
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
Costas Busch - LSU 44
Special case:
qq ,*
for any state q
Costas Busch - LSU 45
qwq ,*
q qw
q qkw 21
1 2 k
states may be repeated
In general:
implies that there is a walk of transitions
Costas Busch - LSU 46
Language accepted by DFA :
Language Accepted by DFA
it is denoted as and containsall the strings accepted by
MLM
M
MLWe also say that recognizesM
Costas Busch - LSU 47
For a DFA
Language accepted by :
FqQM ,,,, 0
M FwqwML ,: 0
**
0q qw Fq
Costas Busch - LSU 48
Language rejected by :
FwqwML ,: 0**
M
0q qw Fq
Costas Busch - LSU 49
0q
More DFA Examples
ba,},{ ba
*)( ML
0q
ba,
}{)( MLEmpty language All strings
Costas Busch - LSU 50
1q
ba,
},{ ba
0q ba,
}{)( MLLanguage of the empty string
Costas Busch - LSU 51
ML = { all strings with prefix }ab
a b
ba,
0q 1q 2q
accept
ba,3q
ab
},{ ba
Costas Busch - LSU 52
ML = { all binary strings containing substring }001
0 00 001
1
0
110
0 1,0
Costas Busch - LSU 53
ML = { all binary strings without substring }001
0 00 001
1
0
110
0 1,0
Costas Busch - LSU 54
*,:)( bawawaML
a
b
ba,
a
b
ba
0q 2q 3q
1q
Costas Busch - LSU 55
Regular LanguagesDefinition:A language is regular if there is a DFA that accepts it ( )
The languages accepted by all DFAs form the family of regular languages
LM LML )(
Costas Busch - LSU 56
abba abbaab,,}0:{ nban
{ all strings in {a,b}* with prefix }ab{ all binary strings without substring }001
Example regular languages:
There exist DFAs that accept theselanguages (see previous slides).
*,: bawawa
even} is and }1{:{ * xxx
}{ }{ *},{ ba
Costas Busch - LSU 57
There exist languages which are not Regular:
}0:{ nbaL nn
There are no DFAs that accept these languages
(we will prove this in a later class)
}n ,1z,1y,1x :{ mn
kmzyxADDITION k