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.

Slides:



Advertisements
Similar presentations
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
Advertisements

3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
1 Non-regular languages. 2 Regular languages Non-regular languages.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
CHAPTER 1 Regular Languages
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Nonregular Languages How do you prove a language to be regular? How do you prove a language to be nonregular? A Pumping Lemma.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Computation Automata Theory Dr. Ayman Srour.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE 105 theory of computation
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
PROPERTIES OF REGULAR LANGUAGES
NPDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
DPDA Deterministic PDA
Non-Deterministic Finite Automata
Non Deterministic Automata
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Non-regular languages
CS21 Decidability and Tractability
More Applications of the Pumping Lemma
CHAPTER 1 Regular Languages
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

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

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

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.

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

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

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

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

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

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.

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

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

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

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 !!!

Fall 2006Costas Busch - RPI14 The Pigeonhole Principle

pigeons pigeonholes

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

Fall 2006Costas Busch - RPI pigeons pigeonholes

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

Fall 2006Costas Busch - RPI19 The Pigeonhole Principle and DFAs

Fall 2006Costas Busch - RPI20 Consider a DFA with states

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

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

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:

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

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

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

Fall 2006Costas Busch - RPI27 The Pumping Lemma

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

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

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 :

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

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

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

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

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

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

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

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

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

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

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

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)

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

Fall 2006Costas Busch - RPI44 Applications of the Pumping Lemma

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)

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

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

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

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

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

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

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

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

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

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

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

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

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