NFAs accept the Regular Languages

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

description

NFAs accept the Regular Languages. Equivalence of Machines. Definition: Machine is equivalent to machine if. Example of equivalent machines. NFA. DFA. Theorem:. Languages accepted by NFAs. Regular Languages. Languages accepted by DFAs. - PowerPoint PPT Presentation

Transcript of NFAs accept the Regular Languages

Page 1: NFAs accept the Regular Languages

Prof. Busch - LSU 1

NFAs accept the Regular Languages

Page 2: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: NFAs accept the Regular Languages

Prof. Busch - LSU 15

General Conversion Procedure

Input: an NFA

Output: an equivalent DFAwith

M

M )(MLML

Page 16: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: NFAs accept the Regular Languages

Prof. Busch - LSU 26

MLML First we show:

)(MLw

We only need to prove:

)(MLw

Page 27: NFAs accept the Regular Languages

Prof. Busch - LSU 27

)(MLw

w

kw 21

0q fq

0q fq1 2 k

symbols

Consider

NFA

Page 28: 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: 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: 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: 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: 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: 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: 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: 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: