MA/CSSE 474 Theory of Computation

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

MA/CSSE 474 Theory of Computation

The Pumping Lemma and Closure Properties

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

MA/CSSE 474 Theory of Computation

Formal Languages, Automata and Models of Computation

Automata: a short introduction

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

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

CSE 105 THEORY OF COMPUTATION

More Properties of Regular Languages

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.

Proving languages to be nonregular

Computational Models - Lecture 3 1

MA/CSSE 474 Theory of Computation

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Properties of Context-Free Languages. Closure Properties Decision Properties

CS 455/555: Finite automata

Context-Free and Noncontext-Free Languages

CSE 105 THEORY OF COMPUTATION

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Chapter-6 Regular Expressions

Finite Automata and Regular languages

CSE 105 THEORY OF COMPUTATION

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

The Three Hour Tour Through Automata Theory

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

Computer Sciences Department

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

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

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

Sri vidya college of engineering and technology

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

Theory of Computation

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

Notes on Pumping Lemma

TDDD65 Introduction to the Theory of Computation

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

Computational Models: Class 3

V Honors Theory of Computation

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

CS Automata, Computability and Formal Languages

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

Languages, regular languages, finite automata

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

In English, there are at least three different types of entities: letters, words, sentences.

Lecture 4: More on Regexps, Non-Regular Languages

Grade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

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

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

FS Properties and FSTs

Functions on languages:

What we have done so far

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

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

COMP4141 Theory of Computation

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

CSE 105 THEORY OF COMPUTATION

3515ICT: Theory of Computation. Regular languages

Ogden s Lemma for CFLs

Computational Models - Lecture 3

Foundations of (Theoretical) Computer Science

Regular Expressions and Language Properties

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

Foundations of Computer Science Lecture 23 Languages: What is Computation?

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

UNIT-III REGULAR LANGUAGES

Computational Models - Lecture 3 1

Closure Properties of Regular Languages

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chapter 4. Regular Expressions. 4.1 Some Definitions

Pushdown Automata. Chapter 12

CSE 105 Theory of Computation Professor Jeanne Ferrante

10. The GNFA method is used to show that

More on Regular Languages and Non-Regular Languages

NPDA, CFG equivalence

Inf2A: Converting from NFAs to DFAs and Closure Properties

Fooling Sets and. Lecture 5

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.

CS 154, Lecture 3: DFA NFA, Regular Expressions

Computational Theory

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

Context Free Language Properties

CS 410/610, MTH 410/610 Theoretical Foundations of Computing

Final exam study sheet for CS3719 Turing machines and decidability.

CSE 105 THEORY OF COMPUTATION

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Advanced Automata Theory 7 Automatic Functions

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

CS 121, Section 2. Week of September 16, 2013

Theory of Computation (Classroom Practice Booklet Solutions)

Transcription:

MA/CSSE 474 Theory of Computation Closure properties of Regular Languages Pumping Theorem Your Questions? Previous class days' material? Reading Assignments? HW 6 or 7 problems? Anything else? 1

To Show that a Language L is Regular We can do any of the following: Construct a DFSM that accepts L. Construct a NDFSM that accepts L. Construct a regular expression that defines L. Construct a regular grammar that generates L. Show that there are finitely many equivalence classes for L. Show that L is finite. Use one or more of the closure properties. Closure Properties of Regular Languages Union Concatenation Kleene Star Complement Intersection Difference Reverse Letter Substitution The first three are easy: definition of regular expressions. We will briefly discuss the ideas of how to do Complement and Reverse. Intersection: HW5, or... Difference You should read about Letter Substitution in the textbook. 2

Don t Try to Use Closure Backwards One Closure Theorem: If L 1 and L 2 are regular, then so is L = L 1 L 2 But if L 1 L 2 is regular, what can we say about L 1 and L 2? L = L 1 L 2 ab = ab (a b)* (L1 and L2 are regular) ab = ab {a n b n, n 0} (they may not be regular) Don t Try to Use Closure Backwards Another Closure Theorem: If L 1 and L 2 are regular, then so is L = L 1 L 2 But if L 2 is not regular, what can we say about L? L = L 1 L 2 {aba n b n : n 0} = {ab} {a n b n : n 0} L(aaa*) = {a}* {a p : p is prime} 3

Showing that a Language is Not Regular Every regular language can be accepted by some FSM. It can only use a finite amount of memory to record essential properties. Example: A n B n = {a n b n, n 0} is not regular Showing that a Language is Not Regular The only way to generate/accept an infinite language with a finite machine/description is to use: Kleene star (in regular expressions), or cycles (in automata). This forces some kind of simple repetitive cycle within the strings. Example: ab*a generates aba, abba, abbba, abbbba, etc. Example: {a n : n 1 is a prime number} is not regular. 4

Exploiting the Repetitive Property If an FSM with n states accepts at least one string of length n, how many strings does it accept? L = bab*ab b a b a b x y z xy*z must be in L. So L includes: baab, babab, babbab, babbbbbbbbbbab Theorem Long Strings Theorem: Let M = (K,,, s, A) be any DFSM. If M accepts any string of length K or greater, then that string will force M to visit some state more than once (thus traversing at least one loop or cycle). Proof: M must start in one of its states. Each time it reads an input character, it visits some state. So, in processing a string of length n, M does a total of n + 1 state visits. If n+1 > K, then, by the pigeonhole principle, some state must get more than one visit. So, if n K, then M must visit at least one state more than once. 5

The Pumping Theorem* for Regular Languages If L is regular, then every long string in L is "pumpable". Formally, if L is regular, then k 1 such that Write this in ( strings w L, contrapositive ( w k form ( x, y, z (w = xyz, xy k, y, and q 0 (xy q z is in L))))) a.k.a. "the pumping lemma". We will use the terms interchangeably. What if L has no strings whose lengths are greater than k? Using The Pumping Theorem to show that L is not Regular: We use the contrapositive of the theorem: If some long enough string in L is not "pumpable", then L is not regular. What we need to show in order to show L non-regular: ( k 1 ( a string w L ( w k and ( x, y, z ((w = xyz xy k y ) q 0 (xy q z L)))))) L is not regular. Before our next class meeting: Be sure that you are convinced that this really is the contrapositive of the pumping theorem. 6

A way to think of it: adversary argument (following J.E. Hopcroft and J.D.Ullman) 1. Choose the language L you want to prove non-regular. 2. The "adversary" picks k, the constant mentioned in the theorem. 3. We must be prepared for any positive integer to be picked, but once it is chosen, the adversary cannot change it. 4. We select a string w L (whose length is at least k) that cannot be pumped". 5. The adversary breaks w into w=xyz, subject to constraints xy k and y. 6. Our choice of w must take into account that any such x and y can be chosen. 7. All we must do is produce a single number q 0 such that xy q z L. Note carefully what we get to choose and what we do not get to choose. Example: {a n b n : n 0} is not Regular k is the number from the Pumping Theorem. We don't get to choose it. Choose w to be a k/2 b k/2 ( long enough ). 1 2 a aaaa a aaaab bbb b bbbbb x y z Adversary chooses x, y, z with the required properties: xy k, y, We must show q 0 (xy q z L). Three cases to consider: y entirely in region 1: y partly in region 1, partly in 2: y entirely in region 2: For each case, we must find at least one value of q that takes xy q z outside the language L. The most common q values to use are q=0 and q=2. 7

A Complete Proof (read later) We prove that L = {a n b n : n 0} is not regular If L were regular, then there would exist some k such that any string w where w k must satisfy the conditions of the theorem. Let w = a k/2 b k/2. Since w k, w must satisfy the conditions of the pumping theorem. So, for some x, y, and z, w = xyz, xy k, y, and q 0, xy q z is in L. We show that no such x, y, and z exist. There are 3 cases for where y could occur: We divide w into two regions: aaaaa..aaaaaa bbbbb..bbbbbb 1 2 So y is in one of the following : (1): y = a p for some p. Since y, p must be greater than 0. Let q = 2. The resulting string is a k+p b k. But this string is not in L, since it has more a s than b s. (2): y = b p for some p. Since y, p must be greater than 0. Let q = 2. The resulting string is a k b k+p. But this string is not in L, since it has more b s than a s. (1, 2): y = a p b r for some non-zero p and r. Let q = 2. The resulting string will have interleaved a s and b s, and so is not in L. There exists one long string in L for which no pumpable x, y, z exist. So L is not regular. What You Should Write (read these details later) We prove that L = {a n b n : n 0} is not regular Let w = a k/2 b k/2. (If not completely obvious, as in this case, show that w is in fact in L.) aaaaa..aaaaaa bbbbb..bbbbbb 1 2 There are three possibilities for y: (1): y = a p for some p. Since y, p must be greater than 0. Let q = 2. The resulting string is a k+p b k. But this string is not in L, since it has more a s than b s.. (2): y = b p for some p. Since y, p must be greater than 0. Let q = 2. The resulting string is a k b k+p. But this string is not in L, since it has more b s than a s. (1, 2): y = a p b r for some non-zero p and r. Let q = 2. The resulting string will have interleaved a s and b s, and so is not in L. Thus L is not regular. 8