/
cs3102: Theory of Computation cs3102: Theory of Computation

cs3102: Theory of Computation - PowerPoint Presentation

phoebe-click
phoebe-click . @phoebe-click
Follow
389 views
Uploaded On 2015-11-11

cs3102: Theory of Computation - PPT Presentation

Class 4 Nondeterminism Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF Read the TexPoint manual before you delete this box A A A A A A A A A A A A ID: 190368

recognized nfa dfa language nfa recognized language dfa set regular finite languages states nfas machine part power recognize nondeterminism

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "cs3102: Theory of Computation" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

cs3102: Theory of ComputationClass 4: Nondeterminism

Spring 2010University of VirginiaDavid Evans

TexPoint fonts used in EMF.

Read the TexPoint manual before you delete this box.: AAAAAAAAAAAAAAAAAA

PS1 is due now!Slide2

Adding Nondeterminism1

2

Deterministic

machine: at every step, there is only one choiceNondeterministic machine: at some steps, there may be more than one choice.

a

a, b

b

bSlide3

Nondeterminism in PracticeSlide4

Nondeterminism in TheoryOmnipotent: Machine splits into a new machine for each choice; if any machine accepts, accept.

Omniscient: Whenever it has to make a choice, machine always guesses right.Slide5

Example NFA1

2

3

a

b

a, bSlide6

Defining DFAs

A

deterministic finite automaton is a 5-tuple:

Q finite set (“states”)

finite

set (“alphabet”)

:

Q

 

Q

transition function

q

0

Q

start state

F

Q

set of accepting states

How do we need to change this to support

nondeterminism

?Slide7

Defining NFAs

A

non

deterministic finite automaton is a 5-tuple:Q finite

set (“states”)

finite

set (“alphabet”)

transition function

q

0

Q

start state

F

Q

set of accepting states

Output of transition function is a

set

of states, not just one state.Slide8

Computation Model of NFASlide9

Computation Model of NFASlide10

Is an NFA more powerful than a DFA?Slide11

Power of MachinesLanguages that can be recognized by an

A

Languages that can be recognized by a B

A and B are non-comparable.Slide12

Power of MachinesLanguages that can be recognized by an

A

Languages that can be recognized by a B

B is less powerful than A:Some A can recognize every language a B can recognize.There is some language that can be recognized by an A but not by any B.Slide13

Power of MachinesLanguages that can be recognized by an

A

Languages that can be recognized by a B

A and B are equal: every language that can be recognized by an A can be recognized by some Bevery language that can be recognized by a B can be recognized by some ASlide14

Power of NFA/DFAEasy part: is there any language a DFA can recognize that cannot be recognized by an

NFA?Hard part: is there any language an NFA can recognized that cannot be recognized by a DFA?Slide15

L(NFA)  L(DFA)

A

non

deterministic finite automaton is a 5-tuple:Q

finite

set (“states”)

finite

set (“alphabet”)

q

0

Q

start state

F

Q

set of accepting states

Proof by construction:

Construct the NFA

N

corresponding to any DFA

A = (

Q

,

,

,

q

0

,F

):

N =

(

Q

,

,

’

,

q

0

,F

) where

q

Q, ’(q, 

)

=

reject

a

 

,

’(q, a

)

=

{

 (q, a

)

} Slide16

Power of NFA/DFAEasy part: is there any language a DFA can recognize that cannot be recognized by an

NFA?Hard part: is there any language an NFA can recognized that cannot be recognized by a DFA?

No:

NFAs are at least as powerful as DFAs.Slide17

L(DFA)  L(NFA)Slide18

L(DFA)  L(NFA)Slide19

Example Conversion1

2

3

a

b

a, bSlide20

1

2

3

a

b

a, b

{1}

{2}

{1, 2}

{1, 3}

{2, 3}

{1,2, 3}

{3}

{}Slide21

1

2

3

a

b

a, b

{1}

{2}

{1, 2}

{1, 3}

{2, 3}

{1,2, 3}

{3}

{}

a

a

b

b

b

a

bSlide22

Converting NFAs to DFAsHow many states may be needed for the DFA corresponding to and NFA with

N states?How much bigger is the

transition function for the DFA corresponding to and NFA with N states?Slide23

Regular ExpressionsSlide24

“something formatted like an [email] address”address@domain

[A-Za-z0-9]*@[A-Za-z0-9]*(. [A-Za-z0-9]*)*

This matches most email addresses. Matching the full spec of all possible email addresses is left as exercise.Slide25

Regular ExpressionBase: Language

a   { a } 

{  }  { }

Induction: R1, R2 are regular expressions R1  R2 L(R

1

) 

L(R

2

)

R

1

R

2 { xy

| xL(R

1) and y

L(R2) }

R

1

*

{

x

n

|

x

L

(R

1

) and

n ≥

0

}Slide26

How powerful are Regular Expressions?Is there a Regular Expression that describes the same language as any NFA?

Is there some NFA that describes the same language as any Regular Expression?Slide27

L(RE)  L(NFA)

Base: Language

a   { a

}  {  }  { }Induction: R1, R2 are regular expressions R

1

R

2

L(R

1

) 

L(R

2

)

R1

 R2 { xy

| xL

(R1) and y

L

(R

2

)

}

R

1

*

{

x

n

|

x

L

(R

1

) and

n ≥

0

}Proof by construction.Trivial to draw NFAs forEach of these languages.Slide28

L(RE)  L(NFA)

Base: Language

a   { a }

 {  }  { }Proof by construction.Trivial to draw NFAs forEach of these languages.Slide29

L(RE)  L(NFA)

Induction:

R1, R

2 are regular expressions R1  R2 L(R1)  L(R2

)

R

1

R

2

{

xy

|

xL

(R1) and y

L(R2) }

R1* {

x

n

|

x

L

(R

1

) and

n ≥

0

}

Proof by

induction and construction

.

Assume there

are NFAs

A

1

and

A2 that recognize the languages L(R1) and L(R2). Show how to construct an NFA that recognizes the produced language for each part.Slide30

Proving: R1  R

2Slide31

ChargePS2 will be posted by tomorrowFinish reading Chapter 1Thursday: how to prove a language is non-regular