Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
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.
CS 3240: Languages and Computation Properties of Context-Free Languages.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
CS21 Decidability and Tractability
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
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.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
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.
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.
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.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
Lexical Analysis Part 2 Professor Yihjia Tsai Tamkang University.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
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.
Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
Solution Exercise 1.43 a A r r s q q > b b e b s’ q r q’ b r’ a A’
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Exercise 1 Consider a language with the following tokens and token classes: ID ::= letter (letter|digit)* LT ::= " " shiftL ::= " >" dot ::= "." LP ::=
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
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.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Computation Automata Theory Dr. Ayman Srour.
Dr. Gary Weiss, January Computer Language Theory Chapter 1: Regular Languages.
Chapter 2 Regular Languages & Finite Automata. Regular Expressions A finitary denotation of a regular language over . ØL Ø = Ø aL a = {a} where a ∈ 
Foundations of Computing Science
Standard Representations of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Intro to Theory of Computation
Regular Expression We shall build expressions from the symbols using simple operations include concatenation, union and kleen closure. Several intuitive.
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non-Deterministic Finite Automata
Non Deterministic Automata
Elementary Questions about Regular Languages
Non-regular languages
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
Chapter 1 Regular Language
CHAPTER 1 Regular Languages
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)

Regular Expressions (Def. 1.26) Given an alphabet , R is a regular expression if: 1.R = a, with a  2.R =  3.R =  4.R = (R 1  R 2 ), with R 1 and R 2 regular expressions 5.R = (R 1  R 2 ), with R 1 and R 2 regular expressions 6.R = (R 1 *), with R 1 a regular expression

Thm 1.28: RL ~ RE We need to prove both ways: If a language is described by a regular expression, then it is regular (Lemma 1.29) (Last week we saw how we can convert a regular expression R into an NFA M such that L(R)=L(M)) Today we do the second part: If a language is regular, then it can be described by a regular expression (Lemma 1.32)

Generalized NFA Generalized nondeterministic finite automaton M=(Q, , , q start, q accept ) with Q finite set of states  the input alphabet q start the start state q accept the accept state  :(Q\{q accept })  (Q\{q start })  R the transition function ( R is the set of regular expressions over  )

Example GNFA qSqS qAqA 01* 0 0*   

Characteristics of GNFA’s   :(Q\{q accept })  (Q\{q start })  R The interior Q\{q accept,q start } is fully connected by  From q start only ‘outgoing transitions’ To q accept only ‘ingoing transitions’ Impossible q i  q j transitions are “  (q i,q j ) =  ” qSqS qAqA RRRR Observation: This GNFA: recognizes the language L(R)

Proof Idea of Lemma 1.32 Proof idea (given a DFA M): Construct an equivalent GNFA M’ with k  2 states Reduce one-by-one the internal states until k=2 This GNFA will be of the form This regular expression R will be such that L(R) = L(M) qSqS qAqA R

DFA M  Equivalent GNFA M’ Let M have k states Q={q 1,…,q k } - Add two states q accept and q start qSqS q1q1  - Connect q start to earlier q 1 : qiqi  qjqj - Complete missing transitions by qAqA qjqj  - Connect old accepting states to q accept - Join multiple transitions: qiqi 0 qjqj 1 becomes qiqi 0101 qjqj

Remove Internal state of GNFA If the GNFA M has more than 2 states, ‘rip’ internal q rip to get equivalent GNFA M’ by: - Removing state q rip : Q’=Q\{q rip } - Changing the transition function  by  ’(q i,q j ) =  (q i,q j )  (  (q i,q rip )(  (q i,q j ))*  (q rip,q j )) for every q i  Q’\{q accept } and q j  Q’\{q start } qiqi R 4  (R 1 R 2 *R 3 ) qjqj qiqi R2R2 qjqj R4R4 q rip R1R1 R3R3 =

Proof Lemma 1.32 Let M be DFA with k states Create equivalent GNFA M’ with k+2 states Reduce in k steps M’ to M’’ with 2 states The resulting GNFA describes a single regular expressions R The regular language L(M) equals the language L(R) of the regular expression R

Recap Regular Languages = Regular Expressions Let R be a regular expression, then there exists an NFA M such that L(R) = L(M) The language L(M) of a DFA M is equivalent to a language L(M’) of a GNFA = M’, which can be converted to a two-state M’’ The transition q start  R  q accept of M’’ obeys L(R) = L(M’’) Hence: RE  NFA = DFA  GNFA  RE

Nonregular Languages §1.4 Which languages cannot be recognized by finite automata? Example: L={ 0 n 1 n | n  N } ‘Playing around’ with FA convinces you that the ‘finiteness’ of FA is problematic for “all n  N” The problem occurs between the 0 n and the 1 n Informal: the memory of a FA is limited by the the number of states |Q|

Repeating DFA Paths q1q1 qkqk qjqj Consider an accepting DFA M with size |Q| On a string of length p, p+1 states get visited For p  |Q|, there must be a j such that the computational path looks like: q 1,…,q j,…,q j,…,q k

Repeating DFA Paths q1q1 qkqk qjqj The action of the DFA in q j is always the same. If we repeat (or ignore) the q j,…,q j part, the new path will again be an accepting path

Line of Reasoning Proof by contradiction: Assume that L is regular Hence, there is a DFA M that recognizes L For strings of length  |Q| the DFA M has to ‘repeat itself’ Show that M will accept strings outside L Conclude that the assumption was wrong Note that we use the simple DFA, not the more elaborate (but equivalent) NFA or GNFA

Pumping Lemma (Thm 1.37) For every regular language L, there is a pumping length p, such that for any string s  L and |s|  p, we can write s=xyz with 1) x y i z  L for every i  {0,1,2,…} 2) |y|  1 3) |xy|  p Note that 1) implies that xz  L 2) says that y cannot be the empty string  Condition 3) is not always used

Formal Proof of Pumping Lemma Let M = (Q, , ,q 1,F) with Q = {q 1,…,q p } Let s = s 1 …s n  L(M) with |s| = n  p Computational path of M on s is the sequence r 1,…,r n+1  Q n+1 with r 1 = q 1, r n+1  F and r t+1 =  (r t,s t ) for 1  t  n Because n+1  p+1, there are two states such that r j = r k (with j<k and k  p+1) Let x = s 1 …s j–1, y = s j …s k–1, and z = s k …s n+1 x takes M from q 1 =r 1 to r j, y takes M from r j to r j, and z takes M from r j to r n+1  F As a result: xy i z takes M from q 1 to r n+1  F (i  0)

Formal Proof of Pumping Lemma Let M = (Q, , ,q 1,F) with Q = {q 1,…,q p } Let s = s 1 …s n  L(M) with |s| = n  p Computational path of M on s is the sequence r 1,…,r n+1  Q n+1 with r 1 = q 1, r n+1  F and r t+1 =  (r t,s t ) for 1  t  n Because n+1  p+1, there are two terms such that r j = r k (with j<k and k  p+1) Let x = s 1 …s j–1, y = s j …s k–1, and z = s k …s n+1 x takes M from q 1 =r 1 to r j, y takes M from r j to r j, and z takes M from r j to r n+1  F As a result: xy i z takes M from q 1 to r n+1  F (i  0) |y|  1 and |xy|  p x y i z  L(M) for every i  {0,1,2,…}

Pumping 0 n 1 n (Ex. 1.38) Assume that B = {0 n 1 n | n  0} is regular Let p be the pumping length, and s = 0 p 1 p  B P.L.: s = xyz = 0 p 1 p, with xy i z  B for all i  0 Three options for y: 1) y=0 k, hence xyyz = 0 p+k 1 p  B 2) y=1 k, hence xyyz = 0 p 1 k+p  B 3) y=0 k 1 l, hence xyyz = 0 p 1 l 0 k 1 p  B Conclusion: The pumping lemma does not hold, the language B is not regular.

F = { ww | w  {0,1}* } (Ex. 1.40) Let p be the pumping length, and take s = 0 p 10 p 1 Let s = xyz = 0 p 10 p 1 with condition 3) |xy|  p Only one option: y=0 k, with xyyz = 0 p+k 10 p 1  F Without 3) this would have been a pain.

Intersecting Regular Languages Let C = { w | # of 0s in w equals # of 1s in w} Problem: If xyz  C with y  C, then xy i z  C Idea: If C is regular and F is regular, then the intersection C  F has to be regular as well Solution: Assume that C is regular Take the regular F = { 0 n 1 m | n,m  N}, then for the intersection: C  F = { 0 n 1 n | n  N } But we know that C  F is not regular Conclusion: C is not regular

Pumping Down E = { 0 i 1 j | i  j } Problem: ‘pumping up’ s=0 p 1 p with y=0 k gives xyyz = 0 p+k 1 p, xy 3 z = 0 p+2k 1 p, which are all in E (hence do not give contradictions) Solution: pump down to xz = 0 p–k 1 p. Overall for s = xyz = 0 p 1 p (with |xy|  p): y=0 k, hence xz = 0 p–k 1 p  E Contradiction: E is not regular End Chapter One