Presentation is loading. Please wait.

Presentation is loading. Please wait.

Finite Automata.

Similar presentations


Presentation on theme: "Finite Automata."— Presentation transcript:

1 Finite Automata

2 Finite Automata Definition :
Finite Automata is a five Tuple (Q,∑,δ,q0,F) Q is a finite set called states ∑ is a finite set called alphabets Q X ∑ -> Q is a transition function Q0 is a start state F is a set of accept states

3 Examples of Finite Automata
1 1 q2 q1 M1

4 Cont…….. Formal Description of M1 :
({ q1,q2},{0,1}, δ,q1,{q2}) The transition function : L(M1) = {ω | ω ends in a 1 } 1 q1 q2

5 Designing a Finite Automata
Example 1 : Design a finite automata for the language that has strings with odd number of 1s. Step 1 : construct two states q-even(even so far) and q-odd (odd so far). Step2 : Make q-odd the accepting state because the language has odd number of ones.

6 Cont Step 3: 1 qodd qeven 1

7 Example 2 : Language for all strings that contain substring 001.
Step1 : Assign states q,q0,q00,q001. Step2 : Start state q. Step3 : Accept state q001.

8 Example 2: FA 0,1 1 q q0 q00 q001 1

9 Class of Regular Languages is Closed Under Union Operation
Let M1 recognize A1 where M1=(Q1,∑,δ1,q1,F1) Let M2 recognize A2 where M2=(Q2,∑,δ2,q2,F2 ) Construct M to recognize A1 U A2 where M==(Q,∑,δ,q0,F) Step 1: Q= {(r1,r2) | r1 Є Q1 and r2 Є Q2} This is cartesian product of sets Q1 and Q2 Step2 : ∑ is the same for M1 and M2

10 Step3 : For each (r1,r2) Є Q and each a Є ∑ δ((r1,r2),a) = (δ(r1,a), δ(r2,a)) Step 4: q0 is the pair (q1, q2) Step5 : F= {(r1,r2) | r1 Є F1 and r2 Є F2}

11 Example Problem Each of the following languages is the intersection of two simpler language In each part construct DFA’s for the simpler language then combine them using the construction discussed in footnote 3 of pg46 in the book to give state diagram of a DFA for the language given.In all parts the alphabets are {a,b} .{ω | ω has atleast 3 a’s and atleast 2 b’s }

12 Solution M1 = ({q0,q1,q2,q3,},{a,b}, δ,q0,{q3})
M2= ({q0,q1,q2,},{a,b}, δ,q0,{q2}) Transition δ for M1 : Transition of M2: a b q0 q1 q2 q3 a b q0 q1 q2

13 Step1 : Q= {(r1,r2) | r1 Є Q1 and r2 Є Q2} Q = {(q0, q0),(q0, q1),(q0, q2), (q1, q0),(q1, q1),(q1, q2),(q2, q0),(q2, q1),(q2, q2),(q3, q0),(q3, q1), (q3, q2)} Step2 : δ ((q0, q0),a) = (q1, q0 ) δ ((q0, q1),a) = (q1, q1 ) And so on…..

14 a b q0, q0 q1, q0 q0, q1 q1, q1 q0, q2 q1, q2 q2, q0 q2, q1 q2, q2 q3, q0 q3, q1 q3, q2 Q3, q0

15 Conversion of NFA to DFA
b {1} {1},{2} {2} e 1 a,b b 2

16 Construction N= (Q1,∑,δ1,q1,F1) Q1 = ({1},{2}) DFA M = (Q2,∑,δ2,q2,F2)
Q2 = P(Q1) Q2 = {{e},{1},{2},{1,2}}

17 a b {e} {1} {1,2} {2} a a,b b 1,2 1 2 a a,b b e

18 Regular Expression to NFA
L(R)UL(S) ε R ε ε ε ε S L(R)L(S) ε S R

19 L(R*) ε ε ε R ε

20 Example (0U1)*000(0U 1)* Step 1 : 1

21 (0U1) ε 1 ε

22 (0U1)* ε ε ε 1 ε ε

23 ε ε

24 ε ε ε 1 ε ε ε ε ε ε ε ε 1 ε

25 NFA to Regular Expressions
1 b b 2 a

26 a S 1 b b 2 a Accept

27 aUba*b E S 2 a*b E Accept a*b(aU(ba*b))* S Accept

28 HomeWork Work out the Problems in Exercise 2 .


Download ppt "Finite Automata."

Similar presentations


Ads by Google