TYPES OF FINITE AUTOMATA:DFA & NFA
date post
15-Jan-2016Category
Documents
view
63download
0
Embed Size (px)
description
Transcript of TYPES OF FINITE AUTOMATA:DFA & NFA
by: Er. Sukhwinder kaur
Deterministic Finite State Automata (DFANON DETERMINISTIC FINITE AUTOMATA(NFA)DFA vs NFA Non Deterministic Features of NFASubset Construction MethodLimitations of Finite Automata
Let M = (Q, , ,q0, F) be a finite automaton and let w = w1w2wn 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:
Here is a DFA for the language that is the set of all strings of 0s and 1s whose numbers of 0s and 1s 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 subsetsFinite number of statesback
There are three main cases of non- determinism in NFAs:Transition to a state without consuming any input.Multiple transitions on the same input symbol.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 states for every input symbol.The set of reachable states constitute a single state in the converted DFA (Each state in the DFA corresponds to a subset of states in the NFA).Find reachable states for each new DFA state, until no more new states can be found.Fig1. NFA without -transitions
Fig1. NFA without -transitions
13245aaaaabbba,ba,b
Fig1. NFA without -transitions
Step113245aaaaabbba,ba,bConstruct a transition table showing all reachable states for every state for every input signal.
Fig1. NFA without -transitions
Fig2. Transition table13245aaaaabbba,ba,b
Fig1. NFA without -transitions
Fig2. Transition table
13245aaaaabbba,ba,b
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
Fig1. NFA without -transitions
Fig2. Transition table
13245aaaaabbba,ba,bTransition from state q with input aTransition from state q with input bStarts here
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
Fig2. Transition tableContStep2The set of states resulting from every transition function constitutes a new state. Calculate all reachable states for every such state for every input signal.
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
Fig2. Transition tableStarts withInitial stateFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}
Fig2. Transition tableStarts withInitial stateFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{4,5}
Fig2. Transition tableStarts withInitial stateFig3. Subset Construction tableStep3Repeat this process(step2) until no more new states are reachable.
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{4,5}
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5} {2,4,5}
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}54
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}454{3,5}
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}454{3,5}
Fig2. Transition tableWe already got 4 and 5.So we dont add them again.Fig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}45454{3,5}
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}45454{3,5}22
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}45454{3,5}22
Fig2. Transition tableFig3. Subset Construction table
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}45454{3,5}22353
Fig2. Transition tableFig3. Subset Construction tableStops here as there are no more reachable states
q(q,a)(q,b)1{1,2,3,4,5}{4,5}2{3}{5}3{2}4{5}{4}5
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}45454{3,5}223532
14512345245355432aaaaaaaabbbbbbbba,ba,bFig3. Subset Construction tableFig4. Resulting FA after applying Subset Construction to fig1back
q(q,a)(q,b)1{1,2,3,4,5}{4,5}{1,2,3,4,5}{1,2,3,4,5} {2,4,5}{4,5}54 {2,4,5}{3,5}45454{3,5}223532
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
*