FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Similar documents
Formal Languages, Automata and Models of Computation

More Properties of Regular Languages

Proving languages to be nonregular

TDDD65 Introduction to the Theory of Computation

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

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

CSE 105 THEORY OF COMPUTATION

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

Computational Theory

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

Finite Automata and Regular languages

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

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

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

More on Regular Languages and Non-Regular Languages

Automata: a short introduction

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

Computational Models: Class 3

What we have done so far

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

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation

Chapter 6. Properties of Regular Languages

CSC236 Week 11. Larry Zhang

Lecture 4: More on Regexps, Non-Regular Languages

Non-regular languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

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

Answers to the CSCE 551 Final Exam, April 30, 2008

UNIT-III REGULAR LANGUAGES

Intro to Theory of Computation

The Pumping Lemma and Closure Properties

Foundations of (Theoretical) Computer Science

Computer Sciences Department

Notes on Pumping Lemma

The Pumping Lemma: limitations of regular languages

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

Assignment #2 COMP 3200 Spring 2012 Prof. Stucki

Computational Models - Lecture 3 1

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

Chapter 2 The Pumping Lemma

Finite Automata (contd)

CS 154 Introduction to Automata and Complexity Theory

Computational Models - Lecture 3

3515ICT: Theory of Computation. Regular languages

CSCE 551 Final Exam, Spring 2004 Answer Key

CS 455/555: Finite automata

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Regular Expressions and Language Properties

Uses of finite automata

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

COM364 Automata Theory Lecture Note 2 - Nondeterminism

We have seen many ways to specify Regular languages. Are all languages Regular languages?

V Honors Theory of Computation

CSE 322, Fall 2010 Nonregular Languages

CS375 Midterm Exam Solution Set (Fall 2017)

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

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

Finite State Machines 2

Formal Language and Automata Theory (CS21004)

Exam 1 CSU 390 Theory of Computation Fall 2007

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

Sri vidya college of engineering and technology

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

CS 154, Lecture 3: DFA NFA, Regular Expressions

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

CS 154 Formal Languages and Computability Assignment #2 Solutions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

10. The GNFA method is used to show that

Theory of Computation (I) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Name: Student ID: Instructions:

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

False. They are the same language.

CS154. Non-Regular Languages, Minimizing DFAs

Nondeterministic Finite Automata

Languages, regular languages, finite automata

Context-Free Languages (Pre Lecture)

CS 133 : Automata Theory and Computability

Closure under the Regular Operations

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

ECS 20: Discrete Mathematics for Computer Science UC Davis Phillip Rogaway June 12, Final Exam

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Fooling Sets and. Lecture 5

Theory of Computation (Classroom Practice Booklet Solutions)

Applied Computer Science II Chapter 1 : Regular Languages

Computational Models - Lecture 4

CSE 105 THEORY OF COMPUTATION

Deterministic Finite Automata (DFAs)

MA/CSSE 474 Theory of Computation

Lecture 3: Nondeterministic Finite Automata

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

Transcription:

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION IDENTIFYING NONREGULAR LANGUAGES PUMPING LEMMA Carnegie Mellon University in Qatar (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 1 / 21

SUMMARY DFAs to Regular Expressions Minimizing DFA s Closure Properties Decision Properties (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 2 / 21

IDENTIFYING NONREGULAR LANGUAGES Given language L how can we check if it is not a regular language? The answer is not obvious. Not being able to design a DFA does not constitute a proof! (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 3 / 21

THE PIGEONHOLE PRINCIPLE If there are n pigeons and m holes and n > m, then at least one hole has > 1 pigeons. What do pigeons have to do with regular languages? (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 4 / 21

THE PIGEONHOLE PRINCIPLE Consider the DFA With strings a, aa or aab, no state is repeated With strings aabb, bbaa, abbabb or abbbabbabb, a state is repeated In fact, for any ω where ω 4, some state has to repeat? Why? (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 5 / 21

THE PIGEONHOLE PRINCIPLE When traversing the DFA with the string ω, if the number of transitions number of states, some state q has to repeat! Transitions are pigeons, states are holes. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 6 / 21

PUMPING A STRING Consider a string ω = xyz y 1 xy m (m the number of states) (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 7 / 21

PUMPING A STRING Consider a string ω = xyz If ω = xyz L that so are xy i z for all i 0 The substring y can be pumped. So if a DFA accepts a sufficiently long string, then it accepts an infinite number of strings! (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 8 / 21

A NONREGULAR LANGUAGE Consider the language L = {a n b n n 0} Suppose L is regular and a DFA with p states accepts L Consider δ (q 0, a i ) for i = 0, 1, 2,... Since there are infinite i s, but a finite number states, the Pigeonhole Principle tells us that there is some state q such that δ (q 0, a n ) = q and δ (q 0, a m ) = q, but n m Thus if M accepts a n b n it must also accept a m b n, since in state q is does not remember if there were n or m a s. Thus M can not exist and L is not regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 9 / 21

THE PUMPING LEMMA LEMMA Given an infinite regular language L 1 There exists an integer m such that 2 for any string ω L with length ω m, 3 we can write ω = xyz with y 1 and xy m, 4 such that the strings xy i z for i = 0, 1, 2... are also in L Thus any sufficiently long string can be pumped. PROOF IDEA We already have some hints. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 10 / 21

THE PUMPING LEMMA PROOF. If L is regular then M with p states recognizes L. Take a string s = s 1 s 2 s n L with n p. Let r 1 r 2 r n+1 be the sequence of n + 1( p + 1) states M enters while processing s (r i+1 = δ(r i, s i )) r j and r l (for some j and l (j < l p + 1) should be the same state (Pigeons!) Now let x = s 1 s j 1, y = s j s l 1, and z = s l s n. x takes M from 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, which is an accepting state. So M must also accept xy i z for i 0. We know j l, so y > 0 and l p + 1 so xy p (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 11 / 21

USING THE PUMPING LEMMA If a language violates the pumping lemma, then it can not be regular. Two Player Proof Strategy: Opponent picks m Given m, we pick ω in L such that ω m. We are free to choose ω as we please, as long as those conditions are satisfied. Opponent picks ω = xyz - the decomposition subject to xy m and y 1. We try to pick an i such that xy i z L If for all possible decompositions the opponent can pick, we can find an i, then L is not regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 12 / 21

USING THE PUMPING LEMMA Consider L = {a n b n n 0} 1 Opponent picks m 2 We pick ω = a m b m. Clearly ω m. 3 Since the first m symbols are all a s, the opponent is forced to pick x = a j, y = a k and z = a l b m, with j + k m and l 0 and j + k + l = m ω = } a {{ a}} a {{ a}} a... ab {{ b} x y z 4 We choose i = 2 which means a j a k a k a l b m = a m+k b m L but it can not be! 5 The opponent does not have any other way of partitioning ω, so L is not regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 13 / 21

USING THE PUMPING LEMMA Consider L = {ω n a (ω) < n b (ω)} 1 Opponent picks m 2 We pick a m b m+1. Clearly ω m. 3 Opponent is forced to pick y = a k for some 1 k m 4 We pick i = 2 which means a m+k b m+1 L but it can not be! 5 The opponent does not have any other way of partitioning ω, so L is not regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 14 / 21

USING THE PUMPING LEMMA Consider L = {1 n2 n 0} 1 Opponent picks m 2 We pick ω = 1 m2. Clearly ω m. 3 Opponent chooses any partitioning of ω = xyz = 1 j 1 k 1 l with 1 k m and j + k m 4 With xyz = m 2 and i = 2, m 2 < xyyz m 2 + m. But m 2 < m 2 + m < m 2 + 2m + 1 = (m + 1) 2 5 xyyz lies between to perfect squares. So xyyz L. 6 L can not be regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 15 / 21

SUMMARY Symbols, Strings, Languages, Set of all Languages DFAs, Regular Languages, NFAs, Regular Expressions DFA REs Minimal DFAs Closure properties, Decision properties Nonregular Languages, Pumping Lemma (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 16 / 21

LET S SEE IF WE CAN TIE THINGS TOGETHER True or False? 1 If L 1 is not regular and L 2 is regular then L = L 1 L 2 = {xy : x L 1 and y L 2 } is not regular. 2 L = {a i b j a k : i + k < 10 and j > 10} is not regular. 3 L = {w {a, b} : n a (w) n b (w) = 0 mod 2} is regular. 4 L = {a i b j : i + j 10} is not regular. 5 L = {a i b j : i j > 10} is not regular. 6 L = {a i a j : i/j = 5} is not regular. 7 If L 1 L 2 is regular then L 1 and L 2 are regular. 8 If L 1 L 2 and L 2 is regular, then L 1 must be regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 17 / 21

LET S SEE IF WE CAN TIE THINGS TOGETHER True or False? 1 There are subsets of a regular language which are not regular. 2 If L 1 and L 2 are nonregular, then L 1 L 2 must be nonregular. 3 If F is a finite language and L is some language, and L F is a regular language, then L must be a regular language. 4 L = {w {a, b} : the number a s times the number of b s in w is greater than 1333} is not regular. 5 If the start state of a DFA has a self-loop, then the language accepted by that DFA is infinite. 6 The set of strings of 0 s, 1 s, and 2 s with at least 100 of each of the three symbols is a regular language. 7 The union of a countable number of regular languages is regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 18 / 21

LET S SEE IF WE CAN TIE THINGS TOGETHER True or False? 1 L = { uww R v u, v, w {a, b} +} is not regular. 2 If L is nonregular then L is nonregular. 3 If L 1 L 2 is finite then L 1 and L 2 are regular. 4 The family of regular languages is closed under nor operation, nor(l 1, L 2 ) = {w : w / L 1 and w / L 2 } 5 If L is a regular language, then so is {xy: x L and y / L} 6 Let L be a regular language over Σ = {a, b, c}. Let us define SINGLE(L) = {w L : all symbols in w are the same}. SINGLE(L) is regular. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 19 / 21

LET S SEE IF WE CAN TIE THINGS TOGETHER Let Σ = {a} and let M be a deterministic finite state acceptor that accepts a regular language L Σ. A) Describe with very simple diagrams, possible structures of the state graph of M, if M has only a single final state. Show any relevant parameters that you feel are necessary. B) Describe with a regular expression the language accepted by M, if M has a single final state. If necessary, use any parameters you showed in part a). C) Describe mathematically the language accepted by M, if M has more than one final state. (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 20 / 21

WHERE DO WE GO FROM HERE? (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011 21 / 21