Presentation is loading. Please wait.

Presentation is loading. Please wait.

Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.

Similar presentations


Presentation on theme: "Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language."— Presentation transcript:

1 Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language is one that is recognized by some FA, remember? Hence: (Lemma) if a language is described by a RegEx, then it is a regular language. See Proof: P.67, example 1.56

2 Lemma: If a language is regular, then it is descried by a RegEx. Because A is regular, it is accepted by a DFA. We describe a procedure for converting DFAs into equivalent RegEx. Breaking the procedure into 2 parts, using a new type of FA called Generalized Nondeterministic Finite Automaton (GNFA) Hence, 1 st convert DFA to GNFA, then GNFA to RegEx

3 GNFA is NFA, but Regex could be used as labels on arrows. Figure 1.61 P.70 shows an example of GNFA, which is on the special form that it should ALWAYS have.

4 To convert a NFA to GNFA (and keep the special form) Add a new start state with ε arrow to the old start Add a new accept state with ε arrow coming from the old accept state. If any arrow has more than one label, or there are more than one arrow between two states on the same direction, replace with one arrow and “union” the labels If two states have no arrows between them, add an arrow with Φ label

5 Convert the GNFA to RegEx In GNFA, the start and accept states are must, and they're different, hence no. of states (k) of any GNFA is always >=2. If k>2, then GNFA is constructed by reducing the number to k=2 (an arrow form start to accept states) whose label is the RegEx. Example, converting a 3 state DFA to RegEx. 3k DFA > 5k GNFA > 4k GNFA > 3k GNFA > 2k GNFA > RegEx

6 Convert the GNFA to RegEx The Challenge in reducing the states if greater than 2, by Ripping the a state out of the machine (other than the start, accept states), we call it q rip, we repair the machine by altering the removed q rip with labeled arrow. The label should cover the absence of q rip.The new label form start to accept states is the RegEx. Figure 1.63 P. 72

7 Formal definition of GNFA Just like the DFA, it's a 5-tuple with same parameters except for δ, which can be given as: δ: (Q - {q accept }) X (Q – {q start }) → R R is the collection of all RegEx over the alphabet ∑, The domain of the transition function is (Q - {q accept }) X (Q – {q start }) simply because in GNFA, an arrow connects every state to every other state, except no arrows are coming from q accept or going to q start. Read: P.73 - 76

8 Nonregular Languages Some languages cannot be recognized by any FA (a limitation of FA) Assume the language B = {0 n 1 n | n>=0}. No DFA can recognize it because the resulting number of 0s is unlimited, and therefore no DFA can remember this number of possibilities. But just because the language appears to require unbounded memory doesn't mean it's nonregular. So we need a method to prove the nonregularity

9 Nonregular Languages Assume we have 2 languages C and D, over the alphabet ∑ = {0,1}, where: C = { w | w has an equal no. of 0s and 1s}, and D = { w | w has an equal number of occurrences of 01 and 10 as substrings} Which one is nonregular? See problem 1.48 >> Difficult? We need a mathematical proof for certainty.

10 The pumping lemma for regular languages Theorem (Pumping Lemma): “All regular languages have a special property, if a language doesn't have that property, it is not regular”. The property states that all strings in the language can be “pumped” if they are at least as long as a certain special value called the “pumping length”. In other words: Such string contains a section that can be repeated any number of times with the resulting string remaining in the language

11 Pumping lemma: if A is a regular language, then there is a number p (the pumping length) where, if s is any string in A of length at least p, then s may be divided into three pieces, s=xyz, satisfying the conditions: 1- for each i>=0, xy i z ∈ A 2- |y| >0, and 3- |xy| <= p. Figure 1.71 P.78

12 Fall 2006Costas Busch - RPI12 Regular languages Non-regular languages

13 Fall 2006Costas Busch - RPI13 How can we prove that a language L is not regular? Prove that there is no DFA or NFA or RE that accepts L Difficulty: this is not easy to prove (since there is an infinite number of them) Solution: use the Pumping Lemma !!!

14 Fall 2006Costas Busch - RPI14 The Pigeonhole Principle

15 pigeons pigeonholes

16 Fall 2006Costas Busch - RPI16 A pigeonhole must contain at least two pigeons

17 Fall 2006Costas Busch - RPI17........... pigeons pigeonholes

18 Fall 2006Costas Busch - RPI18 The Pigeonhole Principle........... pigeons pigeonholes There is a pigeonhole with at least 2 pigeons

19 Fall 2006Costas Busch - RPI19 The Pigeonhole Principle and DFAs

20 Fall 2006Costas Busch - RPI20 Consider a DFA with states

21 Fall 2006Costas Busch - RPI21 Consider the walk of a “long’’ string: A state is repeated in the walk of (length at least 4)

22 Fall 2006Costas Busch - RPI22 Pigeons: Nests: (Automaton states) Are more than Walk of The state is repeated as a result of the pigeonhole principle (walk states) Repeated state

23 Fall 2006Costas Busch - RPI23 Consider the walk of a “long’’ string: A state is repeated in the walk of (length at least 4) Due to the pigeonhole principle:

24 Fall 2006Costas Busch - RPI24 Automaton States Pigeons: Nests: (Automaton states) Are more than Walk of The state is repeated as a result of the pigeonhole principle (walk states) Repeated state

25 Fall 2006Costas Busch - RPI25...... Repeated state Walk of.... Arbitrary DFA If, by the pigeonhole principle, a state is repeated in the walk In General:

26 Fall 2006Costas Busch - RPI26 Walk of Pigeons: Nests: (Automaton states) Are more than (walk states).... A state is repeated

27 Fall 2006Costas Busch - RPI27 The Pumping Lemma

28 Fall 2006Costas Busch - RPI28 Take an infinite regular language There exists a DFA that accepts states (contains an infinite number of strings)

29 Fall 2006Costas Busch - RPI29 (number of states of DFA) then, at least one state is repeated in the walk of...... Take string with Walk in DFA of Repeated state in DFA

30 Fall 2006Costas Busch - RPI30 Take to be the first state repeated.... There could be many states repeated.... Second occurrence First occurrence Unique states One dimensional projection of walk :

31 Fall 2006Costas Busch - RPI31.... Second occurrence First occurrence One dimensional projection of walk : We can write

32 Fall 2006Costas Busch - RPI32... In DFA:... contains only first occurrence of

33 Fall 2006Costas Busch - RPI33 Observation:lengthnumber of states of DFA Since, in no state is repeated (except q) Unique States...

34 Fall 2006Costas Busch - RPI34 Observation:length Since there is at least one transition in loop...

35 Fall 2006Costas Busch - RPI35 We do not care about the form of string... may actually overlap with the paths of and

36 Fall 2006Costas Busch - RPI36 The string is accepted Additional string:... Do not follow loop...

37 Fall 2006Costas Busch - RPI37 The string is accepted... Follow loop 2 times Additional string:...

38 Fall 2006Costas Busch - RPI38 The string is accepted... Follow loop 3 times Additional string:...

39 Fall 2006Costas Busch - RPI39 The string is accepted In General:... Follow loop times...

40 Fall 2006Costas Busch - RPI40 Therefore: Language accepted by the DFA...

41 Fall 2006Costas Busch - RPI41 In other words, we described: The Pumping Lemma !!!

42 Fall 2006Costas Busch - RPI42 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we can write with and such that: (critical length)

43 Fall 2006Costas Busch - RPI43 In the book: Critical length = Pumping length

44 Fall 2006Costas Busch - RPI44 Applications of the Pumping Lemma

45 Fall 2006Costas Busch - RPI45 Observation: Every language of finite size has to be regular Therefore, every non-regular language has to be of infinite size (contains an infinite number of strings) (we can easily construct an NFA that accepts every string in the language)

46 Fall 2006Costas Busch - RPI46 Suppose you want to prove that An infinite language is not regular 1. Assume the opposite: is regular 2. The pumping lemma should hold for 3. Use the pumping lemma to obtain a contradiction 4. Therefore, is not regular

47 Fall 2006Costas Busch - RPI47 Explanation of Step 3: How to get a contradiction 2. Choose a particular string which satisfies the length condition 3. Write 4. Show thatfor some 5. This gives a contradiction, since from pumping lemma 1. Let be the critical length for

48 Fall 2006Costas Busch - RPI48 Note: It suffices to show that only one string gives a contradiction You don’t need to obtain contradiction for every

49 Fall 2006Costas Busch - RPI49 Theorem: The language is not regular Proof: Use the Pumping Lemma Example of Pumping Lemma application

50 Fall 2006Costas Busch - RPI50 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma

51 Fall 2006Costas Busch - RPI51 Let be the critical length for Pick a string such that: and length We pick

52 Fall 2006Costas Busch - RPI52 with lengths From the Pumping Lemma: we can write Thus:

53 Fall 2006Costas Busch - RPI53 From the Pumping Lemma: Thus:

54 Fall 2006Costas Busch - RPI54 From the Pumping Lemma: Thus:

55 Fall 2006Costas Busch - RPI55 BUT: CONTRADICTION!!!

56 Fall 2006Costas Busch - RPI56 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore: END OF PROOF

57 Fall 2006Costas Busch - RPI57 Regular languages Non-regular language

58 Read P. 80 – 82 (examples) Solve Exercises and Problems (P. 83 – 98) Prepare for a quiz!


Download ppt "Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language."

Similar presentations


Ads by Google