Finite Automata. Definition : Finite Automata is a five Tuple (Q,∑,δ,q0,F) – Q is a finite set...

download 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.

of 28

  • date post

    13-Dec-2015
  • Category

    Documents

  • view

    230
  • download

    0

Embed Size (px)

Transcript of Finite Automata. Definition : Finite Automata is a five Tuple (Q,∑,δ,q0,F) – Q is a finite set...

  • Slide 1

Finite Automata Slide 2 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 Slide 3 Examples of Finite Automata 1 0 q1 q2 0 1 M1 Slide 4 Cont.. Formal Description of M1 : ({ q1,q2},{0,1}, ,q1,{q2}) The transition function : L(M1) = { | ends in a 1 } 01 q1 q2 q1q2 Slide 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. Slide 6 Cont....... Step 3: 1 1 qeven 0 0 qodd Slide 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. Slide 8 Example 2: FA qq0 1 q00 0 0 0 1 0 0,1 q001 Slide 9 Class of Regular Languages is Closed Under Union Operation Let M1 recognize A1 where M1=(Q 1,, 1,q 1,F 1 ) Let M2 recognize A2 where M2=(Q 2,, 2,q 2,F 2 ) Construct M to recognize A1 U A2 where M==(Q,,,q 0,F) Step 1: Q= {(r1,r2) | r1 Q 1 and r2 Q 2 } This is cartesian product of sets Q 1 and Q 2 Step2 : is the same for M1 and M2 Slide 10 Step3 : For each (r1,r2) Q and each a ((r1,r2),a) = ((r1,a), (r2,a)) Step 4: q 0 is the pair (q 1, q 2 ) Step5 : F= {(r1,r2) | r1 F 1 and r2 F 2 } Slide 11 Example Problem Each of the following languages is the intersection of two simpler language In each part construct DFAs 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 as and atleast 2 bs } Slide 12 Solution M1 = ({q 0,q 1,q 2,q 3,},{a,b}, ,q 0,{q 3 }) M2= ({q 0,q 1,q 2,},{a,b}, ,q 0,{q 2 }) Transition for M1 :Transition of M2: ab q0q0 q1q1 q0q0 q1q1 q2q2 q1q1 q2q2 q3q3 q2q2 q3q3 q3q3 q3q3 ab q0q0 q0q0 q1q1 q1q1 q1q1 q2q2 q2q2 q2q2 q2q2 Slide 13 Step1 : Q= {(r1,r2) | r1 Q 1 and r2 Q 2 } Q = {(q 0, q 0 ),(q 0, q 1 ),(q 0, q 2 ), (q 1, q 0 ),(q 1, q 1 ),(q 1, q 2 ),(q 2, q 0 ),(q 2, q 1 ),(q 2, q 2 ),(q 3, q 0 ),(q 3, q 1 ), (q 3, q 2 )} Step2 : ((q 0, q 0 ),a) = (q 1, q 0 ) ((q 0, q 1 ),a) = (q 1, q 1 ) And so on.. Slide 14 ab q 0, q 0 q 1, q 0 q 0, q 1 q 1, q 1 q 0, q 2 q 1, q 2 q 0, q 2 q 1, q 0 q 2, q 0 q 1, q 1 q 2, q 1 q 1, q 2 q 2, q 2 q 1, q 2 q 2, q 0 q 3, q 0 q 2, q 1 q 3, q 1 q 2, q 2 q 3, q 2 q 2, q 2 Q 3, q 0 q 3, q 0 q 3, q 1 q 3, q 2 Slide 15 Conversion of NFA to DFA 1 a 2 a,b b ab {1}{1},{2}{2} e{1} Slide 16 Construction N= (Q 1,, 1,q 1,F 1) Q 1 = ({1},{2}) DFA M = (Q 2,, 2,q 2,F 2) Q 2 = P(Q 1 ) Q 2 = {{e},{1},{2},{1,2}} Slide 17 ab {e} {1}{1,2}{2} {e}{1} {1,2} 1 1,2 2 a b b e a,b a Slide 18 Regular Expression to NFA R S L(R)UL(S) L(R)L(S) R S Slide 19 L(R*) R Slide 20 Example (0U1)*000(0U 1)* Step 1 : 0 1 Slide 21 (0U1) 0 1 Slide 22 (0U1)* 0 1 Slide 23 00 0 Slide 24 0 1 00 0 1 0 Slide 25 NFA to Regular Expressions 1 a 2 b b a Slide 26 1 a 2 b b a S Accept Slide 27 2 S aUba*b Ea*b S Accept a*b(aU(ba*b))* E Slide 28 HomeWork Work out the Problems in Exercise 2.