+ All Categories
Home > Documents > BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1...

BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1...

Date post: 04-Jul-2020
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
23
BU CS 332 – Theory of Computation Lecture 3: Nondeterminism Equivalence of NFAs and DFAs More on closure properties Reading: Sipser Ch 1.11.2 Mark Bun January 29, 2020
Transcript
Page 1: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

BU CS 332 – Theory of Computation

Lecture 3:• Nondeterminism• Equivalence of NFAs and DFAs• More on closure properties

Reading:Sipser Ch 1.1‐1.2

Mark BunJanuary 29, 2020

Page 2: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Nondeterminism

1/29/2020 CS332 ‐ Theory of Computation 2

1 0

1

0 1

0,1

0

A Nondeterministic Finite Automaton (NFA) accepts if there is a way to make it reach an accept state.

Page 3: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Nondeterminism

1/29/2020 CS332 ‐ Theory of Computation 3

1 0

1

0 1

0,1

0

Example: Does this NFA accept the string 1100?

Page 4: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Some special transitions

1/29/2020 CS332 ‐ Theory of Computation 4

0

0, 1

1

Page 5: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Example

1/29/2020 CS332 ‐ Theory of Computation 5

1

0

0

Page 6: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Example

1/29/2020 CS332 ‐ Theory of Computation 6

0,1

0, 1

0,1

1

Page 7: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Formal Definition of a NFA

1/29/2020 CS332 ‐ Theory of Computation 7

is the set of statesis the alphabet

is the transition function

0 is the start stateis the set of accept states

An NFA is a 5‐tuple  0

accepts a string  if there exists a path from  0 to an accept state that can be followed by reading  .

Page 8: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Example

1/29/2020 CS332 ‐ Theory of Computation 8

1

0

0

𝟑

𝟎

𝟎, 𝟏 𝟐 𝟑 𝟒

𝟒

𝟐

𝟏

𝟐

𝟑

𝟒

𝟎

Page 9: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Example

1/29/2020 CS332 ‐ Theory of Computation 9

0,1

0, 1

0,1

1𝟏 𝟐 𝟑𝟎

𝟎

𝟎, 𝟏 𝟐 𝟑

𝟑

𝟎

𝟐

𝟎

𝟏

Page 10: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Nondeterminism

1/29/2020 CS332 ‐ Theory of Computation 10

Ways to think about nondeterminism• (restricted) parallel computation• tree of possible computations• guessing and verifying the “right” choice

DeterministicComputation

NondeterministicComputation

accept or reject accept

reject

Page 11: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Why study NFAs?• Not really a realistic model of computation: Real computing devices can’t really try many possibilities in parallel

But:

• Useful tool for understanding power of DFAs/regular languages• NFAs can be simpler than DFAs• Lets us study “nondeterminism” as a resource

(cf. P vs. NP)

1/29/2020 CS332 ‐ Theory of Computation 11

Page 12: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

NFAs can be simpler than DFAs

1/29/2020 CS332 ‐ Theory of Computation 12

An NFA that recognizes the language  :

1

1 0,1

0,10A DFA that recognizes the language  :

Page 13: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Sometimes DFAs must be larger

1/29/2020 CS332 ‐ Theory of Computation 13

Theorem. Every DFA for the language  must have at least 3 states.Proof:

Page 14: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Equivalence of NFAs and DFAs

1/29/2020 CS332 ‐ Theory of Computation 14

Page 15: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Equivalence of NFAs and DFAsEvery DFA is an NFA, so NFAs are at least as powerful as DFAs

Theorem: For every NFA  , there is a DFA  such that 

Corollary: A language is regular if and only if it is recognized by an NFA

1/29/2020 CS332 ‐ Theory of Computation 15

Page 16: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Equivalence of NFAs and DFAs (Proof)

1/29/2020 CS332 ‐ Theory of Computation 16

Let 0 be an NFA

Intuition: Run all threads of  in parallel, maintaining the set of states where all threads are.

accept

reject

Goal: Construct DFA  0 recognizing 

Formally:

“The Subset Construction”

Page 17: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

NFA ‐> DFA Example

1/29/2020 CS332 ‐ Theory of Computation 17

1a b

Page 18: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Subset Construction (Formally)

1/29/2020 CS332 ‐ Theory of Computation 18

for all  and  .

0

Input: NFA    0Output: DFA  0

Page 19: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

NFA ‐> DFA Example

1/29/2020 CS332 ‐ Theory of Computation 19

0,1

ε 02 31

1

Page 20: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Subset Construction (Formally)

1/29/2020 CS332 ‐ Theory of Computation 20

∈ for all  and  .

0 0

contains some accept state of

Input: NFA    0Output: DFA  0

Page 21: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Proving the Construction WorksClaim: For every string  , running  on  leads to state

There exists a computation of on input ending at  

Proof idea: By induction on 

1/29/2020 CS332 ‐ Theory of Computation 21

Page 22: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Historical NoteSubset Construction introduced in Rabin & Scott’s 1959 paper “Finite Automata and their Decision Problems”

1/29/2020 CS332 ‐ Theory of Computation 22

1976 ACM Turing Award citation

For their joint paper "Finite Automata and Their Decision Problem," which introduced the idea of nondeterministic machines, which has proved to be an enormously valuable concept. Their (Scott & Rabin) 

classic paper has been a continuous source of inspiration for subsequent work in this 

field.

Page 23: BU CS 332 of - Boston University … · Nondeterminism 1/29/2020 CS332 ‐Theory of Computation 2 1 0 1 0 1 0,1 0 A Nondeterministic Finite Automaton (NFA) accepts if there is a way

Is this construction the best we can do?Subset construction converts an  state NFA into a  ‐state DFA

Could there be a construction that always produces, say, an ‐state DFA?

Theorem: For every  , there is a language  such that 1. There is an  ‐state NFA recognizing  . 2. There is no DFA recognizing  with fewer than  

states.Conclusion: For finite automata, nondeterminism provides an exponential savings over determinism (in the worst case).

1/29/2020 CS332 ‐ Theory of Computation 23


Recommended