Professional Documents
Culture Documents
1
Finite Automaton
Input
String
Output
Finite String
Automaton
2
Finite Accepter
Input
String
Output
“Accept”
Finite
or
Automaton
“Reject”
3
Formalities
Deterministic (in their operation)Finite Accepter
(DFA)
M Q, , , q0 , F
Q : set of states
: input alphabet
: transition function
q0 : initial state
F : set of final states
4
Operation of DFA
• At the initial time it is assumed to be in the initial
state q0 , with its input mechanism on the leftmost
symbol of the input string.
• During each move of the automaton, the input
mechanism advances one position to the right so
each move consumes one input symbol.
• When the end of the string is reached, the string
is accepted if the automaton is in one of its final
states.
• Otherwise the string is rejected.
• The input mechanism can move only from left to
right and reads exactly one symbol on each step.
5
Operation of DFA
• The transition from one internal state to
another are governed by the transition
function δ. For example, if
• δ(q0,a) = q1.
6
Transition Graph
abba -Finite Accepter a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
initial final
state state
transition
state “accept”
7
Initial Configuration
Input String
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
8
Reading the Input
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
9
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
10
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
11
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
12
Input finished
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Output: “accept”
13
Rejection
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
14
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
15
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
16
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
17
Input finished
a b a
a, b
Output:
q5 “reject”
a a, b
b a b
q0 a q1 b q2 b q3 a q4
18
Another Rejection
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
19
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Output:
“reject” 20
Input Alphabet
a, b
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
21
Set of States Q
Q q0 , q1, q2 , q3 , q4 , q5
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
22
Initial State q0
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
23
Set of Final States F
F q4
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
24
Transition Function
:Q Q
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
25
q0 , a q1
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
26
q0 , b q5
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
27
q2 , b q3
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
28
Transition Function
a b
q0 q1 q5
q1 q5 q2
q2 q5 q3
q3 q4 q5 a, b
q4 q5 q5
q5 q5 q5 q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
29
Extended Transition Function *
The transition function can be extended so its second
argument is a string.
* : Q * Q
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
30
* q0 , ab q2
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
31
* q0 , abba q4
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
32
* q0 , abbbaa q5
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
33
Observation: There is a walk from q to q
with label w
* q, w q
q w q
w 1 2 k
1 2 k
q q
34
Example: There is a walk from q0 to q5
with label abbbaa
* q0 , abbbaa q5
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
35
Recursive Definition
* q, q
* q, w ( * (q, w), )
q w q1 q
* q, w q
* q, w (q1, )
(q1, ) q
* q, w ( * (q, w), )
* q, w q1
36
* q0 , ab
* (q0 , a ), b
* q0 , , a , b
q0 , a , b
q1 , b
q2 a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
37
Languages Accepted by DFAs
Take DFA M
Definition:
The language LM contains
all input strings accepted by M
38
Example
LM abba M
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
accept
39
Another Example
LM , ab, abba M
a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
accept accept accept
40
Formally
For a DFA M Q, , , q0 , F
Language accepted by M :
LM w * : * q0 , w F
q0 w q q F
41
Observation
Language rejected by M :
q0 w q q F
42
More Examples
n
LM {a b : n 0}
a a,b
q0 b q1 a, b q2
43
LM = { all strings with prefix ab }
a, b
q0 a q1 b q2
b a accept
q3 a, b
44
L M = { all strings without
substring 001 }
1 0 0,1
1
0 1
0 00 001
0
45
Regular Languages
46
Examples of regular languages:
b a
q4
a, b
48
There exist languages which are not Regular:
n n
Example: L {a b : n 0}
49