Download presentation
Presentation is loading. Please wait.
Published byImogen Cain Modified over 8 years ago
1
CS 461 – Aug. 31 Section 1.2 – Nondeterministic FAs How to trace input √ NFA design makes “union” operation easier Equivalence of NFAs and DFAs
2
NFA’s using “or” Can you draw NFA for: { begin with 0 or end with 1 } ? New start Old start 1 Old start 2 ε ε
3
Amazing fact NFA = DFA In other words, the two kinds of machines have the same power. Proof idea: we can always convert a DFA into an NFA, or vice versa. Which do you think is easier to do?
4
Formal NFA def’n The essential difference with DFA is in the transition function: DFA δ: Q x Σ Q NFA δ: Q x Σ ε P(Q) Thus, converting DFA NFA is easy. We already satisfy the definition!
5
NFA DFA construction 1.When creating DFA, states will be all possible subsets of states from NFA. –This takes care of “all possible destinations.” –In practice we won’t need whole subset: only create states as you need them. –“empty set” can be our dead state. 2.DFA start state = NFA’s start state or anywhere you can begin for free. Happy state will be any subset containing NFA’s happy state. 3.Transitions: Please write as a table. Drawing would be too cluttered. When finished, can eliminate useless states.
6
Example #1 NFA transition table given to the right. DFA start state is {1, 3}, or more simply 13. DFA accept state would be anything containing 1. Could be 1, 12, 13, 123, but we may not need all these states. inputs stateabε 1 -23 22,33- 31--
7
continued The resulting DFA could require 2 n states, but we should only create states as we need them. inputs stateabε 1 -23 22,33- 31-- Let’s begin: If we’re in state 1 or 3, where do we go if we read an ‘a’ or a ‘b’? δ(13, a) = 1, but we can get to 3 for free. δ(13, b) = 2. We need to create a new state “2”. Continue the construction by considering transitions from state 2.
8
answer NFA DFA inputs stateabε 1 -23 22,33- 31-- inputs stateab 13 132 2233 1233 23 313 Notice that the DFA is in fact deterministic: it has exactly one destination per transition. Also there is no column for ε.
9
Example #2 NFA transition table given to the right. DFA start state is A. DFA accept state would be anything containing D. inputs State01ε AAAA,C- BD-C C-B- D BD-
10
continued Let’s begin. δ(A, 0) = A δ(A, 1) = AC We need new state AC. δ(AC, 0) = A δ(AC, 1) = ABC Continue from ABC… inputs State01ε AAAA,C- BD-C C-B- D BD-
11
answer NFA DFA inputs State01ε AAAA,C- BD-C C-B- D BD- inputs State01 AAAAC AABC ADABC AD ABCACD ABCABCD
12
final thoughts NFAs and DFAs have same computational power. NFAs often have fewer states than corresponding DFA. Typically, we want to design a DFA, but NFAs are good for combining 2+ DFAs. After doing NFA DFA construction, we may see that some states can be combined. –Later in chapter, we’ll see how to simplify FAs.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.