The Pumping Lemma and Closure Properties

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

Homomorphisms and Efficient State Minimization

Regular Expressions and Language Properties

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

CS 455/555: Finite automata

Formal Languages, Automata and Models of Computation

Lecture 7 Properties of regular languages

More Properties of Regular Languages

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

Sri vidya college of engineering and technology

Properties of Context-Free Languages. Closure Properties Decision Properties

Proving languages to be nonregular

Finite Automata and Regular languages

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

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

More on Regular Languages and Non-Regular Languages

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

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

Computational Models - Lecture 3 1

Ogden s Lemma for CFLs

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

MA/CSSE 474 Theory of Computation

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

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

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Closure Properties of Regular Languages

Properties of Regular Languages (2015/10/15)

Automata Theory, Computability and Complexity

TDDD65 Introduction to the Theory of Computation

Nondeterminism and Epsilon Transitions

CSE 105 THEORY OF COMPUTATION

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

Name: Student ID: Instructions:

Computational Models: Class 3

MA/CSSE 474 Theory of Computation. Your Questions? Previous class days' material Reading Assignments

Theory of Computation (II) Yijia Chen Fudan University

Comment: The induction is always on some parameter, and the basis case is always an integer or set of integers.

Computational Models - Lecture 3 1

3515ICT: Theory of Computation. Regular languages

NPDA, CFG equivalence

Chapter 6. Properties of Regular Languages

CSE 105 Theory of Computation Professor Jeanne Ferrante

Theory of Computation

1 Alphabets and Languages

Automata: a short introduction

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

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

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

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

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

Regular Expressions. Definitions Equivalence to Finite Automata

Properties of Context-Free Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CS 455/555: Mathematical preliminaries

Fall 1999 Formal Language Theory Dr. R. Boyer. 1. There are other methods of nding a regular expression equivalent to a nite automaton in

CS 154, Lecture 3: DFA NFA, Regular Expressions

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

1. Induction on Strings

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

Lecture 4: More on Regexps, Non-Regular Languages

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Regular expressions. Regular expressions. Regular expressions. Regular expressions. Remark (FAs with initial set recognize the regular languages)

Computer Sciences Department

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

front pad rear pad door

Computational Models - Lecture 3

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

This lecture covers Chapter 7 of HMU: Properties of CFLs

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

MA/CSSE 474 Theory of Computation

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CSE 105 THEORY OF COMPUTATION

Context-Free Languages (Pre Lecture)

Fooling Sets and. Lecture 5

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 9 : Myhill-Nerode Theorem and applications

COMP4141 Theory of Computation

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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,

DM17. Beregnelighed. Jacob Aae Mikkelsen

CS 154 Introduction to Automata and Complexity Theory

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Closure under the Regular Operations

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Properties of Regular Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

What we have done so far

CSE 355 Test 2, Fall 2016

Miscellaneous. Closure Properties Decision Properties

1 More finite deterministic automata

Warshall s algorithm

Notes on Pumping Lemma

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

Theory of Computation 4 Non-Deterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

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

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

Uses of finite automata

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Transcription:

The Pumping Lemma and Closure Properties Mridul Aanjaneya Stanford University July 5, 2012 Mridul Aanjaneya Automata Theory 1/ 27

Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10), Due (07/18) HW #3: Out (07/17), Due (07/25) Midterm: 07/31 (in class) HW #4: Out (07/31), Due (08/08) Tentative grades out by 08/12. Final: 08/18 (?) Mridul Aanjaneya Automata Theory 2/ 27

The Infiniteness Problem Question Is a given regular language L infinite? Start with a DFA for the language. Key idea: If the DFA has n states, and the language contains any string of length n or more, then the language is infinite. Otherwise, the language is surely finite. Limited to strings of length n or less. Mridul Aanjaneya Automata Theory 3/ 27

Proof of Key Idea If an n-state DFA accepts a string w of length n or more, then there must be a state that appears twice on the path labeled w from the start state to a final state. Note: Pigeonhole principle! Because there are at least n + 1 states along the path. y x z Since y is not ε, we see an infinite number of strings in L of the form xy i z for all i 0. Mridul Aanjaneya Automata Theory 4/ 27

The Pumping Lemma Theorem For every regular language L, there is an integer n such that for every string w L of length n, we can write w = xyz such that: xy n. y > 0. For all i 0, xy i z is in L. Mridul Aanjaneya Automata Theory 5/ 27

The Pumping Lemma: Examples Question Prove that the language L = {0 k 1 k k 1} is not regular. Proof by contradiction. Suppose it were, and let a DFA with n states accept all strings in L. Choose the string w = 0 n 1 n. We can write w = xyz where x and y consist of 0 s, and y ε. But then xyyz would be in L, and this string has more 0 s than 1 s! Choice of the proper string is very important! Example: w = (01) n does not work! Same argument as above also works for L = {w w has equal number of 0 s and 1 s.} Mridul Aanjaneya Automata Theory 6/ 27

The Pumping Lemma: Examples Question Prove that the language L = {ww w {0,1} } is not regular. Mridul Aanjaneya Automata Theory 7/ 27

The Pumping Lemma: Examples Question Prove that the language L = {ww w {0,1} } is not regular. Suppose it were, and let a DFA with n states accept all strings in L. Choose the string w = 0 n 10 n 1. We can write w = xyz where x and y consist of 0 s, and y ε. But then xyyz would be in L! Note that the string w = 0 n 0 n does not work. Mridul Aanjaneya Automata Theory 8/ 27

The Pumping Lemma: Examples Question Prove that the language L = {1 k2 k 0} is not regular. Mridul Aanjaneya Automata Theory 9/ 27

The Pumping Lemma: Examples Question Prove that the language L = {1 k2 k 0} is not regular. Suppose it were, and let a DFA with n states accept all strings in L. Choose the string w = 1 n2. We can write w = xyz. Consider the string s = xyyz. We know that xy n and thus y n. So no. of 1 s in xyyz is n 2 +n < n 2 +2n+1! The parameter n is often called the pumping length. Mridul Aanjaneya Automata Theory 10/ 27

The Pumping Lemma: Examples Question Prove that the language L = {0 i 1 j i > j} is not regular. Mridul Aanjaneya Automata Theory 11/ 27

The Pumping Lemma: Examples Sometimes pumping down is useful as well! Question Prove that the language L = {0 i 1 j i > j} is not regular. Let n be the pumping length, i.e., suppose there exists a DFA with n states that accepts all strings in L. Choose the string w = 0 n+1 1 n. We can write w = xyz where x and y consist of 0 s, and y ε. The pumping lemma states that all strings xy i z L, even for i = 0! The string w = xz cannot have more 0 s than 1 s. Mridul Aanjaneya Automata Theory 12/ 27

The Pumping Lemma: Examples Question Prove that the language L = {1 p where p is prime} is not regular. Mridul Aanjaneya Automata Theory 13/ 27

The Pumping Lemma: Examples Question Prove that the language L = {1 p where p is prime} is not regular. Consider some primt q n + 2, where n is the pumping length. Choose the string w = 1 q. We can write w = xyz such that y ε and xy n. Let y = m. Then xz = q m. Consider the string s = xy q m z which is in L by the pumping lemma. xy q m z = xz + (q m) y = q m + (q m)m = (m+1)(q m). Note that m+1 > 1, as y ε. Also note that q n + 2, and so q m > 1. Mridul Aanjaneya Automata Theory 14/ 27

Closure Properties A closure property of a language class says that given languages in the class, an operator (e.g., union) produces another language in the same class. Example: We saw that regular languages are closed under union, concatenation and Kleene closure (star) operations. We will see more examples: intersection, difference, reversal, homomorphism, inverse homomorphism. Mridul Aanjaneya Automata Theory 15/ 27

Closure Properties: Intersection Construct the product DFA from DFA s for L and M. Let these DFA s have sets of states Q and R respectively. Product DFA has set of states Q R. i.e., pairs [q,r] with q Q and r Q. Start state = [q 0,r 0 ] (the start states of the DFA for L and M). Transitions: δ([q,r],a) = [δ L (q,a),δ M (r,a)]. δ L, δ M are the transition functions for the DFA s of L and M. i.e., we simulate the two DFA s in the two state components of the product DFA. Make final states be pairs consisting of final states of both DFA s of L and M. Mridul Aanjaneya Automata Theory 16/ 27

Product DFA: Example 0 1 0 A 1 0,1 B C 0 1 D 0 [A,C] 0 [A,D] 1 1 1 0 0 [B,C] [B,D] 1 Mridul Aanjaneya Automata Theory 17/ 27

Closure Properties: Difference If L and M are regular, then so is L M = strings in L but not in M. Proof: Let A and B be DFA s whose languages are L and M. Construct the product DFA C of A and B. Make the final states of C be the pairs where A-state is final but B-state is not. Mridul Aanjaneya Automata Theory 18/ 27

Difference: Example 0 1 0 A 1 0,1 B C 0 1 D 0 [A,C] 0 [A,D] 1 1 1 0 0 [B,C] [B,D] 1 Mridul Aanjaneya Automata Theory 19/ 27

Closure Properties: Containment If L and M are regular, then so is L M = strings in L but not in M. Proof: Let A and B be DFA s whose languages are L and M. Construct the product DFA C of A and B. Make the final states of C be the pairs where A-state is final but B-state is not. Note: Can also be used to test containment. If L M =, then L M. How did we test if the language of a DFA is empty? Mridul Aanjaneya Automata Theory 20/ 27

Closure Properties: Complement The complement of a language L is Σ L. Since Σ is regular, the complement is always regular. Mridul Aanjaneya Automata Theory 21/ 27

Closure Properties: Reversal Given language L, L R has all strings whose reversal is in L. Example: L = {0, 01, 100}; L R = {0, 10, 001} Proof: Let E be a regular expression for L. We show how to reverse E, to provide a regular expression E R for L R. Mridul Aanjaneya Automata Theory 22/ 27

Reversal of a Regular Expression Basis: If E is a symbol a, ε, or, then E R = E. Induction: If E is: F + G, then E R = F R + G R FG, then E R = G R F R F, then E R = (F R ) Mridul Aanjaneya Automata Theory 23/ 27

Reversal of a RE: Example Let E = 01 + 10. E R = (01 + 10 ) R = (01 ) R + (10 ) R = (1 ) R 0 R + (0 ) R 1 R = (1 R )0 R + (0 R )1 R = (1 )0 + (0 )1 Mridul Aanjaneya Automata Theory 24/ 27

Homomorphisms A homomorphism on an alphabet is a function that gives a string for each symbol in that alphabet. Example: h(0) = ab, h(1) = ε. Extend to strings by h(a 1 a 2...a n )=h(a 1 )h(a 2 )...h(a n ). Example: h(01010) = ababab. Mridul Aanjaneya Automata Theory 25/ 27

Closure Properties: Homomorphism If L is regular, and h is a homomorphism on its alphabet, then h(l) = {h(w) w L} is also regular. Proof: Let E be a regular expression for L. Apply h to each symbol in E. Language of resulting RE is h(l). Mridul Aanjaneya Automata Theory 26/ 27

Closure under Homomorphism: Example Let h(0) = ab, h(1) = ε. Let L be the language of a regular expression 01 + 10. Then h(l) is the language of regular expression abε + ε(ab). Note: abε + ε(ab) = ab + (ab) = (ab). Mridul Aanjaneya Automata Theory 27/ 27