Cs3102 theory of computation class 3 nondeterminism
This presentation is the property of its rightful owner.
Sponsored Links
1 / 31

cs3102: Theory of Computation Class 3: Nondeterminism PowerPoint PPT Presentation


  • 73 Views
  • Uploaded on
  • Presentation posted in: General

PS1 is due now!. cs3102: Theory of Computation Class 3: 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 A A A A A A. Adding Nondeterminism. a. b. 1. 2. b. a, b.

Download Presentation

cs3102: Theory of Computation Class 3: Nondeterminism

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Cs3102 theory of computation class 3 nondeterminism

PS1 is due now!

cs3102: Theory of ComputationClass 3: Nondeterminism

Spring 2010

University of Virginia

David Evans

TexPoint fonts used in EMF.

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


Adding nondeterminism

Adding Nondeterminism

a

b

1

2

b

a, b

Deterministic machine:

at every step, there is only one choice

Nondeterministic machine:

at some steps, there may be more than one choice.


Nondeterminism in practice

Nondeterminism in Practice


Nondeterminism in theory

Nondeterminism in Theory

Omnipotent: 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.


Example nfa

Example NFA

a

b

1

2

3

a, b


Defining dfas

Defining DFAs

A deterministic finite automaton is a 5-tuple:

Qfinite set (“states”)

  • finite set (“alphabet”)

  • : Q    Qtransition function

    q0  Qstart state

    F  Qset of accepting states

How do we need to change this to support nondeterminism?


Defining n fas

Defining NFAs

A nondeterministic finite automaton is a 5-tuple:

Qfinite set (“states”)

  • finite set (“alphabet”)

  • transition function

    q0  Qstart state

    F  Qset of accepting states

Output of transition function is a set of states, not just one state.


Computation model of nfa

Computation Model of NFA


Computation model of nfa1

Computation Model of NFA


Cs3102 theory of computation class 3 nondeterminism

Is an NFA more powerful than a DFA?


Power of machines

Power of Machines

Languages that can be recognized by an A

Languages that can be recognized by a B

A and B are non-comparable.


Power of machines1

Power of Machines

Languages that can be recognized by an A

B is less powerful than A:

SomeAcan recognize every language a B can recognize.

There is some language that can be recognized by an A but not by any B.

Languages that can be recognized by a B


Power of machines2

Power of Machines

Languages 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 B

every language that can be recognized by a B can be recognized by some A


Power of nfa dfa

Power of NFA/DFA

Easy 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?


L nfa l dfa

L(NFA)  L(DFA)

A nondeterministic finite automaton is a 5-tuple:

Qfinite set (“states”)

  • finite set (“alphabet”)

  • q0  Qstart state

    F  Qset of accepting states

Proof by construction:

Construct the NFA N corresponding to any DFA A = (Q, , , q0,F):

N = (Q, , ’, q0,F) where

q  Q, ’(q, ) = reject

a   ,’(q, a) = { (q, a) }


Power of nfa dfa1

Power of NFA/DFA

Easy 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.


L dfa l nfa

L(DFA)  L(NFA)


L dfa l nfa1

L(DFA)  L(NFA)


Example conversion

Example Conversion

a

b

1

2

3

a, b


Cs3102 theory of computation class 3 nondeterminism

a

b

1

2

3

a, b

{2}

{1, 2}

{1}

{1, 3}

{1,2, 3}

{2, 3}

{3}

{}


Cs3102 theory of computation class 3 nondeterminism

a

b

1

2

3

a, b

a

a

b

{2}

{1, 2}

{1}

{1, 3}

b

b

b

a

{1,2, 3}

{2, 3}

{3}

{}


Converting nfas to dfas

Converting NFAs to DFAs

How 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?


Regular expressions

Regular Expressions


Something formatted like an email address

“something formatted like an [email] address”

[email protected]

[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.


Regular expression

Regular Expression

Base: Language

a { a }

{  }

{ }

Induction:R1, R2 are regular expressions

R1  R2 L(R1)  L(R2)

R1  R2 { xy | xL(R1) and yL(R2) }

R1*{ xn | xL(R1) and n ≥ 0 }


How powerful are regular expressions

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?


L re l nfa

L(RE)  L(NFA)

Base: Language

a { a }

{  }

{ }

Induction:R1, R2 are regular expressions

R1  R2 L(R1)  L(R2)

R1  R2 { xy | xL(R1) and yL(R2) }

R1*{ xn | xL(R1) and n ≥ 0 }

Proof by construction.

Trivial to draw NFAs for

Each of these languages.


L re l nfa1

L(RE)  L(NFA)

Base: Language

a { a }

{  }

{ }

Proof by construction.

Trivial to draw NFAs for

Each of these languages.


L re l nfa2

L(RE)  L(NFA)

Induction:R1, R2 are regular expressions

R1  R2 L(R1)  L(R2)

R1  R2 { xy | xL(R1) and yL(R2) }

R1*{ xn | xL(R1) and n ≥ 0 }

Proof by induction and construction.

Assume there are NFAs A1 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.


Proving r 1 r 2

Proving: R1  R2


Charge

Charge

  • PS2 will be posted by tomorrow

  • Finish reading Chapter 1

  • Thursday: how to prove a language is non-regular


  • Login