Top Ad unit 728 × 90

What is Finite Automata?|| DFA , NFA ||

Basic Concept:

The finite state system represents a mathematical model of a system with certain input. The model finally gives certain output. The input when is given to the machine it is processed by various states, these state are called as intermediate states.

The very good example of finite state system is a control mechanism of elevator. This mechanism only remembers the current floor number pressed, it does not remember all the previously pressed numbers.

The finite state system is a very good design tool for the programs such as text editors and lexical analyzers (which is used in compilers). The lexical analyzers is a program which cans your program character by character and recognizes those words as tokens.

Definition of Finite Automata(FA):

A finite automata is a collections of  5-tuple ( Q , Σ , δ , q0 ,  F )

where,
Q is a finite set of state, which is non empty.
Σ  is input alphabet, indicates input set.
q0 is an initial state and q0 is in Q i.e. Є Q.
F is a set of final states.
δ is a transition function  or a mapping function. Using this function the next state can be determined.

Finite Automata Model:

The finite automata cab be represented as :
Model for finite automata


The finite automata can be represented using
i). Input tape :- It is linear tape having some number of cells. Each input symbol is placed in each cell.

ii). Finite control :- The finite control decides the next state on receiving particular input from input tape. The tape reader reads the cells one by one from left to right and at a time only one input symbol is read.

For example, suppose current state is q, and suppose reader is reading the symbol 'a' then it is finite control which decides what will be the next state at input 'a' The transition from current state  q with input w to next state q' producing w' will be represented as, 
(q, w) |- (q', w')

If w is a string and M is a automata, than w is accepted by the FA.
iff  (w, s) |-* (q , ε ) 

with q as final state.

The set of string accepted by FA given by M is accepted by language L. The acceptance of M by some language L is denoted by L(M).

A machine M by accepts a language  L iff,
                                     
                      L   =  L(M).

Types  of Automata:

There are  two types of finite automata
  1. Deterministic Finite Automata.
  2. Non deterministic Finite Automata/
The deterministic finite automata is deterministic in nature, in the sense, each move in this automata is uniquely determined on current input and current state. On the other hand, it is non deterministic in nature, in NFA i.e. Non deterministic finite automata.

1. Deterministic Finite Automata (DFA):

The finite automata is called Deterministic Finite Automata if there in only one path for a specific input from current state to next state. For example, the DFA can be shown as below.

Deterministic Finite Automata
From state S0 for  input 'a' there is only one path, going to S2. Similar from S0 there is only one path for input b going to S1.

The DFA can be represented by the same 5-tuples described in the definition of FSM. All the above example are actually the DFAs.

Definition of DFA:

A deterministic finite automata is a collection of following things -
  1. The finite set of state which can be denoted by Q.
  2. The finite set of input symbols Σ.
  3. The start state q0 such that q0 Є Q.
  4. A set of final state F such that F Є  Q.
  5. The mapping function or transition function denoted by Î´. Two parameters are passed to this transition function : One is current state and other is input symbol. The transition function returns a state which can be called as next state.
For example, q1 = δ (q0 ,a ) means from current state q0 , with input a the next state transition is q1. 

In short , the DFA is a five tuple notation denoted as :
                A = (Q , Σ , δ , q0 ,  F )
The name of DFA is A which is a collection of above describe five elements.

Example : Design a FA which accepts the only input 101 over the input set Z = { 0 ,1 }

Solution: 
Note that in the problem statement it is mentioned as only input 101 will be accepted. Hence in the solution we have simply shown the transitions, for input 101. There is no other path shown for other input. 

Non deterministic Finite Automata (NFA):

The concept of Non deterministic finite automata is exactly reverse of Deterministic finite automata. The Finite Automata is called NFA  When there exists many paths for a specific input from current state to next state. The NFA can be shown as 


Note that the NFA shows from q0 for input a there are two next state q1 and q2 similarly, from q0 for input b the next state are q0 and q1.

Thus it is not fixed or that with a particular input where to go next. Hence this FA is called non deterministic finite automata.

     Consider the input string bba. This string can be derived as
                        Input       b     b     a
                        path        q0   q0    q1
                        
         or           input       b     b       a
                       path        q0    q0     q2

         or            Input        b       b     a
                        path          q0     q1    q1

Thus you can't take the decision of which path has to be followed for deriving the given string.

Definition of NFA:

The NFA can be formally defined as a collection of 5-tuples.
  1.  Q is a finite set of states.                         
  2.  Î£ is a finite set of inputs.
  3.  Î´  is called next state or transition function.
  4. q0 is initial state. 
  5. F is a final state where F ⊆ Q . 
There can be multiple final states. Thus the next question might be what is the use of NFA. The NFA is basically used in theory of computations because they are more flexible and easier to use than the DFAs.

Difference between DFA and NFA :

Difference between DFA and NFA
Difference between DFA and NFA


Language of NFA :

We can construct a NFA for the given language. Following are the examples that show how to build NFA for any given language. 

Example:  Construct a NFA for the language, L1 = { consisting a substring 0 1 0 1 }, L2  ={  an    bn }.

Solution:  We will consider L1 first to design NFA. There can be any combination of 0 and 1 in the language but a substring 0101 must be present. We will get such a substring then it leads to a final state or accept state. 



Thus is a NFA as for 0 input we have two different paths one going to q0 and other is going to q1.

The String 00010101 is acceptable by above given NFA and it is as shown below.
                         00010101 is accepted as q4  is final state.

Now we will build a NFA for L2. The language L2 is a language in which there  be any number of a's or any number of b's. It accepts {a, b, aa, bb, aaa, bbb .....}.
Hence the NFA will be 

The NFA shows two different state q1 and q2 for the input ε from q0 state. Here ε (pronounced as epsilon ) is basically a null move i.e. a move carrying no symbol from input set  Σ. But a state change occurs from one state to other.








               









 
What is Finite Automata?|| DFA , NFA || Reviewed by For Learnig on April 24, 2023 Rating: 5

No comments:

If you have any doubts, please tell me know

Contact Form

Name

Email *

Message *

Powered by Blogger.