300 likes | 417 Views
CD5560 FABER Formal Languages, Automata and Models of Computation Exercise 2 Mälardalen University 2007. NEXT WEEK! Midterm Exam 1 Regular Languages. Place: U2-114 Time: Tuesday 2007-04-24, 10:15-12:00 It is OPEN BOOK .
E N D
CD5560 FABER Formal Languages, Automata and Models of Computation Exercise 2 Mälardalen University 2007
NEXT WEEK!Midterm Exam 1Regular 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).
Tenta 29 okt 1999; uppgift 2 (L Salling) Construct (and explain) a) A regular expression over wich strings contain all three symbols!
Solution or
Construct (and explain) b) A minimal DFA for a language L over wich strings contain all three symbols!
Tenta 24 okt 1994; uppgift 2 (L Salling) Reguljära? a) Språket över vars strängar innehåller ett jämnt antal a:n! Ja, språket är reguljärt och beskrivs med ett reguljärt uttryck:
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.
a) Tenta 15 mars 1995; uppgift 3 (L Salling) Reguljära? Ja, språket är reguljärt och beskrivs med ett reguljärt uttryck:
b) Tenta 15 mars 1995; uppgift 3 (L Salling) Reguljära? 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.
c) Tenta 15 mars 1995; uppgift 3 (L Salling) Reguljära? 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).
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.
Minimizing DFA’s By Partitioning (Delmängdskonstruktion)
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
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?
S2and S7are really the same: • Both Final states • Both go to S6 under input b • Both go to S3 under an a • S0and S5 really the same. Why? • We say each pair is equivalent • Are there any other equivalent states? • We can merge equivalent states into 1 state
Partitioning Algorithm • First • Divide the set of states into • Final and • Non-final states • Partition I • Partition II
Partitioning Algorithm • Now • See if states in each partition each go to the • same partition • S1 &S6 are different from the rest of the states in Partition I • (but like each other) • We will move them to their own partition
Partitioning Algorithm • Now again • See if states in each partition each go to the same partition • In Partition I, S3goes • to a different partition • from S0, S5andS4 • We’ll move S3 to its own partition
Partitioning Algorithm • Note changes in S6, S2 and S7
Partitioning Algorithm • Now S6 goes to a different partition on an a from S1 • S6 gets its own partition. • We now have 5 partitions • Note changes in S2 and S7
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.
b b b V b a a a a b a b Partitioning Algorithm Here they are:
Non-regular languages Context-Free Languages Regular Languages