Lecture 5II 1
Lecture 5II 1
Lecture 5II 1
1
Finite Automaton
Input
String
Output
“Accept”
Finite
or
Automaton
“Reject”
2
Transition Graph
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
initial accepting
state state
transition
state
3
Initial Configuration
Input String
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
4
Reading the Input
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
5
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
6
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
7
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
8
Input finished
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
accept
9
Rejection
a b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
10
a b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
11
a b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
12
a b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
13
Input finished
a b a
a, b
reject
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
14
Another Rejection
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
15
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
reject
16
Another Example
a a b
a a, b
b a, b
q0 q1 q2
17
a a b
a a, b
b a, b
q0 q1 q2
18
a a b
a a, b
b a, b
q0 q1 q2
19
a a b
a a, b
b a, b
q0 q1 q2
20
Input finished
a a b
a a, b
accept
b a, b
q0 q1 q2
21
Rejection Example
b a b
a a, b
b a, b
q0 q1 q2
22
b a b
a a, b
b a, b
q0 q1 q2
23
b a b
a a, b
b a, b
q0 q1 q2
24
b a b
a a, b
b a, b
q0 q1 q2
25
Input finished
b a b
a a, b
b a, b
q0 q1 q2
reject
26
Languages Accepted by FAs
FA M
Definition:
The languageLM contains
M
all input strings accepted by
LM M
= { strings that bring
to an accepting state}
27
Example
LM abba M
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
accept
28
Example
LM , ab, abba M
a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
29
Example
n
LM {a b : n 0}
a a, b
b a, b
q0 q1 q2
30
Language Accepted by FAs
For a FA M Q, , , q0 , F
M
Language accepted by :
q0 w q q F
31
Observation
Language rejected byM :
q0 w q q F
32
Example
LM= { all strings with prefix ab }
a, b
q0 a q1 b q2
b a accept
q3 a, b
33
Example
LM = { all strings without
substring 001 }
1 0 0,1
1
0 1
0 00 001
0
34
Example
L( M ) awa : w a, b *
a
b
b
q0 a q2 q3
b a
q4
a, b
35
Regular Languages
Definition:
A languageL is regular if there is
FA M such that L LM
Observation:
All languages accepted by FAs
form the family of regular languages
36
Examples of regular languages:
38