lecture 22

22
1 Lecture 22 • Myhill-Nerode Theorem – distinguishability – equivalence classes of strings – designing FSA’s – proving a language L is not regular

Upload: tegan

Post on 06-Feb-2016

22 views

Category:

Documents


0 download

DESCRIPTION

Lecture 22. Myhill-Nerode Theorem distinguishability equivalence classes of strings designing FSA’s proving a language L is not regular. Distinguishability. Distinguishable and Indistinguishable. String x is distinguishable from string y with respect to language L iff - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lecture 22

1

Lecture 22

• Myhill-Nerode Theorem– distinguishability– equivalence classes of strings– designing FSA’s– proving a language L is not regular

Page 2: Lecture 22

2

Distinguishability

Page 3: Lecture 22

3

Distinguishable and Indistinguishable

• String x is distinguishable from string y with respect to language L iff – there exists a string z such that

• xz is in L and yz is not in L OR

• xz is not in L and yz is in L

• String x is indistinguishable from string y with respect to language L iff – for all strings z,

• xz and yz are both in L OR

• xz and yz are both not in L

Page 4: Lecture 22

4

Example

• Let EVEN-ODD be the set of strings over {a,b} with an even number of a’s and an odd number of b’s– Is the string aa distinguishable from the string

bb with respect to EVEN-ODD?– Is the string aa distinguishable from the string

ab with respect to EVEN-ODD?

Page 5: Lecture 22

5

Equivalence classes of strings(Societies in the handout)

Page 6: Lecture 22

6

Definition of equivalence classes

• Every language L partitions * into equivalence classes via indistinguishability– Two strings x and y belong to the same equivalence

class defined by L iff x and y are indistinguishable w.r.t L

– Two strings x and y belong to different equivalence classes defined by L iff x and y are distinguishable w.r.t. L

Page 7: Lecture 22

7

ExampleHow does EVEN-ODD partition {a,b}* into equivalence classes?

Strings with anEVEN number of a’s

and anEVEN number of b’s

Strings with anEVEN number of a’s

and anODD number of b’s

Strings with anODD number of a’s

and anEVEN number of b’s

Strings with anODD number of a’s

and anODD number of b’s

Page 8: Lecture 22

8

Second ExampleLet 1MOD3 be the set of strings over {a,b} whose length mod 3 = 1.How does 1MOD3 partition {a,b}* into equivalence classes?

Length mod 3 = 0

Length mod 3 = 1

Length mod 3 = 2

Page 9: Lecture 22

9

Designing FSA’s

Page 10: Lecture 22

10

Designing an FSA for EVEN-ODD

EvenEven

EvenOdd

OddOdd

OddEven

b ab

aa

b b

a

Page 11: Lecture 22

11

Designing an FSA for 1MOD3

Length mod 3 = 0

Length mod 3 = 1

Length mod 3 = 2

a aaa,b a,b

a,b

Page 12: Lecture 22

12

Proving a language is not regular

Page 13: Lecture 22

13

Third Example• Let EQUAL be the set of strings x over {a,b} s.t. the

number of a’s in x = the number of b’s in x

• How does EQUAL partition {a,b}* into equivalence classes?– Strings with an equal number of a’s and b’s

– Strings with one extra a

– Strings with one extra b

– Strings with two extra a’s

– Strings with two extra b’s

– …

• There are an infinite number of equivalence classes.– Can we construct a finite state automaton for EQUAL?

– We shall see that the answer is no.

Page 14: Lecture 22

14

Myhill-Nerode Theorem

Page 15: Lecture 22

15

Theorem Statement

• Two part statement– If L is regular, then L partitions * into a finite

number of equivalence classes– If L partitions * into a finite number of

equivalence classes, then L is regular

• One part statement– L is regular iff L partitions * into a finite

number of equivalence classes

Page 16: Lecture 22

16

Implication 1

• Method for constructing FSA’s to accept a language L– Identify equivalence classes defined by L– Make a state for each equivalence class– Identify initial and accepting states– Add transitions between the states

• You can use a canonical element of each equivalence class to help with building the transition function

Page 17: Lecture 22

17

Implication 2

• Method for proving a language L is not regular– Identify equivalence classes defined by L– Show there are an infinite number of such

equivalence classes• Table format may help, but it is only a way to help

illustrate that there are an infinite number of equivalence classes defined by L

Page 18: Lecture 22

18

Proving a language is not regular revisited

Page 19: Lecture 22

19

Proving EQUAL is not regular

• Let EQUAL be the set of strings x over {a,b} s.t. the number of a’s in x = the number of b’s in x

• We want to show that EQUAL partitions {a,b}* into an infinite number of equivalence classes

• We will use a table that is somewhat reminiscent of the table used for diagonalization

Page 20: Lecture 22

20

Table

aaa

aaaaaaa

aaaaa...

bINOUTOUTOUTOUT...

bbOUTINOUTOUTOUT...

bbbOUTOUTINOUTOUT...

bbbbOUTOUTOUTINOUT...

bbbbbOUTOUTOUTOUTIN...

………………

The strings being distinguished are the rows.The tables entries indicate the the concatenation of the row

string with the column string is in or not in EQUAL.Each complete column shows one row string is distinguishable

from all the other row strings.

Page 21: Lecture 22

21

Concluding EQUAL is nonregular

• We have shown that EQUAL partitions {a,b}* into an infinite number of equivalence classes– In this case, we only identified some of the equivalence

classes defined by EQUAL, but that is sufficient• Strings with one extra a

• Strings with two extra a’s

• Strings with three extra a’s

• …

• Thus, the Myhill-Nerode Theorem implies that EQUAL is nonregular

Page 22: Lecture 22

22

Summary

• Myhill-Nerode Theorem and what it says– It does not say a language L is regular iff L is finite

• Many regular languages such as * are not finite

– It says that a language L is regular iff L partitions * into a finite number of equivalence classes

• Provides method for designing FSA’s• Provides method for proving a language L is not

regular– Show that L partitions * into an infinite number of

equivalence classes