The document Finite Automata Computer Science Engineering (CSE) Notes | EduRev is a part of the Computer Science Engineering (CSE) Course Theory of Computation.

All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

**Part II. Finite Automata**

Different classes of automata are there. examples: finite automata, pushdown automata. Of them finite automata is the simplest one.In Module I, during the discussion of chomsky classification, it was seen that type-3 or regular languages are recognised using finite automata.

Definition

A finite automation, M is a 5 tuple structure,

M ( Q, ∑, q_{0}, δ, F )

where M is the finite automation,

Q is a finite set of states,

∑ is a set of input symbols,

q0 is the start state,

δ is the set of transition functions,

F is the set of final states.

Consider the following example for a finite automation, M.

In the above finite automation, M,

1. Q = {q_{0}, q_{1}, q_{2}, q_{3}, q4}

Q is the set of states in the finite automata. In the above finite automata, q_{0}, q_{1}, q_{2}, q_{3}, q_{4} are the states. The states are shown in circles.

2. ∑ = a, b, c

∑ is the set of input symbols in the finite automata. In the above, a, b, c are the input symbols. The arrowsare labelled with input symbols.

3. q_{0} = {q_{0}}

q_{0} is the start state. In the above, q_{0} is the start state. For our study, a finite automata contains only one start state. A state with arrow from free space (not coming from any other state) is designated as start state.

4. δ describes the operation of finite automation. δ is the transition function.

For example,

δ(q_{0}, a) = q_{1}

This means, given the current state q0 and the input symbol, a, the finite automation moves (transits) to state q1.

Similarly,

δ(q_{1}, b) = q_{2}

δ(q_{2}, c) = q_{3}

δ(q_{1}, c) = q_{4}

δ(q_{3}, b) = q_{4}

5. F = {q_{2}, q_{4}}

F is the set of final states or accepting states. In the above finite automation, q and q_{4} are the final states. They are shown enclosed in double circles.

**Transition Diagrams and Transition Tables**

Consider the following finite automation, M.

The above representation of finite automation is called a transition diagram. A finite automata can also be represented as a transition table.This is shown below:

→ q_{0} denotes that q_{0} is the start state.

∗ before q_{2} and q_{4} indicates that q_{2} and q_{4 }are the final states.

**3 Language Acceptibility by Finite Automata****String Processing by Finite Automation****Example 1:**

Consider the following finite automation, M.

Check whether the string abcb is accepted by the above finite automation.

In the above, q_{0} is the start state. the string abcb has the first symbol, a.

So,

δ(q_{0}, abcb) = q_{1}

δ(q_{1}, abcb) = q_{2}

δ(q_{2}, abcb) = q_{3}

δ(q_{3}, abcb) = q_{4}

Thus,

Thus, after processing the string abcb, we reached the state, q4. Here q4 is a final state. So the string abcb is accepted by the finite automation.

**Example 2:**

Consider the following finite automation, M

Check whether the string abc is accepted by M.

On processing the string, beginning from the start state, q0,

δ(q_{0}, abc) = q_{1}

δ(q_{1}, abc) = q_{2 }

δ(q_{2}, abc) = q_{3}

Here M halts at q_{3}. But q_{3 }is not a final state. Hence the string abc is rejected by the above finite automation, M.

**Example 3:**

Conisder the finite automation, M,

Check whether the string abca is accepted by the finite automation, M.

Beginning from the start state, q0,

δ(q_{0}, __a__bca) = q_{1}

δ(q_{1}, a__b__ca) = q_{2}

δ(q_{2}, ab__c__a) = q_{3}

δ(q_{3}, abc__a__) =

Here for current state, q_{3}, and for input symbol, a, there is no transition. This means M is unable to process the string abca completely. So the string abca is rejected by M.

**Language of Finite Automation**

In the above, finite automation is used to check the validity of a string. A language is a finite set of strings. So we can use

finite automation to check whether a string belongs to a language.

Consider the following finite automation,

Let L be the language corresponding to the above finite automation, M. Then a string belongs to the language L only if it is accepted by the finite automation, M.

We can say that,

The string abcb belongs to the language, L.

The string abc does not belong to the language, L.

The string abca does not belong to the language, L.

The string ab belongs to the language, L.

The string ac belongs to the language, L.

The string abcbc does not belong to the language , L.

**4 Types of Finite Automata**

Finite automation is of different types. They are,

Non-deterministic Finite Automata (NFA), and

Deterministic Finite Automata (DFA).

**4.1 Non- Deterministic Finite Automata (NFA)**

Consider the following finite automation, M,

In the above, from state q_{0 }with input symbol 0, there are two possible next states. The next state can be either q_{0} or q_{1}.

Also from state q_{1}, on input symbol, 1, there are two possible next states. The next state can be either q_{1}or q_{2}.

Thus some moves of the finite automation cannot be detrmined uniquely by the input symbol and the current state.

Such finite automation are called Non-deterministic Finite automata (NFA or NDFA).

**Example 1:**

Consider the following NFA,

Check whether the string 0100 is accepted by the above NFA.

Beginning from the start symbol, q_{0},

δ(q_{0},__ 0__100) = q_{0}

δ(q_{0}, 0__1__00) = q_{0}

δ(q_{0}, 01__0__0) = q_{3}

δ(q_{3}, 010__0__) = q_{4}

q_{4} is a final state. So the string 0100 is accepted by the above finite automation.

**Example 2:**

Consider the following NFA,

Check whether the string 01101 is accepted by the above NFA.

δ(q_{0}, __0__1101) = q_{0}

δ(q_{0}, 0__1__101) = q_{0}

δ(q_{0}, 01__1__01) = q_{0}

δ(q_{0}, 011__0__1) = q_{1}

δ(q1, 0110__1__) = q_{2}

q2 is a final state. So the string 01101 is accepted by the above NFA.

**Example 3:**

Check whether the string abbaa is accepted by the above NFA.

δ(q_{0}, __a__bbaa) = q_{0}

δ(q_{0}, a__b__baa) = q_{0}

δ(q_{0}, ab__b__aa) = q_{1}

δ(q_{1}, abb__a__a) = q_{2}

δ(q_{1}, abba__a__) = q_{f}

q_{f} is a final state. So the string abbaa is accepted by the above NFA.**4.1.1 NFA with Epsilon Transitions**

An NFA can contain certain transitions on input symbol, ε (epsilon).

ε means ’null’.

For example, consider the following NFA,

Check whether the string 100110 is accepted by the above NFA.

δ(q_{0}, __1__00110) = q_{0}

δ(q_{0}, 1__0__0110) =q_{0}

δ(q_{0}, 10__0__110) = q_{0}

δ(q_{0}, 100__1__10) = q_{1}

δ(q_{1}, 1001__1__0) = q_{2}

δ(q_{2}, 10011__0__) = q_{2}

δ(q_{2}, ε) = q_{4}

q4 is a final state. So the string 100110 is accepted by the above NFA.

Here note that, we made an ε move to reach the final state, q_{4}.

Thus, ε transition means a transition without scanning the symbol in the input string.**Example 2:**

Consider the following NFA,

Check whether the string 0012 is accepted by the above NFA.

Beginning with the start state, q0,

δ(q_{0}, __0__012) = q_{0}

δ(q_{0}, 0__0__12) = q_{0}

δ(q_{0}, ε) = q_{1}

δ(q_{1}, 00__1__2) = q_{1}

δ(q_{1}, ε) = q_{2}

δ(q_{2}, 001__2__) = q_{2}

Here q_{2} is a final state. So the string 0012 is accepted by the NFA.

**4.2 Deterministic Finite Automata**

Consider the following finite automation,

In the above, input symbols are 0, 1 and 2. From every state, there is only one transition for an input symbol.

From state, q_{0}, for symbol, 0, there is only one transition, that is to state q_{0} itself.

From state, q_{0}, for symbol, 1, there is only one transition, that is to state q_{1}.

From state, q_{1}, for symbol, 1, there is only one transition, that is to state q_{3}, and so on.

Thus all the moves of the above finite automation can be determined uniquely by the current state and input symbol.

Such a finite automation is called Deterministic finite Automation (DFA).

Thus in a DFA, at every step, next move is uniquely determined. No ε transitions are present in a DFA.**Example 1:**

The following shows a DFA,

Above transition diagram can be represented using the transition table as follows:

Check whether the string aaba is accepted by the above DFA.

Beginning from the start state, q0,

δ(q_{0}, aaba) = q_{0}

δ(q_{0}, aaba) = q_{0}

δ(q_{0}, aaba) = q_{1}

δ(q_{1}, aaba) = q_{1}

After processing all the characters in the input string, final state q_{1 }is reached. So the string aaba is accepted by the above finite automation.

**Example 2:**

Consider the following DFA,

Check whether the string aabba is accepted by the above DFA.

δ(q_{0}, aabba) = q_{0}

δ(q_{0}, aabba) = q_{0}

δ(q_{0}, aabba) = q_{1}

δ(q_{1}, aabba) = q_{0}

δ(q_{0}, aabba) = q_{0}

After processing all the symbols in the input string, aabba, the state q_{0} is reached. But q_{0} is not a final state. So the DFA rejects the string aabba.

Offer running on EduRev: __Apply code STAYHOME200__ to get INR 200 off on our premium plan EduRev Infinity!

18 videos|44 docs|39 tests