BU CS 332 Theory of Computation Lecture 3: Reading: Nondeterminism - - PowerPoint PPT Presentation

bu cs 332 theory of computation
SMART_READER_LITE
LIVE PREVIEW

BU CS 332 Theory of Computation Lecture 3: Reading: Nondeterminism - - PowerPoint PPT Presentation

BU CS 332 Theory of Computation Lecture 3: Reading: Nondeterminism Sipser Ch 1.1 1.2 Equivalence of NFAs and DFAs More on closure properties Mark Bun January 29, 2020 Non Nondeterminism 1 0,1 0 0 0 1 1 A


slide-1
SLIDE 1

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 Bun January 29, 2020

slide-2
SLIDE 2

Non Nondeterminism

1/29/2020 CS332 ‐ Theory of Computation 2

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

slide-3
SLIDE 3

Non Nondeterminism

1/29/2020 CS332 ‐ Theory of Computation 3

1 1 1 0,1 Example: Does this NFA accept the string 1100?

slide-4
SLIDE 4

Some special transitions

1/29/2020 CS332 ‐ Theory of Computation 4

0, 1 1

slide-5
SLIDE 5

Example

1/29/2020 CS332 ‐ Theory of Computation 5

1

slide-6
SLIDE 6

Example

1/29/2020 CS332 ‐ Theory of Computation 6

0,1 0, 1 0,1 1

slide-7
SLIDE 7

Formal Definition of a NFA

1/29/2020 CS332 ‐ Theory of Computation 7

is the set of states is the alphabet 

  • is the transition function

0 

is the start state is the set of accept states

An NFA is a 5‐tuple 

accepts a string if there exists a path from

0 to

an accept state that can be followed by reading .

slide-8
SLIDE 8

Example

1/29/2020 CS332 ‐ Theory of Computation 8

1 

𝟒

𝟏 𝟏, 𝟐 𝟑 𝟒 𝟓 𝟓

𝟑 𝟐 𝟑 𝟒 𝟓 𝟏

slide-9
SLIDE 9

Example

1/29/2020 CS332 ‐ Theory of Computation 9

0,1 0, 1 0,1 1

𝟐 𝟑 𝟒 𝟏

𝟏 𝟏, 𝟐 𝟑 𝟒 𝟒

𝟏

𝟑

𝟏

𝟐

slide-10
SLIDE 10

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 Deterministic Computation Nondeterministic Computation accept or reject accept reject

slide-11
SLIDE 11

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

slide-12
SLIDE 12

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,1 A DFA that recognizes the language :

slide-13
SLIDE 13

Sometimes DFAs mu must st be larger

1/29/2020 CS332 ‐ Theory of Computation 13

  • Theorem. Every DFA for the language

must have at least 3 states. Proof:

slide-14
SLIDE 14

Equivalence of NFAs and DFAs

1/29/2020 CS332 ‐ Theory of Computation 14

slide-15
SLIDE 15

Equivalence of NFAs and DFAs

Every 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

slide-16
SLIDE 16

Equivalence of NFAs and DFAs (Proof)

1/29/2020 CS332 ‐ Theory of Computation 16

Let  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”

slide-17
SLIDE 17

NFA ‐> DFA Example

1/29/2020 CS332 ‐ Theory of Computation 17

1 a b

slide-18
SLIDE 18

Subset Construction (Formally)

1/29/2020 CS332 ‐ Theory of Computation 18

  for all and .     

0

 Input: NFA Output: DFA  

0

slide-19
SLIDE 19

NFA ‐> DFA Example

1/29/2020 CS332 ‐ Theory of Computation 19

0,1 ε 2 3 1 1

slide-20
SLIDE 20

Subset Construction (Formally)

1/29/2020 CS332 ‐ Theory of Computation 20

 

for all and .     

0

   contains some accept state of Input: NFA Output: DFA  

0

slide-21
SLIDE 21

Proving the Construction Works

Claim: For every string , running

  • n

leads to state There exists a computation

  • f
  • n input

ending at Proof idea: By induction on

1/29/2020 CS332 ‐ Theory of Computation 21

slide-22
SLIDE 22

Historical Note

Subset 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

  • f inspiration for subsequent work in this

field.

slide-23
SLIDE 23

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