prof. busch - lsu1 nfas accept the regular languages

35
Prof. Busch - LSU 1 NFAs accept the Regular Languages

Upload: jodie-anderson

Post on 04-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 1

NFAs accept the Regular Languages

Page 2: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 2

Equivalence of Machines

Definition:

Machine is equivalent to machine

if

1M 2M

21 MLML

Page 3: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 3

0q 1q

0

1

0q 1q 2q

0

11

0

1,0

NFA

DFA

*}10{1 ML

*}10{2 ML

1M

2M

Example of equivalent machines

Page 4: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 4

Theorem:

Languages acceptedby NFAs

RegularLanguages

NFAs and DFAs have the same computation power,accept the same set of languages

Languages acceptedby DFAs

Page 5: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 5

Languages acceptedby NFAs

RegularLanguages

Languages acceptedby NFAs

RegularLanguages

we only need to showProof:

AND

Page 6: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 6

Languages acceptedby NFAs

RegularLanguages

Proof-Step 1

Every DFA is trivially an NFA

Any language accepted by a DFAis also accepted by an NFA

L

Page 7: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 7

Languages acceptedby NFAs

RegularLanguages

Proof-Step 2

Any NFA can be converted to anequivalent DFA

Any language accepted by an NFAis also accepted by a DFA

L

Page 8: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 8

Conversion NFA to DFA

a

b

a

0q 1q 2q

NFA

DFA

0q

M

M

Page 9: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 9

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

M

M

},{),( 210* qqaq

Page 10: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 10

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

M

M

),( 0* bq empty set

trap state

Page 11: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 11

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

a

M

M

},{),( 211* qqaq

),( 2* aq

21,qq

union

Page 12: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 12

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

ab

M

M

}{),( 01* qbq

}{),( 02* qbq

0q

union

Page 13: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 13

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

ab

ba,

M

M

trap state

Page 14: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 14

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

ab

ba,

M

M

END OF CONSTRUCTION

Fq 1

Fqq 21,

Page 15: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 15

General Conversion Procedure

Input: an NFA

Output: an equivalent DFAwith

M

M )(MLML

Page 16: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 16

The NFA has states

The DFA has states from the power set

,...,, 210 qqq

....,,,,,,,, 3211010 qqqqqqq

Page 17: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 17

1. Initial state of NFA:

Initial state of DFA:

0q

,, 00* qq

Conversion Procedure Steps

step

,0q

Page 18: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 18

a

b

a

0q 1q 2q

NFA

DFA

0q

M

M

Example 00* , qq

Page 19: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 19

2. For every DFA’s state

compute in the NFA

add transition to DFA

},...,,{ mji qqq

aq

aq

aq

m

j

i

,*

...

,*

,*

},...,,{ nlk qqq

},...,,{},,...,,{ nlkmji qqqaqqq

Union

step

Page 20: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 20

a

b

a

0q 1q 2q

NFA

0q 21,qqa

DFA

},{),(* 210 qqaq

210 ,, qqaq

M

M

Example

Page 21: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 21

3. Repeat Step 2 for every state in DFA and symbols in alphabet until no more states can be added in the DFA

step

Page 22: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 22

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

ab

ba,

M

M

Example

Page 23: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 23

4. For any DFA state

if some is accepting state in NFA

Then, is accepting state in DFA

},...,,{ mji qqq

jq

},...,,{ mji qqq

step

Page 24: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 24

a

b

a

0q 1q 2q

NFA

DFA

0q 21,qqa

b

ab

ba,

Fq 1

Fqq 21,

M

M

Example

Page 25: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 25

If we convert NFA to DFAthen the two automata are equivalent:

M

MLML

M Lemma:

Proof:

MLML

MLML AND

We only need to show:

Page 26: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 26

MLML First we show:

)(MLw

We only need to prove:

)(MLw

Page 27: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 27

)(MLw

w

kw 21

0q fq

0q fq1 2 k

symbols

Consider

NFA

Page 28: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 28

i

i

denotes a possible sub-path like

iq jq

iq jq

symbol

symbol

Page 29: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 29

0q fq

kw 211 2 k

:M

},{ 0 q

1 2 k:M

},{ fq

)(MLw

)(MLw

We will show that if

then

NFA

DFA

state label

state label

Page 30: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 30

0q mq

naaav 211a 2a na:M

1a 2a na:M },{ iq

iq jq lq

},{ jq },{ lq },{ mq

More generally, we will show that if in :M

(arbitrary string)

then

NFA

DFA},{ 0 q

Page 31: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 31

0q 1a:M

1a:M },{ iq

iq

Proof by induction on

Induction Basis: 1av

|| v

is true by construction of M

NFA

DFA

1|| v

},{ 0 q

Page 32: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 32

Induction hypothesis: kv ||1

0q dq1a 2a ka:M iq jq cq

1a 2a ka:M },{ iq },{ jq },{ cq },{ dq

kaaav 21

NFA

DFA

Suppose that the following hold

},{ 0 q

Page 33: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 33

Induction Step: 1|| kv

0q dq1a 2a ka:M iq jq cq

1a 2a ka:M },{ iq },{ jq },{ cq },{ dq

1121

kk

v

k avaaaav

v

v

eq1ka

1ka

},{ eq

NFA

DFA

Then this is true by construction ofM

},{ 0 q

Page 34: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 34

0q fq

kw 211 2 k

:M

1 2 k:M

},{ fq

)(MLw

)(MLw

Therefore if

NFA

DFA

then

},{ 0 q

Page 35: Prof. Busch - LSU1 NFAs accept the Regular Languages

Prof. Busch - LSU 35

We have shown: MLML

With a similar proof we can show: MLML

END OF LEMMA PROOF

MLML Therefore: