120 likes | 234 Vues
This document explores Nondeterministic Finite Automata (NFAs), detailing how to trace inputs, the simplicity of designing NFAs for union operations, and their equivalence to Deterministic Finite Automata (DFAs). It discusses the formal definitions and essential differences between NFAs and DFAs, the process of converting NFAs to DFAs, and the construction of DFAs from NFA transition tables. Through practical examples, it illustrates the transition process and highlights the computational power shared by both types of automata.
E N D
CS 461 – Aug. 31 Section 1.2 – Nondeterministic FAs • How to trace input √ • NFA design makes “union” operation easier • Equivalence of NFAs and DFAs
NFA’s using “or” • Can you draw NFA for: { begin with 0 or end with 1 } ? Old start 1 ε New start Old start 2 ε
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?
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!
NFA DFA construction • 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. • 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. • Transitions: Please write as a table. Drawing would be too cluttered. When finished, can eliminate useless states.
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.
continued • The resulting DFA could require 2n states, but we should only create states as we need them. 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.
NFA DFA answer Notice that the DFA is in fact deterministic: it has exactly one destination per transition. Also there is no column for ε.
Example #2 • NFA transition table given to the right. • DFA start state is A. • DFA accept state would be anything containing D.
continued Let’s begin. δ(A, 0) = A δ(A, 1) = AC We need new state AC. δ(AC, 0) = A δ(AC, 1) = ABC Continue from ABC…
NFA DFA answer
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.