finite automata - pvt 2 chapter finite automata warren mcculloch (1898–1968) and walter pitts...

26
2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist who co-founded Cybernetics. His greatest contribuons to Computer Science include an early existence proof for universal computers (Turing Machines) and a model of Arficial Neural Networks that stands as a theory which explains how a biological brain could perform logical calculaons and serves as the basis of Arficial Intelligence (AI). In order to study the structural properes of nervous acvity, McCulloch moved to the Yale Medical School and finally in 1940, he moved to Chicago to accept a posion as Professor of Psychiatry and Physiology. There, McCulloch met two students, Jerome Levin and Walter Pis (1923–1969), who would become his closest colleagues, collaborators and friends. Lewin was a young medical student interested in the use of mathemacs in biology and electrical properes of brain. Pis was a polymath who had never graduated from high school nor enrolled in college, but began studying logic at University of Chicago aſter running away from home at the age of 14, the 18-year-old Homeless Pis began working with McCulloch on a theory of mind which would show how neurons in the brain could represent logical proposions. In their 1943 paper, McCulloch and Pis demonstrated that a suitably configured network of mathemacally idealized neurons could represent any well-formed logical proposion and compute any funcon representable in their logical calculus. Moreover, any such network could simulate a memory if its outputs were fed back into its inputs. Thus, their neuron nets were a kind of universal computer. In search of simplest models to capture the finite state machines, McCulloch and Pies were among the first researchers to introduce a concept similar to finite Automaton in 1943.

Upload: dangdat

Post on 26-Aug-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

2C H A P T E R

Finite Automata

Warren McCulloch (1898–1968) and Walter Pitts (1923–1969)

Warren S. McCulloch was an American psychiatrist and neurophysiologist who co-founded Cybernetics. His greatest contributions to Computer Science include an early existence proof for universal computers (Turing Machines) and a model of Artificial Neural Networks that stands as a theory which explains how a biological brain could perform logical calculations and serves as the basis of Artificial Intelligence (AI).

In order to study the structural properties of nervous activity, McCulloch moved to the Yale Medical School and finally in 1940, he moved to Chicago to accept a position as Professor of Psychiatry and Physiology.

There, McCulloch met two students, Jerome Lettvin and Walter Pitts (1923–1969), who would become his closest colleagues, collaborators and friends. Lettwin was a young medical student interested in the use of mathematics in biology and electrical properties of brain. Pitts was a polymath who had never graduated from high school nor enrolled in college, but began studying logic at University of Chicago after running away from home at the age of 14, the 18-year-old Homeless Pitts began working with McCulloch on a theory of mind which would show how neurons in the brain could represent logical propositions.

In their 1943 paper, McCulloch and Pitts demonstrated that a suitably configured network of mathematically idealized neurons could represent any well-formed logical proposition and compute any function representable in their logical calculus. Moreover, any such network could simulate a memory if its outputs were fed back into its inputs. Thus, their neuron nets were a kind of universal computer. In search of simplest models to capture the finite state machines, McCulloch and Pittes were among the first researchers to introduce a concept similar to finite Automaton in 1943.

Page 2: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 15

Any deterministic automaton can be shown pictorially by using a state-transition graph where the states are represented by the vertices and each edge from any q0 to q1 is labeled with a symbol, say a, which belongs to S if d(q0, a) Æ q1. A directed labeled arrow is drawn from q0 to q1.

One circle is drawn for each state, and the name of the state is written inside the circle. An arrow that does not start at a state, but points to the initial state or starting state tells that this state is the starting state (see Figure 2.1, q0 is starting state).

All circles drawn for final states F are drawn double, i.e., concentric circles (q1 is final state in Figure 2.1)

q1 q2

a

b a a,b

bq0

Figure 2.1

Another way of representing dfa is transition table. Table has one row for each state and one column for each symbol. Row labelled with start state is prefixed by arrow Æ, and row labelled with final state is prefixed by arrow ¨ for a state q ŒQ and symbolx ŒS, in the position of row q, and column x, the state d(q, x) is written. Transition table for Figure 2.1 is shown in Figure 2.2.

Figure 2.2

2.2.1 Language of DFALanguage is a set of all the strings accepted by the automaton. Formally, the language accepted by dfa M = (Q, S, d, q0, F) is the set of all strings on S accepted by M.

L(M) = {w S* : d* (q0, w) ŒF}.

If dfa enters into a state and after reading any symbol it cannot escape from that state (unable to reach other state) then this particular state is called sink state or trap state. State q2 in Figure 2.1 is an example of trap state.

Page 3: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

16 | Automata Theory, Language of Machines and Computability

2.2.2 Basic Properties of DFAAutomaton that we are discussing is deterministic, because in every state and for every value of the alphabet that is read, there is one and only one state in which automata can be.

Missing transitions are not allowed in dfa. There must be transition on each symbol of S from each state of dfa. If there is no transition on symbol a from only state q then a new trap state is introduced in state transition graph such that d (q, a) Æ ft and label this new state as ft.

ExamplE 2.2

Give dfa that recongizes the string ab on S = {a, b} First we will make a start state

Now the first symbol of string is a so,

The second symbol of string is b

Since string is completed, after reading b, dfa is in state q2, hence q2 must be the final state.

This is our generalized result. We know that missing transitions are not allowed in dfa so we add a new trap state f because d(q0, b), d(q1, a) and d(q2, a), d(q2, b) are missing.

This is the final dfa we need. It accepts only ab and rejects all other strings. It canbe written formally as

M = ({q0, q1, q2, ft}, S = {a, b}, d, q0, {q2})

d: d(q0, a) Æ q1, d (q0, b) Æ ft

d(q1, a) Æ ft, d (q1, b) Æ q2

d(q2, a) Æ dt, d (q2, b) Æ ft

d(f, a) Æ ft, d (f, b) Æ ft

Page 4: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 17

ExamplE 2.3

Give dfa that recognizes string ‘00111’ on S = {0, 1}

First we will draw a generalized dfa.

Now we will complete all missing transitions.

ft

ExamplE 2.4Give dfa which accepts all strings starting from ab on S = {a, b} First we will construct dfa to fulfil the basic need, i.e., prefix ab.

Now completing missing transitions

ExamplE 2.5

Give dfa which accepts strings with even number of 1’s on S = {0, 1}For even number of 1’s

now 0’s can be anywhere in the string so

Page 5: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 19

ExamplE 2.10Give dfa which accepts all the strings which contain odd number of a’s followed by string abbb on S = {a, b}.

Here first we consider dfa which accepts odd number of as.

Now string bbaa

Now we will join these automatons.

Now fulfilling all the missing transitions.

ExamplE 2.11Give dfa for language L = {aw1aaw2a : w1, w2 Œ{a, b}*} on S = {a, b}. Write its formal definition with transition table.First of all we will construct dfa for the given language:

q0 q1 q3q2 q4

aa

b

fta b,

aa

a

b

b

b

b

Now let us give its formal description

M = ({q0, q1, q2, q3, q4, f}, S = {a, b}, d, q0, {q4})

d : d(q0, a) Æ q1

d(q0, b) Æ ft

Page 6: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

20 | Automata Theory, Language of Machines and Computability

d(q1, a) Æ q2 d(q1, b) Æ q1

d(q2, a) Æ q3

d(q2, b) Æ q1

d(q3, a) Æ q4

d(q3, b) Æ q3

d(q4, a) Æ q4

d(q4, b) Æ q3

d(ft, a) Æ ft

d(ft, b) Æ ft

Transition table is given as:

Input symbols

States

a b

q0 q1 ft

q1 q2 q1

q2 q3 q1

q3 q4 q3

q4 q4 q3

ft ft ft

2.3 NON-DETERMINISTIC FINITE ACCEPTORS OR NFA

Digital computers are completely deterministic, it means their state at any time is uniquely predictable. So, why do we need nfa’s. nfa provides multiple options and are useful in solving problems easily. Non-determinism simplifies formal arguments also. Now let us see the fomal definition of nfa’s.

A non-deterministic finite acceptor or nfa is defined by the quintuple

M = (Q, S, d, q0, F),where

Q is a finite set of internal statesS is a finite set of symbols called the input alphabetd: Q ¥ (S {Œ} Æ 2Q is transition function q0 Œ Q is the initial stateF Õ Q is a set of final states

Page 7: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

22 | Automata Theory, Language of Machines and Computability

ExamplE 2.13Give dfa on S = {0, 1} for all those strings whose leftmost symbol is different from the rightmost symbol.

It means if the leftmost symbol is 1 the rightmost symbol must be 0 and vice versa.

q0

q1

q2

q3

q4

0

1

0,1

1

0

1

0

1,0

ExamplE 2.14Give dfa on S = {0, 1} for all those strings of length five or more in which the fourth symbol from the left end is different from the left most symbol.

q0

q1

q2

q3

q4

q5

q6

q7

q8

q9

q10

f t

0

0,1 0,1 0,1 0,11

0,1 0,1 0,1 0,10

1

1

0,1

ExamplE 2.15Give dfa on S = {x, y, z} for all strings where the starting symbol is x and the lastsymbol is z.

q0 q1

ft

q2

x z

x y,

x y z, ,

x y z, ,

y z,

A string is accepted by an nfa if there is some sequence of possible moves that will put the machine in a final state at the end of the string. A string is rejected only if there is no possible sequence of moves by which a final state can be reached. Non-determinism

Page 8: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 23

can therefore be viewed as involving intuitive insight by which the best move can be chosen at every state.

The language accepted by an nfa can be defined as the language consists of all strings w for which there is a walk present from initial vertex of transition graph to final vertex.

Let us assume an nfa is in state q and reads the next symbol, say a, for which there is no transition present d (q, a) = f. Note that here f is not any state it means NULL here, then this situation is called a dead configuration. In Figure 2.3 d(q0, a), d(q1, b), d(q2, a),d(q2, b), d(q3, a), d(q3, b) are dead configurations.

ExamplE 2.16Construct an nfa that accepts strings aaa or bbb.

First of all draw nfa for string aaa

Now let us draw nfa for string bbb

Now we will join these two nfas in order to get the final solution.

Since, missing transitions are allowed in nfa so, our nfa is ready.

ExamplE 2.17Construct an nfa with three states that accept language {ab, abc}*.

q2q1q0a b

c,Œ

Note that * means it may repeat 0 or more times.

ExamplE 2.18Find an nfa with four states for L = {an: n ≥ 0} {bna : n ≥ 1}

First see an: n ≥ 0 it means it can accept 0 or more a’s, so its nfa can be

Now see {bna :n ≥ 1}. It means any number of b’s can be there but atleast one b must be there followed by single a

Page 9: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 25

For every language accepted by some nfa there is a dfa that accepts the same language.Two finite acceptors M1 and M2 are said to be equivalent if

L(M1) = L(M2)

i.e., if they both accept the same language.Let us focus on equivalence of dfa and nfa. Let MN be a non-deterministic finite

acceptor and MD be deterministic finite acceptor. L(MN) be the language accepted by nfa MN. Then MD equivalent to MN if

L(MN) = L(MD)

NFA to DFA ConversionTo convert any nfa to its equivalent dfa, we must follow these steps:

Step 1. Draw the start state of MD, label it with a set of all states of MN that we can reach from the start state of MN by following zero or more epsilon (Œ)-transitions.

Step 2. Pick a symbol a ŒS, any state of MD so that this state does not have a transition for a. Draw transition from the state we chose to new state and label edge as a. The label of this new state is a set which includes every state that we can get to in MN by following exactly one transition labelled by a, and zero or more transitions a labelled by epsilon (Œ), starting from any state in MN that is subset labelling the state of MD we are starting from.

Step 3. Repeat step 2 untill no more edges are missing

Step 4. Each state in MD is an accept state iff it contains any state in its set which is a final state of MN.

Step 5. If MN accepts Œ, start vertex of MD is also made a final vertex.

For better understanding of this algorithm (conversion of nfa to its equivalent dfa) see Examples 2.20 to 2.24.

ExamplE 2.20Convert the given ndfa to its equivalent dfa.

First of all draw the start state of our dfa including the start state of nfa and all the states we can reach from q0 by zero or more Œ-transitions as a set

Page 10: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

26 | Automata Theory, Language of Machines and Computability

Now choosing this state and a symbol from S and making the next state to which it can reach by taking symbol as input. This new state is labeled by a set of states which is reached by the symbol and states which can be reached from that state by zero or more transitions of Œ.

Now considering next symbol and same state {q0, q1} and repeating above process.

In state {q0, q1} neither q0 is having ab transition nor q1 is having any transition for symbol b so we introduce a trap by state ft because missing transitions are not allowed in dfa.

We have completed transitions for S for state {q0, q1}. Now choosing the next state{q2, q3} and symbol a from S.

Now considering input symbol b for state {q2, q3}.

Page 11: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

28 | Automata Theory, Language of Machines and Computability

Now input symbol b for state {q2, q1}

Since {q2} is already present.

We have completed all of our states except state {q2}. Now let us choose state {q2} and input symbol a.

Now taking input symbol b for state {q2}

We have completed our dfa. Now mark the final states of dfa. All the states of dfa are final states if they are labeled by a set which contains a state which is a final state of given nfa.

Page 12: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 29

Final states of NFA = q2

So, final states of DFA are {q2, q3}, {q2, q1}, {q2}, {q2, q4, q5, q6}

This is final dfa, equivalent to given nfa.

ExamplE 2.21Convert the given nfa to its equivalent dfa.

First of all we will find the start state of our dfa

Now we will find transitions for input symbol 0 on state {q0}

Now considering input symbol 1 for state {q0}.

Page 13: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 31

Here, a new state {q1, q3, q2} is introduced.

{ }q0 { , }q1 q2 { , }q0 q4

{ }q3 ft0,1 0,1

0,10{ , }q1 q q3 2,

0

1

For symbol 1

State {q3} is already present in DFA.

{ }q0 { , }q1 q2 { , }q0 q4

{ }q3 ft0,1 0,1

0,10{ , }q1 q q3 2,

0

11

We have completed all state transitions except state {q1, q3, q2}. Now let us find its transitions.

State {q1, q3, q2} for input symbol 0

{q0, q4} is already present in our dfa, so no need to create new state.

{ }q0 { , }q1 q2 { , }q1 q q3 2,{ , }q0 q4

{ }q3

0

1

0,1 0,1

0,1 0

01

ft

Page 14: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

32 | Automata Theory, Language of Machines and Computability

For input symbol 1

q4q1

q2

– q0

Œ

q4

Œ

q0 –

{ }q0 { , }q1 q2 { , }q1 q q3 2,

1

q3

{ , }q0 q4

{ }q3

0

1

0,1 0,1

0,1 0

1 1,0

ft

Now, find all the final states of our dfa. Final state(s) of our nfa is q4, so all those states of dfa which contain q4 are final states of dfa.

{ }q0 { , }q1 q2 { , }q1 q q3 2,{ , }q0 q4

{ }q3

0

1

0,1 0,1

0,1 0

1 1,0

ft

ExamplE 2.22Find equivalent dfa for given nfa.

q1

q4

q2

q5

q3

q6

0

1

0

1

0

0 1

1

ŒŒŒ

Equivalent dfa:

{ , }q1 q4 { , }q2 q40,10 0

{ , }q3 q5{ }q3

1

1

0

1

{ , }q2 q q q q3 4 5 6, , ,

0

10

1

ft

Page 15: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

34 | Automata Theory, Language of Machines and Computability

To make it clear we introduce a new column with name “final state.” If the state is the final state we mark it with a yes tag else a no tag.

Æ0 1 Final state

{q0}{q0,q1}{q0,q2}

{q0,q1,q3

{q0,q2,q3}

{q0,q1}{q0,q1,q3}

{q0,q1}{q0,q1,q3}{q0,q1,q3}

{q0,q2}{q0,q2}

{q0,q2,q3}q0,q2,q3}q0,q2,q3}

NoNoNoYesYes

This is transition table of our equivalent dfa. Now let us draw its state transition diagram, as follows:

Equivalent dfa for the given nfa is:

ExamplE 2.24Convert the given non-deterministic automata to its equivalent deterministic state transition graph.

Equivalent dfa

Page 16: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 35

2.5 EQUIVALENT OF NFA WITH Œ-TRANSITIONS AND NFA WITHOUT Œ-TRANSITIONS

We can convert any nfa (with Œ-transitions) to its equivalent nfa that have noŒ-transitions. Note that nfa without Œ-transitions may or may not dfa because it may hold other properties of nfa like missing transitions and multiple transitions.

It is a simple method. It says that we can remove Œ-transitions from some state q by copying the transitions from each successor state which can be reached from q by Œ-transition.

Let us understand this concept in a more simpler way, suppose there is a state q and it has an epsilon transition to a state qs, then for a while think q is qs, edges (transitions) which are associated to qs also add them to q. Just like they are connected to qs and remove Œ-edge between q and qs. For more abstraction of concept see Examples 2.25 and 2.26.

ExamplE 2.25Find equivalent nfa for the given nfa without Œ-transitions.

First of all consider Œ-transition between q0 and q1. Now think as if q0 is q1 and find all transitions of q1

d(q1, a) Æ q2

d(q1, b) Æ q3

Now add these edges (transitions) to q0 and remove Œ-labeled edge between q0 and q1

d(q0, a) Æ q2

d(q1, b) Æ q3

We successfully eliminated Œ-transition between q0 and q1. Now let us now consider Œ-transition between q2 and q4

Page 17: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 37

ExamplE 2.26Remove Œ-transitions from the given nfa.

First of all consider Œ-transition between q0 and q2. Find all the transitions of q2:

d (q2, b) Æ q3

Copy transitions of q2 to q0 and remove Œ-link between q0 and q2.

d(q0, b) Æ q3

Now, consider Œ-transition between states q1 and q4. Find all transitons of q4:

d(q1, a) Æ q3

d(q1, b) Æ q4

q0 q1

q2

q4

q3

a

b

a

ba

b

a

b

This nfa is without Œ-transitions.

2.6 REMOVING Œ-CYCLES FROM NFA

Œ-cycle means when we start from any state and get back to the same state after successive Œ-transitions (without taking any input). See example 2.27 q1, q2, q3, q4 form an Œ-cycle.

If we want to remove Œ-cycle then replace the states forming Œ-cycle by a new state say qnew. If any of the states removed was the first or say the start state then make qnew the start state and same is the case of final states. Any transition which was in/out of removed states will be now in/out in new state qnew.

Page 18: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

38 | Automata Theory, Language of Machines and Computability

ExamplE 2.27Remove Œ-cycle from given nfa.

Removing Œ-cycles.

2.7 MINIMIZATION OF DFA

For a given language, there are many dfa‘s that accept it, and they have distinct number of states in them. Theoretically, all solutions are acceptable but for storage efficiency dfa with minimum number of states is preferred. So, we are interested in minimization of dfa or reduction of states of any dfa. Before we proceed for minimization of dfa we have to understand a basic concept.

Two states p and q of a dfa are called distinguishable if

d*(p, w) ŒF implies d*(q, w) ŒF,

and d*(p, w) ŒF implies d*(q, w) ŒF,

For all w ΠS*, if, on the other hand, there exists some string w ΠS* such that

d*(p, w) ŒF and d*(q, w) ŒF

or d*(p, w) ŒF and d*(q, w) ŒF

Then the states p and q are said to be distinguishable by a string w.

Steps for minimization of DFA are as follows:

First of all see the procedure for finding pairs of distinguishable states:

1. Remove all inaccessible states, any state which can‘t be reached from the start state after one or more transitions is an inaccessible state.

2. Consider all pairs of states (p, q). If p ŒF and q œF or vice versa, mark the pair(p, q) as distinguishable.

3. For all pairs (p, q) and all a ŒS, calculate d(p, a) = pa and d(q, a) = qa. If the pair(pa, qa) is marked as distinguishable, mark (p, q) as distinguishable.

Page 19: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

40 | Automata Theory, Language of Machines and Computability

Now we have four sets {q2}, {q4}, {q0} and {q1, q3}Since {q2}, {q4} and {q0} do not exist in pairs so they all are considerednon-distinguishable.Now checking for set {q1, q3}

0 1q1

q3q2

q2

q4

q4

d(q1, 0) Æ q2 ŒF

d(1, 1) Æ q4 ŒFd(q3, 0) Æ q2 ŒF

d(q3, 1) Æ q4 ŒF

Pair is non-distinguishable.Finally, we have four sets {q2}, {q4}, {q0}, {q1, q3}Start state of the given DFA is q0 so, start state of minimized dfa is {q0}Final state of given DFA is q2 and q4 so, final states of minimized dfa are {q2}, {q4}.State transition graph for minimized dfa is as follows:

0 1{q2}{q4}{q0}{q1,q3}

{q1,q3}{q4}{q1,q3}

q2

{q4}{q4}{q1,q3}

q4

ExamplE 2.29Minimize the state in the dfa depicted in the following diagram.

First of all, select two sets:

1. Set of all final states: {q3, q5}

2. Set of all non-final states: {q0, q1, q2, q4}

Page 20: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 41

0 1q3q5

q5q5

q5q5

d (q3, 0) Æq5 ŒFd (q3, 1) Æq5 ŒFd (q5, 0) Æq5 ŒFd (q5, 1) Æq5 ŒF

This pair is non-distinguishable

0 1q0q1q2q4

q1q0q1q3

q3q3q4q3

d(q0, 0) Æ q1 œF

d(q0, 1) Æ q3 ŒFd (q1, 0) Æ q0 œFd (q1, 1) Æ q3 ŒF

d(q2, 0) Æ q1 œFd(q2, 1) Æ q4 œF

d (q4, 0) Æ q3 ŒF

d (q4, 1) Æ q3 ŒF

Splitting the set {q0, q1, q2, q4} into three sets {q0, q1}, {q2}, {q4}

Now we have four sets {q3, q5}, {q0, q1}, {q2}, {q4}

Set {q3, q5} is non-distinguishable, now checking for sets {q0, q1}, {q2}, {q4}.

0 1q0q1

q1q0

q3q3

d (q0, 0) Æ q1 œF

d (q0, 1) Æ q3 ŒFd (q1, 0) Æ q0 œFd (q1, 1) Æ q3 ŒF

Since states {q2}, {q4} are not in pairs so they are considered non-distinguishable. Finally, we have four states:

{q3, q5}, {q0, q1}, {q2}, {q4}Minimized dfa is:

0 1

{q3,q5}{q0,q1}{q2}{q4}

{q3,q5}{q0,q1}{q0,q1}{q3,q5}

{q3,q5}{q3,q5}{q4}{q3,q5}

Start state of the minimized dfa is {q0, q1} because q0 is the start state of the given dfa. Final states of dfa are q3 and q5, so final states of minimized dfa is {q3, q5}.

{ , }q0 q1 { , }q3 q5

{ }q2 { }q4

1

1

1

0,1

0,10

Page 21: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 43

16. Construct a dfa for all strings that do not contain the substring 110.

(HPTU, Himachal Pradesh, 2014) 17. Design a dfa which accepts even number of 0‘s and odd number of 1‘s. 18. Design an nfa which accepts any binary string that contains 00 or 11 as a substring. 19. Give an nfa for the set of all binary strings that have either the number of 0’s odd,

or the number of 1’s not a multiples of 3 or both. 20. Design an nfa to accept the set of strings of 0’s and 1’s that either (a) ends in 010 and has 011 somewhere preceding, or (b) ends in 101 and has 100 somewhere preceding. 21. Convert the following nfa to its equivalent dfa.

22. Construct a dfa equivalent to the ndfa whose transition diagram is given below. (RTU, Rajasthan, 2012)

23. Construct a deterministic finite automata equivalent to the following ndfa.(RTU, Rajasthan, 2013)

24. Convert the following nfa to dfa. (GTU, Gujarat, 2014)

Page 22: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

44 | Automata Theory, Language of Machines and Computability

25. Convert the following nfa to equivalent dfa. (DTU, Delhi, 2012)

26. Convert the following nfa to dfa. (MU, Mumbai, 2015)

27. Convert the given nfa to dfa.

28. Convert the given nfa to its equivalent dfa.

29. Convert the following nfa into an equivalent dfa.

30. Remove all empty moves from this nfa.(DTU, Delhi, 2013)

Page 23: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 45

31. Write an algorithm to minimize dfa using the subset construction method.(UPTU, Uttar Pradesh, 2012-13)

32. Construct a minimum state dfa equivalent to finite automata given:(CSVTU, Chhattisgarh, 2015)

33. Minimize the given dfa.

GATE AND UGC-NET QUESTIONS

1.

Consider the dfa given. Which of the following are FALSE? 1. Complement of L(A) is context free. 2. L(A) = L(11* 0 + 0) (0 + 1) *0*1*) 3. For the language accepted by A, A is minimal dfa. 4. A accepts all strings over {0, 1} of length at least 2. (A) 1 and 3 only (B) 2 and 4 only (C) 2 and 3 only (D) 3 and 4 only (GATE, 2013) 2. What is the complement of the language accepted by the nfa shown below?

Page 24: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

Finite Automata | 47

(D)

00 01 10 11 q

00 1

01 1

10 0

11 0

(A) A (B) B (C) C (D) D (GATE, 2012)

4. A DFA with alphabet {a, b} is given below:

Which of the following finite state machines is a valid minimal dfa which accepts the same language as D?

(A) (B)

(C) (D)

(A) A (B) B (C) C (D) D (GATE, 2011) 5. Match the following nfa’s with the regular expressions they correspond to:

1. Π+ 0 (01*1 + 00)*01* 2. Π+ 0 (10*1 + 00)*0* 3. Π+ 0 (10*1 + 10)*1 4. Π+ 0 (10*1 + 10)*10*

Page 25: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

48 | Automata Theory, Language of Machines and Computability

(A) P-2, Q-1, R-3, S-4 (B) P-1, Q-3, R-2, S-4 (C) P-1, Q-2, R-3, S-4 (D) P-3, Q-2, R-1, S-4

(GATE, 2008) 6. A minimum state deterministic finite automaton accepting the language

L = {w |wŒ{0, 1}*, number of 0 ’s and 1’s in w are divisible by 3 and 5, respectively} has

(A) 15 states (B) 11 states (C) 10 states (D) 9 states (GATE, 2007) 7. Consider the finite automaton in the following figure:

What is the set of reachable states for input string 0011?

(A) {q0, q1, q2} (B) {q0, q1} (C) {q0, q1, q2, q3} (D) {q3} (GATE, 2014) 8. M:

Consider a machine M: The language recognized by M is:

(A) {w Œ{a, b}*|every a in w is followed by exactly two b’s} (B) {w Œ{a, b}*|every a in w is followed by at least two b} (C) {w Œ{a, b}*|w contains the substring abb} (D) {w Œ{a, b}*|w does not contain aa as a substring} (GATE 2005)

Page 26: Finite Automata - PVT 2 CHAPTER Finite Automata Warren McCulloch (1898–1968) and Walter Pitts (1923–1969) Warren S. McCulloch was an American psychiatrist and neurophysiologist

50 | Automata Theory, Language of Machines and Computability

The minimum number of states required in deterministic finite automaton (dfa) equivalent to nfa is

(A) 5 (B) 4 (C) 3 (D) 2

(UGC-NET, Paper II, June 2013)

13. The transition function for the language L = {w|na (w) and nb (w) are both odd } is given by:

d (q0, a) = q1 ; d (q0, b) = (q2) d (q1, a) = q0 ; d (q1, b) = q3

d (q2, a) = q3 ; d (q2, b) = q0 d (q3, a) = q2 ; d (q3, b) = q1

The initial and final state of an automaton are:

(A) q0 and q0 respectively. (B) q0 and q1 respectively. (C) q0 and q2 respectively. (D) q0 and q3 respectively.

(UGC-NET, Paper III, June 2015)