จำนวนสถานะ number of states

19
จจจจจจ จจจจจจ จจจจจ จจจจจ NUMBER OF STATES NUMBER OF STATES

Upload: gyala

Post on 06-Jan-2016

29 views

Category:

Documents


1 download

DESCRIPTION

จำนวนสถานะ NUMBER OF STATES. NUMBER OF STATES. ประเด็นที่สนใจ. The number of distinct states the finite state machine needs in order to recognize a language is related to the number of distinct strings that must be distinguished from each other. NUMBER OF STATES. สามารถแยกความแตกต่างได้. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: จำนวนสถานะ NUMBER OF STATES

จำ��นวนจำ��นวนสถ�นะสถ�นะ

NUMBER OF STATESNUMBER OF STATES

Page 2: จำนวนสถานะ NUMBER OF STATES

ประเด็ นที่��ประเด็ นที่��สนใจำสนใจำ

The number of distinct states The number of distinct states the finite state machine needs the finite state machine needs

in order to recognize a in order to recognize a language is related to the language is related to the

number of distinct strings that number of distinct strings that must be distinguished from must be distinguished from

each other.each other.

NUMBER OF STATES

Page 3: จำนวนสถานะ NUMBER OF STATES

นิ�ยามนิ�ยามLet L be a language in Let L be a language in *.*.

Two strings x and y in Two strings x and y in * are* are

distinguishable with respect to Ldistinguishable with respect to L

if there is a string z in if there is a string z in * so that* so that

exactly one of the strings xz and yz is in L.exactly one of the strings xz and yz is in L.

The string z is said to distinguish x and yThe string z is said to distinguish x and y

with respect to L.with respect to L.

DISTINGUISHABLE

ส�ม�รถแยกคว�มแตกส�ม�รถแยกคว�มแตกต��งได็�ต��งได็�

NUMBER OF STATES

Page 4: จำนวนสถานะ NUMBER OF STATES

นิ�ยามLet L be a language in Let L be a language in *.*.

Two strings x and y in Two strings x and y in * are* are

distinguishable with respect to Ldistinguishable with respect to L

if L/x ≠ L/y whereif L/x ≠ L/y where

L/x = { zL/x = { z* | xz * | xz L } L }

L/y = { zL/y = { z* | yz * | yz L }. L }.

DISTINGUISHABLE

ส�ม�รถแยกคว�มแตกส�ม�รถแยกคว�มแตกต��งได็�ต��งได็�

NUMBER OF STATES

Page 5: จำนวนสถานะ NUMBER OF STATES

Let Let = { 0, 1 }. = { 0, 1 }.

Let L be the language associated with (0+1)*10.Let L be the language associated with (0+1)*10.

Two strings x= 01101 and y= 010 in Two strings x= 01101 and y= 010 in *.*.Since there is a string z= 0 in Since there is a string z= 0 in * such that* such thatxz = 011010 is in L but yz = 0100 is not in L,xz = 011010 is in L but yz = 0100 is not in L,x and y are x and y are distinguishable with respect to L.distinguishable with respect to L.

We may say that x and y are indistinguishable with respect to We may say that x and y are indistinguishable with respect to L if there is no such string z.L if there is no such string z.The strings 0 and 100 are The strings 0 and 100 are indistinguishable with respect to Lindistinguishable with respect to L..

EXAMPLEDISTINGUISHABLE

ส�ม�รถแยกคว�มแตกส�ม�รถแยกคว�มแตกต��งได็�ต��งได็�

NUMBER OF STATES

Page 6: จำนวนสถานะ NUMBER OF STATES

Suppose that L Suppose that L *, and M = (Q,*, and M = (Q,,q,q00,A,,A,).).If x and y are two strings in If x and y are two strings in * for which* for which

*(q*(q00,x) = ,x) = *(q*(q00,y),y)then x and y arethen x and y are

indistinguishable with respective to L.indistinguishable with respective to L.

Note: Note: *(q*(q00,x)= q,x)= qjj means that there is a path from means that there is a path from qq00 to q to qjj with respect to x: with respect to x:

*(q*(q00,x) = ,x) = ((…((…(((q(q00,x,x11),x),x22),…),x),…),xjj) = q) = qjj

where x = xwhere x = x11xx22…x…xjj..

LEMMANUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะNUMBER OF STATES

Page 7: จำนวนสถานะ NUMBER OF STATES

Suppose that L Suppose that L *, and M = (Q,*, and M = (Q,,q,q00,A,,A,).).If x and y are two strings in If x and y are two strings in * for which* for which

*(q*(q00,x) = ,x) = *(q*(q00,y),y)then x and y arethen x and y are

indistinguishable with respective to L.indistinguishable with respective to L.

Note: Note: *(q*(q00,x)= q,x)= qjj means that there is a path from means that there is a path from qq00 to q to qjj with respect to x: with respect to x:

*(q*(q00,x) = ,x) = ((…((…(((q(q00,x,x11),x),x22),…),x),…),xjj) = q) = qjj

where x = xwhere x = x11xx22…x…xjj..

LEMMANUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะ

Proof: Let z be any string in *. Consider xz and yz,We have that *(q0,xz) = *(*(q0,x),z)

*(q0,yz) = *(*(q0,y),z).Then *(q0,xz) = *(q0,yz). Two strings xz and yzare either both in L or both not in L.Therefore, x and y are indistinguishable with respect to L. QED.

NUMBER OF STATES

Page 8: จำนวนสถานะ NUMBER OF STATES

Suppose that L Suppose that L *, and for some positive *, and for some positive integer n, there are n strings in integer n, there are n strings in *, any two of *, any two of which are distinguishable with respect to L.which are distinguishable with respect to L.

Then there can be no finite state machine Then there can be no finite state machine recognizing L with fewer than n states.recognizing L with fewer than n states.

Proof: Suppose x1,x2,…,xn strings are distinguishable withrespect to L. Assume that M is a finite state machine withfewer than n states. By the pigeonhole principle, the state*(q0,x1), *(q0,x2),…*(q0,xn) cannot all be distinct, so for some ij *(q0,xi)=*(q0,xj).Since xi and xj are distinguishable with respect to L,it follows from Lemma that M cannot recognize L. QED.

THEOREMNUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะNUMBER OF STATES

Page 9: จำนวนสถานะ NUMBER OF STATES

Let Let ={0,1}, and let L={0,1}, and let Lnn**

LLnn={x| |x|={x| |x|n and the nn and the nthth character from the right in x is 1}. character from the right in x is 1}.

For instance, n = 2,For instance, n = 2,

all words accepted by Lall words accepted by L22 is of the form (1+0)*1(0+1). is of the form (1+0)*1(0+1).

1

1

EXAMPLENUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะNUMBER OF STATES

Page 10: จำนวนสถานะ NUMBER OF STATES

1 0

1 0

Let Let ={0,1}, and let L={0,1}, and let Lnn**

LLnn={x| |x|={x| |x|n and the nn and the nthth character from the right in x is 1}. character from the right in x is 1}.

For instance, n = 2,For instance, n = 2,

all words accepted by Lall words accepted by L22 is of the form (1+0)*1(0+1). is of the form (1+0)*1(0+1).

NUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะEXAMPLE

NUMBER OF STATES

Page 11: จำนวนสถานะ NUMBER OF STATES

1 0 0

1 0 0

Let Let ={0,1}, and let L={0,1}, and let Lnn**

LLnn={x| |x|={x| |x|n and the nn and the nthth character from the right in x is 1}. character from the right in x is 1}.

For instance, n = 2,For instance, n = 2,

all words accepted by Lall words accepted by L22 is of the form (1+0)*1(0+1). is of the form (1+0)*1(0+1).

NUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะEXAMPLE

NUMBER OF STATES

Page 12: จำนวนสถานะ NUMBER OF STATES

1 0 0 1

1 0 0 1

Let Let ={0,1}, and let L={0,1}, and let Lnn**

LLnn={x| |x|={x| |x|n and the nn and the nthth character from the right in x is 1}. character from the right in x is 1}.

For instance, n = 2,For instance, n = 2,

all words accepted by Lall words accepted by L22 is of the form (1+0)*1(0+1). is of the form (1+0)*1(0+1).

NUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะEXAMPLE

NUMBER OF STATES

Page 13: จำนวนสถานะ NUMBER OF STATES

1 0 0 1 1

1 0 0 1 1

Let Let ={0,1}, and let L={0,1}, and let Lnn**

LLnn={x| |x|={x| |x|n and the nn and the nthth character from the right in x is 1}. character from the right in x is 1}.

For instance, n = 2,For instance, n = 2,

all words accepted by Lall words accepted by L22 is of the form (1+0)*1(0+1). is of the form (1+0)*1(0+1).

NUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะEXAMPLE

NUMBER OF STATES

Page 14: จำนวนสถานะ NUMBER OF STATES

10

11

00

01

1

0

0

1

1

0

10

0

1

1

0

0

1

0

1

(1+0)*1(0+1)(1+0)*1(0+1)

NUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะEXAMPLE

NUMBER OF STATES

Page 15: จำนวนสถานะ NUMBER OF STATES

PALINDROME language over the alphabet {0,1} PALINDROME language over the alphabet {0,1} cannot be accepted by any finite automaton.cannot be accepted by any finite automaton.

Proof: Any two strings in {0,1}* are distinguishablewith respect to PALINDROME language. QED.

EXAMPLE

For two strings, 010101and 1011100 11101

Rejectedaccepted

THEOREMNUMBER OF STATESจำ��นวนสถ�นะจำ��นวนสถ�นะNUMBER OF STATES

Page 16: จำนวนสถานะ NUMBER OF STATES

77กร�ฟก�รส�งกร�ฟก�รส�งผ่��นผ่��น

TRANSITION GRAPHSTRANSITION GRAPHS

Page 17: จำนวนสถานะ NUMBER OF STATES

ว�ตถ�ประสงค ว�ตถ�ประสงค More powerful machine:More powerful machine:

read one or more lettersread one or more letters

of input string at a timeof input string at a time

q2

b

q3

b

q0q1

ab

ab aab

aba

b

TRANSITION GRAPHS

Page 18: จำนวนสถานะ NUMBER OF STATES

A transition graph (abbreviated TG) is a 5-tuple (Q, , q0, , A) where

•Q means a finite set of states. is a finite input alphabet.•q0 Q named Initial state.•A Q , A is the set of all accepted states. is a function from Q* to P(Q), called transition function.

น!ย�ม TRANSITION GRAPHSกร�ฟก�รส�งผ่��นกร�ฟก�รส�งผ่��นTRANSITION GRAPHS

Page 19: จำนวนสถานะ NUMBER OF STATES

0 2

31

aa

b

b

aa

b

b

Language associated with this TG is (aa+b)*bbb.

TRANSITION GRAPHSกร�ฟก�รส�งผ่��นกร�ฟก�รส�งผ่��นEXAMPLE

TRANSITION GRAPHS