Presentation laddar. Vänta.

Presentation laddar. Vänta.

1 CD5560 FABER Formal Languages, Automata and Models of Computation Exercise 2 Mälardalen University 2007.

Liknande presentationer


En presentation över ämnet: "1 CD5560 FABER Formal Languages, Automata and Models of Computation Exercise 2 Mälardalen University 2007."— Presentationens avskrift:

1 1 CD5560 FABER Formal Languages, Automata and Models of Computation Exercise 2 Mälardalen University 2007

2 2 NEXT WEEK! Midterm Exam 1 Regular Languages Place: U2-114 Time: Tuesday 2007-04-24, 10:15-12:00 It is OPEN BOOK. (This means you are allowed to bring in one book of your choice.) It will cover lectures 1 through 5 (Regular Languages).

3 3 Tenta 29 okt 1999; uppgift 2 (L Salling) Construct (and explain) wich strings contain all three symbols! a) A regular expression over

4 4 Solution or

5 5 Construct (and explain) wich strings contain all three symbols! b) A minimal DFA for a language L over

6 6

7 7 Särskiljningsalgoritm

8 8 c) En reguljär grammatik för L

9 9 Tenta 24 okt 1994; uppgift 2 (L Salling) Reguljära? vars strängar innehåller ett jämnt antal a:n! a) Språket över Ja, språket är reguljärt och beskrivs med ett reguljärt uttryck:

10 10 Tenta 24 okt 1994; uppgift 2 (L Salling) b) De välformade aritmetiska uttrycken formade i alfabetet Nej, språket är inte reguljärt: Ta följande sträng: N stycken a adderas Om språket vore reguljärt skulle det kunna pumpas. Men de N avslutande tecknen består enbart av höger- parenteser och kan inte ändras utan att balansen med vänsterparenteserna förstörs.

11 11 Tenta 15 mars 1995; uppgift 3 (L Salling) Reguljära? a) Ja, språket är reguljärt och beskrivs med ett reguljärt uttryck:

12 12 Tenta 15 mars 1995; uppgift 3 (L Salling) Reguljära? b) Nej. Strängen vars enda palindromprefix längre än 2 är strängen själv, kan inte pumpas någonstans inuti b-block utan att falla ur språket.

13 13 Tenta 15 mars 1995; uppgift 3 (L Salling) Reguljära? c) Nej. Om det vore reguljärt skulle även föregående språk vara det (eftersom det är komplementspråk, och regulariteten bevaras under komplementbildning).

14 14 Pumping Lemma is necessary but not sufficient for RL OBS! The pumping lemma does not give a sufficient condition for a language to be regular! You can not use it to show that language is regular. For example, the language (strings over the alphabet {0,1} consisting of a nonempty even palindrome followed by another nonempty string) is not regular but can still be "pumped" with m = 4: Suppose w=uuRv has length at least 4. If u has length 1, then |v| ≥ 2 and we can take y to be the first character in v. Otherwise, take y to be the first character of u and note that yk for k ≥ 2 starts with the nonempty palindrome yy. For a practical test that exactly characterizes regular languages, see the Myhill-Nerode theorem. The typical method for proving that a language is regular is to construct either a Finite State Machine or a Regular Expression for the language.

15 15 Minimizing DFA’s By Partitioning (Delmängdskonstruktion)

16 16 Minimizing DFA’s Different methods All involve finding equivalent states: States that go to equivalent states under all inputs We will use the Partitioning Method

17 17 Minimizing DFA’s by Partitioning Consider the following DFA (from Forbes Louis): Accepting states are yellow Non-accepting states are blue Are any states really the same?

18 18 S 2 and S 7 are really the same: Both Final states Both go to S6 under input b Both go to S3 under an a S 0 and S 5 really the same. Why? We say each pair is equivalent Are there any other equivalent states? We can merge equivalent states into 1 state

19 19 Partitioning Algorithm First Divide the set of states into Final and Non-final states Partition I Partition II a b S0S0 S1S1 S4S4 S1S1 S5S5 S2S2 S3S3 S3S3 S3S3 S4S4 S1S1 S4S4 S5S5 S1S1 S4S4 S6S6 S3S3 S7S7 *S 2 S3S3 S6S6 *S 7 S3S3 S6S6

20 20 Partitioning Algorithm Now See if states in each partition each go to the same partition S 1 & S 6 are different from the rest of the states in Partition I (but like each other) We will move them to their own partition a b S0S0 S 1 I S 4 I S1S1 S 5 I S 2 II S3S3 S 3 I S4S4 S 1 I S 4 I S5S5 S 1 I S 4 I S6S6 S 3 I S 7 II *S 2 S 3 I S 6 I *S 7 S 3 I S 6 I

21 21 Partitioning Algorithm a b S0S0 S1S1 S4S4 S5S5 S1S1 S4S4 S3S3 S3S3 S3S3 S4S4 S1S1 S4S4 S1S1 S5S5 S2S2 S6S6 S3S3 S7S7 *S 2 S3S3 S6S6 *S 7 S3S3 S6S6

22 22 Partitioning Algorithm Now again See if states in each partition each go to the same partition In Partition I, S 3 goes to a different partition from S 0, S 5 and S 4 We’ll move S3 to its own partition a b S0S0 S 1 III S 4 I S5S5 S 1 III S 4 I S3S3 S 3 I S4S4 S 1 III S 4 I S1S1 S 5 I S 2 II S6S6 S 3 I S 7 II *S 2 S 3 I S 6 III *S 7 S 3 I S 6 III

23 23 Partitioning Algorithm Note changes in S 6, S 2 and S 7 a b S0S0 S 1 III S 4 I S5S5 S 1 III S 4 I S4S4 S 1 III S 4 I S3S3 S 3 IV S1S1 S 5 I S 2 II S6S6 S 3 IV S 7 II *S 2 S 3 IV S 6 III *S 7 S 3 IV S 6 III

24 24 Partitioning Algorithm Now S 6 goes to a different partition on an a from S 1 S 6 gets its own partition. We now have 5 partitions Note changes in S 2 and S 7 a b S0S0 S 1 III S 4 I S5S5 S 1 III S 4 I S4S4 S 1 III S 4 I S3S3 S 3 IV S1S1 S5 IS5 I S 2 II S6S6 S 3 IV S 7 II *S 2 S 3 IV S 6 V *S 7 S 3 IV S 6 V

25 25 Partitioning Algorithm All states within each of the 5 partitions are identical. We might as well call the states I, II III, IV and V. a b S0S0 S 1 III S 4 I S5S5 S 1 III S 4 I S4S4 S 1 III S 4 I S3S3 S 3 IV S1S1 S 5 I S 2 II S6S6 S 3 IV S 7 II *S 2 S 3 IV S 6 V *S 7 S 3 IV S 6 V

26 26 Partitioning Algorithm a b I III I *II IVV III I II IV V II Here they are: V a a a a a b b b b b b

27 27 Chomsky Hierarchy

28 28 Automata theory: formal languages and formal grammars

29 29 Automata theory: formal languages and formal grammars

30 30 Regular Languages Context-Free Languages Non-regular languages


Ladda ner ppt "1 CD5560 FABER Formal Languages, Automata and Models of Computation Exercise 2 Mälardalen University 2007."

Liknande presentationer


Google-annonser