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

Similar documents
More Properties of Regular Languages

Formal Languages, Automata and Models of Computation

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Lecture 7 Properties of regular languages

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

Chapter 6. Properties of Regular Languages

CSE 105 THEORY OF COMPUTATION

The Pumping Lemma and Closure Properties

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

Non-regular languages

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

TDDD65 Introduction to the Theory of Computation

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

Properties of Regular Languages (2015/10/15)

Proving languages to be nonregular

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

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

CS375 Midterm Exam Solution Set (Fall 2017)

Computational Models - Lecture 3 1

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

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

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

Homework 5 - Solution

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CSE 105 THEORY OF COMPUTATION

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41

More on Regular Languages and Non-Regular Languages

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

Finite Automata and Regular languages

Finite Automata (contd)

Intro to Theory of Computation

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

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

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

What we have done so far

Lecture 4: More on Regexps, Non-Regular Languages

The Pumping Lemma: limitations of regular languages

Regular Expressions and Language Properties

Context-Free Languages (Pre Lecture)

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

Computational Models: Class 3

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

CSE 105 Theory of Computation Professor Jeanne Ferrante

CS 154 Introduction to Automata and Complexity Theory

Theory of Computation

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

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

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

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

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,

Question Bank UNIT I

CS375: Logic and Theory of Computing

Computational Models - Lecture 3 1

1 More finite deterministic automata

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.

CSE 105 THEORY OF COMPUTATION

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

Ogden s Lemma for CFLs

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

CSCE 551 Final Exam, Spring 2004 Answer Key

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Non-context-Free Languages. CS215, Lecture 5 c

Sri vidya college of engineering and technology

Computational Models - Lecture 4

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Name: Student ID: Instructions:

Fooling Sets and. Lecture 5

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Nondeterministic Finite Automata

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

MA/CSSE 474 Theory of Computation

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

Notes on Pumping Lemma

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

The Pumping Lemma for Context Free Grammars

CS 455/555: Finite automata

Theory of Computation (II) Yijia Chen Fudan University

Languages, regular languages, finite automata

V Honors Theory of Computation

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Computational Models - Lecture 4 1

front pad rear pad door

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CMSC 330: Organization of Programming Languages

CSE 105 THEORY OF COMPUTATION

Finite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

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

UNIT II REGULAR LANGUAGES

Transcription:

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

Closure Properties Question: L is a regular language and op is an operator on strings. Is op(l) still a regular language? Example L={a n b : n 1} is regular. Is reverse(l) = L R = {ba n : n 1} regular? 2

General: L is regular. Assume an r.e., dfa, nfa, or linear grammar for L. Can you design an r.e., dfa, nfa, or linear grammar for op(l)? If the answer to the above is yes, we say that the regular languages are closed under operator op. 3

Over simple operations L 1 and L 2 are regular. So are comp(l 1 ), L 1 L 2, L 1 * Comp(L 1 ) L 1 L 2 L 1 * 4

Closure under right quotient Right quotient: L 1 /L 2 ={x : xy L 1 for some y L 2 } Example, L 1 ={a n b m : n 1, m 0} {ba} L 2 ={b m : m 1} L 1 /L 2 = {a n b m : n 1, m 0} 5

Regular languages are closed under right quotient. Let M 1 = (Q,,, q 0, F) for L 1. Idea: A string x in L 1 /L 2 : there is a string y in L 2 such that xy is in L 1. If such y exists, make state q as a final state. So, we check every q in Q to see whether it should be a final for L 1 /L 2 M 1 x q y 6

Example Find L 1 /L 2 for L 1 =L(a*baa*) and L 2 =L(ab*) L 1 /L 2 is r=a*ba* L 1 /L 2 : M=(Q,,, q 0, F ), where F ={q Q : exist y L 2, *(q, y) F} M 1 for L 1 M for L 1 /L 2 7

Closure under AND, OR, XOR L 1 is accepted by dfa M 1 and L 2 is accepted by dfa M 2. Find a dfa for L=L 1 L 2 ={w : w L 1, w L 2 } Method 1: Find dfa for L= comp(comp(l 1 ) comp(l 2 )) 8

Method 2: direct construction from M 1 =(Q 1,, 1, q 0, F 1 ) and M 2 =(Q 2,, 2, p 0, F 2 ) run M 1 and M 2 simultaneously M 2 M 1 a p 0 p 1 a b M 1 M 2 9

Question: Find a dfa for L 1 or L 2 L 1 xor L 2 10

Elementary questions Standard representation for regular languages Finite automata Regular expressions Regular grammars Membership question Given a regular language L (standard representation) and a string w, determine whether w L Emptiness Given a regular language L, determine whether L=? Finiteness, Equality, 11

For given dfa M, determine whether L(M)=? Minimize M as M? Determine whether M is a, b 12

For given dfa M 1 and M 2, determine whether L(M 1 )=L(M 2 )? Find a dfa M for L=L(M 1 ) xor L(M 2 ) Determine whether L(M)= 13

Identifying non-regular languages Prove that L is regular. Design an r.e., dfa, nfa, linear grammar Show the designed is indeed L. Prove that L is not regular By the pigeon hole principle By the Pumping Lemma By closure properties 14

Pigeonhole principle L is accepted by dfa M of m states. Type 1: For m+1 strings w 1, w 2,, w m+1, there are i, j, i j, * (q 0, w i ) = * (q 0, w j ) 15

L={a n b n : n 0} is not regular. Assume that M=(Q, {a,b},, q 0, F) accepts L and Q =m. Consider * (q 0, a), * (q 0, a 2 ),, * (q 0, a m+1 ), and there must be r and s, r s, * (q 0, a r )= q = * (q 0, a s ). But, consider reading b r further * (q 0, a r b r ) = * (q 0, a s b r ) = p. Is p in F? Contradiction!! Thus, L is not regular. q 0 a s a r q p Final or not? 16

Type 2: If a string w=a 1 a 2 a n, of length n m, is accepted by M, the accepting configuration must at least pass a state (q i =q j ) twice. a 1 a 2 a i a i+1 a j a j+1 a n q 0 q 1 q i q j q mn 17

18

Pumping Lemma If L is a regular language, there exists some positive integer m such that for any w L, w m, there exist x, y, z, such that w=xyz, xy m, y 1, so that for any i=0, 1, 2,, xy i z is also in L. 19

Use Pumping Lemma To prove that L is not regular 1. Assume L is regular and m is the constant for the pumping lemma. 2. Find a string w L, w m, consider all possible (x, y, z) with w=xyz xy m, y 1 For each possible (x, y, z), find one i, w i =x y i z L. 3. Conclusion: L is no regular. 20

Game view To prove that L is not regular YOU Pick m m w Find w L, w m Find x, y, z w=xyz xy m y 1 x, y, z You can win the game L is not regular Win, if found i 0 such that w i = x yy y z L i 21

Game tree m w L, w m x 1,y 1, z 1 x 2,y 2, z 2 x k,y k, z k... i=2 i=0 i=4... x 1 y 1 y 1 z 1 L x 2 z 2 L x k y k y k y k y k z k L 22

Example Show that L = {a n b n : n>0} is not regular Assume that m is the constant in the pumping lemma. We consider the following string w For the following possible x, y, z Case: Case: 23

Show that L = {uu R : u {a,b}*} is not regular Assume that m is the constant in the pumping lemma. We consider the following string w For the following possible x, y, z Case: Case: 24

Show that L={a n b k c n+k : n,k 0} is non-regular 25

Show that L = {a n : n is a perfect square} is not regular. 26

Show that L = {a n b l : n l} is not regular. Method 1: use pumping lemma pick w=a m! b (m+1)!, m 2. 27

Method 2: by closure properties consider L = comp(l) L(a*b*) = {a n b n : n 0} If L is regular, L must be regular. (think over!!!) Thus, L is not regular. 28

Use closure and pumping lemma To show that L is not regular Regular languages are closed under op Find another regular language L Compute L = L op L Show that L is not regular Note: it is easier to prove L non-regular 29

Proof of pumping lemma 30

Proof of pumping lemma (cont.) 31

Comments The pumping lemma CANNOT be used to prove that L is regular. Some mistakes in using the pumping lemma 1. Fix m=20, etc, some constant. 2. Choose w L, or w <m. 3. Not consider ALL possible decompositions w=xyz, xy m, y 1. 4. Every possible w=xyz, xy 2 z L for an integer i=2 (e.g.) is enough 32