0% found this document useful (0 votes)
9 views

Finite Automata

Finite Automata (FA) is an abstract machine used to recognize patterns, consisting of a finite set of states, input symbols, an initial state, final states, and a transition function. There are two types of FA: Deterministic Finite Automata (DFA), which have a single state transition for each input, and Nondeterministic Finite Automata (NFA), which allow multiple transitions and null moves. Both types are equivalent in terms of power, and an NFA can be converted to a DFA through a defined process.

Uploaded by

Jio Jio
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Finite Automata

Finite Automata (FA) is an abstract machine used to recognize patterns, consisting of a finite set of states, input symbols, an initial state, final states, and a transition function. There are two types of FA: Deterministic Finite Automata (DFA), which have a single state transition for each input, and Nondeterministic Finite Automata (NFA), which allow multiple transitions and null moves. Both types are equivalent in terms of power, and an NFA can be converted to a DFA through a defined process.

Uploaded by

Jio Jio
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Finite Automata

Finite Automata(FA) is the simplest machine to recognize patterns.The finite automata or finite state machine is
an abstract machine which have five elements or tuple. It has a set of states and rules for moving from one state to
another but it depends upon the applied input symbol. Basically it is an abstract model of digital computer.
Following figure shows some essential features of a general automation.

A Finite Automata consists of the following :

Q : Finite set of states.


Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function.
Formal specification of machine is
{ Q, Σ, q, F, δ }.
FA is characterized into two types:
Deterministic Finite Automata (DFA)

DFA consists of 5 tuples {Q, Σ, q, F, δ}.


Q : set of all states.
Σ : set of input symbols. ( Symbols which machine takes as input )
q : Initial state. ( Starting state of a machine )
F : set of final state.
δ : Transition Function, defined as δ : Q X Σ --> Q.
In a DFA, for a particular input character, the machine goes to one state only. A transition function is defined
on every state for every input symbol. Also in DFA null (or ε) move is not allowed, i.e., DFA cannot change
state without any input character.
For example, below DFA with Σ = {0, 1} accepts all strings ending with 0.
One important thing to note is, there can be many possible DFAs for a pattern. A DFA with minimum number
of states is generally preferred.

2) Nondeterministic Finite Automata(NFA)


NFA is similar to DFA except following additional features:
1. Null (or ε) move is allowed i.e., it can move forward without reading symbols.
2. Ability to transmit to any number of states for a particular input.
However, these above features don’t add any power to NFA. If we compare both in terms of power, both are
equivalent.
Due to above additional features, NFA has a different transition function, rest is same as DFA.
δ: Transition Function
δ: Q X (Σ U ε ) --> 2 ^ Q.
As you can see in transition function is for any input including null (or ε), NFA can go to any state number of
states.
For example, below is a NFA for above problem

NFA

One important thing to note is, in NFA, if any path for an input string leads to a final state, then the input
string accepted. For example, in above NFA, there are multiple paths for input string “00”. Since, one of the
paths leads to a final state, “00” is accepted by above NFA.

Some Important Points:

 Justification:
Since all the tuples in DFA and NFA are the same except for one of the tuples, which is Transition Function (δ)
In case of DFA
δ : Q X Σ --> Q
In case of NFA
δ : Q X Σ --> 2Q

Now if you observe you’ll find out Q X Σ –> Q is part of Q X Σ –> 2 Q.


In the RHS side, Q is the subset of 2 Q which indicates Q is contained in 2 Q or Q is a part of 2Q, however, the
reverse isn’t true. So mathematically, we can conclude that every DFA is NFA but not vice-versa. Yet there is a
way to convert an NFA to DFA, so there exists an equivalent DFA for every NFA.

1. Both NFA and DFA have same power and each NFA can be translated into a DFA.
2. There can be multiple final states in both DFA and NFA.
3. NFA is more of a theoretical concept.
4. DFA is used in Lexical Analysis in Compiler.

Conversion from NFA to DFA

In this section, we will discuss the method of converting NFA to its equivalent DFA. In NFA, when a specific input
is given to the current state, the machine goes to multiple states. It can have zero, one or more than one move on a
given input symbol. On the other hand, in DFA, when a specific input is given to the current state, the machine goes
to only one state. DFA has only one move on a given input symbol.

Let, M = (Q, ∑, δ, q0, F) is an NFA which accepts the language L(M). There should be equivalent DFA denoted by
M' = (Q', ∑', q0', δ', F') such that L(M) = L(M').

Steps for converting NFA to DFA:

Step 1: Initially Q' = ϕ

Step 2: Add q0 of NFA to Q'. Then find the transitions from this start state.

Step 3: In Q', find the possible set of states for each input symbol. If this set of states is not in Q', then add it to Q'.

Step 4: In DFA, the final state will be all the states which contain F(final states of NFA)

Example 1:

Convert the given NFA to DFA.

Solution: For the given transition diagram we will first construct the transition table.

State 0 1

→q0 q0 q1
q1 {q1, q2} q1

*q2 q2 {q1, q2}

Now we will obtain δ' transition for state q0.

1. δ'([q0], 0) = [q0]
2. δ'([q0], 1) = [q1]

The δ' transition for state q1 is obtained as:

1. δ'([q1], 0) = [q1, q2] (new state generated)


2. δ'([q1], 1) = [q1]

The δ' transition for state q2 is obtained as:

1. δ'([q2], 0) = [q2]
2. δ'([q2], 1) = [q1, q2]

Now we will obtain δ' transition on [q1, q2].

δ'([q1, q2], 0) = δ(q1, 0) ∪ δ(q2, 0)


= {q1, q2} ∪ {q2}
1.
2.

δ'([q1, q2], 1) = δ(q1, 1) ∪ δ(q2, 1)


3. = [q1, q2]

= {q1} ∪ {q1, q2}


4.
5.
6. = {q1, q2}
7. = [q1, q2]

The state [q1, q2] is the final state as well because it contains a final state q2. The transition table for the constructed
DFA will be:

State 0 1

→[q0] [q0] [q1]

[q1] [q1, q2] [q1]

*[q2] [q2] [q1, q2]

*[q1, q2] [q1, q2] [q1, q2]

The Transition diagram will be:


The state q2 can be eliminated because q2 is an unreachable state.

References:

1) https://www.geeksforgeeks.org/
2) https://www.javatpoint.com/

You might also like