types of finite automata:dfa & nfa
DESCRIPTION
TYPES OF FINITE AUTOMATA:DFA & NFA. by: Er. Sukhwinder kaur. Topics to be discussed…. Deterministic Finite State Automata (DFA NON DETERMINISTIC FINITE AUTOMATA(NFA) DFA vs NFA Non Deterministic Features of NFA Subset Construction Method Limitations of Finite Automata. - PowerPoint PPT PresentationTRANSCRIPT
by: Er. Sukhwinder kaur
Deterministic Finite State Automata (DFA NON DETERMINISTIC FINITE AUTOMATA(NFA) DFA vs NFA Non Deterministic Features of NFA Subset Construction Method Limitations of Finite Automata
Let M = (Q, , δ,q0, F) be a finite automaton and let w = w1w2…wn be a string where each wi is a member of alphabet ∑.
Where Q= total no of states = input alphabet δ= transition function F=final state
One-way, infinite tape, broken into cells
One-way, read-only tape head.
Finite control, I.e., a program, containing the position of the read head, current symbol being scanned, and the current “state.”
A string is placed on the tape, read head is positioned at the left end, and the DFA will read the string one symbol at a time until all symbols have been read. The DFA will then either accept or reject.
For every string x, there is a unique path from initial state and associated with x.The finite control can be described by a transition diagram:
Example #1:
q3
q0 q1
q2
Start
1
1
1
1
0 0 0 0
Here is a DFA for the language that is the set of all strings of 0’s and 1’s whose numbers of 0’s and 1’s are both even:
back
For any string x, there may exist none or more than one path from initial state and associated with x.
x is accepted if there is some path that ends at a accept state.
We can have a simpler representation for common suffix language using NFA:
Use subset construction to convert it to a DFA.
back
Deterministic vs nondeterministicFor every nondeterministic automata, there is an equivalent deterministic automata
Finite acceptors are equivalent iff they both accept the same language
L(M1) = L(M2)
Deterministic vs nondeterministicIn DFA, label resultant state as a set of states
{q1, q2, q3,…}For a set of |Q| states, there are exactly 2Q subsets
Finite number of states
back
There are three main cases of non- determinism in NFAs:1. Transition to a state without consuming any input.2. Multiple transitions on the same input symbol.3. No transition on an input symbol.
To convert NFAs to DFAs we need to get rid of non-determinism from NFAs.
back
Using Subset construction method to convert NFA to DFA involves the following steps:
For every state in the NFA, determine all reachable statesreachable states for every input symbol.
The set of reachable states constitute a single statesingle state in the converted DFA (Each state in the DFA corresponds to a subset of states in the NFA).
Find reachable statesreachable states for each new DFAnew DFA state, until no more new states can be found.
Fig1. NFA without λ-transitions
Fig1. NFA without λ-transitions
1
3
2
4
5
a aaaa
aa
aa
b
b
b
a,b
a,b
Fig1. NFA without λ-transitions
Step1Step1
1
3
2
4
5
a aaaa
aa
aa
b
b
b
a,b
a,b
Construct a transition table showing all reachable states for every state for every input signal.
Fig1. NFA without λ-transitions Fig2. Transition table
1
3
2
4
5
a aaaa
aa
aa
b
b
b
a,b
a,b
Fig1. NFA without λ-transitions Fig2. Transition table
1
3
2
4
5
a aaaa
aa
aa
b
b
b
a,b
a,b
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
Fig1. NFA without λ-transitions Fig2. Transition table
1
3
2
4
5
a aaaa
aa
aa
b
b
b
a,b
a,b
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
Transition from state q with input a
Transition from state q with input b
Starts here
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
Cont…
Step2Step2
The set of states resulting from every transition function constitutes a new state. Calculate all reachable states for every such state for every input signal.
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
Starts withInitial state
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5}
{4,5}{4,5}
Starts withInitial state
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5}
{4,5}{4,5}
Starts withInitial state
Fig3. Subset Construction tableFig3. Subset Construction table
Step3Step3
Repeat this process(step2) until no more new states are reachable.
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5}
{2,4,5}{2,4,5}
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5}
55
44
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55
44
{3,5}{3,5}
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44
{3,5}{3,5}
∅
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44 55 44
{3,5}{3,5}
We already got 4 and 5.So we don’t add them again.
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44 55 44
{3,5}{3,5} ∅ 22
∅22
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44 55 44
{3,5}{3,5} ∅ 22
∅ ∅ ∅22
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44 55 44
{3,5}{3,5} ∅ 22
∅ ∅ ∅22 33 5533
Fig3. Subset Construction tableFig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
22 {3}{3} {5}{5}
33 ∅ {2}{2}
44 {5}{5} {4}{4}
55 ∅ ∅
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44 55 44
{3,5}{3,5} ∅ 22
∅ ∅ ∅22 33 5533 ∅ 22
Fig3. Subset Construction tableFig3. Subset Construction table
Stops here as there are no more reachable states
q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}
{1,2,3,4,5}{1,2,3,4,5} {1,2,3,4,5}{1,2,3,4,5} {2,4,5}{2,4,5}
{4,5}{4,5} 55 44
{2,4,5}{2,4,5} {3,5}{3,5} 44
55 ∅ ∅44 55 44
{3,5}{3,5} ∅ 22
∅ ∅ ∅22 33 55
33 ∅ 22
1
45
12345 245
35
5
4
∅3
2
a
a
a
a
a
a
a
a
b
b
b
b
bb
b
b
a,b
a,b
Fig3. Subset Construction tableFig3. Subset Construction tableFig4. Resulting FA after Fig4. Resulting FA after applying Subset applying Subset Construction to fig1Construction to fig1
back
Obvious: Can only accept languages that can be represented in finite memory!Can this language be represented with a FA?
L(M)=(ai bi | i n)How about this one?
L(M)=(ai bi | i > 0)
back
Thank You