class2
DESCRIPTION
TRANSCRIPT
11
Finite AutomataFinite Automata
22
FiniteFinite AutomatonAutomatonInput
String
Output
String
FiniteAutomaton
A string over a given alphabet written on an input file
A control unit consisting of a finite number of internal states
The internal state at the next time step is determined by the transition function
33
FiniteFinite AccepterAccepter
Input
“ Accept” or“Reject”
String
FiniteAutomaton
Output
44
Input String of
Internal states
FiniteFinite AccepterAccepter
““ Accept”Accept”
oror
““Reject”Reject”
q0
q1
q2
q3
q4
q5
Initial state
final state
55
FormalitiesFormalitiesDeterministic Finite Accepter (DFA)
(p.38)
FqQM ,,,, 0Q
0q
F
: set of internal states
: input alphabet
: Q × Q transition function
: initial state
: set of final states
66
configuration
Input String
Internal states
FiniteFinite AccepterAccepter
“ Accept” or“Reject”
q0
q1
q2
q3
q4
q5
abba
a ab b
Leftmost position
initial state
: a particular status of the input file and internal stateInitial
×
77
Internal states
“ Accept” or“Reject”
q0
q1
q2
q3
q4
q5
a ab b 10 , qaq Transition function
current state current input symbol
move to the next state
Next state
At q0 now check for current symbol-
×
88
Internal states
“ Accept” or“Reject”
q0
q1
q2
q3
q4
q5
a ab b 21, qbq Transition function
current state current input symbol
Next state
move to the next state
At q1 now check for current symbol-
×
99
Internal states
“ Accept” or“Reject”
q0
q1
q2
q3
q4
q5
a ab b 32 , qbq Transition function
At q2 now check for current symbol-
×
1010
Internal states
“ Accept” or“Reject”
q0
q1
q2
q3
q4
q5
a ab b 43 , qaq Transition function
At q3 now check for current symbol-
×
1111
Internal states
“ Accept” or“Reject”
q0
q1
q2
q3
q4
q5
a ab b No symbol left and it stops at final state
The string abba is accepted by the machine.
At q4 now check for current symbol-
×
1212
Transition functions are the most important part for a finite accepter.
We use a transition graph to represent a finite accepter such that Node state, and Edge with label transition function
(current symbol)
Transition Graph Transition Graph GGMM
1313
32 , qbq Transition Graph forTransition Graph for
current state current input symbol
Next state
q2 q3b
Initial state
Final state qf
q0
1414
Transition Graph
initialstate
final
state
“accept”statetransition
abba –Finite Accepter
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
32 , qbq It is important to have a clear and intuitive picture to work with DFA. Transition graph: vertices > states, edges > transitions
1515
Initial ConfigurationInitial Configuration
Input Stringa b b a
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
1616
Reading the InputReading the Input
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
One at a time from left to right
a b b a
1717
a b b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b b a
1818
a b b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b b a
1919
a b b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b b a
2020
Output: “accept”
a b b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
Input finished
a b b a
2121
Another Example: Another Example: abaaba
a b a
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
2222
a b a
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
Initial ConfigurationInitial Configuration
a b a
2323
a b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b a
2424
a b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b a
2525
a b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b a
2626
Output:“reject”
a b a
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
Input finished
a b a
2727
Another Input StringAnother Input String
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
2828
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
Output:“ reject”
End of input!
2929
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
A Trap StateA Trap State
GGMM
It is important to have a clear and intuitive picture to work with DFA. Transition graph: vertices > states, edges > transitions
3030
What are Q, , , q0, F?
A Deterministic Finite Accepter or DFA is defined as (Def. 2.1 p.38)
FqQM ,,,, 0
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
GGMM
It is important to have a clear and intuitive picture to work with DFA. Transition graph: vertices > states, edges > transitions
3131
InputInput AlphabetAlphabet
ba,
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
3232
SetSet ofof StatesStates
Q
543210 ,,,,, qqqqqqQ
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
3333
InitialInitial StateState
0q
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
3434
SetSet ofof FinalFinal StatesStates
F
4qF
0q 1q 2q 3qa b b a
5q
a a bb
ba,
ba,
4q
3535
TransitionTransition FunctionFunction
QQ :
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
By Transition Graph
GM
3636
What does “deterministic” mean?What does “deterministic” mean?
Other than using Other than using transition graph transition graph GGMM to represent a to represent a
transition function, there are two common ways to transition function, there are two common ways to represent a transition function.represent a transition function.
is a total function
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,GM
FqQM ,,,, 0
It is important to have a clear and intuitive picture to work with DFA. Transition graph: vertices > states, edges > transitions
3737
TransitionTransition FunctionFunction
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
10 , qaq 50 , qbq
51, qaq 21, qbq
52 , qaq 32 , qbq
43 , qaq 53 , qbq
54 , qaq 54 , qbq
55 , qaq 55 , qbq
3838
TransitionTransition FunctionFunction
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
a b
0q
1q
2q
3q
4q
5q
1q 5q
5q 2q
5q 3q
4q 5q
5q5q5q5q
3939
ExtendedExtended Transition Transition Function Function
*QQ *:*
QQ :Transition Transition functionfunction
including including
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
4040
20 ,* qabq
3q 4qa b b a
5q
a a bb
ba,
ba,
0q 1q 2q
QQ *:*
4141
40 ,* qabbaq
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
4242
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
50 ,* qabbbaaq
4343
Extended Transition Extended Transition Function Function
)),,(*(),(*
,),(*
awqwaq
Recursive DefinitionRecursive Definition
for all for all qq Q, w Q, w*, a*, a
QQ *:*
4444
RecursiveRecursive DefinitionDefinition
)),,(*(,*
,*
awqwaq
q qwa
)),,(*(,* awqwaq
qwaq ,*If
1
1
,*
),(,*
qwq
and
aqwaq
then a state, say q1, such that
aq qw1q
4545
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0,
2q
q
1 ,bq
, ,ba0q , 0 ,,* baq
* b 0 ),,( aq * ab
)),,(*(,*
,*
wqwq
4646
qwq ,*kw ...21
In the DFA M, there iswith
q q1 2 k
There is a walk in GM
from to with labelq q
q qw
kw ...21
4747
q q1 2 k
There is a walk in GM
from to with labelq q
q qw
kw ...21
qwq ,*In the DFA M, there iswith kw ...21
4848
q q1 2 k
There is a walk in GM
from to with labelq q
q qw
kw ...21
qwq ,*In the DFA M, there iswith kw ...21
Theorem 2.1Theorem 2.1
4949
50 ,* qabbbaaq
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
There is a walk from to with label
0qabbbaa
5q
If and only if
5050
LanguagesLanguages AcceptedAccepted byby DFAsDFAs
Take DFA
Definition: (p.40)
The language contains all input strings accepted by
= { strings that drive to a final state}
M
MLM
ML
= { = { w w * : * : *(*(qq00, , ww)) FF } }
FqQM ,,,, 0
5151
ExampleExample
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
abbaML
M
acceptaccept
back to complement Ex. p.51
5252
AnotherAnother ExampleExample
abbaabML ,,
M
acceptaccept
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
acceptacceptacceptaccept
5353
Formally, for a DFA Formally, for a DFA
Since M is DFA, every w*, corresponding to a unique walk in the transition graph of M.
If
If
qwq ,* 0
FqQM ,,,, 0
0q qwFq )(MLw
Fq )(MLw
qw0q
5454
ObservationObservation Language rejected by :
FwqwML ,*:* 0
M
Fq
What is the complement of language on example (p.48)?Example on p.48
qw0q
5555
Examples on Constructing Examples on Constructing DFAsDFAs
}0:{ nbaML n
a
b ba,
ba,
0q 1q 2q
accept trap state
5656
= { all strings with prefix }ab ML
accept
a b
ba,
0q 1q 2q
ba,3q
ab
5757
= { all strings without substring 001} ML
001 0 00
1
0
1
10
0 1,0
What if consider DFA for {strings with What if consider DFA for {strings with 001}?001}?
5858
RegularRegular LanguagesLanguages
A language is regular if there is a DFA such that
All regular languages form a language family
LM MLL
5959
abba abbaab,,
}0:{ nban
{ all strings with prefix }{ all strings with prefix }ab
{ all strings without substring }{ all strings without substring }001
Examples of regular languages:
There exist automata that accept theseLanguages (see previous slides).
6060
abbaIs the complement of also regular?
How can you show that the complement of a regular language is regular? (referring to Hw# 3, 4 on p.47)
6161
AnotherAnother ExampleExample
The language is regular
*,: bawawaL
a
a
b a
b
b
0q 2q 3q
ba,
4q
MLL
since we can find a DFA M such that
L*=L {}
6262
AnotherAnother ExampleExample
The language is regular. How about L2 ?
*,: bawawaL
Can you show LL* is a regular language?Try Hw # 20, 21, 22
6363
Is Is L?L?
If there is a DFA M for L, can you tell if L?
If L is regular, then how about L-{}?
Try hw #17 & 18 p.48
How can you construct a DFA for L-{How can you construct a DFA for L-{} } fromfrom the DFA of L? the DFA of L? How can you construct a DFA for LHow can you construct a DFA for L{{} } from from the DFA of L? the DFA of L?
6464
Homework 2.1 Homework 2.1 p.47
Try: 1 ~7, 9, 11~25 Hand in: 2bd, 4, 6, 7e, 9bf, 18
For hw18, state the general method then use the example to illustrate the method where L {a,b}*L= {w: w= or w contains a substring “ab”}