Chapter 2 The Pumping Lemma

Similar documents
Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Proving languages to be nonregular

More on Regular Languages and Non-Regular Languages

Foundations of (Theoretical) Computer Science

TDDD65 Introduction to the Theory of Computation

Before we show how languages can be proven not regular, first, how would we show a language is regular?

UNIT-III REGULAR LANGUAGES

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computer Sciences Department

CSE 105 THEORY OF COMPUTATION

Context-Free Languages

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

CS 154, Lecture 4: Limitations on DFAs (I), Pumping Lemma, Minimizing DFAs

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

CS 455/555: Finite automata

Computational Theory

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

(Refer Slide Time: 0:21)

Languages, regular languages, finite automata

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

What we have done so far

Applied Computer Science II Chapter 1 : Regular Languages

CS154. Non-Regular Languages, Minimizing DFAs

Lecture 4: More on Regexps, Non-Regular Languages

CSCE 551 Final Exam, Spring 2004 Answer Key

Finite Automata and Regular languages

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Please give details of your calculation. A direct answer without explanation is not counted.

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Closure under the Regular Operations

CISC4090: Theory of Computation

V Honors Theory of Computation

CPSC 421: Tutorial #1

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Automata: a short introduction

Inf2A: The Pumping Lemma

Nondeterminism. September 7, Nondeterminism

ECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!)

10. The GNFA method is used to show that

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

The Pumping Lemma and Closure Properties

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

Lecture 4: Finite Automata

Lecture 3: Finite Automata

Nondeterministic Finite Automata

Computational Models - Lecture 3 1

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Sample Midterm. Understanding the questions is part of the exam; you are not allowed to ask questions during the exam.

CS243, Logic and Computation Nondeterministic finite automata

Theory of Computation (II) Yijia Chen Fudan University

Notes on Pumping Lemma

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Lecture 3: Finite Automata

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

CS 154, Lecture 3: DFA NFA, Regular Expressions

CSE 105 Theory of Computation Professor Jeanne Ferrante

Introduction to Turing Machines. Reading: Chapters 8 & 9

Intro to Theory of Computation

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

CS500 Homework #2 Solutions

Sri vidya college of engineering and technology

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Problem 2.6(d) [4 pts] Problem 2.12 [3pts] Original CFG:

Notes for Comp 497 (Comp 454) Week 5 2/22/05. Today we will look at some of the rest of the material in Part 1 of the book.

Computational Models - Lecture 3

CSE 105 THEORY OF COMPUTATION

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

MA/CSSE 474 Theory of Computation

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

The Pumping Lemma: limitations of regular languages

Final Exam Comments. UVa - cs302: Theory of Computation Spring < Total

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

Computability and Complexity

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA

Computational Models: Class 3

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

1.3 Regular Expressions

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

DM17. Beregnelighed. Jacob Aae Mikkelsen

Context-Free Languages (Pre Lecture)

Formal Definition of Computation. August 28, 2013

1 Showing Recognizability

Nondeterministic finite automata

Chapter 6. Properties of Regular Languages

Ogden s Lemma for CFLs

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Part 3 out of 5. Automata & languages. A primer on the Theory of Computation. Last week, we learned about closure and equivalence of regular languages

Transcription:

Chapter 2 The Pumping Lemma Fourth Academic Year/ Elective Course-General Electrical Engineering Department College of Engineering University of Salahaddin April 2015

Nonregular Languages Consider the language L(M) = {0 n 1 n n 0} 1. If we attempt to find a DFA that recognize L(M) we discover that such a machine needs to remember how many 0s have been seen so far as it reads the input. 2. Because the number of 0s isn t limited, the machine needs to keep track of an unlimited number of possibilities. 3. This cannot be done with any finite number of states. EED at University of Salahaddin 2 of 15

Nonregular Languages: Intuition may fail us Just because a language appears to require unbounded memory to be recognized. It doesn t mean that it is necessary so. Example 1) C = {w w has an equal umber of 0s and 1s} Not Regular 2) D = {w w has equal no. of 01 and 10 substrings} Regular EED at University of Salahaddin 3 of 15

Observation The technique for providing noregularity of some language is provided by a theorem about regular languages called Pumping Lemma. Pumping lemma states that all regular languages have a special property. Pumping lemma does not state that only regular languages have this property. Hence, the property used to prove that a language L is not regular does not ensure that language is L regular. Consequence: A language may not be regular and still have strings that have all the properties of regular languages. Pumping Property: All strings in the language can be pumped if they are at least as long as a certain value, called pumping length. Meaning: each such string in the language contains a section that can be repeated any number of times with the resulting remaining the language. EED at University of Salahaddin 4 of 15

Theorem Pumping Lemma: if A is a regular language, then there is a pumping length p such that: If s is any string in A of length at least p, Then s may be divided into three pieces, s=xyz, satisfying the following conditions: 1. For each i 0, xy i z A 2. y > 0 3. xy p Interpretation Recall that s represents the length of string s and y i means that y may be concatenated i times, and y 0 = When s=xyz, either x or z may be, but y Without condition y, theorem would be trivially true. EED at University of Salahaddin 5 of 15

Using Pumping Lemma Proving the a language A is not regular using pumping lemma: 1. Assume that A is regular in order to obtain a contradiction 2. The pumping lemma guarantees the existence of a pumping length p so that all strings of length p or greater in A can be pumped 3. Find s A, s p, that cannot be pumped: demonstrate that s cannot be pumped by considering all ways of dividing s into x,y,z, showing that for each division one of the pumping lemma conditions;(i) xy i z A, (ii) y > 0, (iii) xy p, fails The existence of s contradicts pumping lemma, hence A cannot be regular Finding s sometimes takes a bit of creative thinking. Experimentation is suggested. EED at University of Salahaddin 6 of 15

Applications Example 1 Prove that B = {0 n 1 n n 0} is not regular Assume that B is regular and let p be the pumping length of B. Choose s = 0 p 1 p B, obviously 0 p 1 p > p. By pumping lemma s= xyz such that for any i 0, xy i z B. Consider the cases: 1. y consists of 0s only. In this case xyyz has more 0s than 1s and so it is not in B, violating condition 1 2. y consists of 1s only. This leads to the same contradiction 3. y consists of 0s and 1s. In this case xyyz may have the same number of 0s and 1s but they are out of order with some 1s before some 0s, hence it cannot be in B either. The contradiction in unavoidable if we make the assumption that B is regular so B is not regular. EED at University of Salahaddin 7 of 15

Applications Cont. Example 2 Prove that C = {w w has an equal number of 0s and 1s} is not regular. Proof: Assume that C is regular and p is its pumping length. Let s=0 p 1 p with s C. Then pumping lemma guarantees that s= xyz where xy i z C for any i 0. Note: if we take the division x = z =, y = 0 p 1 p it seems that indeed, no contradiction occurs. However: Condition 3 states that xy p, and in our case xy = 0 p 1 p and xy > p. Hence, 0 p 1 p cannot be pumped. If xy p, then y must consists of only 1s, so xyyz C because there are more 1s than 0s. This gives us the desired contradiction EED at University of Salahaddin 8 of 15

Applications Cont. Example 3 Show that F={ww w {0,1}* } is nonregular using pumping lemma. Proof Assume that F is regular and p is its pumping length. Consider s = 0 p 10 p 1 F. Since s > p, s = xyz and satisfies the conditions of the pumping lemma. Note: Condition 3 is again crucial because without it we could pump s if we let x = z =, so xyyz F. The string s = 0 p 10 p 1 exhibits the essence of the nonregular of F. If we chose, say 0 p 0 p F we fail because this string can be pumped. EED at University of Salahaddin 9 of 15

Minimum Pumping Length The pumping lemma says that every regular language has a pumping length p, such that every string in the language of length at least p can be pumped. Hence, if p is a pumping length for a regular language A so is any length p p. The minimum pumping length for A is the smallest p that is a pumping length for A. EED at University of Salahaddin 10 of 15

Minimum Pumping Length: Examples Example 5 Consider A = 01*. The minimum pumping length for A is 2. Reason: the string s = 0 A, s = 1 and s cannot be pumped. But any string s A, s 2 can be pumped because for s = xyz where x=0. y=1, z=rest and xy i z A. Hence, the minimum pumping length for A is 2. EED at University of Salahaddin 11 of 15

Minimum Pumping Length: Examples Example 6 Find the minimum pumping length for the language 0001* Answer The minimum pumping length for 0001* is 4. Reason: 000 0001* but 000 cannot be pumped. Hence, 3 is not a pumping length for 0001*. If s 0001* and s 4s can be pumped by the division s=xyz, x= 000, y = 1, z = rest. EED at University of Salahaddin 12 of 15

Minimum Pumping Length: Examples Example 7 Find the minimum pumping length for the language 0*1* Answer The minimum pumping length for 0*1* is 2. Reason: the minimum pumping length for 0*1* cannot be 0 because is in the language but cannot be pumped. Every nonempty string s 0*1*, s 2 can be pumped by the division: s = xyz, x =, y first character of s and z the rest of s. EED at University of Salahaddin 13 of 15

Minimum Pumping Length: Examples Example 8 Find the minimum pumping length for the language 0*1 + 0 + 1* 10*1. Answer The minimum pumping length for 0*1 + 0 + 1* 10*1 is 3. Reason: the pumping length cannot be 2 because the string 11 is in the language and it cannot be pumped. Let s be a string in the language of length at least 3. if s is generated by 0*1 + 0 + 1* we can write it as s = xyz, x=, y is the first symbol of s, and z is the rest of the string. If s is generated by 10*1 we can write it as s = xyz, x = 1, y = 0 and z is the remainder of s. EED at University of Salahaddin 14 of 15

End of Chapter 2! EED at University of Salahaddin 15 of 15