flat unit 1
flat unit 1
where,
• Circle represent the states
• Initial state is denoted by single incoming arc
• Final state is denoted by double circles
Q={q0,q1,q2}
∑={0,1}
q0={q0}
F={q2}
• Structural Representation of FA:
1) Transition Diagram
2) Transition Table
Transition Table:
• The transition table is basically a tabular representation of the
transition function. It takes two arguments (a state and a symbol)
and returns a state (the "next state").
→q0 q1 q2
q1 q0 q2
*q2 q2 q2
Acceptance and rejection of String:
a a b
b c a
c b c
• Example 1:
1) Q = {q0, q1, q2}
∑ = {0, 1}
q0 = {q0}
F = {q2}
• Transition Diagram:
• Transition Table: Present State Next state for Input 0 Next State of Input 1
→q0 q0 q1
q1 q2 q1
*q2 q2 q2
• Example 2:
1
Q = {q0, q1}
0
Σ = {0, 1}
q0 q1 1
Initial state= {q0} 0
F = {q0}
δ:
0 1
q1 q0
q0
q1 q0 q1
• Example 3:
Accepts those strings that contain at least two c’s
a a a/b/c
c c
q0 q1 q2
b b
a c c c b accepted
q0 q0 q1 q2 q2 q2
a a c rejected
q0 q0 q0 q1
• Revisit example #3:
a a a/b/c
Q = {q0, q1, q2}
c c q2
Σ = {a, b, c} q0 q1
q1 q1 q1 q2
q2 q2 q2 q2
q0 0/1 q1
q0
0/1
q0 q0 q1
Nondeterministic Finite Automata (NFA):
• An NFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
where,
Q = A finite set of states
Σ = A finite input alphabet
q0 = initial/starting state, q0 is in Q
F= A set of final/accepting states, which is a subset of Q
δ = A transition function, which is a total function from Q x Σ to 2 Q
δ: (Q x Σ) –> 2Q :2Q is the power set of Q,
the set of all subsets δ(q,s) is a function from Q x S to 2Q (but not only
to Q)
• Example 1:
One or more 0’s followed by one or0more 1’s
1 0/1
Q = {q0, q1, q2} 0 1
q1 q2
q0
Σ = {0, 1}
Initial state = {q0}
F = {q2}
δ: 0 1
q0{q0, q1} {}
{} {q1, q2}
q1
{q2} {q2}
q2
• Example 2:
Pair of 0’s or pair of 1’s as substring 0/1
0/1
Q = {q0, q1, q2 , q3 , q4} 0 0
q0 q3 q4
Σ = {0, 1}
Start state is q0 1 0/1
F = {q2, q4}
1
q1 q2
δ: 0 1
{q0, q3} {q0, q1}
q0
{} {q2}
q1
{q2} {q2}
q2
{q4} {}
q3
{q4} {q4}
q4
• Determining if a given NFA (example 2) accepts a given string (001) can
be done algorithmically:
q0 q0 q0 q0
0 0 1
q3 q3 q1
q4 q4 accepted
0/1
1
0/1
q1 q2
Minimization of DFA:
• Minimization of DFA means reducing the number of states from given
FA. Thus, we get the FSM(finite state machine) with redundant states
after minimizing the FSM.
• We have to follow the various steps to minimize the DFA. These are
as follows:
• Step 1: Remove all the states that are unreachable from the initial
state via any set of the transition of DFA.
• Step 2: Draw the transition table for all pair of states.
• Step 3: Now split the transition table into two tables T1 and T2. T1
contains all final states, and T2 contains non-final states.
• Step 4: Find similar rows from T1 such that:
• 1. δ (q, a) = p
• 2. δ (r, a) = p
• That means, find the two states which have the same value of a and b
and remove one of them.
• Step 5: Repeat step 3 until we find no similar rows available in the
transition table T1.
• Step 6: Repeat step 3 and step 4 for table T2 also.
• Step 7: Now combine the reduced T1 and T2 tables. The combined
transition table is the transition table of minimized DFA.
Very Simple Example
s0
s1
s2
s0 s1 s2
Very Simple Example
s0
s1 ε
s2 ε
s s s
0 1 2
Label pairs with ε where one is a final state and the other is not
Very Simple Example
s0
s1 ε
s2 ε
s s s
0 1 2
s0
s1 ε
s2 ε
s s s
0 1 2