abc

11
ASSIGNMENT -1 OF AUTOMATA THEORY SUBMITTED TO: SUBMITTED BY: Ms. MANJIT KAUR GAGANPREET KAUR 1

Transcript of abc

Page 1: abc

ASSIGNMENT -1

OF

AUTOMATA THEORY

SUBMITTED TO: SUBMITTED BY:

Ms. MANJIT KAUR GAGANPREET KAUR

ROLL NO: 42

SECTION: B1803

1

Page 2: abc

PART A:

1. The following are the state diagrams of two DFAs, M1 and M2. Answer the following questions about each of these machines.

a. What is the start state?Ans: 1) M1 start state is q12) M2 start state is q1

b. What is the set of accept states?Ans: accept states are the final states. So in this case, set of accept states are:-

1) M1 it is q22) M2 it is q1,q4

c. What sequence of states does the machine go through on input aabb?Ans:

For M1 :-

q1q2q3q1q1 For M2 :-

q1q1q1q2q4

D.Does the machine accept the string aabb?Ans:

1) For M1:-

2

Page 3: abc

q1q2q3q1q1

Since it does not end at any final state. So this string is not acceptable.

2) For M2:- q1q1q1q2q4

Since it ends at q4 which is one of the final state. So this string is acceptable.

e. Does the machine accept the string e?

Ans: No both the machines will not accept the string e because inputs given to the machine are a and b. rest inputs will not be acceptable. There exists no node namely e.

Ques 2. For ∑= {0, 1}, Construct DFA’s that accepts the set consisting of (a) All strings with at least one 0 and exactly two 1’s.

Ans: - 01010

(b) All strings ending in 010.

3

Page 4: abc

Ans :-

(c) All strings with no more than three 0’s.

Ans :- 11010

4

Page 5: abc

Ques 3. Construct DFA equivalent to the NDFA described by fig below: -

0, 1 1

0, 1 1

0

^ 0, 1

0

The transition table as per given diagram of the NDFA is as shown in figure;

States 0 1

Q0 q0,q3 q0,q1

Q1 q2

Q2 q2 q2

Q3 q4

Q4 q4 q4

And the corresponding transition table in DFA is as given…

States 0 1

[q0] [q0,q3] [q0,q1]

[q0,q3] [q0,q3,q4] [q0,q1]

[q0,q1] [q0,q3] [q0,q1,q2]

[q0,q3,q4] [q0,q3,q4] [q0,q1,q4]

[q0,q1,q2] [q0,q3,q2] [q0,q1,q2]

[q0,q1,q4] [q0,q3,q4] [q0,q1,q2,q4]

[q0,q2,q3] [q0,q3,q2,q4] [q0,q1,q2]

[q0,q1,q2,q4] [q0,q3,q2,q4] [q0,q1,q2,q4]

5

q1

q0

q4

q3

q2

Page 6: abc

[q0,q2,q3,q4] [q0,q3,q2,q4] [q0,q1,q2,q4]

PART B:

Ques 4. Construct a Mealy machine which is equivalent to the Moore machine defined by table given below.

Present states Next state Outputa=0 a=1

q0 q1 q1 1

q1 q3 q2 0q2 q2 q0 0q3 q0 q1 1

Ans: The corresponding Mealy machine is as shown below:

Present states Next states

A=0 Output A=1 output

->q0 Q1 0 Q1 0

Q1 Q3 1 Q2 0

Q2 Q2 0 Q0 1

Q3 Q0 1 Q1 0

Ques 5. Construct a Moore machine which is equivalent to the Mealy machine defined by table given below.

6

Page 7: abc

Present states Next state a=0state output

a=1state output

q1 q1 1 q1 0q2 q2 1 q4 1

q3 q4 1 q2 1

q4 q3 0 q3 0

Ans: now rewriting states, we do get what follows next….

q11 (q10 for 0)

0 (q11 for 1)

q21

q30

q41

The table corresponding table according to the Mealy machine is as shown :-

Present state Next state

A=0 output A=1 output

Q10 Q11 1 Q10 0

Q11 Q11 1 Q1 0

Q2 Q2 1 Q4 1

Q3 Q4 1 Q2 1

Q4 Q3 0 Q3 0

And finally the Moore machine is constructed as follows.

Present states Next state Output

7

Page 8: abc

a=0 a=1q0 q11 q10 0

q10 Q11 Q10 0Q11 Q11 Q10 1Q2 Q2 Q4 1Q3 Q4 Q2 0Q4 Q3 Q3 1

Ques 6. Construct a minimum state automaton equivalent to given automaton M whose transition table is defined by table given below.

Ans:

Step 1:

Q1= {q3}, Q2 = { q1,q2, q4,q5,q6,q7}

Step2.

π0={{q3},{q0,q1,q2,q4,q5,q6,q7}}

8

State Input

a b

q0 q0 q1

q1 q2 q0

q2 q1 q3

q0 q3

q4 q5 q3

q5 q4 q6

q6 q6 q5

q7 q3 q6

q3

Page 9: abc

step3.

Enacting π1, π2 and so on until πn= πn+1

π1= {{q3},{q0,q1,q5,q6},{q2,q4},{q7}}

π2= {{q3},{q0,q6},{q1,q5},{q2,q4},{q7}}

π3= {{q3},{q0,q6},{q1,q5},{q2,q4},{q7}}

From the above equation, we have,

π3=π2

Hence the minimized automaton is as follows:-

States A B

[q0,q6] [q0,q6] [q1,q5]

[q1,q5] [q2,q4] [q0,q6]

[q2,q4] [q1,q5] [q3]

[q3] [q0,q6] [q3]

[q7] [q3] [q0,q6]

The figure is shown below:-

9

Page 10: abc

10