Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.

Slides:



Advertisements
Similar presentations
Lecture 9,10 Theory of AUTOMATA
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.
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
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 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
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.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
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.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
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.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
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 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Theory of Languages and Automata
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.
Lecture 5 Sept 06, 2012 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
CHAPTER 1 Regular Languages
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
Regular Expressions Costas Busch - LSU.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
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.
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.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
1 Introduction to the Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Non Deterministic Automata
Single Final State for NFA
Infiniteness Test The Pumping Lemma Nonregular Languages
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
Elementary Questions about Regular Languages
Non-regular languages
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
Chapter 1 Regular Language - 02
CS21 Decidability and Tractability
LECTURE # 07.
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to NFA Pumping lemma

Theorem: A language is regular if and only if it is accepted by a regular expression. Proof: Show how to convert from regular expression to NFA and vice- versa. Let L be accepted by a regular expression. We prove that it is regular, i.e., there is a NFA for L. Cases to consider: (1)empty-set (2) single symbol {a} (3) {  } (4)(a) R1 + R2 (b) R1. R2 (c) R1* (1), (2) and (3) are easy base cases. For (4), inductively construct NFA’s for R1 and R2, and from it construct an NFA for R.

Converse is shown as follows: Given a DFA (or NFA), we remove states one by one until we have one state left. At this point, we can write down the regular expression. The idea is to use generalized NFA, one in which the transitions are labeled not by a single symbol, but by a regular expression. Example of GNFA:

Conversion from DFA to regular expression Key step: how to remove a state of a GNFA

So far, we have seen how to design DFA, NFA or regular expressions for various languages. We also learned how to convert: NFA  DFA DFA  regular expression Regular expression  NFA But there are many languages for which we can never build a DFA or an NFA or a regular expression. Can you think of such a language?

Two fundamental examples L = { a n b n | n > 0} This contains strings , ab, aabb, aaabbb, … etc. Why is it not possible to create a DFA for L? L’ = { w | w is a balanced parentheses string over [, ] } This includes strings such as [ ], [ ][ ], [ [ ] ], etc. How can we show that it is impossible to build DFA for these languages?

A tool known as pumping lemma is used to show that certain languages are not regular. Idea: Because a DFA D has a finite number of states, say n D, before reading n D + 1 input characters, D must enter some state q for a second time. Characteristics of Regular Languages

The Pumping Lemma If L is a regular language, then:  a value n such that:  w in L such that |w| > n,  x,y,z such that w = xyz where |y| > 0, |xy| < n  i > 0, xy i z  L

Proof: let L = L(D) Given w = w 1 w 2 … w k, let s 1 s 2 … s k+1 be the consecutive states reached by DFA D on w (where s 1 = s the start state) If k>n D, then by the pigeon hole principle, we know  i,j, (i<j), i, j  {1 … k+1} such that s i = s j Then x = w 1 w 2 … w i-1 puts D in state s i and so does xy = w 1 w 2 … w i-1 w i … w j-1 … and so does xy t = w 1 w 2 … w i-1 (w i … w j-1 ) t

Proof … visualization x = w 1 w 2 … w i-1 y = w i … w j-1 z = w j … w k accept s1s1 s k+1 sisi

Proof … continued z = w j … w k takes D from state s i to s k+1, an accept state So xy t z = w 1 w 2 … w i-1 (w i … w j-1 ) t w j … w k takes D from the start state to the same accept state

Crucial use of the Pumping Lemma: to show that L is not regular ! Using the contrapositive A implies B B implies A

the Pumping Lemma in contrapositive form L is NOT a regular language  n in Z  w such that |w| > n  x,y,z such that w = xyz and |y|>0 and |xy|<n  i>0 s.t. xy i z is NOT in L If then

Applications of pumping lemma Therefore L is not regular.

A technique for showing lower-bound on the number of states in a DFA Example: Consider the regular language L = { x | the 5-th symbol from the right-end of x is 1} over the alphabet  = {0, 1}. We will show that any DFA for this language requires at least 32 states. Let w 0 = 00000, w 1 = 00001, …, w 31 = be the list of all strings of length 5 over . Let M be any DFA accepting L. Let q j =  (s, w j ) be the state reached from the starting state on input w j. We will argue that all q j ’s must be distinct. (The proof will be completed in lecture.) Note: Problem 4 of HW 4 requires you to use this technique.