Properties of Regular Languages. Reading: Chapter 4

Similar documents
Course 8 Properties of Regular Languages

Finite Automata. Reading: Chapter 2

Infinite Sequences and Series

If a subset E of R contains no open interval, is it of zero measure? For instance, is the set of irrationals in [0, 1] is of measure zero?

Lecture 2: April 3, 2013

Worksheet on Generating Functions

PRACTICE FINAL SOLUTIONS

Mathematical Induction

MA131 - Analysis 1. Workbook 2 Sequences I

Introduction to Automata Theory. Reading: Chapter 1

1. By using truth tables prove that, for all statements P and Q, the statement

SEQUENCES AND SERIES

Lesson 10: Limits and Continuity

Lecture Notes for Analysis Class

1 Generating functions for balls in boxes

Induction: Solutions

Sequences I. Chapter Introduction

Computability and computational complexity

( ) = p and P( i = b) = q.

Frequentist Inference

6.3 Testing Series With Positive Terms

It is always the case that unions, intersections, complements, and set differences are preserved by the inverse image of a function.

Axioms of Measure Theory

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

Recurrence Relations

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 22

Math 220A Fall 2007 Homework #2. Will Garner A

Context-free grammars and. Basics of string generation methods

REAL ANALYSIS II: PROBLEM SET 1 - SOLUTIONS

Seunghee Ye Ma 8: Week 5 Oct 28

4.3 Growth Rates of Solutions to Recurrences

Chapter 10: Power Series

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer.

Definition 4.2. (a) A sequence {x n } in a Banach space X is a basis for X if. unique scalars a n (x) such that x = n. a n (x) x n. (4.

Lecture 9: Hierarchy Theorems

Lecture Notes for CS 313H, Fall 2011

Math 61CM - Solutions to homework 3

Product measures, Tonelli s and Fubini s theorems For use in MAT3400/4400, autumn 2014 Nadia S. Larsen. Version of 13 October 2014.

2.4 Sequences, Sequences of Sets

2017 PRACTICE MIDTERM SOLUTIONS

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

MA131 - Analysis 1. Workbook 3 Sequences II

Square-Congruence Modulo n

MATH 304: MIDTERM EXAM SOLUTIONS

Bertrand s Postulate

A Proof of Birkhoff s Ergodic Theorem

Chapter 4. Fourier Series

Metric Space Properties

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018

The Borel hierarchy classifies subsets of the reals by their topological complexity. Another approach is to classify them by size.

Markov Decision Processes

Math F215: Induction April 7, 2013

(A sequence also can be thought of as the list of function values attained for a function f :ℵ X, where f (n) = x n for n 1.) x 1 x N +k x N +4 x 3

Infinite Series. Definition. An infinite series is an expression of the form. Where the numbers u k are called the terms of the series.

An Introduction to Randomized Algorithms

Solutions to Math 347 Practice Problems for the final

CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo

Polynomials with Rational Roots that Differ by a Non-zero Constant. Generalities

Discrete-Time Systems, LTI Systems, and Discrete-Time Convolution

Math 475, Problem Set #12: Answers

7 Sequences of real numbers

[ 11 ] z of degree 2 as both degree 2 each. The degree of a polynomial in n variables is the maximum of the degrees of its terms.

End-of-Year Contest. ERHS Math Club. May 5, 2009

Math 299 Supplement: Real Analysis Nov 2013

Sets. Sets. Operations on Sets Laws of Algebra of Sets Cardinal Number of a Finite and Infinite Set. Representation of Sets Power Set Venn Diagram

6.003 Homework #3 Solutions

Chapter 6 Infinite Series

Random Models. Tusheng Zhang. February 14, 2013

Assignment 5: Solutions

Resolution Proofs of Generalized Pigeonhole Principles

Optimally Sparse SVMs

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs

10-701/ Machine Learning Mid-term Exam Solution

7.1 Convergence of sequences of random variables

Massachusetts Institute of Technology

PRELIM PROBLEM SOLUTIONS

11. FINITE FIELDS. Example 1: The following tables define addition and multiplication for a field of order 4.

(ii) Two-permutations of {a, b, c}. Answer. (B) P (3, 3) = 3! (C) 3! = 6, and there are 6 items in (A). ... Answer.

Analytic Continuation

CS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016

Lecture 11: Hash Functions and Random Oracle Model

Chapter 0. Review of set theory. 0.1 Sets

Design and Analysis of Algorithms

Lecture 11: Pseudorandom functions

Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 21. Some Important Distributions

MATH 324 Summer 2006 Elementary Number Theory Solutions to Assignment 2 Due: Thursday July 27, 2006

MA131 - Analysis 1. Workbook 10 Series IV

Math 25 Solutions to practice problems

Definitions and Theorems. where x are the decision variables. c, b, and a are constant coefficients.

Information Theory and Statistics Lecture 4: Lempel-Ziv code

Randomized Algorithms I, Spring 2018, Department of Computer Science, University of Helsinki Homework 1: Solutions (Discussed January 25, 2018)

Mathematical Foundations -1- Sets and Sequences. Sets and Sequences

Roberto s Notes on Infinite Series Chapter 1: Sequences and series Section 3. Geometric series

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER / Statistics

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Lecture 10: Mathematical Preliminaries

Convergence of random variables. (telegram style notes) P.J.C. Spreij

Vector Quantization: a Limiting Case of EM

CS284A: Representations and Algorithms in Molecular Biology

EE260: Digital Design, Spring n Binary Addition. n Complement forms. n Subtraction. n Multiplication. n Inputs: A 0, B 0. n Boolean equations:

Transcription:

Properties of Regular Laguages Readig: Chapter 4

Topics ) How to prove whether a give laguage is regular or ot? 2) Closure properties of regular laguages 3) Miimizatio of DFAs 2

Some laguages are ot regular Whe is a laguage is regular? if we are able to costruct oe of the followig: DFA or NFA or ε -NFA or regular expressio Whe is it ot? If we ca show that o FA ca be built for a laguage 3

How to prove laguages are ot regular? What if we caot come up with ay FA? A) Ca it be laguage that is ot regular? B) Or is it that we tried wrog approaches? How do we decisively prove that a laguage is ot regular? The hardest thig of all is to fid a black cat i a dark room, especially if there is o cat! -Cofucius 4

Example of a o-regular laguage Let L = {w w is of the form, for all } Hypothesis: L is ot regular Ituitive ratioale: How do you keep track of a ruig cout i a FA? A more formal ratioale: By cotraditio, if L is regular the there should exist a DFA for L. Let k = umber of states i that DFA. Cosider the special word w= k k => w L DFA is i some state p i, after cosumig the first i symbols i w 5

Uses Pigeo Hole Priciple Ratioale Let {p,p, p k } be the sequece of states that the DFA should have visited after cosumig the first k symbols i w which is k But there are oly k states i the DFA! ==> at least oe state should repeat somewhere alog the path (by ++ Priciple) ==> Let the repeatig state be p i =p J for i < j ==> We ca fool the DFA by iputig (k-(j-i)) k ad still get it to accept (ote: k-(j-i) is at most k-). ==> DFA accepts strigs w/ uequal umber of s ad s, implyig that the DFA is wrog! 6

The Pumpig Lemma for Regular Laguages What it is? The Pumpig Lemma is a property of all regular laguages. How is it used? A techique that is used to show that a give laguage is ot regular 7

Pumpig Lemma for Regular Laguages Let L be a regular laguage The there exists some costat N such that for every strig w L s.t. w N, there exists a way to break w ito three parts, w=xyz, such that:. y ε 2. xy N 3. For all k, all strigs of the form xy k z L This property should hold for all regular laguages. Defiitio: N is called the Pumpig Lemma Costat 8

Pumpig Lemma: Proof L is regular => it should have a DFA. Set N := umber of states i the DFA Ay strig w L, s.t. w N, should have the form: w=a a 2 a m, where m N Let the states traversed after readig the first N symbols be: {p,p, p N } ==> There are N+ p-states, while there are oly N DFA states ==> at least oe state has to repeat i.e, p i = p J where i<j N (by PHP) 9

Pumpig Lemma: Proof => We should be able to break w=xyz as follows: x=a a 2..a i ; y=a i+ a i+2..a J ; z=a J+ a J+2..a m x s path will be p..p i y s path will be p i p i+..p J (but p i =p J implyig a loop) z s path will be p J p J+..p m Now cosider aother strig w k =xy k z, where k Case k= y k (for k loops) p x z p i p m =p j DFA will reach the accept state p m Case k> DFA will loop for y k, ad fially reach the accept state p m for z I either case, w k L This proves part (3) of the lemma

Pumpig Lemma: Proof For part (): Sice i<j, y ε y k (for k loops) p x z p i p m =p j For part (2): By PHP, the repetitio of states has to occur withi the first N symbols i w ==> xy N

The Purpose of the Pumpig Lemma for RL To prove that some laguages caot be regular. 2

How to use the pumpig lemma? Thik of playig a 2 perso game Role : We claim that the laguage caot be regular Role 2: A adversary who claims the laguage is regular We show that the adversary s statemet will lead to a cotradictio that implyies pumpig lemma caot hold for the laguage. We wi!! 3

How to use the pumpig lemma? (The Steps). (we) L is ot regular. 2. (adv.) Claims that L is regular ad gives you a value for N as its P/L costat 3. (we) Usig N, choose a strig w L s.t.,. w N, 2. Usig w as the template, costruct other words w k of the form xy k z ad show that at least oe such w k L => this implies we have successfully broke the pumpig lemma for the laguage, ad hece that the adversary is wrog. (Note: I this process, we may have to try may values of k, startig with k=, ad the 2, 3,.. so o, util w k L ) 4

Note: We do t have ay cotrol over N, except that it is positive. We also do t have ay cotrol over how to split w=xyz, but xyz should respect the P/L coditios () ad (2). Usig the Pumpig Lemma What WE do? 3. Usig N, we costruct our template strig w 4. Demostrate to the adversary, either through pumpig up or dow o w, that some strig w k L (this should happe regardless of w=xyz) What the Adversary does?. Claims L is regular 2. Provides N 5

Note: This N ca be aythig (eed ot ecessarily be the #states i the DFA. It s the adversary s choice.) Example of usig the Pumpig Lemma to prove that a laguage is ot regular Let L eq = {w w is a biary strig with equal umber of s ad s} Your Claim: L eq is ot regular Proof: By cotradictio, let L eq be regular P/L costat should exist Let N = that P/L costat Cosider iput w = N N (your choice for the template strig) By pumpig lemma, we should be able to break w=xyz, such that: ) y ε 2) xy N 3) For all k, the strig xy k z is also i L è adv. è adv. è you èyou 6

Template strig w = N N =. N N Proof Settig k= is referred to as pumpig dow Because xy N, xy should cotai oly s (This ad because y ε, implies y= + ) Therefore x ca cotai at most N- s Also, all the N s must be iside z By (3), ay strig of the form xy k z L eq for all k Case k=: xz has at most N- s but has N s Therefore, xy z L eq This violates the P/L (a cotradictio) è you Settig k> is referred to as pumpig up Aother way of provig this will be to show that if the #s is arbitrarily pumped up (e.g., k=2), the the #s will become exceed the #s 7

Exercise 2 Prove L = { } is ot regular Note: This is ot to be cofused with the pumpig lemma costat N. That ca be differet. I other words, the above questio is same as provig: L = { m m m } is ot regular 8

Example 3: Pumpig Lemma Claim: L = { i i is a perfect square} is ot regular Proof: By cotradictio, let L be regular. P/L should apply Let N = P/L costat Choose w= N2 By pumpig lemma, w=xyz satisfyig all three rules By rules () & (2), y has betwee ad N s By rule (3), ay strig of the form xy k z is also i L for all k Case k=: #zeros (xy z) = #zeros (xyz) - #zeros (y) N 2 N #zeros (xy z) N 2 - (N-) 2 < N 2 - N #zeros (xy z) N 2 - < N 2 xy z L But the above will complete the proof ONLY IF N>. (proof cotd.. Next slide) 9

Example 3: Pumpig Lemma (proof cotd ) If the adversary pick N=, the (N-) 2 N 2 N, ad therefore the #zeros(xy z) could ed up beig a perfect square! This meas that pumpig dow (i.e., settig k=) is ot givig us the proof! So lets try pumpig up ext Case k=2: #zeros (xy 2 z) = #zeros (xyz) + #zeros (y) N 2 + #zeros (xy 2 z) N 2 + N N 2 < N 2 + #zeros (xy 2 z) N 2 + N < (N+) 2 xy 2 z L (Notice that the above should hold for all possible N values of N>. Therefore, this completes the proof.) 2

Closure properties of Regular Laguages 2

Closure properties for Regular Laguages (RL) Closure property: If a set of regular laguages are combied usig a operator, the the resultig laguage is also regular Regular laguages are closed uder: This is differet from Kleee closure Uio, itersectio, complemet, differece Reversal Kleee closure Cocateatio Homomorphism Iverse homomorphism Now, lets prove all of this! 22

RLs are closed uder uio IF L ad M are two RLs THEN: they both have two correspodig regular expressios, R ad S respectively (L U M) ca be represeted usig the regular expressio R+S Therefore, (L U M) is also regular How ca this be proved usig FAs? 23

RLs are closed uder complemetatio DFA for L If L is a RL over, the L= *-L To show L is also regular, make the followig costructio Covert every fial state ito o-fial, ad every o-fial state ito a fial state q F DFA for L q F q q i q F2 q q i q F2 q Fk q Fk Assumes q is a o-fial state. If ot, do the opposite. 24

RLs are closed uder itersectio A quick, idirect way to prove: By DeMorga s law: L M = (L U M) Sice we kow RLs are closed uder uio ad complemetatio, they are also closed uder itersectio A more direct way would be costruct a fiite automato for L M 25

DFA costructio for L M A L = DFA for L = {Q L,, q L,F L, δ L } A M = DFA for M = {Q M,, q M,F M, δ M } Build A L M = {Q L x Q M,, (q L,q M ), F L x F M,δ} such that: δ((p,q),a) = (δ L (p,a), δ M (q,a)), where p i Q L, ad q i Q M This costructio esures that a strig w will be accepted if ad oly if w reaches a acceptig state i both iput DFAs. 26

DFA costructio for L M DFA for L q F DFA for M p F q q i a q j q F2 p p i a p j p F2 DFA for L M (q F,p F ) (q,p ) a (q i,p i ) (q j,p j ) 27

RLs are closed uder set differece We observe: L - M = L M Closed uder itersectio Closed uder complemetatio Therefore, L - M is also regular 28

RLs are closed uder reversal Reversal of a strig w is deoted by w R E.g., w=, w R = Reversal of a laguage: L R = The laguage geerated by reversig all strigs i L Theorem: If L is regular the L R is also regular 29

ε -NFA Costructio for L R New ε-nfa for L R DFA for L q F ε Make the old start state as the oly ew fial state q q i a q j q F2 q Fk ε ε q New start state What to do if q was oe of the fial states i the iput DFA? Reverse all trasitios Covert the old set of fial states ito o-fial states 3

If L is regular, L R is regular (proof usig regular expressios) Let E be a regular expressio for L Give E, how to build E R? Basis: If E= ε,, or a, the E R =E Iductio: Every part of E (refer to the part as F ) ca be i oly oe of the three followig forms:. F = F +F 2 F R = F R +F R 2 2. F = F F 2 F R = F 2R F R 3. F = (F )* (F R )* = (F R )* 3

Homomorphisms Substitute each symbol i (mai alphabet) by a correspodig strig i T (aother alphabet) h: --->T* Example: Let ={,} ad T={a,b} Let a homomorphic fuctio h o be: h()=ab, h()=ε If w=, the h(w) = εabεεab = abab I geeral, h(w) = h(a ) h(a 2 ) h(a ) 32

RLs are closed uder homomorphisms Theorem: If L is regular, the so is h(l) Proof: If E is a RE for L, the show L(h(E)) = h(l(e)) Basis: If E= ε,, or a, the the claim holds. Iductio: There are three forms of E:. E = E +E 2 L(h(E)) = L(h(E ) + h(e 2 )) = L(h(E )) U L(h(E 2 )) ----- () h(l(e)) = h(l(e ) + L(E 2 )) = h(l(e )) U h(l(e 2 )) ----- (2) By iductive hypothesis, L(h(E ))= h(l(e )) ad L(h(E 2 ))= h(l(e 2 )) 2. E = E E 2 3. E = (E )* Therefore, L(h(E)= h(l(e) Similar argumet Thik of a DFA based costructio 33

Give a DFA for L, how to covert it ito a FA for h(l)? FA Costructio for h(l) DFA for L q F Replace every edge a by a path labeled h(a) i the ew DFA q q i a q j q F2 h(a) q Fk - Build a ew FA that simulates h(a) for every symbol a trasitio i the above DFA - The resultig FA may or may ot be a DFA, but will be a FA for h(l) 34

Give a DFA for M, how to covert it ito a FA for h - (M)? The set of strigs i * whose homomorphic traslatio results i the strigs of M Iverse homomorphism Let h: --->T* Let M be a laguage over alphabet T h - (M) = {w w * s.t., h(w) M } Claim: If M is regular, the so is h - (M) Proof: Let A be a DFA for M Costruct aother DFA A which ecodes h - (M) A is a exact replica of A, except that its trasitio fuctios are s.t. for ay iput symbol a i, A will simulate h(a) i A. δ(p,a) = δ(p,h(a)) 35

Decisio properties of regular laguages Ay decisio problem looks like this: Iput (geerally a questio) Decisio problem solver Yes No 36

Membership questio Decisio Problem: Give L, is w i L? Possible aswers: Yes or No Approach:. Build a DFA for L 2. Iput w to the DFA 3. If the DFA eds i a acceptig state, the yes; otherwise o. 37

Emptiess test Decisio Problem: Is L=? Approach: O a DFA for L:. From the start state, ru a reachability test, which returs:. success: if there is at least oe fial state that is reachable from the start state 2. failure: otherwise 2. L= if ad oly if the reachability test fails How to implemet the reachability test? 38

Fiiteess Decisio Problem: Is L fiite or ifiite? Approach: O a DFA for L:. Remove all states ureachable from the start state 2. Remove all states that caot lead to ay acceptig state. 3. After removal, check for cycles i the resultig FA 4. L is fiite if there are o cycles; otherwise it is ifiite Aother approach Build a regular expressio ad look for Kleee closure How to implemet steps 2 ad 3? 39

Fiiteess test - examples Ex ) Is the laguage of this DFA fiite or ifiite? X q 6 X Ex 2) Is the laguage of this DFA fiite or ifiite? FINITE X INFINITE due to this 4

Equivalece & Miimizatio of DFAs 4

Applicatios of iterest Comparig two DFAs: L(DFA ) == L(DFA 2 )? How to miimize a DFA?. Remove ureachable states 2. Idetify & codese equivalet states ito oe 42

Whe to call two states i a DFA equivalet? Past does t matter - oly future does! AND Two states p ad q are said to be equivalet iff: i) Ay strig w accepted by startig at p is also accepted by startig at q; ii) p q Ay strig w rejected by startig at p is also rejected by startig at q. è p q p q w w 43

Computig equivalet states i a DFA Table Fillig Algorithm A C E G B D F H Pass #. Mark acceptig states o-acceptig states Pass #. Compare every pair of states 2. Distiguish by oe symbol trasitio 3. Mark = or or blak(tbd) Pass #2. Compare every pair of states 2. Distiguish by up to two symbol trasitios (util differet or same or tbd). (keep repeatig util table complete) A = B = = C x x = D x x x = E x x x x = F x x x x x = G x x x = x x = H x x = x x x x = A B C D E F G H 44

Table Fillig Algorithm - step by step A C E G B D F H A = B = C = D = E = F = G = H = A B C D E F G H 45

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state A = B = C = D = E X X X X = F X = G X = H X = A B C D E F G H 46

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state 2. Look - hop away for distiguishig states or strigs A = B = C X = D X = E X X X X = F X = G X X = H X X = A B C D E F G H 47

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state 2. Look - hop away for distiguishig states or strigs A = B = C X X = D X X = E X X X X = F X = G X X X = H X X X = A B C D E F G H 48

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state 2. Look - hop away for distiguishig states or strigs A = B = C X X = D X X X = E X X X X = F X X = G X X X X = H X X = X = A B C D E F G H 49

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state 2. Look - hop away for distiguishig states or strigs A = B = C X X = D X X X = E X X X X = F X X X = G X X X = X = H X X = X X = A B C D E F G H 5

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state 2. Look - hop away for distiguishig states or strigs A = B = C X X = D X X X = E X X X X = F X X X = G X X X = X X = H X X = X X X = A B C D E F G H 5

Table Fillig Algorithm - step by step A C E G B D F H. Mark X betwee acceptig vs. o-acceptig state 2. Look - hop away for distiguishig states or strigs A = B = C X X = D X X X = E X X X X = F X X X = G X X X = X X = H X X = X X X X = A B C D E F G H 52

Table Fillig Algorithm - step by step A C E G B D F H A = B = =. Mark X betwee acceptig vs. o-acceptig state 2. Pass : Look - hop away for distiguishig states or strigs 3. Pass 2: Look -hop away agai for distiguishig states or strigs cotiue. C X X = D X X X = E X X X X = F X X X X X = G X X X = X X = H X X = X X X X = A B C D E F G H 53

Table Fillig Algorithm - step by step A C E G B D F H A = B = = C X X = D X X X = E X X X X = F X X X X X = G X X X = X X =. Mark X betwee acceptig vs. o-acceptig state H X X = X X X X = 2. Pass : A B C D E F G H Look - hop away for distiguishig states or strigs 3. Pass 2: Look -hop away agai for distiguishig states or strigs Equivaleces: cotiue. A=B C=H D=G 54

Table Fillig Algorithm - step by step A C E G B D F H A C E D F Retrai oly oe copy for each equivalece set of states Equivaleces: A=B C=H D=G 55

Table Fillig Algorithm special case A C E G B D F H Q) What happes if the iput DFA has more tha oe fial state? Ca all fial states iitially be treated as equivalet to oe aother? A = B = C = D = E? = F = G = H = A B C D E F G H 56

Puttig it all together How to miimize a DFA? Goal: Miimize the umber of states i a DFA Depth-first traversal from the start state Algorithm:. Elimiate states ureachable from the start state Table fillig algorithm 2. Idetify ad remove equivalet states 3. Output the resultat DFA 57

Are Two DFAs Equivalet? Uified DFA DFA q DFA 2 Is q q? : if yes, the DFA DFA 2 : else, ot equiv. q. Make a ew dummy DFA by just puttig together both DFAs 2. Ru table-fillig algorithm o the uified DFA 3. IF the start states of both DFAs are foud to be equivalet, THEN: DFA DFA 2 ELSE: differet 58

Summary How to prove laguages are ot regular? Pumpig lemma & its applicatios Closure properties of regular laguages Simplificatio of DFAs How to remove ureachable states? How to idetify ad collapse equivalet states? How to miimize a DFA? How to tell whether two DFAs are equivalet? 59