View
8
Download
0
Category
Preview:
Citation preview
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
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.
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?
Some special transitions
1/29/2020 CS332 ‐ Theory of Computation 4
0
0, 1
1
Example
1/29/2020 CS332 ‐ Theory of Computation 5
1
0
0
Example
1/29/2020 CS332 ‐ Theory of Computation 6
0,1
0, 1
0,1
1
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 .
Example
1/29/2020 CS332 ‐ Theory of Computation 8
1
0
0
𝟑
𝟎
𝟎, 𝟏 𝟐 𝟑 𝟒
𝟒
𝟐
𝟏
𝟐
𝟑
𝟒
𝟎
Example
1/29/2020 CS332 ‐ Theory of Computation 9
0,1
0, 1
0,1
1𝟏 𝟐 𝟑𝟎
𝟎
𝟎, 𝟏 𝟐 𝟑
𝟑
𝟎
𝟐
𝟎
𝟏
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
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
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 :
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:
Equivalence of NFAs and DFAs
1/29/2020 CS332 ‐ Theory of Computation 14
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
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”
NFA ‐> DFA Example
1/29/2020 CS332 ‐ Theory of Computation 17
1a b
Subset Construction (Formally)
1/29/2020 CS332 ‐ Theory of Computation 18
for all and .
0
Input: NFA 0Output: DFA 0
NFA ‐> DFA Example
1/29/2020 CS332 ‐ Theory of Computation 19
0,1
ε 02 31
1
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
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
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.
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