460 likes | 1k Views
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.
E N D
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
Formal Definition of Computation 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
Deterministic Finite State Automata (DFA) 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.
DFA 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:
Example Of DFA 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
Non Deterministic Finite Automata(NFA) 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.
Example of NFA We can have a simpler representation for common suffix language using NFA: Use subset construction to convert it to a DFA. back
DFA vs NFA Deterministic vs nondeterministic For every nondeterministic automata, there is an equivalent deterministic automata Finite acceptors are equivalent iff they both accept the same language L(M1) = L(M2)
Cont….. Deterministic vs nondeterministic In 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
Non Deterministic Features of NFA 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
Subset Construction Method Using Subset construction method to convert NFA to DFA involves the following steps: • For every state in the NFA, determine all reachable statesfor 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 Subset Construction Method 3 a b a a 2 a b a,b 1 5 a a,b 4 b
Fig1. NFA without λ-transitions Step1 Subset Construction Method 3 a b a a 2 a b Construct a transition table showing all reachable states for every state for every input signal. a,b 1 5 a a,b 4 b
Fig1. NFA without λ-transitions Fig2. Transition table Cont… 3 a b a a 2 a b a,b 1 5 a a,b 4 b
Fig1. NFA without λ-transitions Fig2. Transition table Cont… 3 a b a a 2 a b a,b 1 5 a a,b 4 b
Fig1. NFA without λ-transitions Fig2. Transition table Cont… Transition from state q with input a Transition from state q with input b 3 a b Starts here a a 2 a b a,b 1 5 a a,b 4 b
Cont… Fig2. Transition table Step2 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.
Fig3. Subset Construction table Starts with Initial state Fig2. Transition table
Fig3. Subset Construction table Starts with Initial state Fig2. Transition table
Fig3. Subset Construction table Starts with Initial state Fig2. Transition table Step3 Repeat this process(step2) until no more new states are reachable.
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table We already got 4 and 5. So we don’t add them again.
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table
Fig3. Subset Construction table Fig2. Transition table Stops here as there are no more reachable states
Fig4. Resulting FA after applying Subset Construction to fig1 Fig3. Subset Construction table a b a 12345 245 35 a a,b a b b a ∅ 1 3 b a,b b a 2 a b 45 5 b a 4 b back
Limitations of Finite Automata 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