1 / 8

03-60-214: Lab 3

03-60-214: Lab 3. Jan 30, Winter 2004. Exercises.  Draw the diagrams of an FA (DFA or NFA) for the following languages, the alphabet is {a, b, ..., z}. Write the regular expression after you have the diagram. A string containing an 'a'; A string containing two consecutive 'a's. 

naida-good
Download Presentation

03-60-214: Lab 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 03-60-214: Lab 3 Jan 30, Winter 2004 Jianguo Lu

  2. Exercises •  Draw the diagrams of an FA (DFA or NFA) for the following languages, the alphabet is {a, b, ..., z}. Write the regular expression after you have the diagram. • A string containing an 'a'; • A string containing two consecutive 'a's.  •  Write regular expressions for each of the following languages over the alphabet {a ,b, c}: the strings that the first a precede the first b. The string with no ‘a’ or no ‘b’ is legal. • Convert the following NFA to DFA, and minimize it. Jianguo Lu

  3. solutions • Draw the diagrams of an FA (DFA or NFA) for the following languages, the alphabet is {a, b, ..., z}. Write the regular expression after you have the diagram. • A string containing an 'a'; • A string containing two consecutive 'a's.  • Solutions a-z a-z a q2 q1 a-z a-z a a q3 q1 q2 Jianguo Lu

  4. Problem 2 • Write regular expressions for each of the following languages over the alphabet {a ,b, c}: the strings that the first a precede the first b. The string with no ‘a’ or no ‘b’ is legal. • Solution: • put the problem in another way: before ‘a’ there should not be any ‘b’; • It can be anything after ‘a’; • If both ‘a’ and ‘b’ appears in the string, ‘a’ must precedes ‘b’, otherwise it is a legal string. c*a[abc]*|[bc]* Jianguo Lu

  5. Problem 3 • NFA to DFA • First compute the epsilon closure of the start state. Let the closure as the new start state. E(0)={0}; Let {0} equals to A, the new start state; • Next compute all the states that can be reached on all input symbols from A: Move(A, $)={1}; E(move(A,$)=e({1}) = {1,2,3,5,7}, let it be a new state B. E(move(A,L)=e({}) ={} Since we generated a new state B, we need to try all the input on B E(move(B,$))=e({4,8})={4, 7,2,3 5,8}, let it be a new state C. E(move(B,L))=e({6})={6,7,2,3,5}, let it be a new state D. Now compute the states can be reached from C and D, on all input symbols. E(move(C,$))=e({4,8})=C E(move(C,L))=e({6})=D E(move(D,$))=e({4,8})=C E(move(D,L))=e({6})=D C is going to be the final state because it contains final states 4 and 8. Jianguo Lu

  6. The corresponding DFA $ $ $ C A B L L $ D L Jianguo Lu

  7. Minimization of the DFA • The initial partition is (ABD) (C), because C is the final state, while others are not. • Lets try to split group (ABD) • Move(A, $)=B • Move(B,$)=C, • Since B and C are distinguishable state, so are A and B. • So (ABD) is split into (A)(BD) • Let’s try to see whether (BD) can be further split • Try B and D on all input symbols, first on $ • Move(B,$)=C • Move(D,$)=C • Can’t tell the difference, so try the next symbol • Try B and D on symbol L: • Move(B,L)=D • Move(D,L)=D • Still can’t tell the difference; • All the possible symbols are tried, B and D are equivalent. Jianguo Lu

  8. The minimized DFA $ $ $ C A BD L L Jianguo Lu

More Related